diff --git a/404.html b/404.html index ee6d1e4..116ba56 100644 --- a/404.html +++ b/404.html @@ -7,6 +7,6 @@ - + \ No newline at end of file diff --git a/index.html b/index.html index ee6d1e4..116ba56 100644 --- a/index.html +++ b/index.html @@ -7,6 +7,6 @@ - + \ No newline at end of file diff --git a/main.477fea569b5088f7.js b/main.477fea569b5088f7.js new file mode 100644 index 0000000..0e962e6 --- /dev/null +++ b/main.477fea569b5088f7.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkangular_barcode_qr_code_scanner=self.webpackChunkangular_barcode_qr_code_scanner||[]).push([[179],{727:()=>{function Vt(f){return"function"==typeof f}function Za(f){const u=f(g=>{Error.call(g),g.stack=(new Error).stack});return u.prototype=Object.create(Error.prototype),u.prototype.constructor=u,u}const $c=Za(f=>function(u){f(this),this.message=u?`${u.length} errors occurred during unsubscription:\n${u.map((g,p)=>`${p+1}) ${g.toString()}`).join("\n ")}`:"",this.name="UnsubscriptionError",this.errors=u});function Ka(f,l){if(f){const u=f.indexOf(l);0<=u&&f.splice(u,1)}}class wi{constructor(l){this.initialTeardown=l,this.closed=!1,this._parentage=null,this._finalizers=null}unsubscribe(){let l;if(!this.closed){this.closed=!0;const{_parentage:u}=this;if(u)if(this._parentage=null,Array.isArray(u))for(const m of u)m.remove(this);else u.remove(this);const{initialTeardown:g}=this;if(Vt(g))try{g()}catch(m){l=m instanceof $c?m.errors:[m]}const{_finalizers:p}=this;if(p){this._finalizers=null;for(const m of p)try{K_(m)}catch(v){l=null!=l?l:[],v instanceof $c?l=[...l,...v.errors]:l.push(v)}}if(l)throw new $c(l)}}add(l){var u;if(l&&l!==this)if(this.closed)K_(l);else{if(l instanceof wi){if(l.closed||l._hasParent(this))return;l._addParent(this)}(this._finalizers=null!==(u=this._finalizers)&&void 0!==u?u:[]).push(l)}}_hasParent(l){const{_parentage:u}=this;return u===l||Array.isArray(u)&&u.includes(l)}_addParent(l){const{_parentage:u}=this;this._parentage=Array.isArray(u)?(u.push(l),u):u?[u,l]:l}_removeParent(l){const{_parentage:u}=this;u===l?this._parentage=null:Array.isArray(u)&&Ka(u,l)}remove(l){const{_finalizers:u}=this;u&&Ka(u,l),l instanceof wi&&l._removeParent(this)}}wi.EMPTY=(()=>{const f=new wi;return f.closed=!0,f})();const q_=wi.EMPTY;function Z_(f){return f instanceof wi||f&&"closed"in f&&Vt(f.remove)&&Vt(f.add)&&Vt(f.unsubscribe)}function K_(f){Vt(f)?f():f.unsubscribe()}const js={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Xc={setTimeout(f,l,...u){const{delegate:g}=Xc;return(null==g?void 0:g.setTimeout)?g.setTimeout(f,l,...u):setTimeout(f,l,...u)},clearTimeout(f){const{delegate:l}=Xc;return((null==l?void 0:l.clearTimeout)||clearTimeout)(f)},delegate:void 0};function Q_(f){Xc.setTimeout(()=>{const{onUnhandledError:l}=js;if(!l)throw f;l(f)})}function J_(){}const vT=kd("C",void 0,void 0);function kd(f,l,u){return{kind:f,value:l,error:u}}let Gs=null;function qc(f){if(js.useDeprecatedSynchronousErrorHandling){const l=!Gs;if(l&&(Gs={errorThrown:!1,error:null}),f(),l){const{errorThrown:u,error:g}=Gs;if(Gs=null,u)throw g}}else f()}class Bd extends wi{constructor(l){super(),this.isStopped=!1,l?(this.destination=l,Z_(l)&&l.add(this)):this.destination=ST}static create(l,u,g){return new Zc(l,u,g)}next(l){this.isStopped?Ud(function CT(f){return kd("N",f,void 0)}(l),this):this._next(l)}error(l){this.isStopped?Ud(function yT(f){return kd("E",void 0,f)}(l),this):(this.isStopped=!0,this._error(l))}complete(){this.isStopped?Ud(vT,this):(this.isStopped=!0,this._complete())}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe(),this.destination=null)}_next(l){this.destination.next(l)}_error(l){try{this.destination.error(l)}finally{this.unsubscribe()}}_complete(){try{this.destination.complete()}finally{this.unsubscribe()}}}const ET=Function.prototype.bind;function Vd(f,l){return ET.call(f,l)}class bT{constructor(l){this.partialObserver=l}next(l){const{partialObserver:u}=this;if(u.next)try{u.next(l)}catch(g){Kc(g)}}error(l){const{partialObserver:u}=this;if(u.error)try{u.error(l)}catch(g){Kc(g)}else Kc(l)}complete(){const{partialObserver:l}=this;if(l.complete)try{l.complete()}catch(u){Kc(u)}}}class Zc extends Bd{constructor(l,u,g){let p;if(super(),Vt(l)||!l)p={next:null!=l?l:void 0,error:null!=u?u:void 0,complete:null!=g?g:void 0};else{let m;this&&js.useDeprecatedNextContext?(m=Object.create(l),m.unsubscribe=()=>this.unsubscribe(),p={next:l.next&&Vd(l.next,m),error:l.error&&Vd(l.error,m),complete:l.complete&&Vd(l.complete,m)}):p=l}this.destination=new bT(p)}}function Kc(f){js.useDeprecatedSynchronousErrorHandling?function wT(f){js.useDeprecatedSynchronousErrorHandling&&Gs&&(Gs.errorThrown=!0,Gs.error=f)}(f):Q_(f)}function Ud(f,l){const{onStoppedNotification:u}=js;u&&Xc.setTimeout(()=>u(f,l))}const ST={closed:!0,next:J_,error:function DT(f){throw f},complete:J_},jd="function"==typeof Symbol&&Symbol.observable||"@@observable";function Hs(f){return f}let cn=(()=>{class f{constructor(u){u&&(this._subscribe=u)}lift(u){const g=new f;return g.source=this,g.operator=u,g}subscribe(u,g,p){const m=function TT(f){return f&&f instanceof Bd||function IT(f){return f&&Vt(f.next)&&Vt(f.error)&&Vt(f.complete)}(f)&&Z_(f)}(u)?u:new Zc(u,g,p);return qc(()=>{const{operator:v,source:y}=this;m.add(v?v.call(m,y):y?this._subscribe(m):this._trySubscribe(m))}),m}_trySubscribe(u){try{return this._subscribe(u)}catch(g){u.error(g)}}forEach(u,g){return new(g=tv(g))((p,m)=>{const v=new Zc({next:y=>{try{u(y)}catch(b){m(b),v.unsubscribe()}},error:m,complete:p});this.subscribe(v)})}_subscribe(u){var g;return null===(g=this.source)||void 0===g?void 0:g.subscribe(u)}[jd](){return this}pipe(...u){return function ev(f){return 0===f.length?Hs:1===f.length?f[0]:function(u){return f.reduce((g,p)=>p(g),u)}}(u)(this)}toPromise(u){return new(u=tv(u))((g,p)=>{let m;this.subscribe(v=>m=v,v=>p(v),()=>g(m))})}}return f.create=l=>new f(l),f})();function tv(f){var l;return null!==(l=null!=f?f:js.Promise)&&void 0!==l?l:Promise}const xT=Za(f=>function(){f(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"});let Ar=(()=>{class f extends cn{constructor(){super(),this.closed=!1,this.currentObservers=null,this.observers=[],this.isStopped=!1,this.hasError=!1,this.thrownError=null}lift(u){const g=new nv(this,this);return g.operator=u,g}_throwIfClosed(){if(this.closed)throw new xT}next(u){qc(()=>{if(this._throwIfClosed(),!this.isStopped){this.currentObservers||(this.currentObservers=Array.from(this.observers));for(const g of this.currentObservers)g.next(u)}})}error(u){qc(()=>{if(this._throwIfClosed(),!this.isStopped){this.hasError=this.isStopped=!0,this.thrownError=u;const{observers:g}=this;for(;g.length;)g.shift().error(u)}})}complete(){qc(()=>{if(this._throwIfClosed(),!this.isStopped){this.isStopped=!0;const{observers:u}=this;for(;u.length;)u.shift().complete()}})}unsubscribe(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null}get observed(){var u;return(null===(u=this.observers)||void 0===u?void 0:u.length)>0}_trySubscribe(u){return this._throwIfClosed(),super._trySubscribe(u)}_subscribe(u){return this._throwIfClosed(),this._checkFinalizedStatuses(u),this._innerSubscribe(u)}_innerSubscribe(u){const{hasError:g,isStopped:p,observers:m}=this;return g||p?q_:(this.currentObservers=null,m.push(u),new wi(()=>{this.currentObservers=null,Ka(m,u)}))}_checkFinalizedStatuses(u){const{hasError:g,thrownError:p,isStopped:m}=this;g?u.error(p):m&&u.complete()}asObservable(){const u=new cn;return u.source=this,u}}return f.create=(l,u)=>new nv(l,u),f})();class nv extends Ar{constructor(l,u){super(),this.destination=l,this.source=u}next(l){var u,g;null===(g=null===(u=this.destination)||void 0===u?void 0:u.next)||void 0===g||g.call(u,l)}error(l){var u,g;null===(g=null===(u=this.destination)||void 0===u?void 0:u.error)||void 0===g||g.call(u,l)}complete(){var l,u;null===(u=null===(l=this.destination)||void 0===l?void 0:l.complete)||void 0===u||u.call(l)}_subscribe(l){var u,g;return null!==(g=null===(u=this.source)||void 0===u?void 0:u.subscribe(l))&&void 0!==g?g:q_}}function iv(f){return Vt(null==f?void 0:f.lift)}function xn(f){return l=>{if(iv(l))return l.lift(function(u){try{return f(u,this)}catch(g){this.error(g)}});throw new TypeError("Unable to lift unknown Observable type")}}function Dn(f,l,u,g,p){return new AT(f,l,u,g,p)}class AT extends Bd{constructor(l,u,g,p,m,v){super(l),this.onFinalize=m,this.shouldUnsubscribe=v,this._next=u?function(y){try{u(y)}catch(b){l.error(b)}}:super._next,this._error=p?function(y){try{p(y)}catch(b){l.error(b)}finally{this.unsubscribe()}}:super._error,this._complete=g?function(){try{g()}catch(y){l.error(y)}finally{this.unsubscribe()}}:super._complete}unsubscribe(){var l;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){const{closed:u}=this;super.unsubscribe(),!u&&(null===(l=this.onFinalize)||void 0===l||l.call(this))}}}function Ut(f,l){return xn((u,g)=>{let p=0;u.subscribe(Dn(g,m=>{g.next(f.call(l,m,p++))}))})}function Ws(f){return this instanceof Ws?(this.v=f,this):new Ws(f)}function MT(f,l,u){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var p,g=u.apply(f,l||[]),m=[];return p={},v("next"),v("throw"),v("return"),p[Symbol.asyncIterator]=function(){return this},p;function v(B){g[B]&&(p[B]=function(U){return new Promise(function(W,Y){m.push([B,U,W,Y])>1||y(B,U)})})}function y(B,U){try{!function b(B){B.value instanceof Ws?Promise.resolve(B.value.v).then(O,L):N(m[0][2],B)}(g[B](U))}catch(W){N(m[0][3],W)}}function O(B){y("next",B)}function L(B){y("throw",B)}function N(B,U){B(U),m.shift(),m.length&&y(m[0][0],m[0][1])}}function LT(f){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var u,l=f[Symbol.asyncIterator];return l?l.call(f):(f=function ov(f){var l="function"==typeof Symbol&&Symbol.iterator,u=l&&f[l],g=0;if(u)return u.call(f);if(f&&"number"==typeof f.length)return{next:function(){return f&&g>=f.length&&(f=void 0),{value:f&&f[g++],done:!f}}};throw new TypeError(l?"Object is not iterable.":"Symbol.iterator is not defined.")}(f),u={},g("next"),g("throw"),g("return"),u[Symbol.asyncIterator]=function(){return this},u);function g(m){u[m]=f[m]&&function(v){return new Promise(function(y,b){!function p(m,v,y,b){Promise.resolve(b).then(function(O){m({value:O,done:y})},v)}(y,b,(v=f[m](v)).done,v.value)})}}}const av=f=>f&&"number"==typeof f.length&&"function"!=typeof f;function lv(f){return Vt(null==f?void 0:f.then)}function cv(f){return Vt(f[jd])}function uv(f){return Symbol.asyncIterator&&Vt(null==f?void 0:f[Symbol.asyncIterator])}function hv(f){return new TypeError(`You provided ${null!==f&&"object"==typeof f?"an invalid object":`'${f}'`} where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`)}const dv=function PT(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}();function fv(f){return Vt(null==f?void 0:f[dv])}function gv(f){return MT(this,arguments,function*(){const u=f.getReader();try{for(;;){const{value:g,done:p}=yield Ws(u.read());if(p)return yield Ws(void 0);yield yield Ws(g)}}finally{u.releaseLock()}})}function pv(f){return Vt(null==f?void 0:f.getReader)}function sr(f){if(f instanceof cn)return f;if(null!=f){if(cv(f))return function NT(f){return new cn(l=>{const u=f[jd]();if(Vt(u.subscribe))return u.subscribe(l);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}(f);if(av(f))return function kT(f){return new cn(l=>{for(let u=0;u{f.then(u=>{l.closed||(l.next(u),l.complete())},u=>l.error(u)).then(null,Q_)})}(f);if(uv(f))return mv(f);if(fv(f))return function VT(f){return new cn(l=>{for(const u of f)if(l.next(u),l.closed)return;l.complete()})}(f);if(pv(f))return function UT(f){return mv(gv(f))}(f)}throw hv(f)}function mv(f){return new cn(l=>{(function jT(f,l){var u,g,p,m;return function RT(f,l,u,g){return new(u||(u=Promise))(function(m,v){function y(L){try{O(g.next(L))}catch(N){v(N)}}function b(L){try{O(g.throw(L))}catch(N){v(N)}}function O(L){L.done?m(L.value):function p(m){return m instanceof u?m:new u(function(v){v(m)})}(L.value).then(y,b)}O((g=g.apply(f,l||[])).next())})}(this,void 0,void 0,function*(){try{for(u=LT(f);!(g=yield u.next()).done;)if(l.next(g.value),l.closed)return}catch(v){p={error:v}}finally{try{g&&!g.done&&(m=u.return)&&(yield m.call(u))}finally{if(p)throw p.error}}l.complete()})})(f,l).catch(u=>l.error(u))})}function Rr(f,l,u,g=0,p=!1){const m=l.schedule(function(){u(),p?f.add(this.schedule(null,g)):this.unsubscribe()},g);if(f.add(m),!p)return m}function Sn(f,l,u=1/0){return Vt(l)?Sn((g,p)=>Ut((m,v)=>l(g,m,p,v))(sr(f(g,p))),u):("number"==typeof l&&(u=l),xn((g,p)=>function GT(f,l,u,g,p,m,v,y){const b=[];let O=0,L=0,N=!1;const B=()=>{N&&!b.length&&!O&&l.complete()},U=Y=>O{m&&l.next(Y),O++;let $=!1;sr(u(Y,L++)).subscribe(Dn(l,q=>{null==p||p(q),m?U(q):l.next(q)},()=>{$=!0},void 0,()=>{if($)try{for(O--;b.length&&OW(q)):W(q)}B()}catch(q){l.error(q)}}))};return f.subscribe(Dn(l,U,()=>{N=!0,B()})),()=>{null==y||y()}}(g,p,f,u)))}function Qa(f=1/0){return Sn(Hs,f)}const Or=new cn(f=>f.complete());function Hd(f){return f[f.length-1]}function _v(f){return Vt(Hd(f))?f.pop():void 0}function Ja(f){return function WT(f){return f&&Vt(f.schedule)}(Hd(f))?f.pop():void 0}function vv(f,l=0){return xn((u,g)=>{u.subscribe(Dn(g,p=>Rr(g,f,()=>g.next(p),l),()=>Rr(g,f,()=>g.complete(),l),p=>Rr(g,f,()=>g.error(p),l)))})}function yv(f,l=0){return xn((u,g)=>{g.add(f.schedule(()=>u.subscribe(g),l))})}function Cv(f,l){if(!f)throw new Error("Iterable cannot be null");return new cn(u=>{Rr(u,l,()=>{const g=f[Symbol.asyncIterator]();Rr(u,l,()=>{g.next().then(p=>{p.done?u.complete():u.next(p.value)})},0,!0)})})}function In(f,l){return l?function KT(f,l){if(null!=f){if(cv(f))return function YT(f,l){return sr(f).pipe(yv(l),vv(l))}(f,l);if(av(f))return function XT(f,l){return new cn(u=>{let g=0;return l.schedule(function(){g===f.length?u.complete():(u.next(f[g++]),u.closed||this.schedule())})})}(f,l);if(lv(f))return function $T(f,l){return sr(f).pipe(yv(l),vv(l))}(f,l);if(uv(f))return Cv(f,l);if(fv(f))return function qT(f,l){return new cn(u=>{let g;return Rr(u,l,()=>{g=f[dv](),Rr(u,l,()=>{let p,m;try{({value:p,done:m}=g.next())}catch(v){return void u.error(v)}m?u.complete():u.next(p)},0,!0)}),()=>Vt(null==g?void 0:g.return)&&g.return()})}(f,l);if(pv(f))return function ZT(f,l){return Cv(gv(f),l)}(f,l)}throw hv(f)}(f,l):sr(f)}function Qc(f){return f<=0?()=>Or:xn((l,u)=>{let g=0;l.subscribe(Dn(u,p=>{++g<=f&&(u.next(p),f<=g&&u.complete())}))})}function Wd(f,l,...u){return!0===l?(f(),null):!1===l?null:l(...u).pipe(Qc(1)).subscribe(()=>f())}function Ft(f){for(let l in f)if(f[l]===Ft)return l;throw Error("Could not find renamed property on target object.")}function zd(f,l){for(const u in l)l.hasOwnProperty(u)&&!f.hasOwnProperty(u)&&(f[u]=l[u])}function Tt(f){if("string"==typeof f)return f;if(Array.isArray(f))return"["+f.map(Tt).join(", ")+"]";if(null==f)return""+f;if(f.overriddenName)return`${f.overriddenName}`;if(f.name)return`${f.name}`;const l=f.toString();if(null==l)return""+l;const u=l.indexOf("\n");return-1===u?l:l.substring(0,u)}function Yd(f,l){return null==f||""===f?null===l?"":l:null==l||""===l?f:f+" "+l}const ex=Ft({__forward_ref__:Ft});function jt(f){return f.__forward_ref__=jt,f.toString=function(){return Tt(this())},f}function rt(f){return wv(f)?f():f}function wv(f){return"function"==typeof f&&f.hasOwnProperty(ex)&&f.__forward_ref__===jt}class Et extends Error{constructor(l,u){super(function $d(f,l){return`NG0${Math.abs(f)}${l?": "+l:""}`}(l,u)),this.code=l}}function Ke(f){return"string"==typeof f?f:null==f?"":String(f)}function An(f){return"function"==typeof f?f.name||f.toString():"object"==typeof f&&null!=f&&"function"==typeof f.type?f.type.name||f.type.toString():Ke(f)}function Jc(f,l){const u=l?` in ${l}`:"";throw new Et(-201,`No provider for ${An(f)} found${u}`)}function si(f,l){null==f&&function Pt(f,l,u,g){throw new Error(`ASSERTION ERROR: ${f}`+(null==g?"":` [Expected=> ${u} ${g} ${l} <=Actual]`))}(l,f,null,"!=")}function yt(f){return{token:f.token,providedIn:f.providedIn||null,factory:f.factory,value:void 0}}function Ui(f){return{providers:f.providers||[],imports:f.imports||[]}}function Xd(f){return Ev(f,eu)||Ev(f,Dv)}function Ev(f,l){return f.hasOwnProperty(l)?f[l]:null}function bv(f){return f&&(f.hasOwnProperty(qd)||f.hasOwnProperty(ax))?f[qd]:null}const eu=Ft({\u0275prov:Ft}),qd=Ft({\u0275inj:Ft}),Dv=Ft({ngInjectableDef:Ft}),ax=Ft({ngInjectorDef:Ft});var Xe=(()=>((Xe=Xe||{})[Xe.Default=0]="Default",Xe[Xe.Host=1]="Host",Xe[Xe.Self=2]="Self",Xe[Xe.SkipSelf=4]="SkipSelf",Xe[Xe.Optional=8]="Optional",Xe))();let Zd;function us(f){const l=Zd;return Zd=f,l}function Sv(f,l,u){const g=Xd(f);return g&&"root"==g.providedIn?void 0===g.value?g.value=g.factory():g.value:u&Xe.Optional?null:void 0!==l?l:void Jc(Tt(f),"Injector")}function hs(f){return{toString:f}.toString()}var ji=(()=>((ji=ji||{})[ji.OnPush=0]="OnPush",ji[ji.Default=1]="Default",ji))(),or=(()=>{return(f=or||(or={}))[f.Emulated=0]="Emulated",f[f.None=2]="None",f[f.ShadowDom=3]="ShadowDom",or;var f})();const cx="undefined"!=typeof globalThis&&globalThis,ux="undefined"!=typeof window&&window,hx="undefined"!=typeof self&&"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&self,Ot=cx||"undefined"!=typeof global&&global||ux||hx,Io={},Nt=[],tu=Ft({\u0275cmp:Ft}),Kd=Ft({\u0275dir:Ft}),Qd=Ft({\u0275pipe:Ft}),Iv=Ft({\u0275mod:Ft}),Lr=Ft({\u0275fac:Ft}),el=Ft({__NG_ELEMENT_ID__:Ft});let dx=0;function ar(f){return hs(()=>{const u={},g={type:f.type,providersResolver:null,decls:f.decls,vars:f.vars,factory:null,template:f.template||null,consts:f.consts||null,ngContentSelectors:f.ngContentSelectors,hostBindings:f.hostBindings||null,hostVars:f.hostVars||0,hostAttrs:f.hostAttrs||null,contentQueries:f.contentQueries||null,declaredInputs:u,inputs:null,outputs:null,exportAs:f.exportAs||null,onPush:f.changeDetection===ji.OnPush,directiveDefs:null,pipeDefs:null,selectors:f.selectors||Nt,viewQuery:f.viewQuery||null,features:f.features||null,data:f.data||{},encapsulation:f.encapsulation||or.Emulated,id:"c",styles:f.styles||Nt,_:null,setInput:null,schemas:f.schemas||null,tView:null},p=f.directives,m=f.features,v=f.pipes;return g.id+=dx++,g.inputs=Rv(f.inputs,u),g.outputs=Rv(f.outputs),m&&m.forEach(y=>y(g)),g.directiveDefs=p?()=>("function"==typeof p?p():p).map(Tv):null,g.pipeDefs=v?()=>("function"==typeof v?v():v).map(xv):null,g})}function Tv(f){return Pn(f)||function ds(f){return f[Kd]||null}(f)}function xv(f){return function zs(f){return f[Qd]||null}(f)}const Av={};function lr(f){return hs(()=>{const l={type:f.type,bootstrap:f.bootstrap||Nt,declarations:f.declarations||Nt,imports:f.imports||Nt,exports:f.exports||Nt,transitiveCompileScopes:null,schemas:f.schemas||null,id:f.id||null};return null!=f.id&&(Av[f.id]=f.type),l})}function Rv(f,l){if(null==f)return Io;const u={};for(const g in f)if(f.hasOwnProperty(g)){let p=f[g],m=p;Array.isArray(p)&&(m=p[1],p=p[0]),u[p]=g,l&&(l[p]=m)}return u}const ze=ar;function Pn(f){return f[tu]||null}function Ei(f,l){const u=f[Iv]||null;if(!u&&!0===l)throw new Error(`Type ${Tt(f)} does not have '\u0275mod' property.`);return u}function cr(f){return Array.isArray(f)&&"object"==typeof f[1]}function Hi(f){return Array.isArray(f)&&!0===f[1]}function tf(f){return 0!=(8&f.flags)}function su(f){return 2==(2&f.flags)}function ou(f){return 1==(1&f.flags)}function Wi(f){return null!==f.template}function vx(f){return 0!=(512&f[2])}function qs(f,l){return f.hasOwnProperty(Lr)?f[Lr]:null}class wx{constructor(l,u,g){this.previousValue=l,this.currentValue=u,this.firstChange=g}isFirstChange(){return this.firstChange}}function Di(){return Mv}function Mv(f){return f.type.prototype.ngOnChanges&&(f.setInput=bx),Ex}function Ex(){const f=Fv(this),l=null==f?void 0:f.current;if(l){const u=f.previous;if(u===Io)f.previous=l;else for(let g in l)u[g]=l[g];f.current=null,this.ngOnChanges(l)}}function bx(f,l,u,g){const p=Fv(f)||function Dx(f,l){return f[Lv]=l}(f,{previous:Io,current:null}),m=p.current||(p.current={}),v=p.previous,y=this.declaredInputs[u],b=v[y];m[y]=new wx(b&&b.currentValue,l,v===Io),f[g]=l}Di.ngInherit=!0;const Lv="__ngSimpleChanges__";function Fv(f){return f[Lv]||null}let af;function Jt(f){return!!f.listen}const Pv={createRenderer:(f,l)=>function lf(){return void 0!==af?af:"undefined"!=typeof document?document:void 0}()};function un(f){for(;Array.isArray(f);)f=f[0];return f}function au(f,l){return un(l[f])}function Ii(f,l){return un(l[f.index])}function cf(f,l){return f.data[l]}function ai(f,l){const u=l[f];return cr(u)?u:u[0]}function uf(f){return 128==(128&f[2])}function fs(f,l){return null==l?null:f[l]}function kv(f){f[18]=0}function hf(f,l){f[5]+=l;let u=f,g=f[3];for(;null!==g&&(1===l&&1===u[5]||-1===l&&0===u[5]);)g[5]+=l,u=g,g=g[3]}const Qe={lFrame:Yv(null),bindingsEnabled:!0};function Vv(){return Qe.bindingsEnabled}function _e(){return Qe.lFrame.lView}function bt(){return Qe.lFrame.tView}function yn(){let f=Uv();for(;null!==f&&64===f.type;)f=f.parent;return f}function Uv(){return Qe.lFrame.currentTNode}function ur(f,l){const u=Qe.lFrame;u.currentTNode=f,u.isParent=l}function df(){return Qe.lFrame.isParent}function Mo(){return Qe.lFrame.bindingIndex++}function Gx(f,l){const u=Qe.lFrame;u.bindingIndex=u.bindingRootIndex=f,gf(l)}function gf(f){Qe.lFrame.currentDirectiveIndex=f}function mf(f){Qe.lFrame.currentQueryIndex=f}function Wx(f){const l=f[1];return 2===l.type?l.declTNode:1===l.type?f[6]:null}function Wv(f,l,u){if(u&Xe.SkipSelf){let p=l,m=f;for(;!(p=p.parent,null!==p||u&Xe.Host||(p=Wx(m),null===p||(m=m[15],10&p.type))););if(null===p)return!1;l=p,f=m}const g=Qe.lFrame=zv();return g.currentTNode=l,g.lView=f,!0}function cu(f){const l=zv(),u=f[1];Qe.lFrame=l,l.currentTNode=u.firstChild,l.lView=f,l.tView=u,l.contextLView=f,l.bindingIndex=u.bindingStartIndex,l.inI18n=!1}function zv(){const f=Qe.lFrame,l=null===f?null:f.child;return null===l?Yv(f):l}function Yv(f){const l={currentTNode:null,isParent:!0,lView:null,tView:null,selectedIndex:-1,contextLView:null,elementDepthCount:0,currentNamespace:null,currentDirectiveIndex:-1,bindingRootIndex:-1,bindingIndex:-1,currentQueryIndex:0,parent:f,child:null,inI18n:!1};return null!==f&&(f.child=l),l}function $v(){const f=Qe.lFrame;return Qe.lFrame=f.parent,f.currentTNode=null,f.lView=null,f}const Xv=$v;function uu(){const f=$v();f.isParent=!0,f.tView=null,f.selectedIndex=-1,f.contextLView=null,f.elementDepthCount=0,f.currentDirectiveIndex=-1,f.currentNamespace=null,f.bindingRootIndex=-1,f.bindingIndex=-1,f.currentQueryIndex=0}function Hn(){return Qe.lFrame.selectedIndex}function gs(f){Qe.lFrame.selectedIndex=f}function en(){const f=Qe.lFrame;return cf(f.tView,f.selectedIndex)}function hu(f,l){for(let u=l.directiveStart,g=l.directiveEnd;u=g)break}else l[b]<0&&(f[18]+=65536),(y>11>16&&(3&f[2])===l){f[2]+=2048;try{m.call(y)}finally{}}}else try{m.call(y)}finally{}}class sl{constructor(l,u,g){this.factory=l,this.resolving=!1,this.canSeeViewProviders=u,this.injectImpl=g}}function gu(f,l,u){const g=Jt(f);let p=0;for(;pl){v=m-1;break}}}for(;m>16}(f),g=l;for(;u>0;)g=g[15],u--;return g}let Cf=!0;function mu(f){const l=Cf;return Cf=f,l}let sA=0;function al(f,l){const u=Ef(f,l);if(-1!==u)return u;const g=l[1];g.firstCreatePass&&(f.injectorIndex=l.length,wf(g.data,f),wf(l,null),wf(g.blueprint,null));const p=_u(f,l),m=f.injectorIndex;if(Qv(p)){const v=Lo(p),y=Fo(p,l),b=y[1].data;for(let O=0;O<8;O++)l[m+O]=y[v+O]|b[v+O]}return l[m+8]=p,m}function wf(f,l){f.push(0,0,0,0,0,0,0,0,l)}function Ef(f,l){return-1===f.injectorIndex||f.parent&&f.parent.injectorIndex===f.injectorIndex||null===l[f.injectorIndex+8]?-1:f.injectorIndex}function _u(f,l){if(f.parent&&-1!==f.parent.injectorIndex)return f.parent.injectorIndex;let u=0,g=null,p=l;for(;null!==p;){const m=p[1],v=m.type;if(g=2===v?m.declTNode:1===v?p[6]:null,null===g)return-1;if(u++,p=p[15],-1!==g.injectorIndex)return g.injectorIndex|u<<16}return-1}function vu(f,l,u){!function oA(f,l,u){let g;"string"==typeof u?g=u.charCodeAt(0)||0:u.hasOwnProperty(el)&&(g=u[el]),null==g&&(g=u[el]=sA++);const p=255&g;l.data[f+(p>>5)]|=1<=0?255&l:lA:l}(u);if("function"==typeof m){if(!Wv(l,f,g))return g&Xe.Host?ty(p,u,g):ny(l,u,g,p);try{const v=m(g);if(null!=v||g&Xe.Optional)return v;Jc(u)}finally{Xv()}}else if("number"==typeof m){let v=null,y=Ef(f,l),b=-1,O=g&Xe.Host?l[16][6]:null;for((-1===y||g&Xe.SkipSelf)&&(b=-1===y?_u(f,l):l[y+8],-1!==b&&oy(g,!1)?(v=l[1],y=Lo(b),l=Fo(b,l)):y=-1);-1!==y;){const L=l[1];if(sy(m,y,L.data)){const N=cA(y,l,u,v,g,O);if(N!==ry)return N}b=l[y+8],-1!==b&&oy(g,l[1].data[y+8]===O)&&sy(m,y,l)?(v=L,y=Lo(b),l=Fo(b,l)):y=-1}}}return ny(l,u,g,p)}const ry={};function lA(){return new Po(yn(),_e())}function cA(f,l,u,g,p,m){const v=l[1],y=v.data[f+8],L=function yu(f,l,u,g,p){const m=f.providerIndexes,v=l.data,y=1048575&m,b=f.directiveStart,L=m>>20,B=p?y+L:f.directiveEnd;for(let U=g?y:y+L;U=b&&W.type===u)return U}if(p){const U=v[b];if(U&&Wi(U)&&U.type===u)return b}return null}(y,v,u,null==g?su(y)&&Cf:g!=v&&0!=(3&y.type),p&Xe.Host&&m===y);return null!==L?ll(l,v,L,y):ry}function ll(f,l,u,g){let p=f[u];const m=l.data;if(function eA(f){return f instanceof sl}(p)){const v=p;v.resolving&&function tx(f,l){const u=l?`. Dependency path: ${l.join(" > ")} > ${f}`:"";throw new Et(-200,`Circular dependency in DI detected for ${f}${u}`)}(An(m[u]));const y=mu(v.canSeeViewProviders);v.resolving=!0;const b=v.injectImpl?us(v.injectImpl):null;Wv(f,g,Xe.Default);try{p=f[u]=v.factory(void 0,m,f,g),l.firstCreatePass&&u>=g.directiveStart&&function Qx(f,l,u){const{ngOnChanges:g,ngOnInit:p,ngDoCheck:m}=l.type.prototype;if(g){const v=Mv(l);(u.preOrderHooks||(u.preOrderHooks=[])).push(f,v),(u.preOrderCheckHooks||(u.preOrderCheckHooks=[])).push(f,v)}p&&(u.preOrderHooks||(u.preOrderHooks=[])).push(0-f,p),m&&((u.preOrderHooks||(u.preOrderHooks=[])).push(f,m),(u.preOrderCheckHooks||(u.preOrderCheckHooks=[])).push(f,m))}(u,m[u],l)}finally{null!==b&&us(b),mu(y),v.resolving=!1,Xv()}}return p}function sy(f,l,u){return!!(u[l+(f>>5)]&1<{const l=bf(rt(f));return l&&l()}:qs(f)}const ko="__parameters__";function Vo(f,l,u){return hs(()=>{const g=function Df(f){return function(...u){if(f){const g=f(...u);for(const p in g)this[p]=g[p]}}}(l);function p(...m){if(this instanceof p)return g.apply(this,m),this;const v=new p(...m);return y.annotation=v,y;function y(b,O,L){const N=b.hasOwnProperty(ko)?b[ko]:Object.defineProperty(b,ko,{value:[]})[ko];for(;N.length<=L;)N.push(null);return(N[L]=N[L]||[]).push(v),b}}return u&&(p.prototype=Object.create(u.prototype)),p.prototype.ngMetadataName=f,p.annotationCls=p,p})}class dt{constructor(l,u){this._desc=l,this.ngMetadataName="InjectionToken",this.\u0275prov=void 0,"number"==typeof u?this.__NG_ELEMENT_ID__=u:void 0!==u&&(this.\u0275prov=yt({token:this,providedIn:u.providedIn||"root",factory:u.factory}))}toString(){return`InjectionToken ${this._desc}`}}const dA=new dt("AnalyzeForEntryComponents");function hr(f,l){f.forEach(u=>Array.isArray(u)?hr(u,l):l(u))}function ly(f,l,u){l>=f.length?f.push(u):f.splice(l,0,u)}function Cu(f,l){return l>=f.length-1?f.pop():f.splice(l,1)[0]}function li(f,l,u){let g=Uo(f,l);return g>=0?f[1|g]=u:(g=~g,function pA(f,l,u,g){let p=f.length;if(p==l)f.push(u,g);else if(1===p)f.push(g,f[0]),f[0]=u;else{for(p--,f.push(f[p-1],f[p]);p>l;)f[p]=f[p-2],p--;f[l]=u,f[l+1]=g}}(f,g,l,u)),g}function If(f,l){const u=Uo(f,l);if(u>=0)return f[1|u]}function Uo(f,l){return function hy(f,l,u){let g=0,p=f.length>>u;for(;p!==g;){const m=g+(p-g>>1),v=f[m<l?p=m:g=m+1}return~(p<({token:f})),-1),ms=pl(Vo("Optional"),8),ml=pl(Vo("SkipSelf"),4);class by{constructor(l){this.changingThisBreaksApplicationSecurity=l}toString(){return`SafeValue must use [property]=binding: ${this.changingThisBreaksApplicationSecurity} (see https://g.co/ng/security#xss)`}}function _s(f){return f instanceof by?f.changingThisBreaksApplicationSecurity:f}const qA=/^(?:(?:https?|mailto|ftp|tel|file|sms):|[^&:/?#]*(?:[/?#]|$))/gi,ZA=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+\/]+=*$/i;var hn=(()=>((hn=hn||{})[hn.NONE=0]="NONE",hn[hn.HTML=1]="HTML",hn[hn.STYLE=2]="STYLE",hn[hn.SCRIPT=3]="SCRIPT",hn[hn.URL=4]="URL",hn[hn.RESOURCE_URL=5]="RESOURCE_URL",hn))();function kf(f){const l=function Cl(){const f=_e();return f&&f[12]}();return l?l.sanitize(hn.URL,f)||"":function vl(f,l){const u=function zA(f){return f instanceof by&&f.getTypeName()||null}(f);if(null!=u&&u!==l){if("ResourceURL"===u&&"URL"===l)return!0;throw new Error(`Required a safe ${l}, got a ${u} (see https://g.co/ng/security#xss)`)}return u===l}(f,"URL")?_s(f):function Tu(f){return(f=String(f)).match(qA)||f.match(ZA)?f:"unsafe:"+f}(Ke(f))}const Ly="__ngContext__";function Bn(f,l){f[Ly]=l}function Vf(f){const l=function wl(f){return f[Ly]||null}(f);return l?Array.isArray(l)?l:l.lView:null}function jf(f){return f.ngOriginalError}function yR(f,...l){f.error(...l)}class El{constructor(){this._console=console}handleError(l){const u=this._findOriginalError(l),g=function vR(f){return f&&f.ngErrorLogger||yR}(l);g(this._console,"ERROR",l),u&&g(this._console,"ORIGINAL ERROR",u)}_findOriginalError(l){let u=l&&jf(l);for(;u&&jf(u);)u=jf(u);return u||null}}const AR=(()=>("undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||setTimeout).bind(Ot))();function fr(f){return f instanceof Function?f():f}var ci=(()=>((ci=ci||{})[ci.Important=1]="Important",ci[ci.DashCase=2]="DashCase",ci))();function Hf(f,l){return undefined(f,l)}function bl(f){const l=f[3];return Hi(l)?l[3]:l}function Wf(f){return Gy(f[13])}function zf(f){return Gy(f[4])}function Gy(f){for(;null!==f&&!Hi(f);)f=f[4];return f}function Wo(f,l,u,g,p){if(null!=g){let m,v=!1;Hi(g)?m=g:cr(g)&&(v=!0,g=g[0]);const y=un(g);0===f&&null!==u?null==p?Xy(l,u,y):Zs(l,u,y,p||null,!0):1===f&&null!==u?Zs(l,u,y,p||null,!0):2===f?function t0(f,l,u){const g=Au(f,l);g&&function HR(f,l,u,g){Jt(f)?f.removeChild(l,u,g):l.removeChild(u)}(f,g,l,u)}(l,y,v):3===f&&l.destroyNode(y),null!=m&&function YR(f,l,u,g,p){const m=u[7];m!==un(u)&&Wo(l,f,g,m,p);for(let y=10;y0&&(f[u-1][4]=g[4]);const m=Cu(f,10+l);!function PR(f,l){Dl(f,l,l[11],2,null,null),l[0]=null,l[6]=null}(g[1],g);const v=m[19];null!==v&&v.detachView(m[1]),g[3]=null,g[4]=null,g[2]&=-129}return g}function zy(f,l){if(!(256&l[2])){const u=l[11];Jt(u)&&u.destroyNode&&Dl(f,l,u,3,null,null),function BR(f){let l=f[13];if(!l)return qf(f[1],f);for(;l;){let u=null;if(cr(l))u=l[13];else{const g=l[10];g&&(u=g)}if(!u){for(;l&&!l[4]&&l!==f;)cr(l)&&qf(l[1],l),l=l[3];null===l&&(l=f),cr(l)&&qf(l[1],l),u=l&&l[4]}l=u}}(l)}}function qf(f,l){if(!(256&l[2])){l[2]&=-129,l[2]|=256,function GR(f,l){let u;if(null!=f&&null!=(u=f.destroyHooks))for(let g=0;g=0?g[p=O]():g[p=-O].unsubscribe(),m+=2}else{const v=g[p=u[m+1]];u[m].call(v)}if(null!==g){for(let m=p+1;mm?"":p[N+1].toLowerCase();const U=8&g?B:null;if(U&&-1!==s0(U,O,0)||2&g&&O!==B){if(zi(g))return!1;v=!0}}}}else{if(!v&&!zi(g)&&!zi(b))return!1;if(v&&zi(b))continue;v=!1,g=b|1&g}}return zi(g)||v}function zi(f){return 0==(1&f)}function KR(f,l,u,g){if(null===l)return-1;let p=0;if(g||!u){let m=!1;for(;p-1)for(u++;u0?'="'+y+'"':"")+"]"}else 8&g?p+="."+v:4&g&&(p+=" "+v);else""!==p&&!zi(v)&&(l+=c0(m,p),p=""),g=v,m=m||!zi(g);u++}return""!==p&&(l+=c0(m,p)),l}const Je={};function Rn(f){u0(bt(),_e(),Hn()+f,!1)}function u0(f,l,u,g){if(!g)if(3==(3&l[2])){const m=f.preOrderCheckHooks;null!==m&&du(l,m,u)}else{const m=f.preOrderHooks;null!==m&&fu(l,m,0,u)}gs(u)}function Mu(f,l){return f<<17|l<<2}function Yi(f){return f>>17&32767}function eg(f){return 2|f}function Nr(f){return(131068&f)>>2}function tg(f,l){return-131069&f|l<<2}function ng(f){return 1|f}function w0(f,l){const u=f.contentQueries;if(null!==u)for(let g=0;g20&&u0(f,l,20,!1),u(g,p)}finally{gs(m)}}function dg(f,l,u){!Vv()||(function T1(f,l,u,g){const p=u.directiveStart,m=u.directiveEnd;f.firstCreatePass||al(u,l),Bn(g,l);const v=u.initialInputs;for(let y=p;y0;){const u=f[--l];if("number"==typeof u&&u<0)return u}return 0})(y)!=b&&y.push(b),y.push(g,p,v)}}function O0(f,l){null!==f.hostBindings&&f.hostBindings(1,l)}function M0(f,l){l.flags|=2,(f.components||(f.components=[])).push(l.index)}function O1(f,l,u){if(u){if(l.exportAs)for(let g=0;g0&&mg(u)}}function mg(f){for(let g=Wf(f);null!==g;g=zf(g))for(let p=10;p0&&mg(m)}const u=f[1].components;if(null!==u)for(let g=0;g0&&mg(p)}}function B1(f,l){const u=ai(l,f),g=u[1];(function V1(f,l){for(let u=l.length;uPromise.resolve(null))();function k0(f){return f[7]||(f[7]=[])}function B0(f){return f.cleanup||(f.cleanup=[])}function U0(f,l){const u=f[9],g=u?u.get(El,null):null;g&&g.handleError(l)}function j0(f,l,u,g,p){for(let m=0;mthis.processProvider(y,l,u)),hr([l],y=>this.processInjectorType(y,[],m)),this.records.set(wg,Xo(void 0,this));const v=this.records.get(Eg);this.scope=null!=v?v.value:null,this.source=p||("object"==typeof l?null:Tt(l))}get destroyed(){return this._destroyed}destroy(){this.assertNotDestroyed(),this._destroyed=!0;try{this.onDestroy.forEach(l=>l.ngOnDestroy())}finally{this.records.clear(),this.onDestroy.clear(),this.injectorDefTypes.clear()}}get(l,u=fl,g=Xe.Default){this.assertNotDestroyed();const p=gy(this),m=us(void 0);try{if(!(g&Xe.SkipSelf)){let y=this.records.get(l);if(void 0===y){const b=function J1(f){return"function"==typeof f||"object"==typeof f&&f instanceof dt}(l)&&Xd(l);y=b&&this.injectableDefInScope(b)?Xo(Dg(l),Tl):null,this.records.set(l,y)}if(null!=y)return this.hydrate(l,y)}return(g&Xe.Self?H0():this.parent).get(l,u=g&Xe.Optional&&u===fl?null:u)}catch(v){if("NullInjectorError"===v.name){if((v[Eu]=v[Eu]||[]).unshift(Tt(l)),p)throw v;return function xA(f,l,u,g){const p=f[Eu];throw l[fy]&&p.unshift(l[fy]),f.message=function AA(f,l,u,g=null){f=f&&"\n"===f.charAt(0)&&"\u0275"==f.charAt(1)?f.substr(2):f;let p=Tt(l);if(Array.isArray(l))p=l.map(Tt).join(" -> ");else if("object"==typeof l){let m=[];for(let v in l)if(l.hasOwnProperty(v)){let y=l[v];m.push(v+":"+("string"==typeof y?JSON.stringify(y):Tt(y)))}p=`{${m.join(", ")}}`}return`${u}${g?"("+g+")":""}[${p}]: ${f.replace(EA,"\n ")}`}("\n"+f.message,p,u,g),f.ngTokenPath=p,f[Eu]=null,f}(v,l,"R3InjectorError",this.source)}throw v}finally{us(m),gy(p)}}_resolveInjectorDefTypes(){this.injectorDefTypes.forEach(l=>this.get(l))}toString(){const l=[];return this.records.forEach((g,p)=>l.push(Tt(p))),`R3Injector[${l.join(", ")}]`}assertNotDestroyed(){if(this._destroyed)throw new Et(205,!1)}processInjectorType(l,u,g){if(!(l=rt(l)))return!1;let p=bv(l);const m=null==p&&l.ngModule||void 0,v=void 0===m?l:m,y=-1!==g.indexOf(v);if(void 0!==m&&(p=bv(m)),null==p)return!1;if(null!=p.imports&&!y){let L;g.push(v);try{hr(p.imports,N=>{this.processInjectorType(N,u,g)&&(void 0===L&&(L=[]),L.push(N))})}finally{}if(void 0!==L)for(let N=0;Nthis.processProvider(W,B,U||Nt))}}this.injectorDefTypes.add(v);const b=qs(v)||(()=>new v);this.records.set(v,Xo(b,Tl));const O=p.providers;if(null!=O&&!y){const L=l;hr(O,N=>this.processProvider(N,L,O))}return void 0!==m&&void 0!==l.providers}processProvider(l,u,g){let p=qo(l=rt(l))?l:rt(l&&l.provide);const m=function $1(f,l,u){return $0(f)?Xo(void 0,f.useValue):Xo(Y0(f),Tl)}(l);if(qo(l)||!0!==l.multi)this.records.get(p);else{let v=this.records.get(p);v||(v=Xo(void 0,Tl,!0),v.factory=()=>Af(v.multi),this.records.set(p,v)),p=l,v.multi.push(l)}this.records.set(p,m)}hydrate(l,u){return u.value===Tl&&(u.value=W1,u.value=u.factory()),"object"==typeof u.value&&u.value&&function Q1(f){return null!==f&&"object"==typeof f&&"function"==typeof f.ngOnDestroy}(u.value)&&this.onDestroy.add(u.value),u.value}injectableDefInScope(l){if(!l.providedIn)return!1;const u=rt(l.providedIn);return"string"==typeof u?"any"===u||u===this.scope:this.injectorDefTypes.has(u)}}function Dg(f){const l=Xd(f),u=null!==l?l.factory:qs(f);if(null!==u)return u;if(f instanceof dt)throw new Et(204,!1);if(f instanceof Function)return function Y1(f){const l=f.length;if(l>0)throw function dl(f,l){const u=[];for(let g=0;gu.factory(f):()=>new f}(f);throw new Et(204,!1)}function Y0(f,l,u){let g;if(qo(f)){const p=rt(f);return qs(p)||Dg(p)}if($0(f))g=()=>rt(f.useValue);else if(function q1(f){return!(!f||!f.useFactory)}(f))g=()=>f.useFactory(...Af(f.deps||[]));else if(function X1(f){return!(!f||!f.useExisting)}(f))g=()=>Ye(rt(f.useExisting));else{const p=rt(f&&(f.useClass||f.provide));if(!function K1(f){return!!f.deps}(f))return qs(p)||Dg(p);g=()=>new p(...Af(f.deps))}return g}function Xo(f,l,u=!1){return{factory:f,value:l,multi:u?[]:void 0}}function $0(f){return null!==f&&"object"==typeof f&&DA in f}function qo(f){return"function"==typeof f}let Qn=(()=>{class f{static create(u,g){var p;if(Array.isArray(u))return W0({name:""},g,u,"");{const m=null!==(p=u.name)&&void 0!==p?p:"";return W0({name:m},u.parent,u.providers,m)}}}return f.THROW_IF_NOT_FOUND=fl,f.NULL=new G0,f.\u0275prov=yt({token:f,providedIn:"any",factory:()=>Ye(wg)}),f.__NG_ELEMENT_ID__=-1,f})();function aO(f,l){hu(Vf(f)[1],yn())}function xt(f){let l=function sC(f){return Object.getPrototypeOf(f.prototype).constructor}(f.type),u=!0;const g=[f];for(;l;){let p;if(Wi(f))p=l.\u0275cmp||l.\u0275dir;else{if(l.\u0275cmp)throw new Et(903,"");p=l.\u0275dir}if(p){if(u){g.push(p);const v=f;v.inputs=Tg(f.inputs),v.declaredInputs=Tg(f.declaredInputs),v.outputs=Tg(f.outputs);const y=p.hostBindings;y&&hO(f,y);const b=p.viewQuery,O=p.contentQueries;if(b&&cO(f,b),O&&uO(f,O),zd(f.inputs,p.inputs),zd(f.declaredInputs,p.declaredInputs),zd(f.outputs,p.outputs),Wi(p)&&p.data.animation){const L=f.data;L.animation=(L.animation||[]).concat(p.data.animation)}}const m=p.features;if(m)for(let v=0;v=0;g--){const p=f[g];p.hostVars=l+=p.hostVars,p.hostAttrs=pu(p.hostAttrs,u=pu(u,p.hostAttrs))}}(g)}function Tg(f){return f===Io?{}:f===Nt?[]:f}function cO(f,l){const u=f.viewQuery;f.viewQuery=u?(g,p)=>{l(g,p),u(g,p)}:l}function uO(f,l){const u=f.contentQueries;f.contentQueries=u?(g,p,m)=>{l(g,p,m),u(g,p,m)}:l}function hO(f,l){const u=f.hostBindings;f.hostBindings=u?(g,p)=>{l(g,p),u(g,p)}:l}let Bu=null;function Zo(){if(!Bu){const f=Ot.Symbol;if(f&&f.iterator)Bu=f.iterator;else{const l=Object.getOwnPropertyNames(Map.prototype);for(let u=0;uy(un(pe[g.index])):g.index;if(Jt(u)){let pe=null;if(!y&&b&&(pe=function HO(f,l,u,g){const p=f.cleanup;if(null!=p)for(let m=0;mb?y[b]:null}"string"==typeof v&&(m+=2)}return null}(f,l,p,g.index)),null!==pe)(pe.__ngLastListenerFn__||pe).__ngNextListenerFn__=m,pe.__ngLastListenerFn__=m,U=!1;else{m=Bg(g,l,N,m,!1);const ve=u.listen(q,p,m);B.push(m,ve),L&&L.push(p,Q,X,X+1)}}else m=Bg(g,l,N,m,!0),q.addEventListener(p,m,v),B.push(m),L&&L.push(p,Q,X,v)}else m=Bg(g,l,N,m,!1);const W=g.outputs;let Y;if(U&&null!==W&&(Y=W[p])){const $=Y.length;if($)for(let q=0;q<$;q+=2){const Te=l[Y[q]][Y[q+1]].subscribe(m),Ae=B.length;B.push(m,Te),L&&L.push(p,g.index,Ae,-(Ae+1))}}}(m,p,p[11],v,f,l,!!u,g),kt}function AC(f,l,u,g){try{return!1!==u(g)}catch(p){return U0(f,p),!1}}function Bg(f,l,u,g,p){return function m(v){if(v===Function)return g;const y=2&f.flags?ai(f.index,l):l;0==(32&l[2])&&_g(y);let b=AC(l,0,g,v),O=m.__ngNextListenerFn__;for(;O;)b=AC(l,0,O,v)&&b,O=O.__ngNextListenerFn__;return p&&!1===b&&(v.preventDefault(),v.returnValue=!1),b}}function Qs(f=1){return function zx(f){return(Qe.lFrame.contextLView=function Yx(f,l){for(;f>0;)l=l[15],f--;return l}(f,Qe.lFrame.contextLView))[8]}(f)}function VC(f,l,u,g,p){const m=f[u+1],v=null===l;let y=g?Yi(m):Nr(m),b=!1;for(;0!==y&&(!1===b||v);){const L=f[y+1];qO(f[y],l)&&(b=!0,f[y+1]=g?ng(L):eg(L)),y=g?Yi(L):Nr(L)}b&&(f[u+1]=g?eg(m):ng(m))}function qO(f,l){return null===f||null==l||(Array.isArray(f)?f[1]:f)===l||!(!Array.isArray(f)||"string"!=typeof l)&&Uo(f,l)>=0}function ju(f,l){return function Xi(f,l,u,g){const p=_e(),m=bt(),v=function Pr(f){const l=Qe.lFrame,u=l.bindingIndex;return l.bindingIndex=l.bindingIndex+f,u}(2);m.firstUpdatePass&&function XC(f,l,u,g){const p=f.data;if(null===p[u+1]){const m=p[Hn()],v=function $C(f,l){return l>=f.expandoStartIndex}(f,u);(function QC(f,l){return 0!=(f.flags&(l?16:32))})(m,g)&&null===l&&!v&&(l=!1),l=function rM(f,l,u,g){const p=function pf(f){const l=Qe.lFrame.currentDirectiveIndex;return-1===l?null:f[l]}(f);let m=g?l.residualClasses:l.residualStyles;if(null===p)0===(g?l.classBindings:l.styleBindings)&&(u=Ol(u=Ug(null,f,l,u,g),l.attrs,g),m=null);else{const v=l.directiveStylingLast;if(-1===v||f[v]!==p)if(u=Ug(p,f,l,u,g),null===m){let b=function sM(f,l,u){const g=u?l.classBindings:l.styleBindings;if(0!==Nr(g))return f[Yi(g)]}(f,l,g);void 0!==b&&Array.isArray(b)&&(b=Ug(null,f,l,b[1],g),b=Ol(b,l.attrs,g),function oM(f,l,u,g){f[Yi(u?l.classBindings:l.styleBindings)]=g}(f,l,g,b))}else m=function aM(f,l,u){let g;const p=l.directiveEnd;for(let m=1+l.directiveStylingLast;m0)&&(O=!0)}else L=u;if(p)if(0!==b){const B=Yi(f[y+1]);f[g+1]=Mu(B,y),0!==B&&(f[B+1]=tg(f[B+1],g)),f[y+1]=function s1(f,l){return 131071&f|l<<17}(f[y+1],g)}else f[g+1]=Mu(y,0),0!==y&&(f[y+1]=tg(f[y+1],g)),y=g;else f[g+1]=Mu(b,0),0===y?y=g:f[b+1]=tg(f[b+1],g),b=g;O&&(f[g+1]=eg(f[g+1])),VC(f,L,g,!0),VC(f,L,g,!1),function XO(f,l,u,g,p){const m=p?f.residualClasses:f.residualStyles;null!=m&&"string"==typeof l&&Uo(m,l)>=0&&(u[g+1]=ng(u[g+1]))}(l,L,f,g,m),v=Mu(y,b),m?l.classBindings=v:l.styleBindings=v}(p,m,l,u,v,g)}}(m,f,v,g),l!==Je&&Vn(p,v,l)&&function ZC(f,l,u,g,p,m,v,y){if(!(3&l.type))return;const b=f.data,O=b[y+1];Gu(function f0(f){return 1==(1&f)}(O)?KC(b,l,u,p,Nr(O),v):void 0)||(Gu(m)||function d0(f){return 2==(2&f)}(O)&&(m=KC(b,null,u,p,y,v)),function $R(f,l,u,g,p){const m=Jt(f);if(l)p?m?f.addClass(u,g):u.classList.add(g):m?f.removeClass(u,g):u.classList.remove(g);else{let v=-1===g.indexOf("-")?void 0:ci.DashCase;if(null==p)m?f.removeStyle(u,g,v):u.style.removeProperty(g);else{const y="string"==typeof p&&p.endsWith("!important");y&&(p=p.slice(0,-10),v|=ci.Important),m?f.setStyle(u,g,p,v):u.style.setProperty(g,p,y?"important":"")}}}(g,v,au(Hn(),u),p,m))}(m,m.data[Hn()],p,p[11],f,p[v+1]=function uM(f,l){return null==f||("string"==typeof l?f+=l:"object"==typeof f&&(f=Tt(_s(f)))),f}(l,u),g,v)}(f,l,null,!0),ju}function Ug(f,l,u,g,p){let m=null;const v=u.directiveEnd;let y=u.directiveStylingLast;for(-1===y?y=u.directiveStart:y++;y0;){const b=f[p],O=Array.isArray(b),L=O?b[1]:b,N=null===L;let B=u[p+1];B===Je&&(B=N?Nt:void 0);let U=N?If(B,g):L===g?B:void 0;if(O&&!Gu(U)&&(U=If(b,g)),Gu(U)&&(y=U,v))return y;const W=f[p+1];p=v?Yi(W):Nr(W)}if(null!==l){let b=m?l.residualClasses:l.residualStyles;null!=b&&(y=If(b,g))}return y}function Gu(f){return void 0!==f}function Kt(f,l=""){const u=_e(),g=bt(),p=f+20,m=g.firstCreatePass?zo(g,p,1,l,null):g.data[p],v=u[p]=function Yf(f,l){return Jt(f)?f.createText(l):f.createTextNode(l)}(u[11],l);Ru(g,u,v,m),ur(m,!1)}function ws(f,l,u){const g=_e(),p=function Qo(f,l,u,g){return Vn(f,Mo(),u)?l+Ke(u)+g:Je}(g,f,l,u);return p!==Je&&kr(g,Hn(),p),ws}const Hu="en-US";let ww=Hu;function Hg(f,l,u,g,p){if(f=rt(f),Array.isArray(f))for(let m=0;m>20;if(qo(f)||!f.multi){const U=new sl(b,p,ye),W=zg(y,l,p?L:L+B,N);-1===W?(vu(al(O,v),m,y),Wg(m,f,l.length),l.push(y),O.directiveStart++,O.directiveEnd++,p&&(O.providerIndexes+=1048576),u.push(U),v.push(U)):(u[W]=U,v[W]=U)}else{const U=zg(y,l,L+B,N),W=zg(y,l,L,L+B),Y=U>=0&&u[U],$=W>=0&&u[W];if(p&&!$||!p&&!Y){vu(al(O,v),m,y);const q=function AL(f,l,u,g,p){const m=new sl(f,u,ye);return m.multi=[],m.index=l,m.componentProviders=0,zw(m,p,g&&!u),m}(p?xL:TL,u.length,p,g,b);!p&&$&&(u[W].providerFactory=q),Wg(m,f,l.length,0),l.push(y),O.directiveStart++,O.directiveEnd++,p&&(O.providerIndexes+=1048576),u.push(q),v.push(q)}else Wg(m,f,U>-1?U:W,zw(u[p?W:U],b,!p&&g));!p&&g&&$&&u[W].componentProviders++}}}function Wg(f,l,u,g){const p=qo(l),m=function Z1(f){return!!f.useClass}(l);if(p||m){const b=(m?rt(l.useClass):l).prototype.ngOnDestroy;if(b){const O=f.destroyHooks||(f.destroyHooks=[]);if(!p&&l.multi){const L=O.indexOf(u);-1===L?O.push(u,[g,b]):O[L+1].push(g,b)}else O.push(u,b)}}}function zw(f,l,u){return u&&f.componentProviders++,f.multi.push(l)-1}function zg(f,l,u,g){for(let p=u;p{u.providersResolver=(g,p)=>function IL(f,l,u){const g=bt();if(g.firstCreatePass){const p=Wi(f);Hg(u,g.data,g.blueprint,p,!0),Hg(l,g.data,g.blueprint,p,!1)}}(g,p?p(f):f,l)}}class Yw{}class ML{resolveComponentFactory(l){throw function OL(f){const l=Error(`No component factory found for ${Tt(f)}. Did you add it to @NgModule.entryComponents?`);return l.ngComponent=f,l}(l)}}let Nl=(()=>{class f{}return f.NULL=new ML,f})();function LL(){return ua(yn(),_e())}function ua(f,l){return new hi(Ii(f,l))}let hi=(()=>{class f{constructor(u){this.nativeElement=u}}return f.__NG_ELEMENT_ID__=LL,f})();class Xw{}let Br=(()=>{class f{}return f.__NG_ELEMENT_ID__=()=>function NL(){const f=_e(),u=ai(yn().index,f);return function PL(f){return f[11]}(cr(u)?u:f)}(),f})(),kL=(()=>{class f{}return f.\u0275prov=yt({token:f,providedIn:"root",factory:()=>null}),f})();class kl{constructor(l){this.full=l,this.major=l.split(".")[0],this.minor=l.split(".")[1],this.patch=l.split(".").slice(2).join(".")}}const BL=new kl("13.3.10"),$g={};function Xu(f,l,u,g,p=!1){for(;null!==u;){const m=l[u.index];if(null!==m&&g.push(un(m)),Hi(m))for(let y=10;y-1&&(Xf(l,g),Cu(u,g))}this._attachedToViewContainer=!1}zy(this._lView[1],this._lView)}onDestroy(l){!function T0(f,l,u,g){const p=k0(l);null===u?p.push(g):(p.push(u),f.firstCreatePass&&B0(f).push(g,p.length-1))}(this._lView[1],this._lView,null,l)}markForCheck(){_g(this._cdRefInjectingView||this._lView)}detach(){this._lView[2]&=-129}reattach(){this._lView[2]|=128}detectChanges(){!function yg(f,l,u){const g=l[10];g.begin&&g.begin();try{$o(f,l,f.template,u)}catch(p){throw U0(l,p),p}finally{g.end&&g.end()}}(this._lView[1],this._lView,this.context)}checkNoChanges(){}attachToViewContainerRef(){if(this._appRef)throw new Et(902,"");this._attachedToViewContainer=!0}detachFromAppRef(){this._appRef=null,function kR(f,l){Dl(f,l,l[11],2,null,null)}(this._lView[1],this._lView)}attachToAppRef(l){if(this._attachedToViewContainer)throw new Et(902,"");this._appRef=l}}class VL extends Bl{constructor(l){super(l),this._view=l}detectChanges(){N0(this._view)}checkNoChanges(){}get context(){return null}}class qw extends Nl{constructor(l){super(),this.ngModule=l}resolveComponentFactory(l){const u=Pn(l);return new Xg(u,this.ngModule)}}function Zw(f){const l=[];for(let u in f)f.hasOwnProperty(u)&&l.push({propName:f[u],templateName:u});return l}class Xg extends Yw{constructor(l,u){super(),this.componentDef=l,this.ngModule=u,this.componentType=l.type,this.selector=function i1(f){return f.map(n1).join(",")}(l.selectors),this.ngContentSelectors=l.ngContentSelectors?l.ngContentSelectors:[],this.isBoundToModule=!!u}get inputs(){return Zw(this.componentDef.inputs)}get outputs(){return Zw(this.componentDef.outputs)}create(l,u,g,p){const m=(p=p||this.ngModule)?function jL(f,l){return{get:(u,g,p)=>{const m=f.get(u,$g,p);return m!==$g||g===$g?m:l.get(u,g,p)}}}(l,p.injector):l,v=m.get(Xw,Pv),y=m.get(kL,null),b=v.createRenderer(null,this.componentDef),O=this.componentDef.selectors[0][0]||"div",L=g?function I0(f,l,u){if(Jt(f))return f.selectRootElement(l,u===or.ShadowDom);let g="string"==typeof l?f.querySelector(l):l;return g.textContent="",g}(b,g,this.componentDef.encapsulation):$f(v.createRenderer(null,this.componentDef),O,function UL(f){const l=f.toLowerCase();return"svg"===l?"svg":"math"===l?"math":null}(O)),N=this.componentDef.onPush?576:528,B=function rC(f,l){return{components:[],scheduler:f||AR,clean:j1,playerHandler:l||null,flags:0}}(),U=Pu(0,null,null,1,0,null,null,null,null,null),W=Sl(null,U,B,N,null,null,v,b,y,m);let Y,$;cu(W);try{const q=function nC(f,l,u,g,p,m){const v=u[1];u[20]=f;const b=zo(v,20,2,"#host",null),O=b.mergedAttrs=l.hostAttrs;null!==O&&(ku(b,O,!0),null!==f&&(gu(p,f,O),null!==b.classes&&Jf(p,f,b.classes),null!==b.styles&&r0(p,f,b.styles)));const L=g.createRenderer(f,l),N=Sl(u,D0(l),null,l.onPush?64:16,u[20],b,g,L,m||null,null);return v.firstCreatePass&&(vu(al(b,u),v,l.type),M0(v,b),L0(b,u.length,1)),Nu(u,N),u[20]=N}(L,this.componentDef,W,v,b);if(L)if(g)gu(b,L,["ng-version",BL.full]);else{const{attrs:X,classes:Q}=function r1(f){const l=[],u=[];let g=1,p=2;for(;g0&&Jf(b,L,Q.join(" "))}if($=cf(U,20),void 0!==u){const X=$.projection=[];for(let Q=0;Qb(v,l)),l.contentQueries){const b=yn();l.contentQueries(1,v,b.directiveStart)}const y=yn();return!m.firstCreatePass||null===l.hostBindings&&null===l.hostAttrs||(gs(y.index),R0(u[1],y,0,y.directiveStart,y.directiveEnd,l),O0(l,v)),v}(q,this.componentDef,W,B,[aO]),Il(U,W,null)}finally{uu()}return new HL(this.componentType,Y,ua($,W),W,$)}}class HL extends class RL{}{constructor(l,u,g,p,m){super(),this.location=g,this._rootLView=p,this._tNode=m,this.instance=u,this.hostView=this.changeDetectorRef=new VL(p),this.componentType=l}get injector(){return new Po(this._tNode,this._rootLView)}destroy(){this.hostView.destroy()}onDestroy(l){this.hostView.onDestroy(l)}}class Vr{}class Kw{}const ha=new Map;class eE extends Vr{constructor(l,u){super(),this._parent=u,this._bootstrapComponents=[],this.injector=this,this.destroyCbs=[],this.componentFactoryResolver=new qw(this);const g=Ei(l);this._bootstrapComponents=fr(g.bootstrap),this._r3Injector=z0(l,u,[{provide:Vr,useValue:this},{provide:Nl,useValue:this.componentFactoryResolver}],Tt(l)),this._r3Injector._resolveInjectorDefTypes(),this.instance=this.get(l)}get(l,u=Qn.THROW_IF_NOT_FOUND,g=Xe.Default){return l===Qn||l===Vr||l===wg?this:this._r3Injector.get(l,u,g)}destroy(){const l=this._r3Injector;!l.destroyed&&l.destroy(),this.destroyCbs.forEach(u=>u()),this.destroyCbs=null}onDestroy(l){this.destroyCbs.push(l)}}class qg extends Kw{constructor(l){super(),this.moduleType=l,null!==Ei(l)&&function zL(f){const l=new Set;!function u(g){const p=Ei(g,!0),m=p.id;null!==m&&(function Qw(f,l,u){if(l&&l!==u)throw new Error(`Duplicate module registered for ${f} - ${Tt(l)} vs ${Tt(l.name)}`)}(m,ha.get(m),g),ha.set(m,g));const v=fr(p.imports);for(const y of v)l.has(y)||(l.add(y),u(y))}(f)}(l)}create(l){return new eE(this.moduleType,l)}}function da(f,l,u){const g=function Gn(){const f=Qe.lFrame;let l=f.bindingRootIndex;return-1===l&&(l=f.bindingRootIndex=f.tView.bindingStartIndex),l}()+f,p=_e();return p[g]===Je?function pr(f,l,u){return f[l]=u}(p,g,u?l.call(u):l()):function Al(f,l){return f[l]}(p,g)}function Zg(f){return l=>{setTimeout(f,void 0,l)}}const nn=class lF extends Ar{constructor(l=!1){super(),this.__isAsync=l}emit(l){super.next(l)}subscribe(l,u,g){var p,m,v;let y=l,b=u||(()=>null),O=g;if(l&&"object"==typeof l){const N=l;y=null===(p=N.next)||void 0===p?void 0:p.bind(N),b=null===(m=N.error)||void 0===m?void 0:m.bind(N),O=null===(v=N.complete)||void 0===v?void 0:v.bind(N)}this.__isAsync&&(b=Zg(b),y&&(y=Zg(y)),O&&(O=Zg(O)));const L=super.subscribe({next:y,error:b,complete:O});return l instanceof wi&&l.add(L),L}};Symbol;let Ur=(()=>{class f{}return f.__NG_ELEMENT_ID__=dF,f})();const uF=Ur,hF=class extends uF{constructor(l,u,g){super(),this._declarationLView=l,this._declarationTContainer=u,this.elementRef=g}createEmbeddedView(l){const u=this._declarationTContainer.tViews,g=Sl(this._declarationLView,u,l,16,null,u.declTNode,null,null,null,null);g[17]=this._declarationLView[this._declarationTContainer.index];const m=this._declarationLView[19];return null!==m&&(g[19]=m.createEmbeddedView(u)),Il(u,g,l),new Bl(g)}};function dF(){return function qu(f,l){return 4&f.type?new hF(l,f,ua(f,l)):null}(yn(),_e())}let Zi=(()=>{class f{}return f.__NG_ELEMENT_ID__=fF,f})();function fF(){return function lE(f,l){let u;const g=l[f.index];if(Hi(g))u=g;else{let p;if(8&f.type)p=un(g);else{const m=l[11];p=m.createComment("");const v=Ii(f,l);Zs(m,Au(m,v),p,function WR(f,l){return Jt(f)?f.nextSibling(l):l.nextSibling}(m,v),!1)}l[f.index]=u=P0(g,l,p,f),Nu(l,u)}return new oE(u,f,l)}(yn(),_e())}const gF=Zi,oE=class extends gF{constructor(l,u,g){super(),this._lContainer=l,this._hostTNode=u,this._hostLView=g}get element(){return ua(this._hostTNode,this._hostLView)}get injector(){return new Po(this._hostTNode,this._hostLView)}get parentInjector(){const l=_u(this._hostTNode,this._hostLView);if(Qv(l)){const u=Fo(l,this._hostLView),g=Lo(l);return new Po(u[1].data[g+8],u)}return new Po(null,this._hostLView)}clear(){for(;this.length>0;)this.remove(this.length-1)}get(l){const u=aE(this._lContainer);return null!==u&&u[l]||null}get length(){return this._lContainer.length-10}createEmbeddedView(l,u,g){const p=l.createEmbeddedView(u||{});return this.insert(p,g),p}createComponent(l,u,g,p,m){const v=l&&!function hl(f){return"function"==typeof f}(l);let y;if(v)y=u;else{const N=u||{};y=N.index,g=N.injector,p=N.projectableNodes,m=N.ngModuleRef}const b=v?l:new Xg(Pn(l)),O=g||this.parentInjector;if(!m&&null==b.ngModule){const B=(v?O:this.parentInjector).get(Vr,null);B&&(m=B)}const L=b.create(O,p,void 0,m);return this.insert(L.hostView,y),L}insert(l,u){const g=l._lView,p=g[1];if(function Lx(f){return Hi(f[3])}(g)){const L=this.indexOf(l);if(-1!==L)this.detach(L);else{const N=g[3],B=new oE(N,N[6],N[3]);B.detach(B.indexOf(l))}}const m=this._adjustIndex(u),v=this._lContainer;!function VR(f,l,u,g){const p=10+g,m=u.length;g>0&&(u[p-1][4]=l),g{class f{constructor(u){this.appInits=u,this.resolve=Qu,this.reject=Qu,this.initialized=!1,this.done=!1,this.donePromise=new Promise((g,p)=>{this.resolve=g,this.reject=p})}runInitializers(){if(this.initialized)return;const u=[],g=()=>{this.done=!0,this.resolve()};if(this.appInits)for(let p=0;p{m.subscribe({complete:y,error:b})});u.push(v)}}Promise.all(u).then(()=>{g()}).catch(p=>{this.reject(p)}),0===u.length&&g(),this.initialized=!0}}return f.\u0275fac=function(u){return new(u||f)(Ye(dp,8))},f.\u0275prov=yt({token:f,factory:f.\u0275fac,providedIn:"root"}),f})();const Gl=new dt("AppId",{providedIn:"root",factory:function RE(){return`${gp()}${gp()}${gp()}`}});function gp(){return String.fromCharCode(97+Math.floor(25*Math.random()))}const OE=new dt("Platform Initializer"),ME=new dt("Platform ID",{providedIn:"platform",factory:()=>"unknown"}),LE=new dt("appBootstrapListener");let jF=(()=>{class f{log(u){console.log(u)}warn(u){console.warn(u)}}return f.\u0275fac=function(u){return new(u||f)},f.\u0275prov=yt({token:f,factory:f.\u0275fac,providedIn:"platform"}),f})();const Es=new dt("LocaleId",{providedIn:"root",factory:()=>IA(Es,Xe.Optional|Xe.SkipSelf)||function GF(){return"undefined"!=typeof $localize&&$localize.locale||Hu}()});class WF{constructor(l,u){this.ngModuleFactory=l,this.componentFactories=u}}let FE=(()=>{class f{compileModuleSync(u){return new qg(u)}compileModuleAsync(u){return Promise.resolve(this.compileModuleSync(u))}compileModuleAndAllComponentsSync(u){const g=this.compileModuleSync(u),m=fr(Ei(u).declarations).reduce((v,y)=>{const b=Pn(y);return b&&v.push(new Xg(b)),v},[]);return new WF(g,m)}compileModuleAndAllComponentsAsync(u){return Promise.resolve(this.compileModuleAndAllComponentsSync(u))}clearCache(){}clearCacheFor(u){}getModuleId(u){}}return f.\u0275fac=function(u){return new(u||f)},f.\u0275prov=yt({token:f,factory:f.\u0275fac,providedIn:"root"}),f})();const YF=(()=>Promise.resolve(0))();function pp(f){"undefined"==typeof Zone?YF.then(()=>{f&&f.apply(null,null)}):Zone.current.scheduleMicroTask("scheduleMicrotask",f)}class On{constructor({enableLongStackTrace:l=!1,shouldCoalesceEventChangeDetection:u=!1,shouldCoalesceRunChangeDetection:g=!1}){if(this.hasPendingMacrotasks=!1,this.hasPendingMicrotasks=!1,this.isStable=!0,this.onUnstable=new nn(!1),this.onMicrotaskEmpty=new nn(!1),this.onStable=new nn(!1),this.onError=new nn(!1),"undefined"==typeof Zone)throw new Error("In this configuration Angular requires Zone.js");Zone.assertZonePatched();const p=this;p._nesting=0,p._outer=p._inner=Zone.current,Zone.TaskTrackingZoneSpec&&(p._inner=p._inner.fork(new Zone.TaskTrackingZoneSpec)),l&&Zone.longStackTraceZoneSpec&&(p._inner=p._inner.fork(Zone.longStackTraceZoneSpec)),p.shouldCoalesceEventChangeDetection=!g&&u,p.shouldCoalesceRunChangeDetection=g,p.lastRequestAnimationFrameId=-1,p.nativeRequestAnimationFrame=function $F(){let f=Ot.requestAnimationFrame,l=Ot.cancelAnimationFrame;if("undefined"!=typeof Zone&&f&&l){const u=f[Zone.__symbol__("OriginalDelegate")];u&&(f=u);const g=l[Zone.__symbol__("OriginalDelegate")];g&&(l=g)}return{nativeRequestAnimationFrame:f,nativeCancelAnimationFrame:l}}().nativeRequestAnimationFrame,function ZF(f){const l=()=>{!function qF(f){f.isCheckStableRunning||-1!==f.lastRequestAnimationFrameId||(f.lastRequestAnimationFrameId=f.nativeRequestAnimationFrame.call(Ot,()=>{f.fakeTopEventTask||(f.fakeTopEventTask=Zone.root.scheduleEventTask("fakeTopEventTask",()=>{f.lastRequestAnimationFrameId=-1,_p(f),f.isCheckStableRunning=!0,mp(f),f.isCheckStableRunning=!1},void 0,()=>{},()=>{})),f.fakeTopEventTask.invoke()}),_p(f))}(f)};f._inner=f._inner.fork({name:"angular",properties:{isAngularZone:!0},onInvokeTask:(u,g,p,m,v,y)=>{try{return PE(f),u.invokeTask(p,m,v,y)}finally{(f.shouldCoalesceEventChangeDetection&&"eventTask"===m.type||f.shouldCoalesceRunChangeDetection)&&l(),NE(f)}},onInvoke:(u,g,p,m,v,y,b)=>{try{return PE(f),u.invoke(p,m,v,y,b)}finally{f.shouldCoalesceRunChangeDetection&&l(),NE(f)}},onHasTask:(u,g,p,m)=>{u.hasTask(p,m),g===p&&("microTask"==m.change?(f._hasPendingMicrotasks=m.microTask,_p(f),mp(f)):"macroTask"==m.change&&(f.hasPendingMacrotasks=m.macroTask))},onHandleError:(u,g,p,m)=>(u.handleError(p,m),f.runOutsideAngular(()=>f.onError.emit(m)),!1)})}(p)}static isInAngularZone(){return"undefined"!=typeof Zone&&!0===Zone.current.get("isAngularZone")}static assertInAngularZone(){if(!On.isInAngularZone())throw new Error("Expected to be in Angular Zone, but it is not!")}static assertNotInAngularZone(){if(On.isInAngularZone())throw new Error("Expected to not be in Angular Zone, but it is!")}run(l,u,g){return this._inner.run(l,u,g)}runTask(l,u,g,p){const m=this._inner,v=m.scheduleEventTask("NgZoneEvent: "+p,l,XF,Qu,Qu);try{return m.runTask(v,u,g)}finally{m.cancelTask(v)}}runGuarded(l,u,g){return this._inner.runGuarded(l,u,g)}runOutsideAngular(l){return this._outer.run(l)}}const XF={};function mp(f){if(0==f._nesting&&!f.hasPendingMicrotasks&&!f.isStable)try{f._nesting++,f.onMicrotaskEmpty.emit(null)}finally{if(f._nesting--,!f.hasPendingMicrotasks)try{f.runOutsideAngular(()=>f.onStable.emit(null))}finally{f.isStable=!0}}}function _p(f){f.hasPendingMicrotasks=!!(f._hasPendingMicrotasks||(f.shouldCoalesceEventChangeDetection||f.shouldCoalesceRunChangeDetection)&&-1!==f.lastRequestAnimationFrameId)}function PE(f){f._nesting++,f.isStable&&(f.isStable=!1,f.onUnstable.emit(null))}function NE(f){f._nesting--,mp(f)}class KF{constructor(){this.hasPendingMicrotasks=!1,this.hasPendingMacrotasks=!1,this.isStable=!0,this.onUnstable=new nn,this.onMicrotaskEmpty=new nn,this.onStable=new nn,this.onError=new nn}run(l,u,g){return l.apply(u,g)}runGuarded(l,u,g){return l.apply(u,g)}runOutsideAngular(l){return l()}runTask(l,u,g,p){return l.apply(u,g)}}let vp=(()=>{class f{constructor(u){this._ngZone=u,this._pendingCount=0,this._isZoneStable=!0,this._didWork=!1,this._callbacks=[],this.taskTrackingZone=null,this._watchAngularEvents(),u.run(()=>{this.taskTrackingZone="undefined"==typeof Zone?null:Zone.current.get("TaskTrackingZone")})}_watchAngularEvents(){this._ngZone.onUnstable.subscribe({next:()=>{this._didWork=!0,this._isZoneStable=!1}}),this._ngZone.runOutsideAngular(()=>{this._ngZone.onStable.subscribe({next:()=>{On.assertNotInAngularZone(),pp(()=>{this._isZoneStable=!0,this._runCallbacksIfReady()})}})})}increasePendingRequestCount(){return this._pendingCount+=1,this._didWork=!0,this._pendingCount}decreasePendingRequestCount(){if(this._pendingCount-=1,this._pendingCount<0)throw new Error("pending async requests below zero");return this._runCallbacksIfReady(),this._pendingCount}isStable(){return this._isZoneStable&&0===this._pendingCount&&!this._ngZone.hasPendingMacrotasks}_runCallbacksIfReady(){if(this.isStable())pp(()=>{for(;0!==this._callbacks.length;){let u=this._callbacks.pop();clearTimeout(u.timeoutId),u.doneCb(this._didWork)}this._didWork=!1});else{let u=this.getPendingTasks();this._callbacks=this._callbacks.filter(g=>!g.updateCb||!g.updateCb(u)||(clearTimeout(g.timeoutId),!1)),this._didWork=!0}}getPendingTasks(){return this.taskTrackingZone?this.taskTrackingZone.macroTasks.map(u=>({source:u.source,creationLocation:u.creationLocation,data:u.data})):[]}addCallback(u,g,p){let m=-1;g&&g>0&&(m=setTimeout(()=>{this._callbacks=this._callbacks.filter(v=>v.timeoutId!==m),u(this._didWork,this.getPendingTasks())},g)),this._callbacks.push({doneCb:u,timeoutId:m,updateCb:p})}whenStable(u,g,p){if(p&&!this.taskTrackingZone)throw new Error('Task tracking zone is required when passing an update callback to whenStable(). Is "zone.js/plugins/task-tracking" loaded?');this.addCallback(u,g,p),this._runCallbacksIfReady()}getPendingRequestCount(){return this._pendingCount}findProviders(u,g,p){return[]}}return f.\u0275fac=function(u){return new(u||f)(Ye(On))},f.\u0275prov=yt({token:f,factory:f.\u0275fac}),f})(),QF=(()=>{class f{constructor(){this._applications=new Map,yp.addToWindow(this)}registerApplication(u,g){this._applications.set(u,g)}unregisterApplication(u){this._applications.delete(u)}unregisterAllApplications(){this._applications.clear()}getTestability(u){return this._applications.get(u)||null}getAllTestabilities(){return Array.from(this._applications.values())}getAllRootElements(){return Array.from(this._applications.keys())}findTestabilityInTree(u,g=!0){return yp.findTestabilityInTree(this,u,g)}}return f.\u0275fac=function(u){return new(u||f)},f.\u0275prov=yt({token:f,factory:f.\u0275fac,providedIn:"platform"}),f})();class JF{addToWindow(l){}findTestabilityInTree(l,u,g){return null}}let yp=new JF,eo=null;const kE=new dt("AllowMultipleToken"),BE=new dt("PlatformOnDestroy");class VE{constructor(l,u){this.name=l,this.token=u}}function UE(f,l,u=[]){const g=`Platform: ${l}`,p=new dt(g);return(m=[])=>{let v=Cp();if(!v||v.injector.get(kE,!1)){const y=[...u,...m,{provide:p,useValue:!0}];f?f(y):function iP(f){if(eo&&!eo.get(kE,!1))throw new Et(400,"");eo=f;const l=f.get(jE),u=f.get(OE,null);u&&u.forEach(g=>g())}(function sP(f=[],l){return Qn.create({name:l,providers:[{provide:Eg,useValue:"platform"},{provide:BE,useValue:()=>eo=null},...f]})}(y,g))}return function rP(f){const l=Cp();if(!l)throw new Et(401,"");return l}()}}function Cp(){var f;return null!==(f=null==eo?void 0:eo.get(jE))&&void 0!==f?f:null}let jE=(()=>{class f{constructor(u){this._injector=u,this._modules=[],this._destroyListeners=[],this._destroyed=!1}bootstrapModuleFactory(u,g){const y=function oP(f,l){let u;return u="noop"===f?new KF:("zone.js"===f?void 0:f)||new On({enableLongStackTrace:!1,shouldCoalesceEventChangeDetection:!!(null==l?void 0:l.ngZoneEventCoalescing),shouldCoalesceRunChangeDetection:!!(null==l?void 0:l.ngZoneRunCoalescing)}),u}(g?g.ngZone:void 0,{ngZoneEventCoalescing:g&&g.ngZoneEventCoalescing||!1,ngZoneRunCoalescing:g&&g.ngZoneRunCoalescing||!1}),b=[{provide:On,useValue:y}];return y.run(()=>{const O=Qn.create({providers:b,parent:this.injector,name:u.moduleType.name}),L=u.create(O),N=L.injector.get(El,null);if(!N)throw new Et(402,"");return y.runOutsideAngular(()=>{const B=y.onError.subscribe({next:U=>{N.handleError(U)}});L.onDestroy(()=>{Ep(this._modules,L),B.unsubscribe()})}),function aP(f,l,u){try{const g=u();return Rl(g)?g.catch(p=>{throw l.runOutsideAngular(()=>f.handleError(p)),p}):g}catch(g){throw l.runOutsideAngular(()=>f.handleError(g)),g}}(N,y,()=>{const B=L.injector.get(fp);return B.runInitializers(),B.donePromise.then(()=>(function PM(f){si(f,"Expected localeId to be defined"),"string"==typeof f&&(ww=f.toLowerCase().replace(/_/g,"-"))}(L.injector.get(Es,Hu)||Hu),this._moduleDoBootstrap(L),L))})})}bootstrapModule(u,g=[]){const p=GE({},g);return function tP(f,l,u){const g=new qg(u);return Promise.resolve(g)}(0,0,u).then(m=>this.bootstrapModuleFactory(m,p))}_moduleDoBootstrap(u){const g=u.injector.get(wp);if(u._bootstrapComponents.length>0)u._bootstrapComponents.forEach(p=>g.bootstrap(p));else{if(!u.instance.ngDoBootstrap)throw new Et(403,"");u.instance.ngDoBootstrap(g)}this._modules.push(u)}onDestroy(u){this._destroyListeners.push(u)}get injector(){return this._injector}destroy(){if(this._destroyed)throw new Et(404,"");this._modules.slice().forEach(g=>g.destroy()),this._destroyListeners.forEach(g=>g());const u=this._injector.get(BE,null);null==u||u(),this._destroyed=!0}get destroyed(){return this._destroyed}}return f.\u0275fac=function(u){return new(u||f)(Ye(Qn))},f.\u0275prov=yt({token:f,factory:f.\u0275fac,providedIn:"platform"}),f})();function GE(f,l){return Array.isArray(l)?l.reduce(GE,f):Object.assign(Object.assign({},f),l)}let wp=(()=>{class f{constructor(u,g,p,m){this._zone=u,this._injector=g,this._exceptionHandler=p,this._initStatus=m,this._bootstrapListeners=[],this._views=[],this._runningTick=!1,this._stable=!0,this.componentTypes=[],this.components=[],this._onMicrotaskEmptySubscription=this._zone.onMicrotaskEmpty.subscribe({next:()=>{this._zone.run(()=>{this.tick()})}});const v=new cn(b=>{this._stable=this._zone.isStable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks,this._zone.runOutsideAngular(()=>{b.next(this._stable),b.complete()})}),y=new cn(b=>{let O;this._zone.runOutsideAngular(()=>{O=this._zone.onStable.subscribe(()=>{On.assertNotInAngularZone(),pp(()=>{!this._stable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks&&(this._stable=!0,b.next(!0))})})});const L=this._zone.onUnstable.subscribe(()=>{On.assertInAngularZone(),this._stable&&(this._stable=!1,this._zone.runOutsideAngular(()=>{b.next(!1)}))});return()=>{O.unsubscribe(),L.unsubscribe()}});this.isStable=function QT(...f){const l=Ja(f),u=function zT(f,l){return"number"==typeof Hd(f)?f.pop():l}(f,1/0),g=f;return g.length?1===g.length?sr(g[0]):Qa(u)(In(g,l)):Or}(v,y.pipe(function JT(f={}){const{connector:l=(()=>new Ar),resetOnError:u=!0,resetOnComplete:g=!0,resetOnRefCountZero:p=!0}=f;return m=>{let v=null,y=null,b=null,O=0,L=!1,N=!1;const B=()=>{null==y||y.unsubscribe(),y=null},U=()=>{B(),v=b=null,L=N=!1},W=()=>{const Y=v;U(),null==Y||Y.unsubscribe()};return xn((Y,$)=>{O++,!N&&!L&&B();const q=b=null!=b?b:l();$.add(()=>{O--,0===O&&!N&&!L&&(y=Wd(W,p))}),q.subscribe($),v||(v=new Zc({next:X=>q.next(X),error:X=>{N=!0,B(),y=Wd(U,u,X),q.error(X)},complete:()=>{L=!0,B(),y=Wd(U,g),q.complete()}}),In(Y).subscribe(v))})(m)}}()))}bootstrap(u,g){if(!this._initStatus.done)throw new Et(405,"");let p;p=u instanceof Yw?u:this._injector.get(Nl).resolveComponentFactory(u),this.componentTypes.push(p.componentType);const m=function nP(f){return f.isBoundToModule}(p)?void 0:this._injector.get(Vr),y=p.create(Qn.NULL,[],g||p.selector,m),b=y.location.nativeElement,O=y.injector.get(vp,null),L=O&&y.injector.get(QF);return O&&L&&L.registerApplication(b,O),y.onDestroy(()=>{this.detachView(y.hostView),Ep(this.components,y),L&&L.unregisterApplication(b)}),this._loadComponent(y),y}tick(){if(this._runningTick)throw new Et(101,"");try{this._runningTick=!0;for(let u of this._views)u.detectChanges()}catch(u){this._zone.runOutsideAngular(()=>this._exceptionHandler.handleError(u))}finally{this._runningTick=!1}}attachView(u){const g=u;this._views.push(g),g.attachToAppRef(this)}detachView(u){const g=u;Ep(this._views,g),g.detachFromAppRef()}_loadComponent(u){this.attachView(u.hostView),this.tick(),this.components.push(u),this._injector.get(LE,[]).concat(this._bootstrapListeners).forEach(p=>p(u))}ngOnDestroy(){this._views.slice().forEach(u=>u.destroy()),this._onMicrotaskEmptySubscription.unsubscribe()}get viewCount(){return this._views.length}}return f.\u0275fac=function(u){return new(u||f)(Ye(On),Ye(Qn),Ye(El),Ye(fp))},f.\u0275prov=yt({token:f,factory:f.\u0275fac,providedIn:"root"}),f})();function Ep(f,l){const u=f.indexOf(l);u>-1&&f.splice(u,1)}let WE=!0,Ju=(()=>{class f{}return f.__NG_ELEMENT_ID__=uP,f})();function uP(f){return function hP(f,l,u){if(su(f)&&!u){const g=ai(f.index,l);return new Bl(g,g)}return 47&f.type?new Bl(l[16],l):null}(yn(),_e(),16==(16&f))}class qE{constructor(){}supports(l){return xl(l)}create(l){return new _P(l)}}const mP=(f,l)=>l;class _P{constructor(l){this.length=0,this._linkedRecords=null,this._unlinkedRecords=null,this._previousItHead=null,this._itHead=null,this._itTail=null,this._additionsHead=null,this._additionsTail=null,this._movesHead=null,this._movesTail=null,this._removalsHead=null,this._removalsTail=null,this._identityChangesHead=null,this._identityChangesTail=null,this._trackByFn=l||mP}forEachItem(l){let u;for(u=this._itHead;null!==u;u=u._next)l(u)}forEachOperation(l){let u=this._itHead,g=this._removalsHead,p=0,m=null;for(;u||g;){const v=!g||u&&u.currentIndex{v=this._trackByFn(p,y),null!==u&&Object.is(u.trackById,v)?(g&&(u=this._verifyReinsertion(u,y,v,p)),Object.is(u.item,y)||this._addIdentityChange(u,y)):(u=this._mismatch(u,y,v,p),g=!0),u=u._next,p++}),this.length=p;return this._truncate(u),this.collection=l,this.isDirty}get isDirty(){return null!==this._additionsHead||null!==this._movesHead||null!==this._removalsHead||null!==this._identityChangesHead}_reset(){if(this.isDirty){let l;for(l=this._previousItHead=this._itHead;null!==l;l=l._next)l._nextPrevious=l._next;for(l=this._additionsHead;null!==l;l=l._nextAdded)l.previousIndex=l.currentIndex;for(this._additionsHead=this._additionsTail=null,l=this._movesHead;null!==l;l=l._nextMoved)l.previousIndex=l.currentIndex;this._movesHead=this._movesTail=null,this._removalsHead=this._removalsTail=null,this._identityChangesHead=this._identityChangesTail=null}}_mismatch(l,u,g,p){let m;return null===l?m=this._itTail:(m=l._prev,this._remove(l)),null!==(l=null===this._unlinkedRecords?null:this._unlinkedRecords.get(g,null))?(Object.is(l.item,u)||this._addIdentityChange(l,u),this._reinsertAfter(l,m,p)):null!==(l=null===this._linkedRecords?null:this._linkedRecords.get(g,p))?(Object.is(l.item,u)||this._addIdentityChange(l,u),this._moveAfter(l,m,p)):l=this._addAfter(new vP(u,g),m,p),l}_verifyReinsertion(l,u,g,p){let m=null===this._unlinkedRecords?null:this._unlinkedRecords.get(g,null);return null!==m?l=this._reinsertAfter(m,l._prev,p):l.currentIndex!=p&&(l.currentIndex=p,this._addToMoves(l,p)),l}_truncate(l){for(;null!==l;){const u=l._next;this._addToRemovals(this._unlink(l)),l=u}null!==this._unlinkedRecords&&this._unlinkedRecords.clear(),null!==this._additionsTail&&(this._additionsTail._nextAdded=null),null!==this._movesTail&&(this._movesTail._nextMoved=null),null!==this._itTail&&(this._itTail._next=null),null!==this._removalsTail&&(this._removalsTail._nextRemoved=null),null!==this._identityChangesTail&&(this._identityChangesTail._nextIdentityChange=null)}_reinsertAfter(l,u,g){null!==this._unlinkedRecords&&this._unlinkedRecords.remove(l);const p=l._prevRemoved,m=l._nextRemoved;return null===p?this._removalsHead=m:p._nextRemoved=m,null===m?this._removalsTail=p:m._prevRemoved=p,this._insertAfter(l,u,g),this._addToMoves(l,g),l}_moveAfter(l,u,g){return this._unlink(l),this._insertAfter(l,u,g),this._addToMoves(l,g),l}_addAfter(l,u,g){return this._insertAfter(l,u,g),this._additionsTail=null===this._additionsTail?this._additionsHead=l:this._additionsTail._nextAdded=l,l}_insertAfter(l,u,g){const p=null===u?this._itHead:u._next;return l._next=p,l._prev=u,null===p?this._itTail=l:p._prev=l,null===u?this._itHead=l:u._next=l,null===this._linkedRecords&&(this._linkedRecords=new ZE),this._linkedRecords.put(l),l.currentIndex=g,l}_remove(l){return this._addToRemovals(this._unlink(l))}_unlink(l){null!==this._linkedRecords&&this._linkedRecords.remove(l);const u=l._prev,g=l._next;return null===u?this._itHead=g:u._next=g,null===g?this._itTail=u:g._prev=u,l}_addToMoves(l,u){return l.previousIndex===u||(this._movesTail=null===this._movesTail?this._movesHead=l:this._movesTail._nextMoved=l),l}_addToRemovals(l){return null===this._unlinkedRecords&&(this._unlinkedRecords=new ZE),this._unlinkedRecords.put(l),l.currentIndex=null,l._nextRemoved=null,null===this._removalsTail?(this._removalsTail=this._removalsHead=l,l._prevRemoved=null):(l._prevRemoved=this._removalsTail,this._removalsTail=this._removalsTail._nextRemoved=l),l}_addIdentityChange(l,u){return l.item=u,this._identityChangesTail=null===this._identityChangesTail?this._identityChangesHead=l:this._identityChangesTail._nextIdentityChange=l,l}}class vP{constructor(l,u){this.item=l,this.trackById=u,this.currentIndex=null,this.previousIndex=null,this._nextPrevious=null,this._prev=null,this._next=null,this._prevDup=null,this._nextDup=null,this._prevRemoved=null,this._nextRemoved=null,this._nextAdded=null,this._nextMoved=null,this._nextIdentityChange=null}}class yP{constructor(){this._head=null,this._tail=null}add(l){null===this._head?(this._head=this._tail=l,l._nextDup=null,l._prevDup=null):(this._tail._nextDup=l,l._prevDup=this._tail,l._nextDup=null,this._tail=l)}get(l,u){let g;for(g=this._head;null!==g;g=g._nextDup)if((null===u||u<=g.currentIndex)&&Object.is(g.trackById,l))return g;return null}remove(l){const u=l._prevDup,g=l._nextDup;return null===u?this._head=g:u._nextDup=g,null===g?this._tail=u:g._prevDup=u,null===this._head}}class ZE{constructor(){this.map=new Map}put(l){const u=l.trackById;let g=this.map.get(u);g||(g=new yP,this.map.set(u,g)),g.add(l)}get(l,u){const p=this.map.get(l);return p?p.get(l,u):null}remove(l){const u=l.trackById;return this.map.get(u).remove(l)&&this.map.delete(u),l}get isEmpty(){return 0===this.map.size}clear(){this.map.clear()}}function KE(f,l,u){const g=f.previousIndex;if(null===g)return g;let p=0;return u&&g{class f{constructor(u){this.factories=u}static create(u,g){if(null!=g){const p=g.factories.slice();u=u.concat(p)}return new f(u)}static extend(u){return{provide:f,useFactory:g=>f.create(u,g||JE()),deps:[[f,new ml,new ms]]}}find(u){const g=this.factories.find(p=>p.supports(u));if(null!=g)return g;throw new Et(901,"")}}return f.\u0275prov=yt({token:f,providedIn:"root",factory:JE}),f})();const DP=UE(null,"core",[]);let SP=(()=>{class f{constructor(u){}}return f.\u0275fac=function(u){return new(u||f)(Ye(wp))},f.\u0275mod=lr({type:f}),f.\u0275inj=Ui({}),f})(),ih=null;function yr(){return ih}const Ai=new dt("DocumentToken");let no=(()=>{class f{historyGo(u){throw new Error("Not implemented")}}return f.\u0275fac=function(u){return new(u||f)},f.\u0275prov=yt({token:f,factory:function(){return function AP(){return Ye(tb)}()},providedIn:"platform"}),f})();const RP=new dt("Location Initialized");let tb=(()=>{class f extends no{constructor(u){super(),this._doc=u,this._init()}_init(){this.location=window.location,this._history=window.history}getBaseHrefFromDOM(){return yr().getBaseHref(this._doc)}onPopState(u){const g=yr().getGlobalEventTarget(this._doc,"window");return g.addEventListener("popstate",u,!1),()=>g.removeEventListener("popstate",u)}onHashChange(u){const g=yr().getGlobalEventTarget(this._doc,"window");return g.addEventListener("hashchange",u,!1),()=>g.removeEventListener("hashchange",u)}get href(){return this.location.href}get protocol(){return this.location.protocol}get hostname(){return this.location.hostname}get port(){return this.location.port}get pathname(){return this.location.pathname}get search(){return this.location.search}get hash(){return this.location.hash}set pathname(u){this.location.pathname=u}pushState(u,g,p){nb()?this._history.pushState(u,g,p):this.location.hash=p}replaceState(u,g,p){nb()?this._history.replaceState(u,g,p):this.location.hash=p}forward(){this._history.forward()}back(){this._history.back()}historyGo(u=0){this._history.go(u)}getState(){return this._history.state}}return f.\u0275fac=function(u){return new(u||f)(Ye(Ai))},f.\u0275prov=yt({token:f,factory:function(){return function OP(){return new tb(Ye(Ai))}()},providedIn:"platform"}),f})();function nb(){return!!window.history.pushState}function Tp(f,l){if(0==f.length)return l;if(0==l.length)return f;let u=0;return f.endsWith("/")&&u++,l.startsWith("/")&&u++,2==u?f+l.substring(1):1==u?f+l:f+"/"+l}function ib(f){const l=f.match(/#|\?|$/),u=l&&l.index||f.length;return f.slice(0,u-("/"===f[u-1]?1:0))+f.slice(u)}function jr(f){return f&&"?"!==f[0]?"?"+f:f}let ga=(()=>{class f{historyGo(u){throw new Error("Not implemented")}}return f.\u0275fac=function(u){return new(u||f)},f.\u0275prov=yt({token:f,factory:function(){return function MP(f){const l=Ye(Ai).location;return new rb(Ye(no),l&&l.origin||"")}()},providedIn:"root"}),f})();const xp=new dt("appBaseHref");let rb=(()=>{class f extends ga{constructor(u,g){if(super(),this._platformLocation=u,this._removeListenerFns=[],null==g&&(g=this._platformLocation.getBaseHrefFromDOM()),null==g)throw new Error("No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.");this._baseHref=g}ngOnDestroy(){for(;this._removeListenerFns.length;)this._removeListenerFns.pop()()}onPopState(u){this._removeListenerFns.push(this._platformLocation.onPopState(u),this._platformLocation.onHashChange(u))}getBaseHref(){return this._baseHref}prepareExternalUrl(u){return Tp(this._baseHref,u)}path(u=!1){const g=this._platformLocation.pathname+jr(this._platformLocation.search),p=this._platformLocation.hash;return p&&u?`${g}${p}`:g}pushState(u,g,p,m){const v=this.prepareExternalUrl(p+jr(m));this._platformLocation.pushState(u,g,v)}replaceState(u,g,p,m){const v=this.prepareExternalUrl(p+jr(m));this._platformLocation.replaceState(u,g,v)}forward(){this._platformLocation.forward()}back(){this._platformLocation.back()}historyGo(u=0){var g,p;null===(p=(g=this._platformLocation).historyGo)||void 0===p||p.call(g,u)}}return f.\u0275fac=function(u){return new(u||f)(Ye(no),Ye(xp,8))},f.\u0275prov=yt({token:f,factory:f.\u0275fac}),f})(),LP=(()=>{class f extends ga{constructor(u,g){super(),this._platformLocation=u,this._baseHref="",this._removeListenerFns=[],null!=g&&(this._baseHref=g)}ngOnDestroy(){for(;this._removeListenerFns.length;)this._removeListenerFns.pop()()}onPopState(u){this._removeListenerFns.push(this._platformLocation.onPopState(u),this._platformLocation.onHashChange(u))}getBaseHref(){return this._baseHref}path(u=!1){let g=this._platformLocation.hash;return null==g&&(g="#"),g.length>0?g.substring(1):g}prepareExternalUrl(u){const g=Tp(this._baseHref,u);return g.length>0?"#"+g:g}pushState(u,g,p,m){let v=this.prepareExternalUrl(p+jr(m));0==v.length&&(v=this._platformLocation.pathname),this._platformLocation.pushState(u,g,v)}replaceState(u,g,p,m){let v=this.prepareExternalUrl(p+jr(m));0==v.length&&(v=this._platformLocation.pathname),this._platformLocation.replaceState(u,g,v)}forward(){this._platformLocation.forward()}back(){this._platformLocation.back()}historyGo(u=0){var g,p;null===(p=(g=this._platformLocation).historyGo)||void 0===p||p.call(g,u)}}return f.\u0275fac=function(u){return new(u||f)(Ye(no),Ye(xp,8))},f.\u0275prov=yt({token:f,factory:f.\u0275fac}),f})(),Ap=(()=>{class f{constructor(u,g){this._subject=new nn,this._urlChangeListeners=[],this._platformStrategy=u;const p=this._platformStrategy.getBaseHref();this._platformLocation=g,this._baseHref=ib(sb(p)),this._platformStrategy.onPopState(m=>{this._subject.emit({url:this.path(!0),pop:!0,state:m.state,type:m.type})})}path(u=!1){return this.normalize(this._platformStrategy.path(u))}getState(){return this._platformLocation.getState()}isCurrentPathEqualTo(u,g=""){return this.path()==this.normalize(u+jr(g))}normalize(u){return f.stripTrailingSlash(function PP(f,l){return f&&l.startsWith(f)?l.substring(f.length):l}(this._baseHref,sb(u)))}prepareExternalUrl(u){return u&&"/"!==u[0]&&(u="/"+u),this._platformStrategy.prepareExternalUrl(u)}go(u,g="",p=null){this._platformStrategy.pushState(p,"",u,g),this._notifyUrlChangeListeners(this.prepareExternalUrl(u+jr(g)),p)}replaceState(u,g="",p=null){this._platformStrategy.replaceState(p,"",u,g),this._notifyUrlChangeListeners(this.prepareExternalUrl(u+jr(g)),p)}forward(){this._platformStrategy.forward()}back(){this._platformStrategy.back()}historyGo(u=0){var g,p;null===(p=(g=this._platformStrategy).historyGo)||void 0===p||p.call(g,u)}onUrlChange(u){this._urlChangeListeners.push(u),this._urlChangeSubscription||(this._urlChangeSubscription=this.subscribe(g=>{this._notifyUrlChangeListeners(g.url,g.state)}))}_notifyUrlChangeListeners(u="",g){this._urlChangeListeners.forEach(p=>p(u,g))}subscribe(u,g,p){return this._subject.subscribe({next:u,error:g,complete:p})}}return f.normalizeQueryParams=jr,f.joinWithSlash=Tp,f.stripTrailingSlash=ib,f.\u0275fac=function(u){return new(u||f)(Ye(ga),Ye(no))},f.\u0275prov=yt({token:f,factory:function(){return function FP(){return new Ap(Ye(ga),Ye(no))}()},providedIn:"root"}),f})();function sb(f){return f.replace(/\/index.html$/,"")}class wN{constructor(l,u,g,p){this.$implicit=l,this.ngForOf=u,this.index=g,this.count=p}get first(){return 0===this.index}get last(){return this.index===this.count-1}get even(){return this.index%2==0}get odd(){return!this.even}}let gb=(()=>{class f{constructor(u,g,p){this._viewContainer=u,this._template=g,this._differs=p,this._ngForOf=null,this._ngForOfDirty=!0,this._differ=null}set ngForOf(u){this._ngForOf=u,this._ngForOfDirty=!0}set ngForTrackBy(u){this._trackByFn=u}get ngForTrackBy(){return this._trackByFn}set ngForTemplate(u){u&&(this._template=u)}ngDoCheck(){if(this._ngForOfDirty){this._ngForOfDirty=!1;const u=this._ngForOf;!this._differ&&u&&(this._differ=this._differs.find(u).create(this.ngForTrackBy))}if(this._differ){const u=this._differ.diff(this._ngForOf);u&&this._applyChanges(u)}}_applyChanges(u){const g=this._viewContainer;u.forEachOperation((p,m,v)=>{if(null==p.previousIndex)g.createEmbeddedView(this._template,new wN(p.item,this._ngForOf,-1,-1),null===v?void 0:v);else if(null==v)g.remove(null===m?void 0:m);else if(null!==m){const y=g.get(m);g.move(y,v),pb(y,p)}});for(let p=0,m=g.length;p{pb(g.get(p.currentIndex),p)})}static ngTemplateContextGuard(u,g){return!0}}return f.\u0275fac=function(u){return new(u||f)(ye(Zi),ye(Ur),ye(nh))},f.\u0275dir=ze({type:f,selectors:[["","ngFor","","ngForOf",""]],inputs:{ngForOf:"ngForOf",ngForTrackBy:"ngForTrackBy",ngForTemplate:"ngForTemplate"}}),f})();function pb(f,l){f.context.$implicit=l.item}let mb=(()=>{class f{constructor(u,g){this._viewContainer=u,this._context=new EN,this._thenTemplateRef=null,this._elseTemplateRef=null,this._thenViewRef=null,this._elseViewRef=null,this._thenTemplateRef=g}set ngIf(u){this._context.$implicit=this._context.ngIf=u,this._updateView()}set ngIfThen(u){_b("ngIfThen",u),this._thenTemplateRef=u,this._thenViewRef=null,this._updateView()}set ngIfElse(u){_b("ngIfElse",u),this._elseTemplateRef=u,this._elseViewRef=null,this._updateView()}_updateView(){this._context.$implicit?this._thenViewRef||(this._viewContainer.clear(),this._elseViewRef=null,this._thenTemplateRef&&(this._thenViewRef=this._viewContainer.createEmbeddedView(this._thenTemplateRef,this._context))):this._elseViewRef||(this._viewContainer.clear(),this._thenViewRef=null,this._elseTemplateRef&&(this._elseViewRef=this._viewContainer.createEmbeddedView(this._elseTemplateRef,this._context)))}static ngTemplateContextGuard(u,g){return!0}}return f.\u0275fac=function(u){return new(u||f)(ye(Zi),ye(Ur))},f.\u0275dir=ze({type:f,selectors:[["","ngIf",""]],inputs:{ngIf:"ngIf",ngIfThen:"ngIfThen",ngIfElse:"ngIfElse"}}),f})();class EN{constructor(){this.$implicit=null,this.ngIf=null}}function _b(f,l){if(l&&!l.createEmbeddedView)throw new Error(`${f} must be a TemplateRef, but received '${Tt(l)}'.`)}let qN=(()=>{class f{}return f.\u0275fac=function(u){return new(u||f)},f.\u0275mod=lr({type:f}),f.\u0275inj=Ui({}),f})();let JN=(()=>{class f{}return f.\u0275prov=yt({token:f,providedIn:"root",factory:()=>new ek(Ye(Ai),window)}),f})();class ek{constructor(l,u){this.document=l,this.window=u,this.offset=()=>[0,0]}setOffset(l){this.offset=Array.isArray(l)?()=>l:l}getScrollPosition(){return this.supportsScrolling()?[this.window.pageXOffset,this.window.pageYOffset]:[0,0]}scrollToPosition(l){this.supportsScrolling()&&this.window.scrollTo(l[0],l[1])}scrollToAnchor(l){if(!this.supportsScrolling())return;const u=function tk(f,l){const u=f.getElementById(l)||f.getElementsByName(l)[0];if(u)return u;if("function"==typeof f.createTreeWalker&&f.body&&(f.body.createShadowRoot||f.body.attachShadow)){const g=f.createTreeWalker(f.body,NodeFilter.SHOW_ELEMENT);let p=g.currentNode;for(;p;){const m=p.shadowRoot;if(m){const v=m.getElementById(l)||m.querySelector(`[name="${l}"]`);if(v)return v}p=g.nextNode()}}return null}(this.document,l);u&&(this.scrollToElement(u),u.focus())}setHistoryScrollRestoration(l){if(this.supportScrollRestoration()){const u=this.window.history;u&&u.scrollRestoration&&(u.scrollRestoration=l)}}scrollToElement(l){const u=l.getBoundingClientRect(),g=u.left+this.window.pageXOffset,p=u.top+this.window.pageYOffset,m=this.offset();this.window.scrollTo(g-m[0],p-m[1])}supportScrollRestoration(){try{if(!this.supportsScrolling())return!1;const l=wb(this.window.history)||wb(Object.getPrototypeOf(this.window.history));return!(!l||!l.writable&&!l.set)}catch(l){return!1}}supportsScrolling(){try{return!!this.window&&!!this.window.scrollTo&&"pageXOffset"in this.window}catch(l){return!1}}}function wb(f){return Object.getOwnPropertyDescriptor(f,"scrollRestoration")}class Hp extends class ik extends class xP{}{constructor(){super(...arguments),this.supportsDOMEvents=!0}}{static makeCurrent(){!function TP(f){ih||(ih=f)}(new Hp)}onAndCancel(l,u,g){return l.addEventListener(u,g,!1),()=>{l.removeEventListener(u,g,!1)}}dispatchEvent(l,u){l.dispatchEvent(u)}remove(l){l.parentNode&&l.parentNode.removeChild(l)}createElement(l,u){return(u=u||this.getDefaultDocument()).createElement(l)}createHtmlDocument(){return document.implementation.createHTMLDocument("fakeTitle")}getDefaultDocument(){return document}isElementNode(l){return l.nodeType===Node.ELEMENT_NODE}isShadowRoot(l){return l instanceof DocumentFragment}getGlobalEventTarget(l,u){return"window"===u?window:"document"===u?l:"body"===u?l.body:null}getBaseHref(l){const u=function rk(){return Yl=Yl||document.querySelector("base"),Yl?Yl.getAttribute("href"):null}();return null==u?null:function sk(f){fh=fh||document.createElement("a"),fh.setAttribute("href",f);const l=fh.pathname;return"/"===l.charAt(0)?l:`/${l}`}(u)}resetBaseElement(){Yl=null}getUserAgent(){return window.navigator.userAgent}getCookie(l){return function vN(f,l){l=encodeURIComponent(l);for(const u of f.split(";")){const g=u.indexOf("="),[p,m]=-1==g?[u,""]:[u.slice(0,g),u.slice(g+1)];if(p.trim()===l)return decodeURIComponent(m)}return null}(document.cookie,l)}}let fh,Yl=null;const Eb=new dt("TRANSITION_ID"),ak=[{provide:dp,useFactory:function ok(f,l,u){return()=>{u.get(fp).donePromise.then(()=>{const g=yr(),p=l.querySelectorAll(`style[ng-transition="${f}"]`);for(let m=0;m{const m=l.findTestabilityInTree(g,p);if(null==m)throw new Error("Could not find testability for element.");return m},Ot.getAllAngularTestabilities=()=>l.getAllTestabilities(),Ot.getAllAngularRootElements=()=>l.getAllRootElements(),Ot.frameworkStabilizers||(Ot.frameworkStabilizers=[]),Ot.frameworkStabilizers.push(g=>{const p=Ot.getAllAngularTestabilities();let m=p.length,v=!1;const y=function(b){v=v||b,m--,0==m&&g(v)};p.forEach(function(b){b.whenStable(y)})})}findTestabilityInTree(l,u,g){if(null==u)return null;const p=l.getTestability(u);return null!=p?p:g?yr().isShadowRoot(u)?this.findTestabilityInTree(l,u.host,!0):this.findTestabilityInTree(l,u.parentElement,!0):null}}let lk=(()=>{class f{build(){return new XMLHttpRequest}}return f.\u0275fac=function(u){return new(u||f)},f.\u0275prov=yt({token:f,factory:f.\u0275fac}),f})();const gh=new dt("EventManagerPlugins");let ph=(()=>{class f{constructor(u,g){this._zone=g,this._eventNameToPlugin=new Map,u.forEach(p=>p.manager=this),this._plugins=u.slice().reverse()}addEventListener(u,g,p){return this._findPluginFor(g).addEventListener(u,g,p)}addGlobalEventListener(u,g,p){return this._findPluginFor(g).addGlobalEventListener(u,g,p)}getZone(){return this._zone}_findPluginFor(u){const g=this._eventNameToPlugin.get(u);if(g)return g;const p=this._plugins;for(let m=0;m{class f{constructor(){this._stylesSet=new Set}addStyles(u){const g=new Set;u.forEach(p=>{this._stylesSet.has(p)||(this._stylesSet.add(p),g.add(p))}),this.onStylesAdded(g)}onStylesAdded(u){}getAllStyles(){return Array.from(this._stylesSet)}}return f.\u0275fac=function(u){return new(u||f)},f.\u0275prov=yt({token:f,factory:f.\u0275fac}),f})(),$l=(()=>{class f extends Db{constructor(u){super(),this._doc=u,this._hostNodes=new Map,this._hostNodes.set(u.head,[])}_addStylesToHost(u,g,p){u.forEach(m=>{const v=this._doc.createElement("style");v.textContent=m,p.push(g.appendChild(v))})}addHost(u){const g=[];this._addStylesToHost(this._stylesSet,u,g),this._hostNodes.set(u,g)}removeHost(u){const g=this._hostNodes.get(u);g&&g.forEach(Sb),this._hostNodes.delete(u)}onStylesAdded(u){this._hostNodes.forEach((g,p)=>{this._addStylesToHost(u,p,g)})}ngOnDestroy(){this._hostNodes.forEach(u=>u.forEach(Sb))}}return f.\u0275fac=function(u){return new(u||f)(Ye(Ai))},f.\u0275prov=yt({token:f,factory:f.\u0275fac}),f})();function Sb(f){yr().remove(f)}const zp={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/",math:"http://www.w3.org/1998/MathML/"},Yp=/%COMP%/g;function mh(f,l,u){for(let g=0;g{if("__ngUnwrap__"===l)return f;!1===f(l)&&(l.preventDefault(),l.returnValue=!1)}}let $p=(()=>{class f{constructor(u,g,p){this.eventManager=u,this.sharedStylesHost=g,this.appId=p,this.rendererByCompId=new Map,this.defaultRenderer=new Xp(u)}createRenderer(u,g){if(!u||!g)return this.defaultRenderer;switch(g.encapsulation){case or.Emulated:{let p=this.rendererByCompId.get(g.id);return p||(p=new gk(this.eventManager,this.sharedStylesHost,g,this.appId),this.rendererByCompId.set(g.id,p)),p.applyToHost(u),p}case 1:case or.ShadowDom:return new pk(this.eventManager,this.sharedStylesHost,u,g);default:if(!this.rendererByCompId.has(g.id)){const p=mh(g.id,g.styles,[]);this.sharedStylesHost.addStyles(p),this.rendererByCompId.set(g.id,this.defaultRenderer)}return this.defaultRenderer}}begin(){}end(){}}return f.\u0275fac=function(u){return new(u||f)(Ye(ph),Ye($l),Ye(Gl))},f.\u0275prov=yt({token:f,factory:f.\u0275fac}),f})();class Xp{constructor(l){this.eventManager=l,this.data=Object.create(null),this.destroyNode=null}destroy(){}createElement(l,u){return u?document.createElementNS(zp[u]||u,l):document.createElement(l)}createComment(l){return document.createComment(l)}createText(l){return document.createTextNode(l)}appendChild(l,u){l.appendChild(u)}insertBefore(l,u,g){l&&l.insertBefore(u,g)}removeChild(l,u){l&&l.removeChild(u)}selectRootElement(l,u){let g="string"==typeof l?document.querySelector(l):l;if(!g)throw new Error(`The selector "${l}" did not match any elements`);return u||(g.textContent=""),g}parentNode(l){return l.parentNode}nextSibling(l){return l.nextSibling}setAttribute(l,u,g,p){if(p){u=p+":"+u;const m=zp[p];m?l.setAttributeNS(m,u,g):l.setAttribute(u,g)}else l.setAttribute(u,g)}removeAttribute(l,u,g){if(g){const p=zp[g];p?l.removeAttributeNS(p,u):l.removeAttribute(`${g}:${u}`)}else l.removeAttribute(u)}addClass(l,u){l.classList.add(u)}removeClass(l,u){l.classList.remove(u)}setStyle(l,u,g,p){p&(ci.DashCase|ci.Important)?l.style.setProperty(u,g,p&ci.Important?"important":""):l.style[u]=g}removeStyle(l,u,g){g&ci.DashCase?l.style.removeProperty(u):l.style[u]=""}setProperty(l,u,g){l[u]=g}setValue(l,u){l.nodeValue=u}listen(l,u,g){return"string"==typeof l?this.eventManager.addGlobalEventListener(l,u,xb(g)):this.eventManager.addEventListener(l,u,xb(g))}}class gk extends Xp{constructor(l,u,g,p){super(l),this.component=g;const m=mh(p+"-"+g.id,g.styles,[]);u.addStyles(m),this.contentAttr=function hk(f){return"_ngcontent-%COMP%".replace(Yp,f)}(p+"-"+g.id),this.hostAttr=function dk(f){return"_nghost-%COMP%".replace(Yp,f)}(p+"-"+g.id)}applyToHost(l){super.setAttribute(l,this.hostAttr,"")}createElement(l,u){const g=super.createElement(l,u);return super.setAttribute(g,this.contentAttr,""),g}}class pk extends Xp{constructor(l,u,g,p){super(l),this.sharedStylesHost=u,this.hostEl=g,this.shadowRoot=g.attachShadow({mode:"open"}),this.sharedStylesHost.addHost(this.shadowRoot);const m=mh(p.id,p.styles,[]);for(let v=0;v{class f extends bb{constructor(u){super(u)}supports(u){return!0}addEventListener(u,g,p){return u.addEventListener(g,p,!1),()=>this.removeEventListener(u,g,p)}removeEventListener(u,g,p){return u.removeEventListener(g,p)}}return f.\u0275fac=function(u){return new(u||f)(Ye(Ai))},f.\u0275prov=yt({token:f,factory:f.\u0275fac}),f})();const Rb=["alt","control","meta","shift"],vk={"\b":"Backspace","\t":"Tab","\x7f":"Delete","\x1b":"Escape",Del:"Delete",Esc:"Escape",Left:"ArrowLeft",Right:"ArrowRight",Up:"ArrowUp",Down:"ArrowDown",Menu:"ContextMenu",Scroll:"ScrollLock",Win:"OS"},Ob={A:"1",B:"2",C:"3",D:"4",E:"5",F:"6",G:"7",H:"8",I:"9",J:"*",K:"+",M:"-",N:".",O:"/","`":"0","\x90":"NumLock"},yk={alt:f=>f.altKey,control:f=>f.ctrlKey,meta:f=>f.metaKey,shift:f=>f.shiftKey};let Ck=(()=>{class f extends bb{constructor(u){super(u)}supports(u){return null!=f.parseEventName(u)}addEventListener(u,g,p){const m=f.parseEventName(g),v=f.eventCallback(m.fullKey,p,this.manager.getZone());return this.manager.getZone().runOutsideAngular(()=>yr().onAndCancel(u,m.domEventName,v))}static parseEventName(u){const g=u.toLowerCase().split("."),p=g.shift();if(0===g.length||"keydown"!==p&&"keyup"!==p)return null;const m=f._normalizeKey(g.pop());let v="";if(Rb.forEach(b=>{const O=g.indexOf(b);O>-1&&(g.splice(O,1),v+=b+".")}),v+=m,0!=g.length||0===m.length)return null;const y={};return y.domEventName=p,y.fullKey=v,y}static getEventFullKey(u){let g="",p=function wk(f){let l=f.key;if(null==l){if(l=f.keyIdentifier,null==l)return"Unidentified";l.startsWith("U+")&&(l=String.fromCharCode(parseInt(l.substring(2),16)),3===f.location&&Ob.hasOwnProperty(l)&&(l=Ob[l]))}return vk[l]||l}(u);return p=p.toLowerCase()," "===p?p="space":"."===p&&(p="dot"),Rb.forEach(m=>{m!=p&&yk[m](u)&&(g+=m+".")}),g+=p,g}static eventCallback(u,g,p){return m=>{f.getEventFullKey(m)===u&&p.runGuarded(()=>g(m))}}static _normalizeKey(u){return"esc"===u?"escape":u}}return f.\u0275fac=function(u){return new(u||f)(Ye(Ai))},f.\u0275prov=yt({token:f,factory:f.\u0275fac}),f})();const Sk=UE(DP,"browser",[{provide:ME,useValue:"browser"},{provide:OE,useValue:function Ek(){Hp.makeCurrent(),Wp.init()},multi:!0},{provide:Ai,useFactory:function Dk(){return function Ax(f){af=f}(document),document},deps:[]}]),Ik=[{provide:Eg,useValue:"root"},{provide:El,useFactory:function bk(){return new El},deps:[]},{provide:gh,useClass:mk,multi:!0,deps:[Ai,On,ME]},{provide:gh,useClass:Ck,multi:!0,deps:[Ai]},{provide:$p,useClass:$p,deps:[ph,$l,Gl]},{provide:Xw,useExisting:$p},{provide:Db,useExisting:$l},{provide:$l,useClass:$l,deps:[Ai]},{provide:vp,useClass:vp,deps:[On]},{provide:ph,useClass:ph,deps:[gh,On]},{provide:class nk{},useClass:lk,deps:[]}];let Tk=(()=>{class f{constructor(u){if(u)throw new Error("BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.")}static withServerTransition(u){return{ngModule:f,providers:[{provide:Gl,useValue:u.appId},{provide:Eb,useExisting:Gl},ak]}}}return f.\u0275fac=function(u){return new(u||f)(Ye(f,12))},f.\u0275mod=lr({type:f}),f.\u0275inj=Ui({providers:Ik,imports:[qN,SP]}),f})();"undefined"!=typeof window&&window;const{isArray:Bk}=Array,{getPrototypeOf:Vk,prototype:Uk,keys:jk}=Object;function Fb(f){if(1===f.length){const l=f[0];if(Bk(l))return{args:l,keys:null};if(function Gk(f){return f&&"object"==typeof f&&Vk(f)===Uk}(l)){const u=jk(l);return{args:u.map(g=>l[g]),keys:u}}}return{args:f,keys:null}}const{isArray:Hk}=Array;function Pb(f){return Ut(l=>function Wk(f,l){return Hk(l)?f(...l):f(l)}(f,l))}function Nb(f,l){return f.reduce((u,g,p)=>(u[g]=l[p],u),{})}let kb=(()=>{class f{constructor(u,g){this._renderer=u,this._elementRef=g,this.onChange=p=>{},this.onTouched=()=>{}}setProperty(u,g){this._renderer.setProperty(this._elementRef.nativeElement,u,g)}registerOnTouched(u){this.onTouched=u}registerOnChange(u){this.onChange=u}setDisabledState(u){this.setProperty("disabled",u)}}return f.\u0275fac=function(u){return new(u||f)(ye(Br),ye(hi))},f.\u0275dir=ze({type:f}),f})(),io=(()=>{class f extends kb{}return f.\u0275fac=function(){let l;return function(g){return(l||(l=function kn(f){return hs(()=>{const l=f.prototype.constructor,u=l[Lr]||bf(l),g=Object.prototype;let p=Object.getPrototypeOf(f.prototype).constructor;for(;p&&p!==g;){const m=p[Lr]||bf(p);if(m&&m!==u)return m;p=Object.getPrototypeOf(p)}return m=>new m})}(f)))(g||f)}}(),f.\u0275dir=ze({type:f,features:[xt]}),f})();const Cr=new dt("NgValueAccessor"),$k={provide:Cr,useExisting:jt(()=>_h),multi:!0},qk=new dt("CompositionEventMode");let _h=(()=>{class f extends kb{constructor(u,g,p){super(u,g),this._compositionMode=p,this._composing=!1,null==this._compositionMode&&(this._compositionMode=!function Xk(){const f=yr()?yr().getUserAgent():"";return/android (\d+)/.test(f.toLowerCase())}())}writeValue(u){this.setProperty("value",null==u?"":u)}_handleInput(u){(!this._compositionMode||this._compositionMode&&!this._composing)&&this.onChange(u)}_compositionStart(){this._composing=!0}_compositionEnd(u){this._composing=!1,this._compositionMode&&this.onChange(u)}}return f.\u0275fac=function(u){return new(u||f)(ye(Br),ye(hi),ye(qk,8))},f.\u0275dir=ze({type:f,selectors:[["input","formControlName","",3,"type","checkbox"],["textarea","formControlName",""],["input","formControl","",3,"type","checkbox"],["textarea","formControl",""],["input","ngModel","",3,"type","checkbox"],["textarea","ngModel",""],["","ngDefaultControl",""]],hostBindings:function(u,g){1&u&&kt("input",function(m){return g._handleInput(m.target.value)})("blur",function(){return g.onTouched()})("compositionstart",function(){return g._compositionStart()})("compositionend",function(m){return g._compositionEnd(m.target.value)})},features:[Xt([$k]),xt]}),f})();const Un=new dt("NgValidators"),Ss=new dt("NgAsyncValidators");function Xb(f){return null!=f}function qb(f){const l=Rl(f)?In(f):f;return kg(l),l}function Zb(f){let l={};return f.forEach(u=>{l=null!=u?Object.assign(Object.assign({},l),u):l}),0===Object.keys(l).length?null:l}function Kb(f,l){return l.map(u=>u(f))}function Qb(f){return f.map(l=>function Kk(f){return!f.validate}(l)?l:u=>l.validate(u))}function Zp(f){return null!=f?function Jb(f){if(!f)return null;const l=f.filter(Xb);return 0==l.length?null:function(u){return Zb(Kb(u,l))}}(Qb(f)):null}function Kp(f){return null!=f?function eD(f){if(!f)return null;const l=f.filter(Xb);return 0==l.length?null:function(u){return function zk(...f){const l=_v(f),{args:u,keys:g}=Fb(f),p=new cn(m=>{const{length:v}=u;if(!v)return void m.complete();const y=new Array(v);let b=v,O=v;for(let L=0;L{N||(N=!0,O--),y[L]=B},()=>b--,void 0,()=>{(!b||!N)&&(O||m.next(g?Nb(g,y):y),m.complete())}))}});return l?p.pipe(Pb(l)):p}(Kb(u,l).map(qb)).pipe(Ut(Zb))}}(Qb(f)):null}function tD(f,l){return null===f?[l]:Array.isArray(f)?[...f,l]:[f,l]}function Qp(f){return f?Array.isArray(f)?f:[f]:[]}function yh(f,l){return Array.isArray(f)?f.includes(l):f===l}function rD(f,l){const u=Qp(l);return Qp(f).forEach(p=>{yh(u,p)||u.push(p)}),u}function sD(f,l){return Qp(l).filter(u=>!yh(f,u))}class oD{constructor(){this._rawValidators=[],this._rawAsyncValidators=[],this._onDestroyCallbacks=[]}get value(){return this.control?this.control.value:null}get valid(){return this.control?this.control.valid:null}get invalid(){return this.control?this.control.invalid:null}get pending(){return this.control?this.control.pending:null}get disabled(){return this.control?this.control.disabled:null}get enabled(){return this.control?this.control.enabled:null}get errors(){return this.control?this.control.errors:null}get pristine(){return this.control?this.control.pristine:null}get dirty(){return this.control?this.control.dirty:null}get touched(){return this.control?this.control.touched:null}get status(){return this.control?this.control.status:null}get untouched(){return this.control?this.control.untouched:null}get statusChanges(){return this.control?this.control.statusChanges:null}get valueChanges(){return this.control?this.control.valueChanges:null}get path(){return null}_setValidators(l){this._rawValidators=l||[],this._composedValidatorFn=Zp(this._rawValidators)}_setAsyncValidators(l){this._rawAsyncValidators=l||[],this._composedAsyncValidatorFn=Kp(this._rawAsyncValidators)}get validator(){return this._composedValidatorFn||null}get asyncValidator(){return this._composedAsyncValidatorFn||null}_registerOnDestroy(l){this._onDestroyCallbacks.push(l)}_invokeOnDestroyCallbacks(){this._onDestroyCallbacks.forEach(l=>l()),this._onDestroyCallbacks=[]}reset(l){this.control&&this.control.reset(l)}hasError(l,u){return!!this.control&&this.control.hasError(l,u)}getError(l,u){return this.control?this.control.getError(l,u):null}}class Is extends oD{constructor(){super(...arguments),this._parent=null,this.name=null,this.valueAccessor=null}}class $n extends oD{get formDirective(){return null}get path(){return null}}let lD=(()=>{class f extends class aD{constructor(l){this._cd=l}is(l){var u,g,p;return"submitted"===l?!!(null===(u=this._cd)||void 0===u?void 0:u.submitted):!!(null===(p=null===(g=this._cd)||void 0===g?void 0:g.control)||void 0===p?void 0:p[l])}}{constructor(u){super(u)}}return f.\u0275fac=function(u){return new(u||f)(ye(Is,2))},f.\u0275dir=ze({type:f,selectors:[["","formControlName",""],["","ngModel",""],["","formControl",""]],hostVars:14,hostBindings:function(u,g){2&u&&ju("ng-untouched",g.is("untouched"))("ng-touched",g.is("touched"))("ng-pristine",g.is("pristine"))("ng-dirty",g.is("dirty"))("ng-valid",g.is("valid"))("ng-invalid",g.is("invalid"))("ng-pending",g.is("pending"))},features:[xt]}),f})();function Xl(f,l){(function tm(f,l){const u=function nD(f){return f._rawValidators}(f);null!==l.validator?f.setValidators(tD(u,l.validator)):"function"==typeof u&&f.setValidators([u]);const g=function iD(f){return f._rawAsyncValidators}(f);null!==l.asyncValidator?f.setAsyncValidators(tD(g,l.asyncValidator)):"function"==typeof g&&f.setAsyncValidators([g]);const p=()=>f.updateValueAndValidity();bh(l._rawValidators,p),bh(l._rawAsyncValidators,p)})(f,l),l.valueAccessor.writeValue(f.value),function o2(f,l){l.valueAccessor.registerOnChange(u=>{f._pendingValue=u,f._pendingChange=!0,f._pendingDirty=!0,"change"===f.updateOn&&uD(f,l)})}(f,l),function l2(f,l){const u=(g,p)=>{l.valueAccessor.writeValue(g),p&&l.viewToModelUpdate(g)};f.registerOnChange(u),l._registerOnDestroy(()=>{f._unregisterOnChange(u)})}(f,l),function a2(f,l){l.valueAccessor.registerOnTouched(()=>{f._pendingTouched=!0,"blur"===f.updateOn&&f._pendingChange&&uD(f,l),"submit"!==f.updateOn&&f.markAsTouched()})}(f,l),function s2(f,l){if(l.valueAccessor.setDisabledState){const u=g=>{l.valueAccessor.setDisabledState(g)};f.registerOnDisabledChange(u),l._registerOnDestroy(()=>{f._unregisterOnDisabledChange(u)})}}(f,l)}function bh(f,l){f.forEach(u=>{u.registerOnValidatorChange&&u.registerOnValidatorChange(l)})}function uD(f,l){f._pendingDirty&&f.markAsDirty(),f.setValue(f._pendingValue,{emitModelToViewChange:!1}),l.viewToModelUpdate(f._pendingValue),f._pendingChange=!1}function rm(f,l){const u=f.indexOf(l);u>-1&&f.splice(u,1)}const ql="VALID",Sh="INVALID",pa="PENDING",Zl="DISABLED";function om(f){return(Ih(f)?f.validators:f)||null}function gD(f){return Array.isArray(f)?Zp(f):f||null}function am(f,l){return(Ih(l)?l.asyncValidators:f)||null}function pD(f){return Array.isArray(f)?Kp(f):f||null}function Ih(f){return null!=f&&!Array.isArray(f)&&"object"==typeof f}const lm=f=>f instanceof um;function _D(f){return(f=>f instanceof CD)(f)?f.value:f.getRawValue()}function vD(f,l){const u=lm(f),g=f.controls;if(!(u?Object.keys(g):g).length)throw new Et(1e3,"");if(!g[l])throw new Et(1001,"")}function yD(f,l){lm(f),f._forEachChild((g,p)=>{if(void 0===l[p])throw new Et(1002,"")})}class cm{constructor(l,u){this._pendingDirty=!1,this._hasOwnPendingAsyncValidator=!1,this._pendingTouched=!1,this._onCollectionChange=()=>{},this._parent=null,this.pristine=!0,this.touched=!1,this._onDisabledChange=[],this._rawValidators=l,this._rawAsyncValidators=u,this._composedValidatorFn=gD(this._rawValidators),this._composedAsyncValidatorFn=pD(this._rawAsyncValidators)}get validator(){return this._composedValidatorFn}set validator(l){this._rawValidators=this._composedValidatorFn=l}get asyncValidator(){return this._composedAsyncValidatorFn}set asyncValidator(l){this._rawAsyncValidators=this._composedAsyncValidatorFn=l}get parent(){return this._parent}get valid(){return this.status===ql}get invalid(){return this.status===Sh}get pending(){return this.status==pa}get disabled(){return this.status===Zl}get enabled(){return this.status!==Zl}get dirty(){return!this.pristine}get untouched(){return!this.touched}get updateOn(){return this._updateOn?this._updateOn:this.parent?this.parent.updateOn:"change"}setValidators(l){this._rawValidators=l,this._composedValidatorFn=gD(l)}setAsyncValidators(l){this._rawAsyncValidators=l,this._composedAsyncValidatorFn=pD(l)}addValidators(l){this.setValidators(rD(l,this._rawValidators))}addAsyncValidators(l){this.setAsyncValidators(rD(l,this._rawAsyncValidators))}removeValidators(l){this.setValidators(sD(l,this._rawValidators))}removeAsyncValidators(l){this.setAsyncValidators(sD(l,this._rawAsyncValidators))}hasValidator(l){return yh(this._rawValidators,l)}hasAsyncValidator(l){return yh(this._rawAsyncValidators,l)}clearValidators(){this.validator=null}clearAsyncValidators(){this.asyncValidator=null}markAsTouched(l={}){this.touched=!0,this._parent&&!l.onlySelf&&this._parent.markAsTouched(l)}markAllAsTouched(){this.markAsTouched({onlySelf:!0}),this._forEachChild(l=>l.markAllAsTouched())}markAsUntouched(l={}){this.touched=!1,this._pendingTouched=!1,this._forEachChild(u=>{u.markAsUntouched({onlySelf:!0})}),this._parent&&!l.onlySelf&&this._parent._updateTouched(l)}markAsDirty(l={}){this.pristine=!1,this._parent&&!l.onlySelf&&this._parent.markAsDirty(l)}markAsPristine(l={}){this.pristine=!0,this._pendingDirty=!1,this._forEachChild(u=>{u.markAsPristine({onlySelf:!0})}),this._parent&&!l.onlySelf&&this._parent._updatePristine(l)}markAsPending(l={}){this.status=pa,!1!==l.emitEvent&&this.statusChanges.emit(this.status),this._parent&&!l.onlySelf&&this._parent.markAsPending(l)}disable(l={}){const u=this._parentMarkedDirty(l.onlySelf);this.status=Zl,this.errors=null,this._forEachChild(g=>{g.disable(Object.assign(Object.assign({},l),{onlySelf:!0}))}),this._updateValue(),!1!==l.emitEvent&&(this.valueChanges.emit(this.value),this.statusChanges.emit(this.status)),this._updateAncestors(Object.assign(Object.assign({},l),{skipPristineCheck:u})),this._onDisabledChange.forEach(g=>g(!0))}enable(l={}){const u=this._parentMarkedDirty(l.onlySelf);this.status=ql,this._forEachChild(g=>{g.enable(Object.assign(Object.assign({},l),{onlySelf:!0}))}),this.updateValueAndValidity({onlySelf:!0,emitEvent:l.emitEvent}),this._updateAncestors(Object.assign(Object.assign({},l),{skipPristineCheck:u})),this._onDisabledChange.forEach(g=>g(!1))}_updateAncestors(l){this._parent&&!l.onlySelf&&(this._parent.updateValueAndValidity(l),l.skipPristineCheck||this._parent._updatePristine(),this._parent._updateTouched())}setParent(l){this._parent=l}updateValueAndValidity(l={}){this._setInitialStatus(),this._updateValue(),this.enabled&&(this._cancelExistingSubscription(),this.errors=this._runValidator(),this.status=this._calculateStatus(),(this.status===ql||this.status===pa)&&this._runAsyncValidator(l.emitEvent)),!1!==l.emitEvent&&(this.valueChanges.emit(this.value),this.statusChanges.emit(this.status)),this._parent&&!l.onlySelf&&this._parent.updateValueAndValidity(l)}_updateTreeValidity(l={emitEvent:!0}){this._forEachChild(u=>u._updateTreeValidity(l)),this.updateValueAndValidity({onlySelf:!0,emitEvent:l.emitEvent})}_setInitialStatus(){this.status=this._allControlsDisabled()?Zl:ql}_runValidator(){return this.validator?this.validator(this):null}_runAsyncValidator(l){if(this.asyncValidator){this.status=pa,this._hasOwnPendingAsyncValidator=!0;const u=qb(this.asyncValidator(this));this._asyncValidationSubscription=u.subscribe(g=>{this._hasOwnPendingAsyncValidator=!1,this.setErrors(g,{emitEvent:l})})}}_cancelExistingSubscription(){this._asyncValidationSubscription&&(this._asyncValidationSubscription.unsubscribe(),this._hasOwnPendingAsyncValidator=!1)}setErrors(l,u={}){this.errors=l,this._updateControlsErrors(!1!==u.emitEvent)}get(l){return function d2(f,l,u){if(null==l||(Array.isArray(l)||(l=l.split(u)),Array.isArray(l)&&0===l.length))return null;let g=f;return l.forEach(p=>{g=lm(g)?g.controls.hasOwnProperty(p)?g.controls[p]:null:(f=>f instanceof g2)(g)&&g.at(p)||null}),g}(this,l,".")}getError(l,u){const g=u?this.get(u):this;return g&&g.errors?g.errors[l]:null}hasError(l,u){return!!this.getError(l,u)}get root(){let l=this;for(;l._parent;)l=l._parent;return l}_updateControlsErrors(l){this.status=this._calculateStatus(),l&&this.statusChanges.emit(this.status),this._parent&&this._parent._updateControlsErrors(l)}_initObservables(){this.valueChanges=new nn,this.statusChanges=new nn}_calculateStatus(){return this._allControlsDisabled()?Zl:this.errors?Sh:this._hasOwnPendingAsyncValidator||this._anyControlsHaveStatus(pa)?pa:this._anyControlsHaveStatus(Sh)?Sh:ql}_anyControlsHaveStatus(l){return this._anyControls(u=>u.status===l)}_anyControlsDirty(){return this._anyControls(l=>l.dirty)}_anyControlsTouched(){return this._anyControls(l=>l.touched)}_updatePristine(l={}){this.pristine=!this._anyControlsDirty(),this._parent&&!l.onlySelf&&this._parent._updatePristine(l)}_updateTouched(l={}){this.touched=this._anyControlsTouched(),this._parent&&!l.onlySelf&&this._parent._updateTouched(l)}_isBoxedValue(l){return"object"==typeof l&&null!==l&&2===Object.keys(l).length&&"value"in l&&"disabled"in l}_registerOnCollectionChange(l){this._onCollectionChange=l}_setUpdateStrategy(l){Ih(l)&&null!=l.updateOn&&(this._updateOn=l.updateOn)}_parentMarkedDirty(l){return!l&&!(!this._parent||!this._parent.dirty)&&!this._parent._anyControlsDirty()}}class CD extends cm{constructor(l=null,u,g){super(om(u),am(g,u)),this.defaultValue=null,this._onChange=[],this._pendingChange=!1,this._applyFormState(l),this._setUpdateStrategy(u),this._initObservables(),this.updateValueAndValidity({onlySelf:!0,emitEvent:!!this.asyncValidator}),Ih(u)&&u.initialValueIsDefault&&(this.defaultValue=this._isBoxedValue(l)?l.value:l)}setValue(l,u={}){this.value=this._pendingValue=l,this._onChange.length&&!1!==u.emitModelToViewChange&&this._onChange.forEach(g=>g(this.value,!1!==u.emitViewToModelChange)),this.updateValueAndValidity(u)}patchValue(l,u={}){this.setValue(l,u)}reset(l=this.defaultValue,u={}){this._applyFormState(l),this.markAsPristine(u),this.markAsUntouched(u),this.setValue(this.value,u),this._pendingChange=!1}_updateValue(){}_anyControls(l){return!1}_allControlsDisabled(){return this.disabled}registerOnChange(l){this._onChange.push(l)}_unregisterOnChange(l){rm(this._onChange,l)}registerOnDisabledChange(l){this._onDisabledChange.push(l)}_unregisterOnDisabledChange(l){rm(this._onDisabledChange,l)}_forEachChild(l){}_syncPendingControls(){return!("submit"!==this.updateOn||(this._pendingDirty&&this.markAsDirty(),this._pendingTouched&&this.markAsTouched(),!this._pendingChange)||(this.setValue(this._pendingValue,{onlySelf:!0,emitModelToViewChange:!1}),0))}_applyFormState(l){this._isBoxedValue(l)?(this.value=this._pendingValue=l.value,l.disabled?this.disable({onlySelf:!0,emitEvent:!1}):this.enable({onlySelf:!0,emitEvent:!1})):this.value=this._pendingValue=l}}class um extends cm{constructor(l,u,g){super(om(u),am(g,u)),this.controls=l,this._initObservables(),this._setUpdateStrategy(u),this._setUpControls(),this.updateValueAndValidity({onlySelf:!0,emitEvent:!!this.asyncValidator})}registerControl(l,u){return this.controls[l]?this.controls[l]:(this.controls[l]=u,u.setParent(this),u._registerOnCollectionChange(this._onCollectionChange),u)}addControl(l,u,g={}){this.registerControl(l,u),this.updateValueAndValidity({emitEvent:g.emitEvent}),this._onCollectionChange()}removeControl(l,u={}){this.controls[l]&&this.controls[l]._registerOnCollectionChange(()=>{}),delete this.controls[l],this.updateValueAndValidity({emitEvent:u.emitEvent}),this._onCollectionChange()}setControl(l,u,g={}){this.controls[l]&&this.controls[l]._registerOnCollectionChange(()=>{}),delete this.controls[l],u&&this.registerControl(l,u),this.updateValueAndValidity({emitEvent:g.emitEvent}),this._onCollectionChange()}contains(l){return this.controls.hasOwnProperty(l)&&this.controls[l].enabled}setValue(l,u={}){yD(this,l),Object.keys(l).forEach(g=>{vD(this,g),this.controls[g].setValue(l[g],{onlySelf:!0,emitEvent:u.emitEvent})}),this.updateValueAndValidity(u)}patchValue(l,u={}){null!=l&&(Object.keys(l).forEach(g=>{this.controls[g]&&this.controls[g].patchValue(l[g],{onlySelf:!0,emitEvent:u.emitEvent})}),this.updateValueAndValidity(u))}reset(l={},u={}){this._forEachChild((g,p)=>{g.reset(l[p],{onlySelf:!0,emitEvent:u.emitEvent})}),this._updatePristine(u),this._updateTouched(u),this.updateValueAndValidity(u)}getRawValue(){return this._reduceChildren({},(l,u,g)=>(l[g]=_D(u),l))}_syncPendingControls(){let l=this._reduceChildren(!1,(u,g)=>!!g._syncPendingControls()||u);return l&&this.updateValueAndValidity({onlySelf:!0}),l}_forEachChild(l){Object.keys(this.controls).forEach(u=>{const g=this.controls[u];g&&l(g,u)})}_setUpControls(){this._forEachChild(l=>{l.setParent(this),l._registerOnCollectionChange(this._onCollectionChange)})}_updateValue(){this.value=this._reduceValue()}_anyControls(l){for(const u of Object.keys(this.controls)){const g=this.controls[u];if(this.contains(u)&&l(g))return!0}return!1}_reduceValue(){return this._reduceChildren({},(l,u,g)=>((u.enabled||this.disabled)&&(l[g]=u.value),l))}_reduceChildren(l,u){let g=l;return this._forEachChild((p,m)=>{g=u(g,p,m)}),g}_allControlsDisabled(){for(const l of Object.keys(this.controls))if(this.controls[l].enabled)return!1;return Object.keys(this.controls).length>0||this.disabled}}class g2 extends cm{constructor(l,u,g){super(om(u),am(g,u)),this.controls=l,this._initObservables(),this._setUpdateStrategy(u),this._setUpControls(),this.updateValueAndValidity({onlySelf:!0,emitEvent:!!this.asyncValidator})}at(l){return this.controls[l]}push(l,u={}){this.controls.push(l),this._registerControl(l),this.updateValueAndValidity({emitEvent:u.emitEvent}),this._onCollectionChange()}insert(l,u,g={}){this.controls.splice(l,0,u),this._registerControl(u),this.updateValueAndValidity({emitEvent:g.emitEvent})}removeAt(l,u={}){this.controls[l]&&this.controls[l]._registerOnCollectionChange(()=>{}),this.controls.splice(l,1),this.updateValueAndValidity({emitEvent:u.emitEvent})}setControl(l,u,g={}){this.controls[l]&&this.controls[l]._registerOnCollectionChange(()=>{}),this.controls.splice(l,1),u&&(this.controls.splice(l,0,u),this._registerControl(u)),this.updateValueAndValidity({emitEvent:g.emitEvent}),this._onCollectionChange()}get length(){return this.controls.length}setValue(l,u={}){yD(this,l),l.forEach((g,p)=>{vD(this,p),this.at(p).setValue(g,{onlySelf:!0,emitEvent:u.emitEvent})}),this.updateValueAndValidity(u)}patchValue(l,u={}){null!=l&&(l.forEach((g,p)=>{this.at(p)&&this.at(p).patchValue(g,{onlySelf:!0,emitEvent:u.emitEvent})}),this.updateValueAndValidity(u))}reset(l=[],u={}){this._forEachChild((g,p)=>{g.reset(l[p],{onlySelf:!0,emitEvent:u.emitEvent})}),this._updatePristine(u),this._updateTouched(u),this.updateValueAndValidity(u)}getRawValue(){return this.controls.map(l=>_D(l))}clear(l={}){this.controls.length<1||(this._forEachChild(u=>u._registerOnCollectionChange(()=>{})),this.controls.splice(0),this.updateValueAndValidity({emitEvent:l.emitEvent}))}_syncPendingControls(){let l=this.controls.reduce((u,g)=>!!g._syncPendingControls()||u,!1);return l&&this.updateValueAndValidity({onlySelf:!0}),l}_forEachChild(l){this.controls.forEach((u,g)=>{l(u,g)})}_updateValue(){this.value=this.controls.filter(l=>l.enabled||this.disabled).map(l=>l.value)}_anyControls(l){return this.controls.some(u=>u.enabled&&l(u))}_setUpControls(){this._forEachChild(l=>this._registerControl(l))}_allControlsDisabled(){for(const l of this.controls)if(l.enabled)return!1;return this.controls.length>0||this.disabled}_registerControl(l){l.setParent(this),l._registerOnCollectionChange(this._onCollectionChange)}}const _2={provide:Is,useExisting:jt(()=>dm)},bD=(()=>Promise.resolve(null))();let dm=(()=>{class f extends Is{constructor(u,g,p,m,v){super(),this._changeDetectorRef=v,this.control=new CD,this._registered=!1,this.update=new nn,this._parent=u,this._setValidators(g),this._setAsyncValidators(p),this.valueAccessor=function im(f,l){if(!l)return null;let u,g,p;return Array.isArray(l),l.forEach(m=>{m.constructor===_h?u=m:function h2(f){return Object.getPrototypeOf(f.constructor)===io}(m)?g=m:p=m}),p||g||u||null}(0,m)}ngOnChanges(u){if(this._checkForErrors(),!this._registered||"name"in u){if(this._registered&&(this._checkName(),this.formDirective)){const g=u.name.previousValue;this.formDirective.removeControl({name:g,path:this._getPath(g)})}this._setUpControl()}"isDisabled"in u&&this._updateDisabled(u),function nm(f,l){if(!f.hasOwnProperty("model"))return!1;const u=f.model;return!!u.isFirstChange()||!Object.is(l,u.currentValue)}(u,this.viewModel)&&(this._updateValue(this.model),this.viewModel=this.model)}ngOnDestroy(){this.formDirective&&this.formDirective.removeControl(this)}get path(){return this._getPath(this.name)}get formDirective(){return this._parent?this._parent.formDirective:null}viewToModelUpdate(u){this.viewModel=u,this.update.emit(u)}_setUpControl(){this._setUpdateStrategy(),this._isStandalone()?this._setUpStandalone():this.formDirective.addControl(this),this._registered=!0}_setUpdateStrategy(){this.options&&null!=this.options.updateOn&&(this.control._updateOn=this.options.updateOn)}_isStandalone(){return!this._parent||!(!this.options||!this.options.standalone)}_setUpStandalone(){Xl(this.control,this),this.control.updateValueAndValidity({emitEvent:!1})}_checkForErrors(){this._isStandalone()||this._checkParentType(),this._checkName()}_checkParentType(){}_checkName(){this.options&&this.options.name&&(this.name=this.options.name),this._isStandalone()}_updateValue(u){bD.then(()=>{var g;this.control.setValue(u,{emitViewToModelChange:!1}),null===(g=this._changeDetectorRef)||void 0===g||g.markForCheck()})}_updateDisabled(u){const g=u.isDisabled.currentValue,p=""===g||g&&"false"!==g;bD.then(()=>{var m;p&&!this.control.disabled?this.control.disable():!p&&this.control.disabled&&this.control.enable(),null===(m=this._changeDetectorRef)||void 0===m||m.markForCheck()})}_getPath(u){return this._parent?function wh(f,l){return[...l.path,f]}(u,this._parent):[u]}}return f.\u0275fac=function(u){return new(u||f)(ye($n,9),ye(Un,10),ye(Ss,10),ye(Cr,10),ye(Ju,8))},f.\u0275dir=ze({type:f,selectors:[["","ngModel","",3,"formControlName","",3,"formControl",""]],inputs:{name:"name",isDisabled:["disabled","isDisabled"],model:["ngModel","model"],options:["ngModelOptions","options"]},outputs:{update:"ngModelChange"},exportAs:["ngModel"],features:[Xt([_2]),xt,Di]}),f})(),SD=(()=>{class f{}return f.\u0275fac=function(u){return new(u||f)},f.\u0275mod=lr({type:f}),f.\u0275inj=Ui({}),f})(),H2=(()=>{class f{}return f.\u0275fac=function(u){return new(u||f)},f.\u0275mod=lr({type:f}),f.\u0275inj=Ui({imports:[[SD]]}),f})(),W2=(()=>{class f{}return f.\u0275fac=function(u){return new(u||f)},f.\u0275mod=lr({type:f}),f.\u0275inj=Ui({imports:[H2]}),f})();function at(...f){return In(f,Ja(f))}class Ji extends Ar{constructor(l){super(),this._value=l}get value(){return this.getValue()}_subscribe(l){const u=super._subscribe(l);return!u.closed&&l.next(this._value),u}getValue(){const{hasError:l,thrownError:u,_value:g}=this;if(l)throw u;return this._throwIfClosed(),g}next(l){super.next(this._value=l)}}function HD(f,l,u){f?Rr(u,f,l):l()}function Th(f,l){const u=Vt(f)?f:()=>f,g=p=>p.error(u());return new cn(l?p=>l.schedule(g,0,p):g)}const xh=Za(f=>function(){f(this),this.name="EmptyError",this.message="no elements in sequence"});function ym(...f){return function $2(){return Qa(1)}()(In(f,Ja(f)))}function WD(f){return new cn(l=>{sr(f()).subscribe(l)})}function zD(){return xn((f,l)=>{let u=null;f._refCount++;const g=Dn(l,void 0,void 0,void 0,()=>{if(!f||f._refCount<=0||0<--f._refCount)return void(u=null);const p=f._connection,m=u;u=null,p&&(!m||p===m)&&p.unsubscribe(),l.unsubscribe()});f.subscribe(g),g.closed||(u=f.connect())})}class X2 extends cn{constructor(l,u){super(),this.source=l,this.subjectFactory=u,this._subject=null,this._refCount=0,this._connection=null,iv(l)&&(this.lift=l.lift)}_subscribe(l){return this.getSubject().subscribe(l)}getSubject(){const l=this._subject;return(!l||l.isStopped)&&(this._subject=this.subjectFactory()),this._subject}_teardown(){this._refCount=0;const{_connection:l}=this;this._subject=this._connection=null,null==l||l.unsubscribe()}connect(){let l=this._connection;if(!l){l=this._connection=new wi;const u=this.getSubject();l.add(this.source.subscribe(Dn(u,void 0,()=>{this._teardown(),u.complete()},g=>{this._teardown(),u.error(g)},()=>this._teardown()))),l.closed&&(this._connection=null,l=wi.EMPTY)}return l}refCount(){return zD()(this)}}function so(f,l){return xn((u,g)=>{let p=null,m=0,v=!1;const y=()=>v&&!p&&g.complete();u.subscribe(Dn(g,b=>{null==p||p.unsubscribe();let O=0;const L=m++;sr(f(b,L)).subscribe(p=Dn(g,N=>g.next(l?l(b,N,L,O++):N),()=>{p=null,y()}))},()=>{v=!0,y()}))})}function Z2(f,l,u,g,p){return(m,v)=>{let y=u,b=l,O=0;m.subscribe(Dn(v,L=>{const N=O++;b=y?f(b,L,N):(y=!0,L),g&&v.next(b)},p&&(()=>{y&&v.next(b),v.complete()})))}}function YD(f,l){return xn(Z2(f,l,arguments.length>=2,!0))}function ma(f,l){return xn((u,g)=>{let p=0;u.subscribe(Dn(g,m=>f.call(l,m,p++)&&g.next(m)))})}function Ts(f){return xn((l,u)=>{let m,g=null,p=!1;g=l.subscribe(Dn(u,void 0,void 0,v=>{m=sr(f(v,Ts(f)(l))),g?(g.unsubscribe(),g=null,m.subscribe(u)):p=!0})),p&&(g.unsubscribe(),g=null,m.subscribe(u))})}function Ql(f,l){return Vt(l)?Sn(f,l,1):Sn(f,1)}function Cm(f){return f<=0?()=>Or:xn((l,u)=>{let g=[];l.subscribe(Dn(u,p=>{g.push(p),f{for(const p of g)u.next(p);u.complete()},void 0,()=>{g=null}))})}function $D(f=K2){return xn((l,u)=>{let g=!1;l.subscribe(Dn(u,p=>{g=!0,u.next(p)},()=>g?u.complete():u.error(f())))})}function K2(){return new xh}function XD(f){return xn((l,u)=>{let g=!1;l.subscribe(Dn(u,p=>{g=!0,u.next(p)},()=>{g||u.next(f),u.complete()}))})}function _a(f,l){const u=arguments.length>=2;return g=>g.pipe(f?ma((p,m)=>f(p,m,g)):Hs,Qc(1),u?XD(l):$D(()=>new xh))}function di(f,l,u){const g=Vt(f)||l||u?{next:f,error:l,complete:u}:f;return g?xn((p,m)=>{var v;null===(v=g.subscribe)||void 0===v||v.call(g);let y=!0;p.subscribe(Dn(m,b=>{var O;null===(O=g.next)||void 0===O||O.call(g,b),m.next(b)},()=>{var b;y=!1,null===(b=g.complete)||void 0===b||b.call(g),m.complete()},b=>{var O;y=!1,null===(O=g.error)||void 0===O||O.call(g,b),m.error(b)},()=>{var b,O;y&&(null===(b=g.unsubscribe)||void 0===b||b.call(g)),null===(O=g.finalize)||void 0===O||O.call(g)}))}):Hs}class Hr{constructor(l,u){this.id=l,this.url=u}}class wm extends Hr{constructor(l,u,g="imperative",p=null){super(l,u),this.navigationTrigger=g,this.restoredState=p}toString(){return`NavigationStart(id: ${this.id}, url: '${this.url}')`}}class Jl extends Hr{constructor(l,u,g){super(l,u),this.urlAfterRedirects=g}toString(){return`NavigationEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}')`}}class qD extends Hr{constructor(l,u,g){super(l,u),this.reason=g}toString(){return`NavigationCancel(id: ${this.id}, url: '${this.url}')`}}class eB extends Hr{constructor(l,u,g){super(l,u),this.error=g}toString(){return`NavigationError(id: ${this.id}, url: '${this.url}', error: ${this.error})`}}class tB extends Hr{constructor(l,u,g,p){super(l,u),this.urlAfterRedirects=g,this.state=p}toString(){return`RoutesRecognized(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}}class nB extends Hr{constructor(l,u,g,p){super(l,u),this.urlAfterRedirects=g,this.state=p}toString(){return`GuardsCheckStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}}class iB extends Hr{constructor(l,u,g,p,m){super(l,u),this.urlAfterRedirects=g,this.state=p,this.shouldActivate=m}toString(){return`GuardsCheckEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state}, shouldActivate: ${this.shouldActivate})`}}class rB extends Hr{constructor(l,u,g,p){super(l,u),this.urlAfterRedirects=g,this.state=p}toString(){return`ResolveStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}}class sB extends Hr{constructor(l,u,g,p){super(l,u),this.urlAfterRedirects=g,this.state=p}toString(){return`ResolveEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`}}class ZD{constructor(l){this.route=l}toString(){return`RouteConfigLoadStart(path: ${this.route.path})`}}class KD{constructor(l){this.route=l}toString(){return`RouteConfigLoadEnd(path: ${this.route.path})`}}class oB{constructor(l){this.snapshot=l}toString(){return`ChildActivationStart(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}}class aB{constructor(l){this.snapshot=l}toString(){return`ChildActivationEnd(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}}class lB{constructor(l){this.snapshot=l}toString(){return`ActivationStart(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}}class cB{constructor(l){this.snapshot=l}toString(){return`ActivationEnd(path: '${this.snapshot.routeConfig&&this.snapshot.routeConfig.path||""}')`}}class QD{constructor(l,u,g){this.routerEvent=l,this.position=u,this.anchor=g}toString(){return`Scroll(anchor: '${this.anchor}', position: '${this.position?`${this.position[0]}, ${this.position[1]}`:null}')`}}const ft="primary";class uB{constructor(l){this.params=l||{}}has(l){return Object.prototype.hasOwnProperty.call(this.params,l)}get(l){if(this.has(l)){const u=this.params[l];return Array.isArray(u)?u[0]:u}return null}getAll(l){if(this.has(l)){const u=this.params[l];return Array.isArray(u)?u:[u]}return[]}get keys(){return Object.keys(this.params)}}function va(f){return new uB(f)}const JD="ngNavigationCancelingError";function Em(f){const l=Error("NavigationCancelingError: "+f);return l[JD]=!0,l}function dB(f,l,u){const g=u.path.split("/");if(g.length>f.length||"full"===u.pathMatch&&(l.hasChildren()||g.lengthg[m]===p)}return f===l}function tS(f){return Array.prototype.concat.apply([],f)}function nS(f){return f.length>0?f[f.length-1]:null}function Mn(f,l){for(const u in f)f.hasOwnProperty(u)&&l(f[u],u)}function Er(f){return kg(f)?f:Rl(f)?In(Promise.resolve(f)):at(f)}const pB={exact:function sS(f,l,u){if(!ao(f.segments,l.segments)||!Ah(f.segments,l.segments,u)||f.numberOfChildren!==l.numberOfChildren)return!1;for(const g in l.children)if(!f.children[g]||!sS(f.children[g],l.children[g],u))return!1;return!0},subset:oS},iS={exact:function mB(f,l){return wr(f,l)},subset:function _B(f,l){return Object.keys(l).length<=Object.keys(f).length&&Object.keys(l).every(u=>eS(f[u],l[u]))},ignored:()=>!0};function rS(f,l,u){return pB[u.paths](f.root,l.root,u.matrixParams)&&iS[u.queryParams](f.queryParams,l.queryParams)&&!("exact"===u.fragment&&f.fragment!==l.fragment)}function oS(f,l,u){return aS(f,l,l.segments,u)}function aS(f,l,u,g){if(f.segments.length>u.length){const p=f.segments.slice(0,u.length);return!(!ao(p,u)||l.hasChildren()||!Ah(p,u,g))}if(f.segments.length===u.length){if(!ao(f.segments,u)||!Ah(f.segments,u,g))return!1;for(const p in l.children)if(!f.children[p]||!oS(f.children[p],l.children[p],g))return!1;return!0}{const p=u.slice(0,f.segments.length),m=u.slice(f.segments.length);return!!(ao(f.segments,p)&&Ah(f.segments,p,g)&&f.children[ft])&&aS(f.children[ft],l,m,g)}}function Ah(f,l,u){return l.every((g,p)=>iS[u](f[p].parameters,g.parameters))}class oo{constructor(l,u,g){this.root=l,this.queryParams=u,this.fragment=g}get queryParamMap(){return this._queryParamMap||(this._queryParamMap=va(this.queryParams)),this._queryParamMap}toString(){return CB.serialize(this)}}class Ct{constructor(l,u){this.segments=l,this.children=u,this.parent=null,Mn(u,(g,p)=>g.parent=this)}hasChildren(){return this.numberOfChildren>0}get numberOfChildren(){return Object.keys(this.children).length}toString(){return Rh(this)}}class ec{constructor(l,u){this.path=l,this.parameters=u}get parameterMap(){return this._parameterMap||(this._parameterMap=va(this.parameters)),this._parameterMap}toString(){return dS(this)}}function ao(f,l){return f.length===l.length&&f.every((u,g)=>u.path===l[g].path)}class lS{}class cS{parse(l){const u=new AB(l);return new oo(u.parseRootSegment(),u.parseQueryParams(),u.parseFragment())}serialize(l){const u=`/${tc(l.root,!0)}`,g=function bB(f){const l=Object.keys(f).map(u=>{const g=f[u];return Array.isArray(g)?g.map(p=>`${Oh(u)}=${Oh(p)}`).join("&"):`${Oh(u)}=${Oh(g)}`}).filter(u=>!!u);return l.length?`?${l.join("&")}`:""}(l.queryParams);return`${u}${g}${"string"==typeof l.fragment?`#${function wB(f){return encodeURI(f)}(l.fragment)}`:""}`}}const CB=new cS;function Rh(f){return f.segments.map(l=>dS(l)).join("/")}function tc(f,l){if(!f.hasChildren())return Rh(f);if(l){const u=f.children[ft]?tc(f.children[ft],!1):"",g=[];return Mn(f.children,(p,m)=>{m!==ft&&g.push(`${m}:${tc(p,!1)}`)}),g.length>0?`${u}(${g.join("//")})`:u}{const u=function yB(f,l){let u=[];return Mn(f.children,(g,p)=>{p===ft&&(u=u.concat(l(g,p)))}),Mn(f.children,(g,p)=>{p!==ft&&(u=u.concat(l(g,p)))}),u}(f,(g,p)=>p===ft?[tc(f.children[ft],!1)]:[`${p}:${tc(g,!1)}`]);return 1===Object.keys(f.children).length&&null!=f.children[ft]?`${Rh(f)}/${u[0]}`:`${Rh(f)}/(${u.join("//")})`}}function uS(f){return encodeURIComponent(f).replace(/%40/g,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",")}function Oh(f){return uS(f).replace(/%3B/gi,";")}function bm(f){return uS(f).replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/%26/gi,"&")}function Mh(f){return decodeURIComponent(f)}function hS(f){return Mh(f.replace(/\+/g,"%20"))}function dS(f){return`${bm(f.path)}${function EB(f){return Object.keys(f).map(l=>`;${bm(l)}=${bm(f[l])}`).join("")}(f.parameters)}`}const DB=/^[^\/()?;=#]+/;function Lh(f){const l=f.match(DB);return l?l[0]:""}const SB=/^[^=?&#]+/,TB=/^[^&#]+/;class AB{constructor(l){this.url=l,this.remaining=l}parseRootSegment(){return this.consumeOptional("/"),""===this.remaining||this.peekStartsWith("?")||this.peekStartsWith("#")?new Ct([],{}):new Ct([],this.parseChildren())}parseQueryParams(){const l={};if(this.consumeOptional("?"))do{this.parseQueryParam(l)}while(this.consumeOptional("&"));return l}parseFragment(){return this.consumeOptional("#")?decodeURIComponent(this.remaining):null}parseChildren(){if(""===this.remaining)return{};this.consumeOptional("/");const l=[];for(this.peekStartsWith("(")||l.push(this.parseSegment());this.peekStartsWith("/")&&!this.peekStartsWith("//")&&!this.peekStartsWith("/(");)this.capture("/"),l.push(this.parseSegment());let u={};this.peekStartsWith("/(")&&(this.capture("/"),u=this.parseParens(!0));let g={};return this.peekStartsWith("(")&&(g=this.parseParens(!1)),(l.length>0||Object.keys(u).length>0)&&(g[ft]=new Ct(l,u)),g}parseSegment(){const l=Lh(this.remaining);if(""===l&&this.peekStartsWith(";"))throw new Error(`Empty path url segment cannot have parameters: '${this.remaining}'.`);return this.capture(l),new ec(Mh(l),this.parseMatrixParams())}parseMatrixParams(){const l={};for(;this.consumeOptional(";");)this.parseParam(l);return l}parseParam(l){const u=Lh(this.remaining);if(!u)return;this.capture(u);let g="";if(this.consumeOptional("=")){const p=Lh(this.remaining);p&&(g=p,this.capture(g))}l[Mh(u)]=Mh(g)}parseQueryParam(l){const u=function IB(f){const l=f.match(SB);return l?l[0]:""}(this.remaining);if(!u)return;this.capture(u);let g="";if(this.consumeOptional("=")){const v=function xB(f){const l=f.match(TB);return l?l[0]:""}(this.remaining);v&&(g=v,this.capture(g))}const p=hS(u),m=hS(g);if(l.hasOwnProperty(p)){let v=l[p];Array.isArray(v)||(v=[v],l[p]=v),v.push(m)}else l[p]=m}parseParens(l){const u={};for(this.capture("(");!this.consumeOptional(")")&&this.remaining.length>0;){const g=Lh(this.remaining),p=this.remaining[g.length];if("/"!==p&&")"!==p&&";"!==p)throw new Error(`Cannot parse url '${this.url}'`);let m;g.indexOf(":")>-1?(m=g.substr(0,g.indexOf(":")),this.capture(m),this.capture(":")):l&&(m=ft);const v=this.parseChildren();u[m]=1===Object.keys(v).length?v[ft]:new Ct([],v),this.consumeOptional("//")}return u}peekStartsWith(l){return this.remaining.startsWith(l)}consumeOptional(l){return!!this.peekStartsWith(l)&&(this.remaining=this.remaining.substring(l.length),!0)}capture(l){if(!this.consumeOptional(l))throw new Error(`Expected "${l}".`)}}class fS{constructor(l){this._root=l}get root(){return this._root.value}parent(l){const u=this.pathFromRoot(l);return u.length>1?u[u.length-2]:null}children(l){const u=Dm(l,this._root);return u?u.children.map(g=>g.value):[]}firstChild(l){const u=Dm(l,this._root);return u&&u.children.length>0?u.children[0].value:null}siblings(l){const u=Sm(l,this._root);return u.length<2?[]:u[u.length-2].children.map(p=>p.value).filter(p=>p!==l)}pathFromRoot(l){return Sm(l,this._root).map(u=>u.value)}}function Dm(f,l){if(f===l.value)return l;for(const u of l.children){const g=Dm(f,u);if(g)return g}return null}function Sm(f,l){if(f===l.value)return[l];for(const u of l.children){const g=Sm(f,u);if(g.length)return g.unshift(l),g}return[]}class Wr{constructor(l,u){this.value=l,this.children=u}toString(){return`TreeNode(${this.value})`}}function ya(f){const l={};return f&&f.children.forEach(u=>l[u.value.outlet]=u),l}class gS extends fS{constructor(l,u){super(l),this.snapshot=u,Im(this,l)}toString(){return this.snapshot.toString()}}function pS(f,l){const u=function RB(f,l){const v=new Fh([],{},{},"",{},ft,l,null,f.root,-1,{});return new _S("",new Wr(v,[]))}(f,l),g=new Ji([new ec("",{})]),p=new Ji({}),m=new Ji({}),v=new Ji({}),y=new Ji(""),b=new Ca(g,p,v,y,m,ft,l,u.root);return b.snapshot=u.root,new gS(new Wr(b,[]),u)}class Ca{constructor(l,u,g,p,m,v,y,b){this.url=l,this.params=u,this.queryParams=g,this.fragment=p,this.data=m,this.outlet=v,this.component=y,this._futureSnapshot=b}get routeConfig(){return this._futureSnapshot.routeConfig}get root(){return this._routerState.root}get parent(){return this._routerState.parent(this)}get firstChild(){return this._routerState.firstChild(this)}get children(){return this._routerState.children(this)}get pathFromRoot(){return this._routerState.pathFromRoot(this)}get paramMap(){return this._paramMap||(this._paramMap=this.params.pipe(Ut(l=>va(l)))),this._paramMap}get queryParamMap(){return this._queryParamMap||(this._queryParamMap=this.queryParams.pipe(Ut(l=>va(l)))),this._queryParamMap}toString(){return this.snapshot?this.snapshot.toString():`Future(${this._futureSnapshot})`}}function mS(f,l="emptyOnly"){const u=f.pathFromRoot;let g=0;if("always"!==l)for(g=u.length-1;g>=1;){const p=u[g],m=u[g-1];if(p.routeConfig&&""===p.routeConfig.path)g--;else{if(m.component)break;g--}}return function OB(f){return f.reduce((l,u)=>({params:Object.assign(Object.assign({},l.params),u.params),data:Object.assign(Object.assign({},l.data),u.data),resolve:Object.assign(Object.assign({},l.resolve),u._resolvedData)}),{params:{},data:{},resolve:{}})}(u.slice(g))}class Fh{constructor(l,u,g,p,m,v,y,b,O,L,N){this.url=l,this.params=u,this.queryParams=g,this.fragment=p,this.data=m,this.outlet=v,this.component=y,this.routeConfig=b,this._urlSegment=O,this._lastPathIndex=L,this._resolve=N}get root(){return this._routerState.root}get parent(){return this._routerState.parent(this)}get firstChild(){return this._routerState.firstChild(this)}get children(){return this._routerState.children(this)}get pathFromRoot(){return this._routerState.pathFromRoot(this)}get paramMap(){return this._paramMap||(this._paramMap=va(this.params)),this._paramMap}get queryParamMap(){return this._queryParamMap||(this._queryParamMap=va(this.queryParams)),this._queryParamMap}toString(){return`Route(url:'${this.url.map(g=>g.toString()).join("/")}', path:'${this.routeConfig?this.routeConfig.path:""}')`}}class _S extends fS{constructor(l,u){super(u),this.url=l,Im(this,u)}toString(){return vS(this._root)}}function Im(f,l){l.value._routerState=f,l.children.forEach(u=>Im(f,u))}function vS(f){const l=f.children.length>0?` { ${f.children.map(vS).join(", ")} } `:"";return`${f.value}${l}`}function Tm(f){if(f.snapshot){const l=f.snapshot,u=f._futureSnapshot;f.snapshot=u,wr(l.queryParams,u.queryParams)||f.queryParams.next(u.queryParams),l.fragment!==u.fragment&&f.fragment.next(u.fragment),wr(l.params,u.params)||f.params.next(u.params),function fB(f,l){if(f.length!==l.length)return!1;for(let u=0;uwr(u.parameters,l[g].parameters))}(f.url,l.url);return u&&!(!f.parent!=!l.parent)&&(!f.parent||xm(f.parent,l.parent))}function nc(f,l,u){if(u&&f.shouldReuseRoute(l.value,u.value.snapshot)){const g=u.value;g._futureSnapshot=l.value;const p=function LB(f,l,u){return l.children.map(g=>{for(const p of u.children)if(f.shouldReuseRoute(g.value,p.value.snapshot))return nc(f,g,p);return nc(f,g)})}(f,l,u);return new Wr(g,p)}{if(f.shouldAttach(l.value)){const m=f.retrieve(l.value);if(null!==m){const v=m.route;return v.value._futureSnapshot=l.value,v.children=l.children.map(y=>nc(f,y)),v}}const g=function FB(f){return new Ca(new Ji(f.url),new Ji(f.params),new Ji(f.queryParams),new Ji(f.fragment),new Ji(f.data),f.outlet,f.component,f)}(l.value),p=l.children.map(m=>nc(f,m));return new Wr(g,p)}}function Ph(f){return"object"==typeof f&&null!=f&&!f.outlets&&!f.segmentPath}function ic(f){return"object"==typeof f&&null!=f&&f.outlets}function Am(f,l,u,g,p){let m={};if(g&&Mn(g,(y,b)=>{m[b]=Array.isArray(y)?y.map(O=>`${O}`):`${y}`}),f===l)return new oo(u,m,p);const v=yS(f,l,u);return new oo(v,m,p)}function yS(f,l,u){const g={};return Mn(f.children,(p,m)=>{g[m]=p===l?u:yS(p,l,u)}),new Ct(f.segments,g)}class CS{constructor(l,u,g){if(this.isAbsolute=l,this.numberOfDoubleDots=u,this.commands=g,l&&g.length>0&&Ph(g[0]))throw new Error("Root segment cannot have matrix parameters");const p=g.find(ic);if(p&&p!==nS(g))throw new Error("{outlets:{}} has to be the last command")}toRoot(){return this.isAbsolute&&1===this.commands.length&&"/"==this.commands[0]}}class Rm{constructor(l,u,g){this.segmentGroup=l,this.processChildren=u,this.index=g}}function wS(f,l,u){if(f||(f=new Ct([],{})),0===f.segments.length&&f.hasChildren())return Nh(f,l,u);const g=function UB(f,l,u){let g=0,p=l;const m={match:!1,pathIndex:0,commandIndex:0};for(;p=u.length)return m;const v=f.segments[p],y=u[g];if(ic(y))break;const b=`${y}`,O=g0&&void 0===b)break;if(b&&O&&"object"==typeof O&&void 0===O.outlets){if(!bS(b,O,v))return m;g+=2}else{if(!bS(b,{},v))return m;g++}p++}return{match:!0,pathIndex:p,commandIndex:g}}(f,l,u),p=u.slice(g.commandIndex);if(g.match&&g.pathIndex{"string"==typeof m&&(m=[m]),null!==m&&(p[v]=wS(f.children[v],l,m))}),Mn(f.children,(m,v)=>{void 0===g[v]&&(p[v]=m)}),new Ct(f.segments,p)}}function Om(f,l,u){const g=f.segments.slice(0,l);let p=0;for(;p{"string"==typeof u&&(u=[u]),null!==u&&(l[g]=Om(new Ct([],{}),0,u))}),l}function ES(f){const l={};return Mn(f,(u,g)=>l[g]=`${u}`),l}function bS(f,l,u){return f==u.path&&wr(l,u.parameters)}class HB{constructor(l,u,g,p){this.routeReuseStrategy=l,this.futureState=u,this.currState=g,this.forwardEvent=p}activate(l){const u=this.futureState._root,g=this.currState?this.currState._root:null;this.deactivateChildRoutes(u,g,l),Tm(this.futureState.root),this.activateChildRoutes(u,g,l)}deactivateChildRoutes(l,u,g){const p=ya(u);l.children.forEach(m=>{const v=m.value.outlet;this.deactivateRoutes(m,p[v],g),delete p[v]}),Mn(p,(m,v)=>{this.deactivateRouteAndItsChildren(m,g)})}deactivateRoutes(l,u,g){const p=l.value,m=u?u.value:null;if(p===m)if(p.component){const v=g.getContext(p.outlet);v&&this.deactivateChildRoutes(l,u,v.children)}else this.deactivateChildRoutes(l,u,g);else m&&this.deactivateRouteAndItsChildren(u,g)}deactivateRouteAndItsChildren(l,u){l.value.component&&this.routeReuseStrategy.shouldDetach(l.value.snapshot)?this.detachAndStoreRouteSubtree(l,u):this.deactivateRouteAndOutlet(l,u)}detachAndStoreRouteSubtree(l,u){const g=u.getContext(l.value.outlet),p=g&&l.value.component?g.children:u,m=ya(l);for(const v of Object.keys(m))this.deactivateRouteAndItsChildren(m[v],p);if(g&&g.outlet){const v=g.outlet.detach(),y=g.children.onOutletDeactivated();this.routeReuseStrategy.store(l.value.snapshot,{componentRef:v,route:l,contexts:y})}}deactivateRouteAndOutlet(l,u){const g=u.getContext(l.value.outlet),p=g&&l.value.component?g.children:u,m=ya(l);for(const v of Object.keys(m))this.deactivateRouteAndItsChildren(m[v],p);g&&g.outlet&&(g.outlet.deactivate(),g.children.onOutletDeactivated(),g.attachRef=null,g.resolver=null,g.route=null)}activateChildRoutes(l,u,g){const p=ya(u);l.children.forEach(m=>{this.activateRoutes(m,p[m.value.outlet],g),this.forwardEvent(new cB(m.value.snapshot))}),l.children.length&&this.forwardEvent(new aB(l.value.snapshot))}activateRoutes(l,u,g){const p=l.value,m=u?u.value:null;if(Tm(p),p===m)if(p.component){const v=g.getOrCreateContext(p.outlet);this.activateChildRoutes(l,u,v.children)}else this.activateChildRoutes(l,u,g);else if(p.component){const v=g.getOrCreateContext(p.outlet);if(this.routeReuseStrategy.shouldAttach(p.snapshot)){const y=this.routeReuseStrategy.retrieve(p.snapshot);this.routeReuseStrategy.store(p.snapshot,null),v.children.onOutletReAttached(y.contexts),v.attachRef=y.componentRef,v.route=y.route.value,v.outlet&&v.outlet.attach(y.componentRef,y.route.value),Tm(y.route.value),this.activateChildRoutes(l,null,v.children)}else{const y=function WB(f){for(let l=f.parent;l;l=l.parent){const u=l.routeConfig;if(u&&u._loadedConfig)return u._loadedConfig;if(u&&u.component)return null}return null}(p.snapshot),b=y?y.module.componentFactoryResolver:null;v.attachRef=null,v.route=p,v.resolver=b,v.outlet&&v.outlet.activateWith(p,b),this.activateChildRoutes(l,null,v.children)}}else this.activateChildRoutes(l,null,g)}}class Mm{constructor(l,u){this.routes=l,this.module=u}}function xs(f){return"function"==typeof f}function lo(f){return f instanceof oo}const rc=Symbol("INITIAL_VALUE");function sc(){return so(f=>function z2(...f){const l=Ja(f),u=_v(f),{args:g,keys:p}=Fb(f);if(0===g.length)return In([],l);const m=new cn(function Y2(f,l,u=Hs){return g=>{HD(l,()=>{const{length:p}=f,m=new Array(p);let v=p,y=p;for(let b=0;b{const O=In(f[b],l);let L=!1;O.subscribe(Dn(g,N=>{m[b]=N,L||(L=!0,y--),y||g.next(u(m.slice()))},()=>{--v||g.complete()}))},g)},g)}}(g,l,p?v=>Nb(p,v):Hs));return u?m.pipe(Pb(u)):m}(f.map(l=>l.pipe(Qc(1),function q2(...f){const l=Ja(f);return xn((u,g)=>{(l?ym(f,u,l):ym(f,u)).subscribe(g)})}(rc)))).pipe(YD((l,u)=>{let g=!1;return u.reduce((p,m,v)=>p!==rc?p:(m===rc&&(g=!0),g||!1!==m&&v!==u.length-1&&!lo(m)?p:m),l)},rc),ma(l=>l!==rc),Ut(l=>lo(l)?l:!0===l),Qc(1)))}class ZB{constructor(){this.outlet=null,this.route=null,this.resolver=null,this.children=new oc,this.attachRef=null}}class oc{constructor(){this.contexts=new Map}onChildOutletCreated(l,u){const g=this.getOrCreateContext(l);g.outlet=u,this.contexts.set(l,g)}onChildOutletDestroyed(l){const u=this.getContext(l);u&&(u.outlet=null,u.attachRef=null)}onOutletDeactivated(){const l=this.contexts;return this.contexts=new Map,l}onOutletReAttached(l){this.contexts=l}getOrCreateContext(l){let u=this.getContext(l);return u||(u=new ZB,this.contexts.set(l,u)),u}getContext(l){return this.contexts.get(l)||null}}let Lm=(()=>{class f{constructor(u,g,p,m,v){this.parentContexts=u,this.location=g,this.resolver=p,this.changeDetector=v,this.activated=null,this._activatedRoute=null,this.activateEvents=new nn,this.deactivateEvents=new nn,this.attachEvents=new nn,this.detachEvents=new nn,this.name=m||ft,u.onChildOutletCreated(this.name,this)}ngOnDestroy(){this.parentContexts.onChildOutletDestroyed(this.name)}ngOnInit(){if(!this.activated){const u=this.parentContexts.getContext(this.name);u&&u.route&&(u.attachRef?this.attach(u.attachRef,u.route):this.activateWith(u.route,u.resolver||null))}}get isActivated(){return!!this.activated}get component(){if(!this.activated)throw new Error("Outlet is not activated");return this.activated.instance}get activatedRoute(){if(!this.activated)throw new Error("Outlet is not activated");return this._activatedRoute}get activatedRouteData(){return this._activatedRoute?this._activatedRoute.snapshot.data:{}}detach(){if(!this.activated)throw new Error("Outlet is not activated");this.location.detach();const u=this.activated;return this.activated=null,this._activatedRoute=null,this.detachEvents.emit(u.instance),u}attach(u,g){this.activated=u,this._activatedRoute=g,this.location.insert(u.hostView),this.attachEvents.emit(u.instance)}deactivate(){if(this.activated){const u=this.component;this.activated.destroy(),this.activated=null,this._activatedRoute=null,this.deactivateEvents.emit(u)}}activateWith(u,g){if(this.isActivated)throw new Error("Cannot activate an already activated outlet");this._activatedRoute=u;const v=(g=g||this.resolver).resolveComponentFactory(u._futureSnapshot.routeConfig.component),y=this.parentContexts.getOrCreateContext(this.name).children,b=new KB(u,y,this.location.injector);this.activated=this.location.createComponent(v,this.location.length,b),this.changeDetector.markForCheck(),this.activateEvents.emit(this.activated.instance)}}return f.\u0275fac=function(u){return new(u||f)(ye(oc),ye(Zi),ye(Nl),function cl(f){return function aA(f,l){if("class"===l)return f.classes;if("style"===l)return f.styles;const u=f.attrs;if(u){const g=u.length;let p=0;for(;p{class f{}return f.\u0275fac=function(u){return new(u||f)},f.\u0275cmp=ar({type:f,selectors:[["ng-component"]],decls:1,vars:0,template:function(u,g){1&u&&Jn(0,"router-outlet")},directives:[Lm],encapsulation:2}),f})();function SS(f,l=""){for(let u=0;uMi(g)===l);return u.push(...f.filter(g=>Mi(g)!==l)),u}const TS={matched:!1,consumedSegments:[],remainingSegments:[],parameters:{},positionalParamSegments:{}};function kh(f,l,u){var g;if(""===l.path)return"full"===l.pathMatch&&(f.hasChildren()||u.length>0)?Object.assign({},TS):{matched:!0,consumedSegments:[],remainingSegments:u,parameters:{},positionalParamSegments:{}};const m=(l.matcher||dB)(u,f,l);if(!m)return Object.assign({},TS);const v={};Mn(m.posParams,(b,O)=>{v[O]=b.path});const y=m.consumed.length>0?Object.assign(Object.assign({},v),m.consumed[m.consumed.length-1].parameters):v;return{matched:!0,consumedSegments:m.consumed,remainingSegments:u.slice(m.consumed.length),parameters:y,positionalParamSegments:null!==(g=m.posParams)&&void 0!==g?g:{}}}function Bh(f,l,u,g,p="corrected"){if(u.length>0&&function nV(f,l,u){return u.some(g=>Vh(f,l,g)&&Mi(g)!==ft)}(f,u,g)){const v=new Ct(l,function tV(f,l,u,g){const p={};p[ft]=g,g._sourceSegment=f,g._segmentIndexShift=l.length;for(const m of u)if(""===m.path&&Mi(m)!==ft){const v=new Ct([],{});v._sourceSegment=f,v._segmentIndexShift=l.length,p[Mi(m)]=v}return p}(f,l,g,new Ct(u,f.children)));return v._sourceSegment=f,v._segmentIndexShift=l.length,{segmentGroup:v,slicedSegments:[]}}if(0===u.length&&function iV(f,l,u){return u.some(g=>Vh(f,l,g))}(f,u,g)){const v=new Ct(f.segments,function eV(f,l,u,g,p,m){const v={};for(const y of g)if(Vh(f,u,y)&&!p[Mi(y)]){const b=new Ct([],{});b._sourceSegment=f,b._segmentIndexShift="legacy"===m?f.segments.length:l.length,v[Mi(y)]=b}return Object.assign(Object.assign({},p),v)}(f,l,u,g,f.children,p));return v._sourceSegment=f,v._segmentIndexShift=l.length,{segmentGroup:v,slicedSegments:u}}const m=new Ct(f.segments,f.children);return m._sourceSegment=f,m._segmentIndexShift=l.length,{segmentGroup:m,slicedSegments:u}}function Vh(f,l,u){return(!(f.hasChildren()||l.length>0)||"full"!==u.pathMatch)&&""===u.path}function xS(f,l,u,g){return!!(Mi(f)===g||g!==ft&&Vh(l,u,f))&&("**"===f.path||kh(l,f,u).matched)}function AS(f,l,u){return 0===l.length&&!f.children[u]}class Uh{constructor(l){this.segmentGroup=l||null}}class RS{constructor(l){this.urlTree=l}}function ac(f){return Th(new Uh(f))}function OS(f){return Th(new RS(f))}class aV{constructor(l,u,g,p,m){this.configLoader=u,this.urlSerializer=g,this.urlTree=p,this.config=m,this.allowRedirects=!0,this.ngModule=l.get(Vr)}apply(){const l=Bh(this.urlTree.root,[],[],this.config).segmentGroup,u=new Ct(l.segments,l.children);return this.expandSegmentGroup(this.ngModule,this.config,u,ft).pipe(Ut(m=>this.createUrlTree(Pm(m),this.urlTree.queryParams,this.urlTree.fragment))).pipe(Ts(m=>{if(m instanceof RS)return this.allowRedirects=!1,this.match(m.urlTree);throw m instanceof Uh?this.noMatchError(m):m}))}match(l){return this.expandSegmentGroup(this.ngModule,this.config,l.root,ft).pipe(Ut(p=>this.createUrlTree(Pm(p),l.queryParams,l.fragment))).pipe(Ts(p=>{throw p instanceof Uh?this.noMatchError(p):p}))}noMatchError(l){return new Error(`Cannot match any routes. URL Segment: '${l.segmentGroup}'`)}createUrlTree(l,u,g){const p=l.segments.length>0?new Ct([],{[ft]:l}):l;return new oo(p,u,g)}expandSegmentGroup(l,u,g,p){return 0===g.segments.length&&g.hasChildren()?this.expandChildren(l,u,g).pipe(Ut(m=>new Ct([],m))):this.expandSegment(l,g,u,g.segments,p,!0)}expandChildren(l,u,g){const p=[];for(const m of Object.keys(g.children))"primary"===m?p.unshift(m):p.push(m);return In(p).pipe(Ql(m=>{const v=g.children[m],y=IS(u,m);return this.expandSegmentGroup(l,y,v,m).pipe(Ut(b=>({segment:b,outlet:m})))}),YD((m,v)=>(m[v.outlet]=v.segment,m),{}),function Q2(f,l){const u=arguments.length>=2;return g=>g.pipe(f?ma((p,m)=>f(p,m,g)):Hs,Cm(1),u?XD(l):$D(()=>new xh))}())}expandSegment(l,u,g,p,m,v){return In(g).pipe(Ql(y=>this.expandSegmentAgainstRoute(l,u,g,y,p,m,v).pipe(Ts(O=>{if(O instanceof Uh)return at(null);throw O}))),_a(y=>!!y),Ts((y,b)=>{if(y instanceof xh||"EmptyError"===y.name)return AS(u,p,m)?at(new Ct([],{})):ac(u);throw y}))}expandSegmentAgainstRoute(l,u,g,p,m,v,y){return xS(p,u,m,v)?void 0===p.redirectTo?this.matchSegmentAgainstRoute(l,u,p,m,v):y&&this.allowRedirects?this.expandSegmentAgainstRouteUsingRedirect(l,u,g,p,m,v):ac(u):ac(u)}expandSegmentAgainstRouteUsingRedirect(l,u,g,p,m,v){return"**"===p.path?this.expandWildCardWithParamsAgainstRouteUsingRedirect(l,g,p,v):this.expandRegularSegmentAgainstRouteUsingRedirect(l,u,g,p,m,v)}expandWildCardWithParamsAgainstRouteUsingRedirect(l,u,g,p){const m=this.applyRedirectCommands([],g.redirectTo,{});return g.redirectTo.startsWith("/")?OS(m):this.lineralizeSegments(g,m).pipe(Sn(v=>{const y=new Ct(v,{});return this.expandSegment(l,y,u,v,p,!1)}))}expandRegularSegmentAgainstRouteUsingRedirect(l,u,g,p,m,v){const{matched:y,consumedSegments:b,remainingSegments:O,positionalParamSegments:L}=kh(u,p,m);if(!y)return ac(u);const N=this.applyRedirectCommands(b,p.redirectTo,L);return p.redirectTo.startsWith("/")?OS(N):this.lineralizeSegments(p,N).pipe(Sn(B=>this.expandSegment(l,u,g,B.concat(O),v,!1)))}matchSegmentAgainstRoute(l,u,g,p,m){if("**"===g.path)return g.loadChildren?(g._loadedConfig?at(g._loadedConfig):this.configLoader.load(l.injector,g)).pipe(Ut(N=>(g._loadedConfig=N,new Ct(p,{})))):at(new Ct(p,{}));const{matched:v,consumedSegments:y,remainingSegments:b}=kh(u,g,p);return v?this.getChildConfig(l,g,p).pipe(Sn(L=>{const N=L.module,B=L.routes,{segmentGroup:U,slicedSegments:W}=Bh(u,y,b,B),Y=new Ct(U.segments,U.children);if(0===W.length&&Y.hasChildren())return this.expandChildren(N,B,Y).pipe(Ut(Q=>new Ct(y,Q)));if(0===B.length&&0===W.length)return at(new Ct(y,{}));const $=Mi(g)===m;return this.expandSegment(N,Y,B,W,$?ft:m,!0).pipe(Ut(X=>new Ct(y.concat(X.segments),X.children)))})):ac(u)}getChildConfig(l,u,g){return u.children?at(new Mm(u.children,l)):u.loadChildren?void 0!==u._loadedConfig?at(u._loadedConfig):this.runCanLoadGuards(l.injector,u,g).pipe(Sn(p=>p?this.configLoader.load(l.injector,u).pipe(Ut(m=>(u._loadedConfig=m,m))):function sV(f){return Th(Em(`Cannot load children because the guard of the route "path: '${f.path}'" returned false`))}(u))):at(new Mm([],l))}runCanLoadGuards(l,u,g){const p=u.canLoad;return p&&0!==p.length?at(p.map(v=>{const y=l.get(v);let b;if(function YB(f){return f&&xs(f.canLoad)}(y))b=y.canLoad(u,g);else{if(!xs(y))throw new Error("Invalid CanLoad guard");b=y(u,g)}return Er(b)})).pipe(sc(),di(v=>{if(!lo(v))return;const y=Em(`Redirecting to "${this.urlSerializer.serialize(v)}"`);throw y.url=v,y}),Ut(v=>!0===v)):at(!0)}lineralizeSegments(l,u){let g=[],p=u.root;for(;;){if(g=g.concat(p.segments),0===p.numberOfChildren)return at(g);if(p.numberOfChildren>1||!p.children[ft])return Th(new Error(`Only absolute redirects can have named outlets. redirectTo: '${l.redirectTo}'`));p=p.children[ft]}}applyRedirectCommands(l,u,g){return this.applyRedirectCreatreUrlTree(u,this.urlSerializer.parse(u),l,g)}applyRedirectCreatreUrlTree(l,u,g,p){const m=this.createSegmentGroup(l,u.root,g,p);return new oo(m,this.createQueryParams(u.queryParams,this.urlTree.queryParams),u.fragment)}createQueryParams(l,u){const g={};return Mn(l,(p,m)=>{if("string"==typeof p&&p.startsWith(":")){const y=p.substring(1);g[m]=u[y]}else g[m]=p}),g}createSegmentGroup(l,u,g,p){const m=this.createSegments(l,u.segments,g,p);let v={};return Mn(u.children,(y,b)=>{v[b]=this.createSegmentGroup(l,y,g,p)}),new Ct(m,v)}createSegments(l,u,g,p){return u.map(m=>m.path.startsWith(":")?this.findPosParam(l,m,p):this.findOrReturn(m,g))}findPosParam(l,u,g){const p=g[u.path.substring(1)];if(!p)throw new Error(`Cannot redirect to '${l}'. Cannot find '${u.path}'.`);return p}findOrReturn(l,u){let g=0;for(const p of u){if(p.path===l.path)return u.splice(g),p;g++}return l}}function Pm(f){const l={};for(const g of Object.keys(f.children)){const m=Pm(f.children[g]);(m.segments.length>0||m.hasChildren())&&(l[g]=m)}return function lV(f){if(1===f.numberOfChildren&&f.children[ft]){const l=f.children[ft];return new Ct(f.segments.concat(l.segments),l.children)}return f}(new Ct(f.segments,l))}class MS{constructor(l){this.path=l,this.route=this.path[this.path.length-1]}}class jh{constructor(l,u){this.component=l,this.route=u}}function uV(f,l,u){const g=f._root;return lc(g,l?l._root:null,u,[g.value])}function Gh(f,l,u){const g=function dV(f){if(!f)return null;for(let l=f.parent;l;l=l.parent){const u=l.routeConfig;if(u&&u._loadedConfig)return u._loadedConfig}return null}(l);return(g?g.module.injector:u).get(f)}function lc(f,l,u,g,p={canDeactivateChecks:[],canActivateChecks:[]}){const m=ya(l);return f.children.forEach(v=>{(function fV(f,l,u,g,p={canDeactivateChecks:[],canActivateChecks:[]}){const m=f.value,v=l?l.value:null,y=u?u.getContext(f.value.outlet):null;if(v&&m.routeConfig===v.routeConfig){const b=function gV(f,l,u){if("function"==typeof u)return u(f,l);switch(u){case"pathParamsChange":return!ao(f.url,l.url);case"pathParamsOrQueryParamsChange":return!ao(f.url,l.url)||!wr(f.queryParams,l.queryParams);case"always":return!0;case"paramsOrQueryParamsChange":return!xm(f,l)||!wr(f.queryParams,l.queryParams);default:return!xm(f,l)}}(v,m,m.routeConfig.runGuardsAndResolvers);b?p.canActivateChecks.push(new MS(g)):(m.data=v.data,m._resolvedData=v._resolvedData),lc(f,l,m.component?y?y.children:null:u,g,p),b&&y&&y.outlet&&y.outlet.isActivated&&p.canDeactivateChecks.push(new jh(y.outlet.component,v))}else v&&cc(l,y,p),p.canActivateChecks.push(new MS(g)),lc(f,null,m.component?y?y.children:null:u,g,p)})(v,m[v.value.outlet],u,g.concat([v.value]),p),delete m[v.value.outlet]}),Mn(m,(v,y)=>cc(v,u.getContext(y),p)),p}function cc(f,l,u){const g=ya(f),p=f.value;Mn(g,(m,v)=>{cc(m,p.component?l?l.children.getContext(v):null:l,u)}),u.canDeactivateChecks.push(new jh(p.component&&l&&l.outlet&&l.outlet.isActivated?l.outlet.component:null,p))}class bV{}function LS(f){return new cn(l=>l.error(f))}class SV{constructor(l,u,g,p,m,v){this.rootComponentType=l,this.config=u,this.urlTree=g,this.url=p,this.paramsInheritanceStrategy=m,this.relativeLinkResolution=v}recognize(){const l=Bh(this.urlTree.root,[],[],this.config.filter(v=>void 0===v.redirectTo),this.relativeLinkResolution).segmentGroup,u=this.processSegmentGroup(this.config,l,ft);if(null===u)return null;const g=new Fh([],Object.freeze({}),Object.freeze(Object.assign({},this.urlTree.queryParams)),this.urlTree.fragment,{},ft,this.rootComponentType,null,this.urlTree.root,-1,{}),p=new Wr(g,u),m=new _S(this.url,p);return this.inheritParamsAndData(m._root),m}inheritParamsAndData(l){const u=l.value,g=mS(u,this.paramsInheritanceStrategy);u.params=Object.freeze(g.params),u.data=Object.freeze(g.data),l.children.forEach(p=>this.inheritParamsAndData(p))}processSegmentGroup(l,u,g){return 0===u.segments.length&&u.hasChildren()?this.processChildren(l,u):this.processSegment(l,u,u.segments,g)}processChildren(l,u){const g=[];for(const m of Object.keys(u.children)){const v=u.children[m],y=IS(l,m),b=this.processSegmentGroup(y,v,m);if(null===b)return null;g.push(...b)}const p=FS(g);return function IV(f){f.sort((l,u)=>l.value.outlet===ft?-1:u.value.outlet===ft?1:l.value.outlet.localeCompare(u.value.outlet))}(p),p}processSegment(l,u,g,p){for(const m of l){const v=this.processSegmentAgainstRoute(m,u,g,p);if(null!==v)return v}return AS(u,g,p)?[]:null}processSegmentAgainstRoute(l,u,g,p){if(l.redirectTo||!xS(l,u,g,p))return null;let m,v=[],y=[];if("**"===l.path){const U=g.length>0?nS(g).parameters:{};m=new Fh(g,U,Object.freeze(Object.assign({},this.urlTree.queryParams)),this.urlTree.fragment,kS(l),Mi(l),l.component,l,PS(u),NS(u)+g.length,BS(l))}else{const U=kh(u,l,g);if(!U.matched)return null;v=U.consumedSegments,y=U.remainingSegments,m=new Fh(v,U.parameters,Object.freeze(Object.assign({},this.urlTree.queryParams)),this.urlTree.fragment,kS(l),Mi(l),l.component,l,PS(u),NS(u)+v.length,BS(l))}const b=function TV(f){return f.children?f.children:f.loadChildren?f._loadedConfig.routes:[]}(l),{segmentGroup:O,slicedSegments:L}=Bh(u,v,y,b.filter(U=>void 0===U.redirectTo),this.relativeLinkResolution);if(0===L.length&&O.hasChildren()){const U=this.processChildren(b,O);return null===U?null:[new Wr(m,U)]}if(0===b.length&&0===L.length)return[new Wr(m,[])];const N=Mi(l)===p,B=this.processSegment(b,O,L,N?ft:p);return null===B?null:[new Wr(m,B)]}}function xV(f){const l=f.value.routeConfig;return l&&""===l.path&&void 0===l.redirectTo}function FS(f){const l=[],u=new Set;for(const g of f){if(!xV(g)){l.push(g);continue}const p=l.find(m=>g.value.routeConfig===m.value.routeConfig);void 0!==p?(p.children.push(...g.children),u.add(p)):l.push(g)}for(const g of u){const p=FS(g.children);l.push(new Wr(g.value,p))}return l.filter(g=>!u.has(g))}function PS(f){let l=f;for(;l._sourceSegment;)l=l._sourceSegment;return l}function NS(f){let l=f,u=l._segmentIndexShift?l._segmentIndexShift:0;for(;l._sourceSegment;)l=l._sourceSegment,u+=l._segmentIndexShift?l._segmentIndexShift:0;return u-1}function kS(f){return f.data||{}}function BS(f){return f.resolve||{}}function VS(f){return[...Object.keys(f),...Object.getOwnPropertySymbols(f)]}function Nm(f){return so(l=>{const u=f(l);return u?In(u).pipe(Ut(()=>l)):at(l)})}class NV extends class PV{shouldDetach(l){return!1}store(l,u){}shouldAttach(l){return!1}retrieve(l){return null}shouldReuseRoute(l,u){return l.routeConfig===u.routeConfig}}{}const km=new dt("ROUTES");class US{constructor(l,u,g,p){this.injector=l,this.compiler=u,this.onLoadStartListener=g,this.onLoadEndListener=p}load(l,u){if(u._loader$)return u._loader$;this.onLoadStartListener&&this.onLoadStartListener(u);const p=this.loadModuleFactory(u.loadChildren).pipe(Ut(m=>{this.onLoadEndListener&&this.onLoadEndListener(u);const v=m.create(l);return new Mm(tS(v.injector.get(km,void 0,Xe.Self|Xe.Optional)).map(Fm),v)}),Ts(m=>{throw u._loader$=void 0,m}));return u._loader$=new X2(p,()=>new Ar).pipe(zD()),u._loader$}loadModuleFactory(l){return Er(l()).pipe(Sn(u=>u instanceof Kw?at(u):In(this.compiler.compileModuleAsync(u))))}}class BV{shouldProcessUrl(l){return!0}extract(l){return l}merge(l,u){return l}}function VV(f){throw f}function UV(f,l,u){return l.parse("/")}function jS(f,l){return at(null)}const jV={paths:"exact",fragment:"ignored",matrixParams:"ignored",queryParams:"exact"},GV={paths:"subset",fragment:"ignored",matrixParams:"ignored",queryParams:"subset"};let fi=(()=>{class f{constructor(u,g,p,m,v,y,b){this.rootComponentType=u,this.urlSerializer=g,this.rootContexts=p,this.location=m,this.config=b,this.lastSuccessfulNavigation=null,this.currentNavigation=null,this.disposed=!1,this.navigationId=0,this.currentPageId=0,this.isNgZoneEnabled=!1,this.events=new Ar,this.errorHandler=VV,this.malformedUriErrorHandler=UV,this.navigated=!1,this.lastSuccessfulId=-1,this.hooks={beforePreactivation:jS,afterPreactivation:jS},this.urlHandlingStrategy=new BV,this.routeReuseStrategy=new NV,this.onSameUrlNavigation="ignore",this.paramsInheritanceStrategy="emptyOnly",this.urlUpdateStrategy="deferred",this.relativeLinkResolution="corrected",this.canceledNavigationResolution="replace",this.ngModule=v.get(Vr),this.console=v.get(jF);const N=v.get(On);this.isNgZoneEnabled=N instanceof On&&On.isInAngularZone(),this.resetConfig(b),this.currentUrlTree=function gB(){return new oo(new Ct([],{}),{},null)}(),this.rawUrlTree=this.currentUrlTree,this.browserUrlTree=this.currentUrlTree,this.configLoader=new US(v,y,B=>this.triggerEvent(new ZD(B)),B=>this.triggerEvent(new KD(B))),this.routerState=pS(this.currentUrlTree,this.rootComponentType),this.transitions=new Ji({id:0,targetPageId:0,currentUrlTree:this.currentUrlTree,currentRawUrl:this.currentUrlTree,extractedUrl:this.urlHandlingStrategy.extract(this.currentUrlTree),urlAfterRedirects:this.urlHandlingStrategy.extract(this.currentUrlTree),rawUrl:this.currentUrlTree,extras:{},resolve:null,reject:null,promise:Promise.resolve(!0),source:"imperative",restoredState:null,currentSnapshot:this.routerState.snapshot,targetSnapshot:null,currentRouterState:this.routerState,targetRouterState:null,guards:{canActivateChecks:[],canDeactivateChecks:[]},guardsResult:null}),this.navigations=this.setupNavigations(this.transitions),this.processNavigations()}get browserPageId(){var u;return null===(u=this.location.getState())||void 0===u?void 0:u.\u0275routerPageId}setupNavigations(u){const g=this.events;return u.pipe(ma(p=>0!==p.id),Ut(p=>Object.assign(Object.assign({},p),{extractedUrl:this.urlHandlingStrategy.extract(p.rawUrl)})),so(p=>{let m=!1,v=!1;return at(p).pipe(di(y=>{this.currentNavigation={id:y.id,initialUrl:y.currentRawUrl,extractedUrl:y.extractedUrl,trigger:y.source,extras:y.extras,previousNavigation:this.lastSuccessfulNavigation?Object.assign(Object.assign({},this.lastSuccessfulNavigation),{previousNavigation:null}):null}}),so(y=>{const b=this.browserUrlTree.toString(),O=!this.navigated||y.extractedUrl.toString()!==b||b!==this.currentUrlTree.toString();if(("reload"===this.onSameUrlNavigation||O)&&this.urlHandlingStrategy.shouldProcessUrl(y.rawUrl))return GS(y.source)&&(this.browserUrlTree=y.extractedUrl),at(y).pipe(so(N=>{const B=this.transitions.getValue();return g.next(new wm(N.id,this.serializeUrl(N.extractedUrl),N.source,N.restoredState)),B!==this.transitions.getValue()?Or:Promise.resolve(N)}),function cV(f,l,u,g){return so(p=>function oV(f,l,u,g,p){return new aV(f,l,u,g,p).apply()}(f,l,u,p.extractedUrl,g).pipe(Ut(m=>Object.assign(Object.assign({},p),{urlAfterRedirects:m}))))}(this.ngModule.injector,this.configLoader,this.urlSerializer,this.config),di(N=>{this.currentNavigation=Object.assign(Object.assign({},this.currentNavigation),{finalUrl:N.urlAfterRedirects})}),function AV(f,l,u,g,p){return Sn(m=>function DV(f,l,u,g,p="emptyOnly",m="legacy"){try{const v=new SV(f,l,u,g,p,m).recognize();return null===v?LS(new bV):at(v)}catch(v){return LS(v)}}(f,l,m.urlAfterRedirects,u(m.urlAfterRedirects),g,p).pipe(Ut(v=>Object.assign(Object.assign({},m),{targetSnapshot:v}))))}(this.rootComponentType,this.config,N=>this.serializeUrl(N),this.paramsInheritanceStrategy,this.relativeLinkResolution),di(N=>{if("eager"===this.urlUpdateStrategy){if(!N.extras.skipLocationChange){const U=this.urlHandlingStrategy.merge(N.urlAfterRedirects,N.rawUrl);this.setBrowserUrl(U,N)}this.browserUrlTree=N.urlAfterRedirects}const B=new tB(N.id,this.serializeUrl(N.extractedUrl),this.serializeUrl(N.urlAfterRedirects),N.targetSnapshot);g.next(B)}));if(O&&this.rawUrlTree&&this.urlHandlingStrategy.shouldProcessUrl(this.rawUrlTree)){const{id:B,extractedUrl:U,source:W,restoredState:Y,extras:$}=y,q=new wm(B,this.serializeUrl(U),W,Y);g.next(q);const X=pS(U,this.rootComponentType).snapshot;return at(Object.assign(Object.assign({},y),{targetSnapshot:X,urlAfterRedirects:U,extras:Object.assign(Object.assign({},$),{skipLocationChange:!1,replaceUrl:!1})}))}return this.rawUrlTree=y.rawUrl,y.resolve(null),Or}),Nm(y=>{const{targetSnapshot:b,id:O,extractedUrl:L,rawUrl:N,extras:{skipLocationChange:B,replaceUrl:U}}=y;return this.hooks.beforePreactivation(b,{navigationId:O,appliedUrlTree:L,rawUrlTree:N,skipLocationChange:!!B,replaceUrl:!!U})}),di(y=>{const b=new nB(y.id,this.serializeUrl(y.extractedUrl),this.serializeUrl(y.urlAfterRedirects),y.targetSnapshot);this.triggerEvent(b)}),Ut(y=>Object.assign(Object.assign({},y),{guards:uV(y.targetSnapshot,y.currentSnapshot,this.rootContexts)})),function pV(f,l){return Sn(u=>{const{targetSnapshot:g,currentSnapshot:p,guards:{canActivateChecks:m,canDeactivateChecks:v}}=u;return 0===v.length&&0===m.length?at(Object.assign(Object.assign({},u),{guardsResult:!0})):function mV(f,l,u,g){return In(f).pipe(Sn(p=>function EV(f,l,u,g,p){const m=l&&l.routeConfig?l.routeConfig.canDeactivate:null;return m&&0!==m.length?at(m.map(y=>{const b=Gh(y,l,p);let O;if(function qB(f){return f&&xs(f.canDeactivate)}(b))O=Er(b.canDeactivate(f,l,u,g));else{if(!xs(b))throw new Error("Invalid CanDeactivate guard");O=Er(b(f,l,u,g))}return O.pipe(_a())})).pipe(sc()):at(!0)}(p.component,p.route,u,l,g)),_a(p=>!0!==p,!0))}(v,g,p,f).pipe(Sn(y=>y&&function zB(f){return"boolean"==typeof f}(y)?function _V(f,l,u,g){return In(l).pipe(Ql(p=>ym(function yV(f,l){return null!==f&&l&&l(new oB(f)),at(!0)}(p.route.parent,g),function vV(f,l){return null!==f&&l&&l(new lB(f)),at(!0)}(p.route,g),function wV(f,l,u){const g=l[l.length-1],m=l.slice(0,l.length-1).reverse().map(v=>function hV(f){const l=f.routeConfig?f.routeConfig.canActivateChild:null;return l&&0!==l.length?{node:f,guards:l}:null}(v)).filter(v=>null!==v).map(v=>WD(()=>at(v.guards.map(b=>{const O=Gh(b,v.node,u);let L;if(function XB(f){return f&&xs(f.canActivateChild)}(O))L=Er(O.canActivateChild(g,f));else{if(!xs(O))throw new Error("Invalid CanActivateChild guard");L=Er(O(g,f))}return L.pipe(_a())})).pipe(sc())));return at(m).pipe(sc())}(f,p.path,u),function CV(f,l,u){const g=l.routeConfig?l.routeConfig.canActivate:null;if(!g||0===g.length)return at(!0);const p=g.map(m=>WD(()=>{const v=Gh(m,l,u);let y;if(function $B(f){return f&&xs(f.canActivate)}(v))y=Er(v.canActivate(l,f));else{if(!xs(v))throw new Error("Invalid CanActivate guard");y=Er(v(l,f))}return y.pipe(_a())}));return at(p).pipe(sc())}(f,p.route,u))),_a(p=>!0!==p,!0))}(g,m,f,l):at(y)),Ut(y=>Object.assign(Object.assign({},u),{guardsResult:y})))})}(this.ngModule.injector,y=>this.triggerEvent(y)),di(y=>{if(lo(y.guardsResult)){const O=Em(`Redirecting to "${this.serializeUrl(y.guardsResult)}"`);throw O.url=y.guardsResult,O}const b=new iB(y.id,this.serializeUrl(y.extractedUrl),this.serializeUrl(y.urlAfterRedirects),y.targetSnapshot,!!y.guardsResult);this.triggerEvent(b)}),ma(y=>!!y.guardsResult||(this.restoreHistory(y),this.cancelNavigationTransition(y,""),!1)),Nm(y=>{if(y.guards.canActivateChecks.length)return at(y).pipe(di(b=>{const O=new rB(b.id,this.serializeUrl(b.extractedUrl),this.serializeUrl(b.urlAfterRedirects),b.targetSnapshot);this.triggerEvent(O)}),so(b=>{let O=!1;return at(b).pipe(function RV(f,l){return Sn(u=>{const{targetSnapshot:g,guards:{canActivateChecks:p}}=u;if(!p.length)return at(u);let m=0;return In(p).pipe(Ql(v=>function OV(f,l,u,g){return function MV(f,l,u,g){const p=VS(f);if(0===p.length)return at({});const m={};return In(p).pipe(Sn(v=>function LV(f,l,u,g){const p=Gh(f,l,g);return Er(p.resolve?p.resolve(l,u):p(l,u))}(f[v],l,u,g).pipe(di(y=>{m[v]=y}))),Cm(1),Sn(()=>VS(m).length===p.length?at(m):Or))}(f._resolve,f,l,g).pipe(Ut(m=>(f._resolvedData=m,f.data=Object.assign(Object.assign({},f.data),mS(f,u).resolve),null)))}(v.route,g,f,l)),di(()=>m++),Cm(1),Sn(v=>m===p.length?at(u):Or))})}(this.paramsInheritanceStrategy,this.ngModule.injector),di({next:()=>O=!0,complete:()=>{O||(this.restoreHistory(b),this.cancelNavigationTransition(b,"At least one route resolver didn't emit any value."))}}))}),di(b=>{const O=new sB(b.id,this.serializeUrl(b.extractedUrl),this.serializeUrl(b.urlAfterRedirects),b.targetSnapshot);this.triggerEvent(O)}))}),Nm(y=>{const{targetSnapshot:b,id:O,extractedUrl:L,rawUrl:N,extras:{skipLocationChange:B,replaceUrl:U}}=y;return this.hooks.afterPreactivation(b,{navigationId:O,appliedUrlTree:L,rawUrlTree:N,skipLocationChange:!!B,replaceUrl:!!U})}),Ut(y=>{const b=function MB(f,l,u){const g=nc(f,l._root,u?u._root:void 0);return new gS(g,l)}(this.routeReuseStrategy,y.targetSnapshot,y.currentRouterState);return Object.assign(Object.assign({},y),{targetRouterState:b})}),di(y=>{this.currentUrlTree=y.urlAfterRedirects,this.rawUrlTree=this.urlHandlingStrategy.merge(y.urlAfterRedirects,y.rawUrl),this.routerState=y.targetRouterState,"deferred"===this.urlUpdateStrategy&&(y.extras.skipLocationChange||this.setBrowserUrl(this.rawUrlTree,y),this.browserUrlTree=y.urlAfterRedirects)}),((f,l,u)=>Ut(g=>(new HB(l,g.targetRouterState,g.currentRouterState,u).activate(f),g)))(this.rootContexts,this.routeReuseStrategy,y=>this.triggerEvent(y)),di({next(){m=!0},complete(){m=!0}}),function J2(f){return xn((l,u)=>{try{l.subscribe(u)}finally{u.add(f)}})}(()=>{var y;m||v||this.cancelNavigationTransition(p,`Navigation ID ${p.id} is not equal to the current navigation id ${this.navigationId}`),(null===(y=this.currentNavigation)||void 0===y?void 0:y.id)===p.id&&(this.currentNavigation=null)}),Ts(y=>{if(v=!0,function hB(f){return f&&f[JD]}(y)){const b=lo(y.url);b||(this.navigated=!0,this.restoreHistory(p,!0));const O=new qD(p.id,this.serializeUrl(p.extractedUrl),y.message);g.next(O),b?setTimeout(()=>{const L=this.urlHandlingStrategy.merge(y.url,this.rawUrlTree),N={skipLocationChange:p.extras.skipLocationChange,replaceUrl:"eager"===this.urlUpdateStrategy||GS(p.source)};this.scheduleNavigation(L,"imperative",null,N,{resolve:p.resolve,reject:p.reject,promise:p.promise})},0):p.resolve(!1)}else{this.restoreHistory(p,!0);const b=new eB(p.id,this.serializeUrl(p.extractedUrl),y);g.next(b);try{p.resolve(this.errorHandler(y))}catch(O){p.reject(O)}}return Or}))}))}resetRootComponentType(u){this.rootComponentType=u,this.routerState.root.component=this.rootComponentType}setTransition(u){this.transitions.next(Object.assign(Object.assign({},this.transitions.value),u))}initialNavigation(){this.setUpLocationChangeListener(),0===this.navigationId&&this.navigateByUrl(this.location.path(!0),{replaceUrl:!0})}setUpLocationChangeListener(){this.locationSubscription||(this.locationSubscription=this.location.subscribe(u=>{const g="popstate"===u.type?"popstate":"hashchange";"popstate"===g&&setTimeout(()=>{var p;const m={replaceUrl:!0},v=(null===(p=u.state)||void 0===p?void 0:p.navigationId)?u.state:null;if(v){const b=Object.assign({},v);delete b.navigationId,delete b.\u0275routerPageId,0!==Object.keys(b).length&&(m.state=b)}const y=this.parseUrl(u.url);this.scheduleNavigation(y,g,v,m)},0)}))}get url(){return this.serializeUrl(this.currentUrlTree)}getCurrentNavigation(){return this.currentNavigation}triggerEvent(u){this.events.next(u)}resetConfig(u){SS(u),this.config=u.map(Fm),this.navigated=!1,this.lastSuccessfulId=-1}ngOnDestroy(){this.dispose()}dispose(){this.transitions.complete(),this.locationSubscription&&(this.locationSubscription.unsubscribe(),this.locationSubscription=void 0),this.disposed=!0}createUrlTree(u,g={}){const{relativeTo:p,queryParams:m,fragment:v,queryParamsHandling:y,preserveFragment:b}=g,O=p||this.routerState.root,L=b?this.currentUrlTree.fragment:v;let N=null;switch(y){case"merge":N=Object.assign(Object.assign({},this.currentUrlTree.queryParams),m);break;case"preserve":N=this.currentUrlTree.queryParams;break;default:N=m||null}return null!==N&&(N=this.removeEmptyProps(N)),function PB(f,l,u,g,p){if(0===u.length)return Am(l.root,l.root,l.root,g,p);const m=function NB(f){if("string"==typeof f[0]&&1===f.length&&"/"===f[0])return new CS(!0,0,f);let l=0,u=!1;const g=f.reduce((p,m,v)=>{if("object"==typeof m&&null!=m){if(m.outlets){const y={};return Mn(m.outlets,(b,O)=>{y[O]="string"==typeof b?b.split("/"):b}),[...p,{outlets:y}]}if(m.segmentPath)return[...p,m.segmentPath]}return"string"!=typeof m?[...p,m]:0===v?(m.split("/").forEach((y,b)=>{0==b&&"."===y||(0==b&&""===y?u=!0:".."===y?l++:""!=y&&p.push(y))}),p):[...p,m]},[]);return new CS(u,l,g)}(u);if(m.toRoot())return Am(l.root,l.root,new Ct([],{}),g,p);const v=function kB(f,l,u){if(f.isAbsolute)return new Rm(l.root,!0,0);if(-1===u.snapshot._lastPathIndex){const m=u.snapshot._urlSegment;return new Rm(m,m===l.root,0)}const g=Ph(f.commands[0])?0:1;return function BB(f,l,u){let g=f,p=l,m=u;for(;m>p;){if(m-=p,g=g.parent,!g)throw new Error("Invalid number of '../'");p=g.segments.length}return new Rm(g,!1,p-m)}(u.snapshot._urlSegment,u.snapshot._lastPathIndex+g,f.numberOfDoubleDots)}(m,l,f),y=v.processChildren?Nh(v.segmentGroup,v.index,m.commands):wS(v.segmentGroup,v.index,m.commands);return Am(l.root,v.segmentGroup,y,g,p)}(O,this.currentUrlTree,u,N,null!=L?L:null)}navigateByUrl(u,g={skipLocationChange:!1}){const p=lo(u)?u:this.parseUrl(u),m=this.urlHandlingStrategy.merge(p,this.rawUrlTree);return this.scheduleNavigation(m,"imperative",null,g)}navigate(u,g={skipLocationChange:!1}){return function HV(f){for(let l=0;l{const m=u[p];return null!=m&&(g[p]=m),g},{})}processNavigations(){this.navigations.subscribe(u=>{this.navigated=!0,this.lastSuccessfulId=u.id,this.currentPageId=u.targetPageId,this.events.next(new Jl(u.id,this.serializeUrl(u.extractedUrl),this.serializeUrl(this.currentUrlTree))),this.lastSuccessfulNavigation=this.currentNavigation,u.resolve(!0)},u=>{this.console.warn(`Unhandled Navigation Error: ${u}`)})}scheduleNavigation(u,g,p,m,v){var y,b;if(this.disposed)return Promise.resolve(!1);let O,L,N;v?(O=v.resolve,L=v.reject,N=v.promise):N=new Promise((W,Y)=>{O=W,L=Y});const B=++this.navigationId;let U;return"computed"===this.canceledNavigationResolution?(0===this.currentPageId&&(p=this.location.getState()),U=p&&p.\u0275routerPageId?p.\u0275routerPageId:m.replaceUrl||m.skipLocationChange?null!==(y=this.browserPageId)&&void 0!==y?y:0:(null!==(b=this.browserPageId)&&void 0!==b?b:0)+1):U=0,this.setTransition({id:B,targetPageId:U,source:g,restoredState:p,currentUrlTree:this.currentUrlTree,currentRawUrl:this.rawUrlTree,rawUrl:u,extras:m,resolve:O,reject:L,promise:N,currentSnapshot:this.routerState.snapshot,currentRouterState:this.routerState}),N.catch(W=>Promise.reject(W))}setBrowserUrl(u,g){const p=this.urlSerializer.serialize(u),m=Object.assign(Object.assign({},g.extras.state),this.generateNgRouterState(g.id,g.targetPageId));this.location.isCurrentPathEqualTo(p)||g.extras.replaceUrl?this.location.replaceState(p,"",m):this.location.go(p,"",m)}restoreHistory(u,g=!1){var p,m;if("computed"===this.canceledNavigationResolution){const v=this.currentPageId-u.targetPageId;"popstate"!==u.source&&"eager"!==this.urlUpdateStrategy&&this.currentUrlTree!==(null===(p=this.currentNavigation)||void 0===p?void 0:p.finalUrl)||0===v?this.currentUrlTree===(null===(m=this.currentNavigation)||void 0===m?void 0:m.finalUrl)&&0===v&&(this.resetState(u),this.browserUrlTree=u.currentUrlTree,this.resetUrlToCurrentUrlTree()):this.location.historyGo(v)}else"replace"===this.canceledNavigationResolution&&(g&&this.resetState(u),this.resetUrlToCurrentUrlTree())}resetState(u){this.routerState=u.currentRouterState,this.currentUrlTree=u.currentUrlTree,this.rawUrlTree=this.urlHandlingStrategy.merge(this.currentUrlTree,u.rawUrl)}resetUrlToCurrentUrlTree(){this.location.replaceState(this.urlSerializer.serialize(this.rawUrlTree),"",this.generateNgRouterState(this.lastSuccessfulId,this.currentPageId))}cancelNavigationTransition(u,g){const p=new qD(u.id,this.serializeUrl(u.extractedUrl),g);this.triggerEvent(p),u.resolve(!1)}generateNgRouterState(u,g){return"computed"===this.canceledNavigationResolution?{navigationId:u,\u0275routerPageId:g}:{navigationId:u}}}return f.\u0275fac=function(u){Lg()},f.\u0275prov=yt({token:f,factory:f.\u0275fac}),f})();function GS(f){return"imperative"!==f}let uc=(()=>{class f{constructor(u,g,p){this.router=u,this.route=g,this.locationStrategy=p,this.commands=null,this.href=null,this.onChanges=new Ar,this.subscription=u.events.subscribe(m=>{m instanceof Jl&&this.updateTargetUrlAndHref()})}set routerLink(u){this.commands=null!=u?Array.isArray(u)?u:[u]:null}ngOnChanges(u){this.updateTargetUrlAndHref(),this.onChanges.next(this)}ngOnDestroy(){this.subscription.unsubscribe()}onClick(u,g,p,m,v){if(0!==u||g||p||m||v||"string"==typeof this.target&&"_self"!=this.target||null===this.urlTree)return!0;const y={skipLocationChange:wa(this.skipLocationChange),replaceUrl:wa(this.replaceUrl),state:this.state};return this.router.navigateByUrl(this.urlTree,y),!1}updateTargetUrlAndHref(){this.href=null!==this.urlTree?this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.urlTree)):null}get urlTree(){return null===this.commands?null:this.router.createUrlTree(this.commands,{relativeTo:void 0!==this.relativeTo?this.relativeTo:this.route,queryParams:this.queryParams,fragment:this.fragment,queryParamsHandling:this.queryParamsHandling,preserveFragment:wa(this.preserveFragment)})}}return f.\u0275fac=function(u){return new(u||f)(ye(fi),ye(Ca),ye(ga))},f.\u0275dir=ze({type:f,selectors:[["a","routerLink",""],["area","routerLink",""]],hostVars:2,hostBindings:function(u,g){1&u&&kt("click",function(m){return g.onClick(m.button,m.ctrlKey,m.shiftKey,m.altKey,m.metaKey)}),2&u&&mr("target",g.target)("href",g.href,kf)},inputs:{target:"target",queryParams:"queryParams",fragment:"fragment",queryParamsHandling:"queryParamsHandling",preserveFragment:"preserveFragment",skipLocationChange:"skipLocationChange",replaceUrl:"replaceUrl",state:"state",relativeTo:"relativeTo",routerLink:"routerLink"},features:[Di]}),f})();function wa(f){return""===f||!!f}class HS{}class WS{preload(l,u){return at(null)}}let zS=(()=>{class f{constructor(u,g,p,m){this.router=u,this.injector=p,this.preloadingStrategy=m,this.loader=new US(p,g,b=>u.triggerEvent(new ZD(b)),b=>u.triggerEvent(new KD(b)))}setUpPreloading(){this.subscription=this.router.events.pipe(ma(u=>u instanceof Jl),Ql(()=>this.preload())).subscribe(()=>{})}preload(){const u=this.injector.get(Vr);return this.processRoutes(u,this.router.config)}ngOnDestroy(){this.subscription&&this.subscription.unsubscribe()}processRoutes(u,g){const p=[];for(const m of g)if(m.loadChildren&&!m.canLoad&&m._loadedConfig){const v=m._loadedConfig;p.push(this.processRoutes(v.module,v.routes))}else m.loadChildren&&!m.canLoad?p.push(this.preloadConfig(u,m)):m.children&&p.push(this.processRoutes(u,m.children));return In(p).pipe(Qa(),Ut(m=>{}))}preloadConfig(u,g){return this.preloadingStrategy.preload(g,()=>(g._loadedConfig?at(g._loadedConfig):this.loader.load(u.injector,g)).pipe(Sn(m=>(g._loadedConfig=m,this.processRoutes(m.module,m.routes)))))}}return f.\u0275fac=function(u){return new(u||f)(Ye(fi),Ye(FE),Ye(Qn),Ye(HS))},f.\u0275prov=yt({token:f,factory:f.\u0275fac}),f})(),Vm=(()=>{class f{constructor(u,g,p={}){this.router=u,this.viewportScroller=g,this.options=p,this.lastId=0,this.lastSource="imperative",this.restoredId=0,this.store={},p.scrollPositionRestoration=p.scrollPositionRestoration||"disabled",p.anchorScrolling=p.anchorScrolling||"disabled"}init(){"disabled"!==this.options.scrollPositionRestoration&&this.viewportScroller.setHistoryScrollRestoration("manual"),this.routerEventsSubscription=this.createScrollEvents(),this.scrollEventsSubscription=this.consumeScrollEvents()}createScrollEvents(){return this.router.events.subscribe(u=>{u instanceof wm?(this.store[this.lastId]=this.viewportScroller.getScrollPosition(),this.lastSource=u.navigationTrigger,this.restoredId=u.restoredState?u.restoredState.navigationId:0):u instanceof Jl&&(this.lastId=u.id,this.scheduleScrollEvent(u,this.router.parseUrl(u.urlAfterRedirects).fragment))})}consumeScrollEvents(){return this.router.events.subscribe(u=>{u instanceof QD&&(u.position?"top"===this.options.scrollPositionRestoration?this.viewportScroller.scrollToPosition([0,0]):"enabled"===this.options.scrollPositionRestoration&&this.viewportScroller.scrollToPosition(u.position):u.anchor&&"enabled"===this.options.anchorScrolling?this.viewportScroller.scrollToAnchor(u.anchor):"disabled"!==this.options.scrollPositionRestoration&&this.viewportScroller.scrollToPosition([0,0]))})}scheduleScrollEvent(u,g){this.router.triggerEvent(new QD(u,"popstate"===this.lastSource?this.store[this.restoredId]:null,g))}ngOnDestroy(){this.routerEventsSubscription&&this.routerEventsSubscription.unsubscribe(),this.scrollEventsSubscription&&this.scrollEventsSubscription.unsubscribe()}}return f.\u0275fac=function(u){Lg()},f.\u0275prov=yt({token:f,factory:f.\u0275fac}),f})();const co=new dt("ROUTER_CONFIGURATION"),YS=new dt("ROUTER_FORROOT_GUARD"),$V=[Ap,{provide:lS,useClass:cS},{provide:fi,useFactory:function QV(f,l,u,g,p,m,v={},y,b){const O=new fi(null,f,l,u,g,p,tS(m));return y&&(O.urlHandlingStrategy=y),b&&(O.routeReuseStrategy=b),function JV(f,l){f.errorHandler&&(l.errorHandler=f.errorHandler),f.malformedUriErrorHandler&&(l.malformedUriErrorHandler=f.malformedUriErrorHandler),f.onSameUrlNavigation&&(l.onSameUrlNavigation=f.onSameUrlNavigation),f.paramsInheritanceStrategy&&(l.paramsInheritanceStrategy=f.paramsInheritanceStrategy),f.relativeLinkResolution&&(l.relativeLinkResolution=f.relativeLinkResolution),f.urlUpdateStrategy&&(l.urlUpdateStrategy=f.urlUpdateStrategy),f.canceledNavigationResolution&&(l.canceledNavigationResolution=f.canceledNavigationResolution)}(v,O),v.enableTracing&&O.events.subscribe(L=>{var N,B;null===(N=console.group)||void 0===N||N.call(console,`Router Event: ${L.constructor.name}`),console.log(L.toString()),console.log(L),null===(B=console.groupEnd)||void 0===B||B.call(console)}),O},deps:[lS,oc,Ap,Qn,FE,km,co,[class kV{},new ms],[class FV{},new ms]]},oc,{provide:Ca,useFactory:function eU(f){return f.routerState.root},deps:[fi]},zS,WS,class YV{preload(l,u){return u().pipe(Ts(()=>at(null)))}},{provide:co,useValue:{enableTracing:!1}}];function XV(){return new VE("Router",fi)}let $S=(()=>{class f{constructor(u,g){}static forRoot(u,g){return{ngModule:f,providers:[$V,XS(u),{provide:YS,useFactory:KV,deps:[[fi,new ms,new ml]]},{provide:co,useValue:g||{}},{provide:ga,useFactory:ZV,deps:[no,[new bu(xp),new ms],co]},{provide:Vm,useFactory:qV,deps:[fi,JN,co]},{provide:HS,useExisting:g&&g.preloadingStrategy?g.preloadingStrategy:WS},{provide:VE,multi:!0,useFactory:XV},[Um,{provide:dp,multi:!0,useFactory:tU,deps:[Um]},{provide:qS,useFactory:nU,deps:[Um]},{provide:LE,multi:!0,useExisting:qS}]]}}static forChild(u){return{ngModule:f,providers:[XS(u)]}}}return f.\u0275fac=function(u){return new(u||f)(Ye(YS,8),Ye(fi,8))},f.\u0275mod=lr({type:f}),f.\u0275inj=Ui({}),f})();function qV(f,l,u){return u.scrollOffset&&l.setOffset(u.scrollOffset),new Vm(f,l,u)}function ZV(f,l,u={}){return u.useHash?new LP(f,l):new rb(f,l)}function KV(f){return"guarded"}function XS(f){return[{provide:dA,multi:!0,useValue:f},{provide:km,multi:!0,useValue:f}]}let Um=(()=>{class f{constructor(u){this.injector=u,this.initNavigation=!1,this.destroyed=!1,this.resultOfPreactivationDone=new Ar}appInitializer(){return this.injector.get(RP,Promise.resolve(null)).then(()=>{if(this.destroyed)return Promise.resolve(!0);let g=null;const p=new Promise(y=>g=y),m=this.injector.get(fi),v=this.injector.get(co);return"disabled"===v.initialNavigation?(m.setUpLocationChangeListener(),g(!0)):"enabled"===v.initialNavigation||"enabledBlocking"===v.initialNavigation?(m.hooks.afterPreactivation=()=>this.initNavigation?at(null):(this.initNavigation=!0,g(!0),this.resultOfPreactivationDone),m.initialNavigation()):g(!0),p})}bootstrapListener(u){const g=this.injector.get(co),p=this.injector.get(zS),m=this.injector.get(Vm),v=this.injector.get(fi),y=this.injector.get(wp);u===y.components[0]&&(("enabledNonBlocking"===g.initialNavigation||void 0===g.initialNavigation)&&v.initialNavigation(),p.setUpPreloading(),m.init(),v.resetRootComponentType(y.componentTypes[0]),this.resultOfPreactivationDone.next(null),this.resultOfPreactivationDone.complete())}ngOnDestroy(){this.destroyed=!0}}return f.\u0275fac=function(u){return new(u||f)(Ye(Qn))},f.\u0275prov=yt({token:f,factory:f.\u0275fac}),f})();function tU(f){return f.appInitializer.bind(f)}function nU(f){return f.bootstrapListener.bind(f)}const qS=new dt("Router Initializer");function ZS(f,l,u,g,p,m,v){try{var y=f[m](v),b=y.value}catch(O){return void u(O)}y.done?l(b):Promise.resolve(b).then(g,p)}function se(f){return function(){var l=this,u=arguments;return new Promise(function(g,p){var m=f.apply(l,u);function v(b){ZS(m,g,p,v,y,"next",b)}function y(b){ZS(m,g,p,v,y,"throw",b)}v(void 0)})}}const rU=[{id:"reader",name:"Barcode and QR Code Reader",description:"Scan barcode and QR code from image files"},{id:"scanner",name:"Barcode and QR Code Scanner",description:"Scan barcode and QR code from camera stream"},{id:"file-detection",name:"Document Detector (File)",description:"Detect document from image files"},{id:"camera-detection",name:"Document Scanner (Camera)",description:"Detect document from camera stream"}];function ut(f,l,u,g){if("a"===u&&!g)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof l?f!==l||!g:!l.has(f))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===u?g:"a"===u?g.call(f):g?g.value:l.get(f)}function uo(f,l,u,g,p){if("m"===g)throw new TypeError("Private method is not writable");if("a"===g&&!p)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof l?f!==l||!p:!l.has(f))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===g?p.call(f,u):p?p.value=u:l.set(f,u),u}var ho,br,Ue,f;"function"==typeof SuppressedError&&SuppressedError,(f=ho||(ho={}))[f.BOPM_BLOCK=0]="BOPM_BLOCK",f[f.BOPM_UPDATE=1]="BOPM_UPDATE",function(f){f[f.CCUT_AUTO=0]="CCUT_AUTO",f[f.CCUT_FULL_CHANNEL=1]="CCUT_FULL_CHANNEL",f[f.CCUT_Y_CHANNEL_ONLY=2]="CCUT_Y_CHANNEL_ONLY",f[f.CCUT_RGB_R_CHANNEL_ONLY=3]="CCUT_RGB_R_CHANNEL_ONLY",f[f.CCUT_RGB_G_CHANNEL_ONLY=4]="CCUT_RGB_G_CHANNEL_ONLY",f[f.CCUT_RGB_B_CHANNEL_ONLY=5]="CCUT_RGB_B_CHANNEL_ONLY"}(br||(br={})),function(f){f[f.IPF_BINARY=0]="IPF_BINARY",f[f.IPF_BINARYINVERTED=1]="IPF_BINARYINVERTED",f[f.IPF_GRAYSCALED=2]="IPF_GRAYSCALED",f[f.IPF_NV21=3]="IPF_NV21",f[f.IPF_RGB_565=4]="IPF_RGB_565",f[f.IPF_RGB_555=5]="IPF_RGB_555",f[f.IPF_RGB_888=6]="IPF_RGB_888",f[f.IPF_ARGB_8888=7]="IPF_ARGB_8888",f[f.IPF_RGB_161616=8]="IPF_RGB_161616",f[f.IPF_ARGB_16161616=9]="IPF_ARGB_16161616",f[f.IPF_ABGR_8888=10]="IPF_ABGR_8888",f[f.IPF_ABGR_16161616=11]="IPF_ABGR_16161616",f[f.IPF_BGR_888=12]="IPF_BGR_888",f[f.IPF_BINARY_8=13]="IPF_BINARY_8",f[f.IPF_NV12=14]="IPF_NV12",f[f.IPF_BINARY_8_INVERTED=15]="IPF_BINARY_8_INVERTED"}(Ue||(Ue={}));const KS=f=>Object.prototype.toString.call(f),jm=f=>Array.isArray?Array.isArray(f):"[object Array]"===KS(f),Gm=f=>"[object Boolean]"===KS(f),rn=f=>"number"==typeof f&&!Number.isNaN(f),er=f=>null!==f&&"object"==typeof f&&!Array.isArray(f),QS=f=>!(!er(f)||!(f.bytes instanceof Uint8Array)||!rn(f.width)||f.width<=0||!rn(f.height)||f.height<=0||!rn(f.stride)||f.stride<=0||!("format"in f)||"tag"in f&&!oU(f.tag)),oU=f=>!!er(f)&&!!rn(f.imageId)&&"type"in f,Ea=f=>!!er(f)&&!!rn(f.x)&&!!rn(f.y);function JS(f,l){return Hm.apply(this,arguments)}function Hm(){return Hm=se(function*(f,l){return yield new Promise((u,g)=>{let p=new XMLHttpRequest;p.open("GET",f,!0),p.responseType=l,p.send(),p.onloadend=se(function*(){p.status<200||p.status>=300?g(f+" "+p.status):u(p.response)}),p.onerror=()=>{g(new Error("Network Error: "+p.statusText))}})}),Hm.apply(this,arguments)}const zr=(f,l)=>{let u=f.split("."),g=l.split(".");for(let p=0;p=ut(this,fo,"f"))switch(ut(this,hc,"f")){case ho.BOPM_BLOCK:break;case ho.BOPM_UPDATE:if(ut(this,gn,"f").push(l),er(ut(this,Li,"f"))&&rn(ut(this,Li,"f").imageId)&&1==ut(this,Li,"f").keepInBuffer)for(;ut(this,gn,"f").length>ut(this,fo,"f");){const g=ut(this,gn,"f").findIndex(p=>{var m;return(null===(m=p.tag)||void 0===m?void 0:m.imageId)!==ut(this,Li,"f").imageId});ut(this,gn,"f").splice(g,1)}else ut(this,gn,"f").splice(0,ut(this,gn,"f").length-ut(this,fo,"f"))}else ut(this,gn,"f").push(l)}getImage(){if(0===ut(this,gn,"f").length)return null;let l;if(ut(this,Li,"f")&&rn(ut(this,Li,"f").imageId)){const u=ut(this,Hh,"m",Wm).call(this,ut(this,Li,"f").imageId);if(u<0)throw new Error(`Image with id ${ut(this,Li,"f").imageId} doesn't exist.`);l=ut(this,gn,"f").slice(u,u+1)[0]}else l=ut(this,gn,"f").pop();if([Ue.IPF_RGB_565,Ue.IPF_RGB_555,Ue.IPF_RGB_888,Ue.IPF_ARGB_8888,Ue.IPF_RGB_161616,Ue.IPF_ARGB_16161616,Ue.IPF_ABGR_8888,Ue.IPF_ABGR_16161616,Ue.IPF_BGR_888].includes(l.format)){if(ut(this,go,"f")===br.CCUT_RGB_R_CHANNEL_ONLY){Fi._onLog&&Fi._onLog("only get R channel data.");const u=new Uint8Array(l.width*l.height);for(let g=0;g0!==g.length&&g.every(p=>rn(p)))(l))throw new TypeError("Invalid 'imageId'.");if(void 0!==u&&!Gm(u))throw new TypeError("Invalid 'keepInBuffer'.");uo(this,Li,{imageId:l,keepInBuffer:u},"f")}_resetNextReturnedImage(){uo(this,Li,null,"f")}hasImage(l){return ut(this,Hh,"m",Wm).call(this,l)>=0}startFetching(){uo(this,dc,!0,"f")}stopFetching(){uo(this,dc,!1,"f")}setMaxImageCount(l){if("number"!=typeof l)throw new TypeError("Invalid 'count'.");if(l<1||Math.round(l)!==l)throw new Error("Invalid 'count'.");for(uo(this,fo,l,"f");ut(this,gn,"f")&&ut(this,gn,"f").length>l;)ut(this,gn,"f").shift()}getMaxImageCount(){return ut(this,fo,"f")}getImageCount(){return ut(this,gn,"f").length}clearBuffer(){ut(this,gn,"f").length=0}isBufferEmpty(){return 0===ut(this,gn,"f").length}setBufferOverflowProtectionMode(l){uo(this,hc,l,"f")}getBufferOverflowProtectionMode(){return ut(this,hc,"f")}setColourChannelUsageType(l){uo(this,go,l,"f")}getColourChannelUsageType(){return ut(this,go,"f")}}gn=new WeakMap,fo=new WeakMap,hc=new WeakMap,dc=new WeakMap,Li=new WeakMap,go=new WeakMap,Hh=new WeakSet,Wm=function(f){if("number"!=typeof f)throw new TypeError("Invalid 'imageId'.");return ut(this,gn,"f").findIndex(l=>{var u;return(null===(u=l.tag)||void 0===u?void 0:u.imageId)===f})};const Wh="undefined"==typeof self,eI=(()=>{if(!Wh&&document.currentScript){let f=document.currentScript.src,l=f.indexOf("?");if(-1!=l)f=f.substring(0,l);else{let u=f.indexOf("#");-1!=u&&(f=f.substring(0,u))}return f.substring(0,f.lastIndexOf("/")+1)}return"./"})(),tI=f=>{if(null==f&&(f="./"),!Wh){let l=document.createElement("a");l.href=f,f=l.href}return f.endsWith("/")||(f+="/"),f};let fc,Yr,zh,Yh,ti;"undefined"!=typeof navigator&&(fc=navigator,Yr=fc.userAgent,zh=fc.platform,Yh=fc.mediaDevices),function(){if(!Wh){const f={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:fc.vendor,search:"Apple",verSearch:["Version","iPhone OS","CPU OS"]},Firefox:null,Explorer:{search:"MSIE",verSearch:"MSIE"}},l={HarmonyOS:null,Android:null,iPhone:null,iPad:null,Windows:{str:zh,search:"Win"},Mac:{str:zh},Linux:{str:zh}};let u="unknownBrowser",g=0,p="unknownOS";for(let m in f){const v=f[m]||{};let O=v.verStr||Yr,L=v.verSearch||m;if(L instanceof Array||(L=[L]),-1!=(v.str||Yr).indexOf(v.search||m)){u=m;for(let N of L){let B=O.indexOf(N);if(-1!=B){g=parseFloat(O.substring(B+N.length+1));break}}break}}for(let m in l){const v=l[m]||{};if(-1!=(v.str||Yr).indexOf(v.search||m)){p=m;break}}"Linux"==p&&-1!=Yr.indexOf("Windows NT")&&(p="HarmonyOS"),ti={browser:u,version:g,OS:p}}Wh&&(ti={browser:"ssr",version:0,OS:"ssr"})}();const hU="undefined"!=typeof WebAssembly&&Yr&&!(/Safari/.test(Yr)&&!/Chrome/.test(Yr)&&/\(.+\s11_2_([2-6]).*\)/.test(Yr)),dU="undefined"!=typeof Worker,nI=!(!Yh||!Yh.getUserMedia),fU=function(){var f=se(function*(){let l=!1;if(nI)try{(yield Yh.getUserMedia({video:!0})).getTracks().forEach(u=>{u.stop()}),l=!0}catch(u){}return l});return function(){return f.apply(this,arguments)}}(),iI=f=>f&&"object"==typeof f&&"function"==typeof f.then;class $h extends Promise{constructor(l){let u,g;super((p,m)=>{u=p,g=m}),this._s="pending",this.resolve=p=>{this.isPending&&(iI(p)?this.task=p:(this._s="fulfilled",u(p)))},this.reject=p=>{this.isPending&&(this._s="rejected",g(p))},this.task=l}get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}get task(){return this._task}set task(l){var u=this;let g;this._task=l,iI(l)?g=l:"function"==typeof l&&(g=new Promise(l)),g&&se(function*(){try{const p=yield g;l===u._task&&u.resolve(p)}catch(p){l===u._task&&u.reject(p)}})()}get isEmpty(){return null==this._task}}const Pi={},rI=function(){var f=se(function*(l){let u="string"==typeof l?[l]:l,g=[];for(let p of u)g.push(Pi[p]=Pi[p]||new $h);yield Promise.all(g)});return function(u){return f.apply(this,arguments)}}(),Xh=function(){var f=se(function*(l,u){let g,p="string"==typeof l?[l]:l,m=[];for(let v of p){let y;m.push(y=Pi[v]=Pi[v]||new $h(g=g||u())),y.isEmpty&&(y.task=g=g||u())}yield Promise.all(m)});return function(u,g){return f.apply(this,arguments)}}();let gt,sI=0;const At=()=>sI++,Dt={};let As,zm=!1;const po={},pn={},je={std:{version:"1.2.10",path:tI(eI+"../../dynamsoft-capture-vision-std@1.2.10/dist/")},core:{version:"3.2.30",path:eI}},gc=new Proxy(je,{get(f,l,u){let g=Reflect.get(f,l,u);return g&&g.path&&(g=g.path),g}}),$r={dip:{wasm:!0}},Dr=function(){var f=se(function*(l){let u;l instanceof Array||(l=l?[l]:[]);{let m=Pi.core;u=!m||m.isEmpty}let g=new Map;for(let m of l){if(m=m.toLowerCase(),"std"==m||"core"==m)continue;if(!$r[m])throw Error("The '"+m+"' module cannot be found.");let v=$r[m].deps;if(null==v?void 0:v.length)for(let b of v){let O=Pi[b];g.has(b)||g.set(b,!O||O.isEmpty)}let y=Pi[m];g.has(m)||g.set(m,!y||y.isEmpty)}let p=[];u&&p.push("core"),p.push(...g.keys()),yield Xh(p,se(function*(){const m=[...g.entries()].filter(N=>N[1]).map(N=>N[0]),v={};for(let N in gc){if("rootDirectory"==N)continue;let B=gc[N];gc.rootDirectory&&(B.startsWith("http://")||B.startsWith("https://")||(B=gc.rootDirectory+"/"+B)),v[N]=tI(B)}const y={};for(let N of m)y[N]=$r[N];const b={engineResourcePaths:v,autoResources:y,names:m};let O=new $h;if(u){b.needLoadCore=!0;let N=v.core+sn._workerName;v.rootDirectory&&(N=v.rootDirectory+N),N.startsWith(location.origin)||(N=yield fetch(N).then(B=>B.blob()).then(B=>URL.createObjectURL(B))),gt=new Worker(N),gt.onerror=B=>{let U=new Error(B.message);O.reject(U)},gt.addEventListener("message",B=>{let U=B.data?B.data:B,Y=U.id,$=U.body;switch(U.type){case"log":As&&As(U.message);break;case"task":try{Dt[Y]($),delete Dt[Y]}catch(q){throw delete Dt[Y],q}break;case"event":try{Dt[Y]($)}catch(q){throw q}break;default:console.log(B)}}),b.bLog=!!As,b.bd=zm,b.dm=location.origin.startsWith("http")?location.origin:"https://localhost"}else yield rI("worker");let L=sI++;Dt[L]=N=>{if(N.success)Object.assign(po,N.versions),"{}"!==JSON.stringify(N.versions)&&(sn._versions=N.versions),O.resolve(void 0);else{const B=Error(N.message);N.stack&&(B.stack=N.stack),O.reject(B)}},gt.postMessage({type:"loadWasm",body:b,id:L}),u&&Xh("worker",()=>Promise.resolve()),yield O}))});return function(u){return f.apply(this,arguments)}}();class sn{static get engineResourcePaths(){return gc}static set engineResourcePaths(l){Object.assign(je,l)}static get bSupportDce4Module(){return this._bSupportDce4Module}static get bSupportIRTModule(){return this._bSupportIRTModule}static get versions(){return this._versions}static get _onLog(){return As}static set _onLog(l){(f=>{As=f,gt&>.postMessage({type:"setBLog",body:{value:!!f}})})(l)}static get _bDebug(){return zm}static set _bDebug(l){(f=>{zm=f,gt&>.postMessage({type:"setBDebug",body:{value:!!f}})})(l)}static isModuleLoaded(l){return l=(l=l||"core").toLowerCase(),!!Pi[l]&&Pi[l].isFulfilled}static loadWasm(l){return se(function*(){return yield Dr(l)})()}static detectEnvironment(){return se(function*(){return yield se(function*(){return{wasm:hU,worker:dU,getUserMedia:nI,camera:yield fU(),browser:ti.browser,version:ti.version,OS:ti.OS}})()})()}static getModuleVersion(){return se(function*(){return yield new Promise((l,u)=>{let g=At();Dt[g]=function(){var p=se(function*(m){if(m.success)return l(m.versions);{let v=new Error(m.message);return v.stack=m.stack+"\n"+v.stack,u(v)}});return function(m){return p.apply(this,arguments)}}(),gt.postMessage({type:"getModuleVersion",id:g})})})()}static getVersion(){return`3.2.30(Worker: ${po.core&&po.core.worker||"Not Loaded"}, Wasm: ${po.core&&po.core.wasm||"Not Loaded"})`}static enableLogging(){Fi._onLog=console.log,sn._onLog=console.log}static disableLogging(){Fi._onLog=null,sn._onLog=null}static cfd(l){return se(function*(){return yield new Promise((u,g)=>{let p=At();Dt[p]=function(){var m=se(function*(v){if(v.success)return u();{let y=new Error(v.message);return y.stack=v.stack+"\n"+y.stack,g(y)}});return function(v){return m.apply(this,arguments)}}(),gt.postMessage({type:"cfd",id:p,body:{count:l}})})})()}}var Yt,oI,Ym,aI,lI,qh,cI,uI,ba,hI,dI;sn._bSupportDce4Module=-1,sn._bSupportIRTModule=-1,sn._versions=null,sn._workerName="core.worker.js",sn.browserInfo=ti,function(f){f[f.CRIT_ORIGINAL_IMAGE=1]="CRIT_ORIGINAL_IMAGE",f[f.CRIT_BARCODE=2]="CRIT_BARCODE",f[f.CRIT_TEXT_LINE=4]="CRIT_TEXT_LINE",f[f.CRIT_DETECTED_QUAD=8]="CRIT_DETECTED_QUAD",f[f.CRIT_NORMALIZED_IMAGE=16]="CRIT_NORMALIZED_IMAGE",f[f.CRIT_PARSED_RESULT=32]="CRIT_PARSED_RESULT"}(Yt||(Yt={})),function(f){f[f.CT_NORMAL_INTERSECTED=0]="CT_NORMAL_INTERSECTED",f[f.CT_T_INTERSECTED=1]="CT_T_INTERSECTED",f[f.CT_CROSS_INTERSECTED=2]="CT_CROSS_INTERSECTED",f[f.CT_NOT_INTERSECTED=3]="CT_NOT_INTERSECTED"}(oI||(oI={})),function(f){f[f.EC_OK=0]="EC_OK",f[f.EC_UNKNOWN=-1e4]="EC_UNKNOWN",f[f.EC_NO_MEMORY=-10001]="EC_NO_MEMORY",f[f.EC_NULL_POINTER=-10002]="EC_NULL_POINTER",f[f.EC_LICENSE_INVALID=-10003]="EC_LICENSE_INVALID",f[f.EC_LICENSE_EXPIRED=-10004]="EC_LICENSE_EXPIRED",f[f.EC_FILE_NOT_FOUND=-10005]="EC_FILE_NOT_FOUND",f[f.EC_FILE_TYPE_NOT_SUPPORTED=-10006]="EC_FILE_TYPE_NOT_SUPPORTED",f[f.EC_BPP_NOT_SUPPORTED=-10007]="EC_BPP_NOT_SUPPORTED",f[f.EC_INDEX_INVALID=-10008]="EC_INDEX_INVALID",f[f.EC_CUSTOM_REGION_INVALID=-10010]="EC_CUSTOM_REGION_INVALID",f[f.EC_IMAGE_READ_FAILED=-10012]="EC_IMAGE_READ_FAILED",f[f.EC_TIFF_READ_FAILED=-10013]="EC_TIFF_READ_FAILED",f[f.EC_DIB_BUFFER_INVALID=-10018]="EC_DIB_BUFFER_INVALID",f[f.EC_PDF_READ_FAILED=-10021]="EC_PDF_READ_FAILED",f[f.EC_PDF_DLL_MISSING=-10022]="EC_PDF_DLL_MISSING",f[f.EC_PAGE_NUMBER_INVALID=-10023]="EC_PAGE_NUMBER_INVALID",f[f.EC_CUSTOM_SIZE_INVALID=-10024]="EC_CUSTOM_SIZE_INVALID",f[f.EC_TIMEOUT=-10026]="EC_TIMEOUT",f[f.EC_JSON_PARSE_FAILED=-10030]="EC_JSON_PARSE_FAILED",f[f.EC_JSON_TYPE_INVALID=-10031]="EC_JSON_TYPE_INVALID",f[f.EC_JSON_KEY_INVALID=-10032]="EC_JSON_KEY_INVALID",f[f.EC_JSON_VALUE_INVALID=-10033]="EC_JSON_VALUE_INVALID",f[f.EC_JSON_NAME_KEY_MISSING=-10034]="EC_JSON_NAME_KEY_MISSING",f[f.EC_JSON_NAME_VALUE_DUPLICATED=-10035]="EC_JSON_NAME_VALUE_DUPLICATED",f[f.EC_TEMPLATE_NAME_INVALID=-10036]="EC_TEMPLATE_NAME_INVALID",f[f.EC_JSON_NAME_REFERENCE_INVALID=-10037]="EC_JSON_NAME_REFERENCE_INVALID",f[f.EC_PARAMETER_VALUE_INVALID=-10038]="EC_PARAMETER_VALUE_INVALID",f[f.EC_DOMAIN_NOT_MATCH=-10039]="EC_DOMAIN_NOT_MATCH",f[f.EC_RESERVED_INFO_NOT_MATCH=-10040]="EC_RESERVED_INFO_NOT_MATCH",f[f.EC_LICENSE_KEY_NOT_MATCH=-10043]="EC_LICENSE_KEY_NOT_MATCH",f[f.EC_REQUEST_FAILED=-10044]="EC_REQUEST_FAILED",f[f.EC_LICENSE_INIT_FAILED=-10045]="EC_LICENSE_INIT_FAILED",f[f.EC_SET_MODE_ARGUMENT_ERROR=-10051]="EC_SET_MODE_ARGUMENT_ERROR",f[f.EC_LICENSE_CONTENT_INVALID=-10052]="EC_LICENSE_CONTENT_INVALID",f[f.EC_LICENSE_KEY_INVALID=-10053]="EC_LICENSE_KEY_INVALID",f[f.EC_LICENSE_DEVICE_RUNS_OUT=-10054]="EC_LICENSE_DEVICE_RUNS_OUT",f[f.EC_GET_MODE_ARGUMENT_ERROR=-10055]="EC_GET_MODE_ARGUMENT_ERROR",f[f.EC_IRT_LICENSE_INVALID=-10056]="EC_IRT_LICENSE_INVALID",f[f.EC_FILE_SAVE_FAILED=-10058]="EC_FILE_SAVE_FAILED",f[f.EC_STAGE_TYPE_INVALID=-10059]="EC_STAGE_TYPE_INVALID",f[f.EC_IMAGE_ORIENTATION_INVALID=-10060]="EC_IMAGE_ORIENTATION_INVALID",f[f.EC_CONVERT_COMPLEX_TEMPLATE_ERROR=-10061]="EC_CONVERT_COMPLEX_TEMPLATE_ERROR",f[f.EC_CALL_REJECTED_WHEN_CAPTURING=-10062]="EC_CALL_REJECTED_WHEN_CAPTURING",f[f.EC_NO_IMAGE_SOURCE=-10063]="EC_NO_IMAGE_SOURCE",f[f.EC_READ_DIRECTORY_FAILED=-10064]="EC_READ_DIRECTORY_FAILED",f[f.EC_MODULE_NOT_FOUND=-10065]="EC_MODULE_NOT_FOUND",f[f.EC_MULTI_PAGES_NOT_SUPPORTED=-10066]="EC_MULTI_PAGES_NOT_SUPPORTED",f[f.EC_FILE_ALREADY_EXISTS=-10067]="EC_FILE_ALREADY_EXISTS",f[f.EC_CREATE_FILE_FAILED=-10068]="EC_CREATE_FILE_FAILED",f[f.EC_IMGAE_DATA_INVALID=-10069]="EC_IMGAE_DATA_INVALID",f[f.EC_IMAGE_SIZE_NOT_MATCH=-10070]="EC_IMAGE_SIZE_NOT_MATCH",f[f.EC_IMAGE_PIXEL_FORMAT_NOT_MATCH=-10071]="EC_IMAGE_PIXEL_FORMAT_NOT_MATCH",f[f.EC_SECTION_LEVEL_RESULT_IRREPLACEABLE=-10072]="EC_SECTION_LEVEL_RESULT_IRREPLACEABLE",f[f.EC_AXIS_DEFINITION_INCORRECT=-10073]="EC_AXIS_DEFINITION_INCORRECT",f[f.EC_RESULT_TYPE_MISMATCH_IRREPLACEABLE=-10074]="EC_RESULT_TYPE_MISMATCH_IRREPLACEABLE",f[f.EC_PDF_LIBRARY_LOAD_FAILED=-10075]="EC_PDF_LIBRARY_LOAD_FAILED",f[f.EC_NO_LICENSE=-2e4]="EC_NO_LICENSE",f[f.EC_HANDSHAKE_CODE_INVALID=-20001]="EC_HANDSHAKE_CODE_INVALID",f[f.EC_LICENSE_BUFFER_FAILED=-20002]="EC_LICENSE_BUFFER_FAILED",f[f.EC_LICENSE_SYNC_FAILED=-20003]="EC_LICENSE_SYNC_FAILED",f[f.EC_DEVICE_NOT_MATCH=-20004]="EC_DEVICE_NOT_MATCH",f[f.EC_BIND_DEVICE_FAILED=-20005]="EC_BIND_DEVICE_FAILED",f[f.EC_INSTANCE_COUNT_OVER_LIMIT=-20008]="EC_INSTANCE_COUNT_OVER_LIMIT",f[f.EC_LICENSE_INIT_SEQUENCE_FAILED=-20009]="EC_LICENSE_INIT_SEQUENCE_FAILED",f[f.EC_TRIAL_LICENSE=-20010]="EC_TRIAL_LICENSE",f[f.EC_FAILED_TO_REACH_DLS=-20200]="EC_FAILED_TO_REACH_DLS",f[f.EC_LICENSE_CACHE_USED=-20012]="EC_LICENSE_CACHE_USED",f[f.EC_BARCODE_FORMAT_INVALID=-30009]="EC_BARCODE_FORMAT_INVALID",f[f.EC_QR_LICENSE_INVALID=-30016]="EC_QR_LICENSE_INVALID",f[f.EC_1D_LICENSE_INVALID=-30017]="EC_1D_LICENSE_INVALID",f[f.EC_PDF417_LICENSE_INVALID=-30019]="EC_PDF417_LICENSE_INVALID",f[f.EC_DATAMATRIX_LICENSE_INVALID=-30020]="EC_DATAMATRIX_LICENSE_INVALID",f[f.EC_CUSTOM_MODULESIZE_INVALID=-30025]="EC_CUSTOM_MODULESIZE_INVALID",f[f.EC_AZTEC_LICENSE_INVALID=-30041]="EC_AZTEC_LICENSE_INVALID",f[f.EC_PATCHCODE_LICENSE_INVALID=-30046]="EC_PATCHCODE_LICENSE_INVALID",f[f.EC_POSTALCODE_LICENSE_INVALID=-30047]="EC_POSTALCODE_LICENSE_INVALID",f[f.EC_DPM_LICENSE_INVALID=-30048]="EC_DPM_LICENSE_INVALID",f[f.EC_FRAME_DECODING_THREAD_EXISTS=-30049]="EC_FRAME_DECODING_THREAD_EXISTS",f[f.EC_STOP_DECODING_THREAD_FAILED=-30050]="EC_STOP_DECODING_THREAD_FAILED",f[f.EC_MAXICODE_LICENSE_INVALID=-30057]="EC_MAXICODE_LICENSE_INVALID",f[f.EC_GS1_DATABAR_LICENSE_INVALID=-30058]="EC_GS1_DATABAR_LICENSE_INVALID",f[f.EC_GS1_COMPOSITE_LICENSE_INVALID=-30059]="EC_GS1_COMPOSITE_LICENSE_INVALID",f[f.EC_DOTCODE_LICENSE_INVALID=-30061]="EC_DOTCODE_LICENSE_INVALID",f[f.EC_PHARMACODE_LICENSE_INVALID=-30062]="EC_PHARMACODE_LICENSE_INVALID",f[f.EC_CHARACTER_MODEL_FILE_NOT_FOUND=-40100]="EC_CHARACTER_MODEL_FILE_NOT_FOUND",f[f.EC_TEXT_LINE_GROUP_LAYOUT_CONFLICT=-40101]="EC_TEXT_LINE_GROUP_LAYOUT_CONFLICT",f[f.EC_TEXT_LINE_GROUP_REGEX_CONFLICT=-40102]="EC_TEXT_LINE_GROUP_REGEX_CONFLICT",f[f.EC_QUADRILATERAL_INVALID=-50057]="EC_QUADRILATERAL_INVALID",f[f.EC_PANORAMA_LICENSE_INVALID=-70060]="EC_PANORAMA_LICENSE_INVALID",f[f.EC_RESOURCE_PATH_NOT_EXIST=-90001]="EC_RESOURCE_PATH_NOT_EXIST",f[f.EC_RESOURCE_LOAD_FAILED=-90002]="EC_RESOURCE_LOAD_FAILED",f[f.EC_CODE_SPECIFICATION_NOT_FOUND=-90003]="EC_CODE_SPECIFICATION_NOT_FOUND",f[f.EC_FULL_CODE_EMPTY=-90004]="EC_FULL_CODE_EMPTY",f[f.EC_FULL_CODE_PREPROCESS_FAILED=-90005]="EC_FULL_CODE_PREPROCESS_FAILED",f[f.EC_ZA_DL_LICENSE_INVALID=-90006]="EC_ZA_DL_LICENSE_INVALID",f[f.EC_AAMVA_DL_ID_LICENSE_INVALID=-90007]="EC_AAMVA_DL_ID_LICENSE_INVALID",f[f.EC_AADHAAR_LICENSE_INVALID=-90008]="EC_AADHAAR_LICENSE_INVALID",f[f.EC_MRTD_LICENSE_INVALID=-90009]="EC_MRTD_LICENSE_INVALID",f[f.EC_VIN_LICENSE_INVALID=-90010]="EC_VIN_LICENSE_INVALID",f[f.EC_CUSTOMIZED_CODE_TYPE_LICENSE_INVALID=-90011]="EC_CUSTOMIZED_CODE_TYPE_LICENSE_INVALID"}(Ym||(Ym={})),function(f){f[f.GEM_SKIP=0]="GEM_SKIP",f[f.GEM_AUTO=1]="GEM_AUTO",f[f.GEM_GENERAL=2]="GEM_GENERAL",f[f.GEM_GRAY_EQUALIZE=4]="GEM_GRAY_EQUALIZE",f[f.GEM_GRAY_SMOOTH=8]="GEM_GRAY_SMOOTH",f[f.GEM_SHARPEN_SMOOTH=16]="GEM_SHARPEN_SMOOTH",f[f.GEM_REV=-2147483648]="GEM_REV"}(aI||(aI={})),function(f){f[f.GTM_SKIP=0]="GTM_SKIP",f[f.GTM_INVERTED=1]="GTM_INVERTED",f[f.GTM_ORIGINAL=2]="GTM_ORIGINAL",f[f.GTM_AUTO=4]="GTM_AUTO",f[f.GTM_REV=-2147483648]="GTM_REV"}(lI||(lI={})),function(f){f[f.ITT_FILE_IMAGE=0]="ITT_FILE_IMAGE",f[f.ITT_VIDEO_FRAME=1]="ITT_VIDEO_FRAME"}(qh||(qh={})),function(f){f[f.PDFRM_VECTOR=1]="PDFRM_VECTOR",f[f.PDFRM_RASTER=2]="PDFRM_RASTER",f[f.PDFRM_REV=-2147483648]="PDFRM_REV"}(cI||(cI={})),function(f){f[f.RDS_RASTERIZED_PAGES=0]="RDS_RASTERIZED_PAGES",f[f.RDS_EXTRACTED_IMAGES=1]="RDS_EXTRACTED_IMAGES"}(uI||(uI={})),function(f){f[f.IRUT_NULL=0]="IRUT_NULL",f[f.IRUT_COLOUR_IMAGE=1]="IRUT_COLOUR_IMAGE",f[f.IRUT_SCALED_DOWN_COLOUR_IMAGE=2]="IRUT_SCALED_DOWN_COLOUR_IMAGE",f[f.IRUT_GRAYSCALE_IMAGE=4]="IRUT_GRAYSCALE_IMAGE",f[f.IRUT_TRANSOFORMED_GRAYSCALE_IMAGE=8]="IRUT_TRANSOFORMED_GRAYSCALE_IMAGE",f[f.IRUT_ENHANCED_GRAYSCALE_IMAGE=16]="IRUT_ENHANCED_GRAYSCALE_IMAGE",f[f.IRUT_PREDETECTED_REGIONS=32]="IRUT_PREDETECTED_REGIONS",f[f.IRUT_BINARY_IMAGE=64]="IRUT_BINARY_IMAGE",f[f.IRUT_TEXTURE_DETECTION_RESULT=128]="IRUT_TEXTURE_DETECTION_RESULT",f[f.IRUT_TEXTURE_REMOVED_GRAYSCALE_IMAGE=256]="IRUT_TEXTURE_REMOVED_GRAYSCALE_IMAGE",f[f.IRUT_TEXTURE_REMOVED_BINARY_IMAGE=512]="IRUT_TEXTURE_REMOVED_BINARY_IMAGE",f[f.IRUT_CONTOURS=1024]="IRUT_CONTOURS",f[f.IRUT_LINE_SEGMENTS=2048]="IRUT_LINE_SEGMENTS",f[f.IRUT_TEXT_ZONES=4096]="IRUT_TEXT_ZONES",f[f.IRUT_TEXT_REMOVED_BINARY_IMAGE=8192]="IRUT_TEXT_REMOVED_BINARY_IMAGE",f[f.IRUT_CANDIDATE_BARCODE_ZONES=16384]="IRUT_CANDIDATE_BARCODE_ZONES",f[f.IRUT_LOCALIZED_BARCODES=32768]="IRUT_LOCALIZED_BARCODES",f[f.IRUT_SCALED_UP_BARCODE_IMAGE=65536]="IRUT_SCALED_UP_BARCODE_IMAGE",f[f.IRUT_DEFORMATION_RESISTED_BARCODE_IMAGE=131072]="IRUT_DEFORMATION_RESISTED_BARCODE_IMAGE",f[f.IRUT_COMPLEMENTED_BARCODE_IMAGE=262144]="IRUT_COMPLEMENTED_BARCODE_IMAGE",f[f.IRUT_DECODED_BARCODES=524288]="IRUT_DECODED_BARCODES",f[f.IRUT_LONG_LINES=1048576]="IRUT_LONG_LINES",f[f.IRUT_CORNERS=2097152]="IRUT_CORNERS",f[f.IRUT_CANDIDATE_QUAD_EDGES=4194304]="IRUT_CANDIDATE_QUAD_EDGES",f[f.IRUT_DETECTED_QUADS=8388608]="IRUT_DETECTED_QUADS",f[f.IRUT_LOCALIZED_TEXT_LINES=16777216]="IRUT_LOCALIZED_TEXT_LINES",f[f.IRUT_RECOGNIZED_TEXT_LINES=33554432]="IRUT_RECOGNIZED_TEXT_LINES",f[f.IRUT_NORMALIZED_IMAGES=67108864]="IRUT_NORMALIZED_IMAGES",f[f.IRUT_SHORT_LINES=134217728]="IRUT_SHORT_LINES",f[f.IRUT_ALL=268435455]="IRUT_ALL"}(ba||(ba={})),function(f){f[f.ROET_PREDETECTED_REGION=0]="ROET_PREDETECTED_REGION",f[f.ROET_LOCALIZED_BARCODE=1]="ROET_LOCALIZED_BARCODE",f[f.ROET_DECODED_BARCODE=2]="ROET_DECODED_BARCODE",f[f.ROET_LOCALIZED_TEXT_LINE=3]="ROET_LOCALIZED_TEXT_LINE",f[f.ROET_RECOGNIZED_TEXT_LINE=4]="ROET_RECOGNIZED_TEXT_LINE",f[f.ROET_DETECTED_QUAD=5]="ROET_DETECTED_QUAD",f[f.ROET_NORMALIZED_IMAGE=6]="ROET_NORMALIZED_IMAGE",f[f.ROET_SOURCE_IMAGE=7]="ROET_SOURCE_IMAGE",f[f.ROET_TARGET_ROI=8]="ROET_TARGET_ROI"}(hI||(hI={})),function(f){f[f.ST_NULL=0]="ST_NULL",f[f.ST_REGION_PREDETECTION=1]="ST_REGION_PREDETECTION",f[f.ST_BARCODE_LOCALIZATION=2]="ST_BARCODE_LOCALIZATION",f[f.ST_BARCODE_DECODING=3]="ST_BARCODE_DECODING",f[f.ST_TEXT_LINE_LOCALIZATION=4]="ST_TEXT_LINE_LOCALIZATION",f[f.ST_TEXT_LINE_RECOGNITION=5]="ST_TEXT_LINE_RECOGNITION",f[f.ST_DOCUMENT_DETECTION=6]="ST_DOCUMENT_DETECTION",f[f.ST_DOCUMENT_NORMALIZATION=7]="ST_DOCUMENT_NORMALIZATION"}(dI||(dI={}));const Rs="undefined"==typeof self,fI=Rs?{}:self,gI=(()=>{if(!Rs&&document.currentScript){let f=document.currentScript.src,l=f.indexOf("?");if(-1!=l)f=f.substring(0,l);else{let u=f.indexOf("#");-1!=u&&(f=f.substring(0,u))}return f.substring(0,f.lastIndexOf("/")+1)}return"./"})(),pI=f=>{if(null==f&&(f="./"),!Rs){let l=document.createElement("a");l.href=f,f=l.href}return f.endsWith("/")||(f+="/"),f},mI=f=>f&&"object"==typeof f&&"function"==typeof f.then;class $m extends Promise{constructor(l){let u,g;super((p,m)=>{u=p,g=m}),this._s="pending",this.resolve=p=>{this.isPending&&(mI(p)?this.task=p:(this._s="fulfilled",u(p)))},this.reject=p=>{this.isPending&&(this._s="rejected",g(p))},this.task=l}get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}get task(){return this._task}set task(l){var u=this;let g;this._task=l,mI(l)?g=l:"function"==typeof l&&(g=new Promise(l)),g&&se(function*(){try{const p=yield g;l===u._task&&u.resolve(p)}catch(p){l===u._task&&u.reject(p)}})()}get isEmpty(){return null==this._task}}const Zh=" is not allowed to change after `createInstance` or `loadWasm` is called.",mU=!Rs&&document.currentScript&&(document.currentScript.getAttribute("data-license")||document.currentScript.getAttribute("data-productKeys")||document.currentScript.getAttribute("data-licenseKey")||document.currentScript.getAttribute("data-handshakeCode")||document.currentScript.getAttribute("data-organizationID"))||"",_I=(f,l)=>{const u=f;if(!u._pLoad.isEmpty)throw new Error("`license`"+Zh);u._license=l};!Rs&&document.currentScript&&document.currentScript.getAttribute("data-sessionPassword");const vI=f=>{if(null==f)f=[];else{f=f instanceof Array?[...f]:[f];for(let l=0;l{const u=f;if(!u._pLoad.isEmpty)throw new Error("`licenseServer`"+Zh);u._licenseServer=vI(l)},CI=(f,l)=>{const u=f;if(!u._pLoad.isEmpty)throw new Error("`deviceFriendlyName`"+Zh);u._deviceFriendlyName=l||""};let pc,mc,Kh,Xm,tr;"undefined"!=typeof navigator&&(pc=navigator,mc=pc.userAgent,Kh=pc.platform,Xm=pc.mediaDevices),function(){if(!Rs){const f={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:pc.vendor,search:"Apple",verSearch:["Version","iPhone OS","CPU OS"]},Firefox:null,Explorer:{search:"MSIE",verSearch:"MSIE"}},l={HarmonyOS:null,Android:null,iPhone:null,iPad:null,Windows:{str:Kh,search:"Win"},Mac:{str:Kh},Linux:{str:Kh}};let u="unknownBrowser",g=0,p="unknownOS";for(let m in f){const v=f[m]||{};let O=v.verStr||mc,L=v.verSearch||m;if(L instanceof Array||(L=[L]),-1!=(v.str||mc).indexOf(v.search||m)){u=m;for(let N of L){let B=O.indexOf(N);if(-1!=B){g=parseFloat(O.substring(B+N.length+1));break}}break}}for(let m in l){const v=l[m]||{};if(-1!=(v.str||mc).indexOf(v.search||m)){p=m;break}}"Linux"==p&&-1!=mc.indexOf("Windows NT")&&(p="HarmonyOS"),tr={browser:u,version:g,OS:p}}Rs&&(tr={browser:"ssr",version:0,OS:"ssr"})}();const wI=function(){var f=se(function*(){return Dr("license"),Xh("dynamsoft_inited",se(function*(){let{lt:l,l:u,ls:g,sp:p,rmk:m,cv:v}=((O,L=!1)=>{const N=O;if(N._pLoad.isEmpty){let B,U,W,Y=N._license||"",$=JSON.parse(JSON.stringify(N._licenseServer)),q=N._sessionPassword,X=0;if(Y.startsWith("t")||Y.startsWith("f"))X=0;else if(0===Y.length||Y.startsWith("P")||Y.startsWith("L")||Y.startsWith("Y")||Y.startsWith("A"))X=1;else{X=2;const Q=Y.indexOf(":");-1!=Q&&(Y=Y.substring(Q+1));const pe=Y.indexOf("?");if(-1!=pe&&(U=Y.substring(pe+1),Y=Y.substring(0,pe)),Y.startsWith("DLC2"))X=0;else{if(Y.startsWith("DLS2")){let ve;try{let Te=Y.substring(4);Te=atob(Te),ve=JSON.parse(Te)}catch(Te){throw new Error("Format Error: The license string you specified is invalid, please check to make sure it is correct.")}if(Y=ve.handshakeCode?ve.handshakeCode:ve.organizationID?ve.organizationID:"","number"==typeof Y&&(Y=JSON.stringify(Y)),0===$.length){let Te=[];ve.mainServerURL&&(Te[0]=ve.mainServerURL),ve.standbyServerURL&&(Te[1]=ve.standbyServerURL),$=vI(Te)}!q&&ve.sessionPassword&&(q=ve.sessionPassword),B=ve.remark}Y&&"200001"!==Y&&!Y.startsWith("200001-")||(X=1)}}if(X&&(L||(fI.crypto||(W="Please upgrade your browser to support online key."),fI.crypto.subtle||(W="Require https to use online key in this browser."))),W){if(1!==X)throw new Error(W);X=0,console.warn(W),N._lastErrorCode=-1,N._lastErrorString=W}return 1===X&&(Y="",console.warn("Applying for a public trial license ...")),{lt:X,l:Y,ls:$,sp:q,rmk:B,cv:U}}throw new Error("Can't preprocess license again"+Zh)})(Bt),y=new $m;Bt._pLoad.task=y,se(function*(){try{yield Bt._pLoad}catch(O){}})();let b=At();Dt[b]=O=>{if(O.message&&Bt._onAuthMessage){let B=Bt._onAuthMessage(O.message);null!=B&&(O.message=B)}let L,N=!1;if(1===l&&(N=!0),O.success?(As&&As("init license success"),O.message&&console.warn(O.message),sn._bSupportIRTModule=O.bSupportIRTModule,sn._bSupportDce4Module=O.bSupportDce4Module,Bt.bPassValidation=!0):(L=Error(O.message),O.stack&&(L.stack=O.stack),O.ltsErrorCode&&(L.ltsErrorCode=O.ltsErrorCode),N||111==O.ltsErrorCode&&-1!=O.message.toLowerCase().indexOf("trial license")&&(N=!0)),N){let B=je.license;je.rootDirectory&&(B=je.rootDirectory+"/"+B),B=pI(B),(U=se(function*(W,Y,$){if(!W._bNeverShowDialog)try{let q=yield fetch(W.engineResourcePath+"dls.license.dialog.html");if(!q.ok)throw Error("Get license dialog fail. Network Error: "+q.statusText);let X=yield q.text();if(!X.trim().startsWith("<"))throw Error("Get license dialog fail. Can't get valid HTMLElement.");let Q=document.createElement("div");Q.innerHTML=X;let pe=[];for(let w=0;w{if(w==D.target){ve.remove();for(let T of pe)T.remove()}});else if(!Ae&&w.classList.contains("dls-license-icon-close"))Ae=w,w.addEventListener("click",()=>{ve.remove();for(let D of pe)D.remove()});else if(!P&&w.classList.contains("dls-license-icon-error"))P=w,"error"!=Y&&w.remove();else if(!Ee&&w.classList.contains("dls-license-icon-warn"))Ee=w,"warn"!=Y&&w.remove();else if(!Be&&w.classList.contains("dls-license-msg-content")){Be=w;let D=$;for(;D;){let T=D.indexOf("["),_=D.indexOf("]",T),C=D.indexOf("(",_),I=D.indexOf(")",C);if(-1==T||-1==_||-1==C||-1==I){w.appendChild(new Text(D));break}T>0&&w.appendChild(new Text(D.substring(0,T)));let M=document.createElement("a"),x=D.substring(T+1,_);M.innerText=x;let A=D.substring(C+1,I);M.setAttribute("href",A),M.setAttribute("target","_blank"),w.appendChild(M),D=D.substring(I+1)}}document.body.appendChild(ve)}catch(q){W._onLog&&W._onLog(q.message||q)}}),function(W,Y,$){return U.apply(this,arguments)})({_bNeverShowDialog:Bt._bNeverShowDialog,engineResourcePath:B,_onLog:As},O.success?"warn":"error",O.message)}var U;O.success?y.resolve(void 0):y.reject(L)},yield rI("worker"),gt.postMessage({type:"dynamsoft",body:{v:"3.2.21",brtk:!!l,bptk:1===l,l:u,os:tr,fn:Bt.deviceFriendlyName,ls:g,sp:p,rmk:m,cv:v},id:b}),Bt.bCallInitLicense=!0,yield y}))});return function(){return f.apply(this,arguments)}}();let EI;pn.license={},pn.license.dynamsoft=wI,pn.license.getAR=se(function*(){{let f=Pi.dynamsoft_inited;f&&f.isRejected&&(yield f)}return gt?new Promise((f,l)=>{let u=At();Dt[u]=function(){var g=se(function*(p){if(p.success){delete p.success;{let m=Bt.license;m&&(m.startsWith("t")||m.startsWith("f"))&&(p.pk=m)}if(Object.keys(p).length){if(p.lem){let m=Error(p.lem);m.ltsErrorCode=p.lec,delete p.lem,delete p.lec,p.ae=m}f(p)}else f(null)}else{let m=Error(p.message);p.stack&&(m.stack=p.stack),l(m)}});return function(p){return g.apply(this,arguments)}}(),gt.postMessage({type:"getAR",id:u})}):null});class Bt{static setLicenseServer(l){yI(Bt,l)}static get license(){return this._license}static set license(l){_I(Bt,l)}static get licenseServer(){return this._licenseServer}static set licenseServer(l){yI(Bt,l)}static get deviceFriendlyName(){return this._deviceFriendlyName}static set deviceFriendlyName(l){CI(Bt,l)}static initLicense(l,u){if(_I(Bt,l),Bt.bCallInitLicense=!0,u)return wI()}static setDeviceFriendlyName(l){CI(Bt,l)}static getDeviceFriendlyName(){return Bt._deviceFriendlyName}static getDeviceUUID(){return se(function*(){return yield Xh("dynamsoft_uuid",se(function*(){yield Dr();let l=new $m,u=At();Dt[u]=g=>{if(g.success)l.resolve(g.uuid);else{const p=Error(g.message);g.stack&&(p.stack=g.stack),l.reject(p)}},gt.postMessage({type:"getDeviceUUID",id:u}),EI=yield l})),EI})()}}Bt._pLoad=new $m,Bt.bPassValidation=!1,Bt.bCallInitLicense=!1,Bt._license=mU,Bt._licenseServer=[],Bt._deviceFriendlyName="",null==je.license&&(je.license=gI),$r.license={wasm:!0},pn.license.LicenseManager=Bt;const qm="1.2.10";"string"!=typeof je.std&&zr(je.std.version,qm)<0&&(je.std={version:qm,path:pI(gI+`../../dynamsoft-capture-vision-std@${qm}/dist/`)});const bI=f=>f&&"object"==typeof f&&"function"==typeof f.then;class Da extends Promise{constructor(l){let u,g;super((p,m)=>{u=p,g=m}),this._s="pending",this.resolve=p=>{this.isPending&&(bI(p)?this.task=p:(this._s="fulfilled",u(p)))},this.reject=p=>{this.isPending&&(this._s="rejected",g(p))},this.task=l}get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}get task(){return this._task}set task(l){var u=this;let g;this._task=l,bI(l)?g=l:"function"==typeof l&&(g=new Promise(l)),g&&se(function*(){try{const p=yield g;l===u._task&&u.resolve(p)}catch(p){l===u._task&&u.reject(p)}})()}get isEmpty(){return null==this._task}}class _U{constructor(l){this._cvr=l}getMaxBufferedItems(){var l=this;return se(function*(){return yield new Promise((u,g)=>{let p=At();Dt[p]=function(){var m=se(function*(v){if(v.success)return u(v.count);{let y=new Error(v.message);return y.stack=v.stack+"\n"+y.stack,g(y)}});return function(v){return m.apply(this,arguments)}}(),gt.postMessage({type:"cvr_getMaxBufferedItems",id:p,instanceID:l._cvr._instanceID})})})()}setMaxBufferedItems(l){var u=this;return se(function*(){return yield new Promise((g,p)=>{let m=At();Dt[m]=function(){var v=se(function*(y){if(y.success)return g();{let b=new Error(y.message);return b.stack=y.stack+"\n"+b.stack,p(b)}});return function(y){return v.apply(this,arguments)}}(),gt.postMessage({type:"cvr_setMaxBufferedItems",id:m,instanceID:u._cvr._instanceID,body:{count:l}})})})()}getBufferedCharacterItemSet(){var l=this;return se(function*(){return yield new Promise((u,g)=>{let p=At();Dt[p]=function(){var m=se(function*(v){if(v.success)return u(v.itemSet);{let y=new Error(v.message);return y.stack=v.stack+"\n"+y.stack,g(y)}});return function(v){return m.apply(this,arguments)}}(),gt.postMessage({type:"cvr_getBufferedCharacterItemSet",id:p,instanceID:l._cvr._instanceID})})})()}}var vU={onTaskResultsReceived:!1,onTaskResultsReceivedForDce:!1,onPredetectedRegionsReceived:!1,onLocalizedBarcodesReceived:!1,onDecodedBarcodesReceived:!1,onLocalizedTextLinesReceived:!1,onRecognizedTextLinesReceived:!1,onDetectedQuadsReceived:!1,onNormalizedImagesReceived:!1,onColourImageUnitReceived:!1,onScaledDownColourImageUnitReceived:!1,onGrayscaleImageUnitReceived:!1,onTransformedGrayscaleImageUnitReceived:!1,onEnhancedGrayscaleImageUnitReceived:!1,onBinaryImageUnitReceived:!1,onTextureDetectionResultUnitReceived:!1,onTextureRemovedGrayscaleImageUnitReceived:!1,onTextureRemovedBinaryImageUnitReceived:!1,onContoursUnitReceived:!1,onLineSegmentsUnitReceived:!1,onTextZonesUnitReceived:!1,onTextRemovedBinaryImageUnitReceived:!1,onLongLinesUnitReceived:!1,onCornersUnitReceived:!1,onCandidateQuadEdgesUnitReceived:!1,onCandidateBarcodeZonesUnitReceived:!1,onScaledUpBarcodeImageUnitReceived:!1,onDeformationResistedBarcodeImageUnitReceived:!1,onComplementedBarcodeImageUnitReceived:!1,onShortLinesUnitReceived:!1};const DI=(f,l)=>{for(let u in l._irrRegistryState)l._irrRegistryState[u]=!1;for(let u of f._intermediateResultReceiverSet)if(u.isDce)l._irrRegistryState.onTaskResultsReceivedForDce=!0;else for(let g in u)l._irrRegistryState[g]||(l._irrRegistryState[g]=!!u[g])};class yU{constructor(l){this._irrRegistryState=vU,this._cvr=l}addResultReceiver(l){var u=this;return se(function*(){if("object"!=typeof l)throw new Error("Invalid receiver.");u._cvr._intermediateResultReceiverSet.add(l),DI(u._cvr,u);let g=-1,p={};if(!l.isDce){if(!l._observedResultUnitTypes||!l._observedTaskMap)throw new Error("Invalid Intermediate Result Receiver.");g=l._observedResultUnitTypes,l._observedTaskMap.forEach((m,v)=>{p[v]=m}),l._observedTaskMap.clear()}return yield new Promise((m,v)=>{let y=At();Dt[y]=function(){var b=se(function*(O){if(O.success)return m();{let L=new Error(O.message);return L.stack=O.stack+"\n"+L.stack,v(L)}});return function(O){return b.apply(this,arguments)}}(),gt.postMessage({type:"cvr_setIrrRegistry",id:y,instanceID:u._cvr._instanceID,body:{receiverObj:u._irrRegistryState,observedResultUnitTypes:String(g),observedTaskMap:p}})})})()}removeResultReceiver(l){var u=this;return se(function*(){return u._cvr._intermediateResultReceiverSet.delete(l),DI(u._cvr,u),yield new Promise((g,p)=>{let m=At();Dt[m]=function(){var v=se(function*(y){if(y.success)return g();{let b=new Error(y.message);return b.stack=y.stack+"\n"+b.stack,p(b)}});return function(y){return v.apply(this,arguments)}}(),gt.postMessage({type:"cvr_setIrrRegistry",id:m,instanceID:u._cvr._instanceID,body:{receiverObj:u._irrRegistryState}})})})()}getOriginalImage(){return this._cvr._dsImage}}const SI="undefined"==typeof self,Zm=(()=>{if(!SI&&document.currentScript){let f=document.currentScript.src,l=f.indexOf("?");if(-1!=l)f=f.substring(0,l);else{let u=f.indexOf("#");-1!=u&&(f=f.substring(0,u))}return f.substring(0,f.lastIndexOf("/")+1)}return"./"})(),II=f=>{if(null==f&&(f="./"),!SI){let l=document.createElement("a");l.href=f,f=l.href}return f.endsWith("/")||(f+="/"),f};var Km;null==je.cvr&&(je.cvr=Zm),$r.cvr={js:!0,wasm:!0,deps:["license","dip"]},pn.cvr={};const Qm="1.2.10";"string"!=typeof je.std&&zr(je.std.version,Qm)<0&&(je.std={version:Qm,path:II(Zm+`../../dynamsoft-capture-vision-std@${Qm}/dist/`)});const Jm="2.2.30";(!je.dip||"string"!=typeof je.dip&&zr(je.dip.version,Jm)<0)&&(je.dip={version:Jm,path:II(Zm+`../../dynamsoft-image-processing@${Jm}/dist/`)});class TI{static getVersion(){return this._version}}var Qh,xI;function AI(f,l){if(f&&f.location){const u=f.location.points;for(let g of u)g.x=g.x/l,g.y=g.y/l;AI(f.referencedItem,l)}}TI._version=`2.2.30(Worker: ${null===(Km=po.cvr)||void 0===Km?void 0:Km.worker}, Wasm: loading...`,function(f){f[f.ISS_BUFFER_EMPTY=0]="ISS_BUFFER_EMPTY",f[f.ISS_EXHAUSTED=1]="ISS_EXHAUSTED"}(Qh||(Qh={})),function(f){f[f.IRUT_NULL=0]="IRUT_NULL",f[f.IRUT_COLOUR_IMAGE=1]="IRUT_COLOUR_IMAGE",f[f.IRUT_SCALED_DOWN_COLOUR_IMAGE=2]="IRUT_SCALED_DOWN_COLOUR_IMAGE",f[f.IRUT_GRAYSCALE_IMAGE=4]="IRUT_GRAYSCALE_IMAGE",f[f.IRUT_TRANSOFORMED_GRAYSCALE_IMAGE=8]="IRUT_TRANSOFORMED_GRAYSCALE_IMAGE",f[f.IRUT_ENHANCED_GRAYSCALE_IMAGE=16]="IRUT_ENHANCED_GRAYSCALE_IMAGE",f[f.IRUT_PREDETECTED_REGIONS=32]="IRUT_PREDETECTED_REGIONS",f[f.IRUT_BINARY_IMAGE=64]="IRUT_BINARY_IMAGE",f[f.IRUT_TEXTURE_DETECTION_RESULT=128]="IRUT_TEXTURE_DETECTION_RESULT",f[f.IRUT_TEXTURE_REMOVED_GRAYSCALE_IMAGE=256]="IRUT_TEXTURE_REMOVED_GRAYSCALE_IMAGE",f[f.IRUT_TEXTURE_REMOVED_BINARY_IMAGE=512]="IRUT_TEXTURE_REMOVED_BINARY_IMAGE",f[f.IRUT_CONTOURS=1024]="IRUT_CONTOURS",f[f.IRUT_LINE_SEGMENTS=2048]="IRUT_LINE_SEGMENTS",f[f.IRUT_TEXT_ZONES=4096]="IRUT_TEXT_ZONES",f[f.IRUT_TEXT_REMOVED_BINARY_IMAGE=8192]="IRUT_TEXT_REMOVED_BINARY_IMAGE",f[f.IRUT_CANDIDATE_BARCODE_ZONES=16384]="IRUT_CANDIDATE_BARCODE_ZONES",f[f.IRUT_LOCALIZED_BARCODES=32768]="IRUT_LOCALIZED_BARCODES",f[f.IRUT_SCALED_UP_BARCODE_IMAGE=65536]="IRUT_SCALED_UP_BARCODE_IMAGE",f[f.IRUT_DEFORMATION_RESISTED_BARCODE_IMAGE=131072]="IRUT_DEFORMATION_RESISTED_BARCODE_IMAGE",f[f.IRUT_COMPLEMENTED_BARCODE_IMAGE=262144]="IRUT_COMPLEMENTED_BARCODE_IMAGE",f[f.IRUT_DECODED_BARCODES=524288]="IRUT_DECODED_BARCODES",f[f.IRUT_LONG_LINES=1048576]="IRUT_LONG_LINES",f[f.IRUT_CORNERS=2097152]="IRUT_CORNERS",f[f.IRUT_CANDIDATE_QUAD_EDGES=4194304]="IRUT_CANDIDATE_QUAD_EDGES",f[f.IRUT_DETECTED_QUADS=8388608]="IRUT_DETECTED_QUADS",f[f.IRUT_LOCALIZED_TEXT_LINES=16777216]="IRUT_LOCALIZED_TEXT_LINES",f[f.IRUT_RECOGNIZED_TEXT_LINES=33554432]="IRUT_RECOGNIZED_TEXT_LINES",f[f.IRUT_NORMALIZED_IMAGES=67108864]="IRUT_NORMALIZED_IMAGES",f[f.IRUT_SHORT_LINES=134217728]="IRUT_SHORT_LINES",f[f.IRUT_ALL=134217727]="IRUT_ALL"}(xI||(xI={}));class St{constructor(){this.maxCvsSideLength=["iPhone","Android","HarmonyOS"].includes(sn.browserInfo.OS)?2048:4096,this._isa=null,this._dsImage=null,this._instanceID=void 0,this._bPauseScan=!0,this._bNeedOutputOriginalImage=!1,this._canvas=null,this._resultReceiverSet=new Set,this._isaStateListenerSet=new Set,this._resultFilterSet=new Set,this._intermediateResultReceiverSet=new Set,this._intermediateResultManager=null,this._bufferdItemsManager=null,this._bOpenDetectVerify=!1,this._bOpenNormalizeVerify=!1,this._bOpenBarcodeVerify=!1,this._bOpenLabelVerify=!1,this._minImageCaptureInterval=0,this._averageProcessintTimeArray=[],this._averageFetchImageTimeArray=[],this._currentSettings=null,this._averageTime=999,this._compressRate=0,this._dynamsoft=!1,this.captureInParallel=!0,this.bDestroyed=!1,this._singleFrameModeCallbackBind=this._singleFrameModeCallback.bind(this),this._promiseStartScan=null}get disposed(){return this.bDestroyed}static createInstance(){return se(function*(){if(!pn.license)throw Error("Module `license` is not existed.");yield pn.license.dynamsoft(),yield Dr(["cvr"]);const l=new St,u=new Da;let g=At();return Dt[g]=function(){var p=se(function*(m){var v;if(m.success)l._instanceID=m.instanceID,l._currentSettings=JSON.parse(m.outputSettings),TI._version=`2.2.30(Worker: ${null===(v=po.cvr)||void 0===v?void 0:v.worker}, Wasm: ${m.version})`,0===sn.bSupportDce4Module&&(l._intermediateResultManager=l.getIntermediateResultManager(!0)),u.resolve(l);else{const y=Error(m.message);m.stack&&(y.stack=m.stack),u.reject(y)}});return function(m){return p.apply(this,arguments)}}(),gt.postMessage({type:"cvr_createInstance",id:g}),u})()}_singleFrameModeCallback(l){var u=this;return se(function*(){u._isa.getCameraView().setScanLaserVisible(!0);for(let v of u._resultReceiverSet)u._bNeedOutputOriginalImage&&v.onOriginalImageResultReceived&&v.onOriginalImageResultReceived({imageData:l});const g={bytes:new Uint8Array(l.bytes),width:l.width,height:l.height,stride:l.stride,format:l.format,tag:l.tag};u._templateName||(u._templateName=u._currentSettings.CaptureVisionTemplates[0].Name);const p=yield u.capture(g,u._templateName);p.originalImageTag=l.tag;for(let v of u._resultReceiverSet)v.isDce&&v.onCapturedResultReceived(p,{isDetectVerifyOpen:!1,isNormalizeVerifyOpen:!1,isBarcodeVerifyOpen:!1,isLabelVerifyOpen:!1});const m={originalImageHashId:p.originalImageHashId,originalImageTag:p.originalImageTag,errorCode:p.errorCode,errorString:p.errorString};for(let v of u._resultReceiverSet)if(v.onDecodedBarcodesReceived&&p.barcodeResultItems&&v.onDecodedBarcodesReceived(Object.assign(Object.assign({},m),{barcodeResultItems:p.barcodeResultItems})),v.onRecognizedTextLinesReceived&&p.textLineResultItems&&v.onRecognizedTextLinesReceived(Object.assign(Object.assign({},m),{textLineResultItems:p.textLineResultItems})),v.onDetectedQuadsReceived&&p.detectedQuadResultItems&&v.onDetectedQuadsReceived(Object.assign(Object.assign({},m),{detectedQuadResultItems:p.detectedQuadResultItems})),v.onNormalizedImagesReceived&&p.normalizedImageResultItems&&v.onNormalizedImagesReceived(Object.assign(Object.assign({},m),{normalizedImageResultItems:p.normalizedImageResultItems})),v.onParsedResultsReceived&&p.parsedResultItems&&v.onParsedResultsReceived(Object.assign(Object.assign({},m),{parsedResultItems:p.parsedResultItems})),v.onCapturedResultReceived&&!v.isDce){if(u._bNeedOutputOriginalImage){const y=p.items.findIndex(b=>1===b.type);-1!==y&&(p.items[y].imageData=l)}v.onCapturedResultReceived(p)}})()}setInput(l){if(this._checkIsDisposed(),l){if(this._isa=l,l.isCameraEnhancer){this._intermediateResultManager&&(this._isa._intermediateResultReceiver.isDce=!0,this._intermediateResultManager.addResultReceiver(this._isa._intermediateResultReceiver));const u=this._isa.getCameraView();if(u){const g=u._capturedResultReceiver;g.isDce=!0,this._resultReceiverSet.add(g)}}}else this._isa=null}getInput(){return this._isa}addImageSourceStateListener(l){if(this._checkIsDisposed(),"object"!=typeof l)return console.warn("Invalid ISA state listener.");l&&Object.keys(l)&&this._isaStateListenerSet.add(l)}removeImageSourceStateListener(l){return this._checkIsDisposed(),this._isaStateListenerSet.delete(l)}addResultReceiver(l){if(this._checkIsDisposed(),"object"!=typeof l)throw new Error("Invalid receiver.");l&&Object.keys(l).length&&(this._resultReceiverSet.add(l),this._setCrrRegistry())}removeResultReceiver(l){this._checkIsDisposed(),this._resultReceiverSet.delete(l),this._setCrrRegistry()}_setCrrRegistry(){var l=this;return se(function*(){const u={onCapturedResultReceived:!1,onDecodedBarcodesReceived:!1,onRecognizedTextLinesReceived:!1,onDetectedQuadsReceived:!1,onNormalizedImagesReceived:!1,onParsedResultsReceived:!1};for(let m of l._resultReceiverSet)m.isDce||(u.onCapturedResultReceived=!!m.onCapturedResultReceived,u.onDecodedBarcodesReceived=!!m.onDecodedBarcodesReceived,u.onRecognizedTextLinesReceived=!!m.onRecognizedTextLinesReceived,u.onDetectedQuadsReceived=!!m.onDetectedQuadsReceived,u.onNormalizedImagesReceived=!!m.onNormalizedImagesReceived,u.onParsedResultsReceived=!!m.onParsedResultsReceived);const g=new Da;let p=At();return Dt[p]=function(){var m=se(function*(v){if(v.success)g.resolve();else{let y=new Error(v.message);y.stack=v.stack+"\n"+y.stack,g.reject()}});return function(v){return m.apply(this,arguments)}}(),gt.postMessage({type:"cvr_setCrrRegistry",id:p,instanceID:l._instanceID,body:{receiver:JSON.stringify(u)}}),g})()}addResultFilter(l){var u=this;return se(function*(){if(u._checkIsDisposed(),"object"!=typeof l)return console.warn("Invalid filter.");if(l&&Object.keys(l)){u._resultFilterSet.add(l),u._handleFilterSwitch();for(let g of u._resultFilterSet)yield u._enableResultCrossVerification(g.verificationEnabled),yield u._enableResultDeduplication(g.duplicateFilterEnabled),yield u._setDuplicateForgetTime(g.duplicateForgetTime)}})()}removeResultFilter(l){var u=this;return se(function*(){u._checkIsDisposed(),u._resultFilterSet.delete(l),u._handleFilterSwitch();for(let g of u._resultFilterSet)yield u._enableResultCrossVerification(g.verificationEnabled),yield u._enableResultDeduplication(g.duplicateFilterEnabled),yield u._setDuplicateForgetTime(g.duplicateForgetTime)})()}_handleFilterSwitch(){this._bOpenBarcodeVerify=!1,this._bOpenLabelVerify=!1,this._bOpenDetectVerify=!1,this._bOpenNormalizeVerify=!1;for(let l of this._resultFilterSet)l.isResultCrossVerificationEnabled(Yt.CRIT_BARCODE)&&(this._bOpenBarcodeVerify=!0),l.isResultCrossVerificationEnabled(Yt.CRIT_TEXT_LINE)&&(this._bOpenLabelVerify=!0),l.isResultCrossVerificationEnabled(Yt.CRIT_DETECTED_QUAD)&&(this._bOpenDetectVerify=!0),l.isResultCrossVerificationEnabled(Yt.CRIT_NORMALIZED_IMAGE)&&(this._bOpenNormalizeVerify=!0)}startCapturing(l){var u=this;return se(function*(){var g,p;if(u._checkIsDisposed(),!u._bPauseScan)return;if(!u._isa)throw new Error("'ImageSourceAdapter' is not set. call 'setInput' before 'startCapturing'");l||(l=u._currentSettings.CaptureVisionTemplates[0].Name);const m=yield u.containsTask(l);return yield Dr(m),m.includes("dlr")&&!(null===(g=pn.dlr)||void 0===g?void 0:g.bLoadConfusableCharsData)&&(yield null===(p=pn.dlr)||void 0===p?void 0:p.loadRecognitionData("ConfusableChars",je.dlr)),u._isa.isCameraEnhancer&&(m.includes("ddn")?u._isa.setPixelFormat(Ue.IPF_ABGR_8888):u._isa.setPixelFormat(Ue.IPF_GRAYSCALED)),void 0!==u._isa.singleFrameMode&&"disabled"!==u._isa.singleFrameMode?(u._templateName=l,void u._isa.on("singleFrameAcquired",u._singleFrameModeCallbackBind)):(u._isa.getColourChannelUsageType()===br.CCUT_AUTO&&u._isa.setColourChannelUsageType(m.includes("ddn")?br.CCUT_FULL_CHANNEL:br.CCUT_Y_CHANNEL_ONLY),u._promiseStartScan&&u._promiseStartScan.isPending?u._promiseStartScan:(u._promiseStartScan=new Da((v,y)=>{if(u.disposed)return;let b=At();Dt[b]=function(){var O=se(function*(L){if(u._promiseStartScan&&!u._promiseStartScan.isFulfilled){if(!L.success){let N=new Error(L.message);return N.stack=L.stack+"\n"+N.stack,y(N)}for(let N of u._resultFilterSet)yield u.addResultFilter(N);u._bPauseScan=!1,u._bNeedOutputOriginalImage=L.bNeedOutputOriginalImage,u._loopReadVideoTimeoutId&&clearTimeout(u._loopReadVideoTimeoutId),u._loopReadVideoTimeoutId=setTimeout(se(function*(){-1!==u._minImageCaptureInterval&&u._isa.startFetching(),u._loopReadVideo(l),v()}),0),u._isa.isCameraEnhancer&&u._isa.getCameraView().setScanLaserVisible(!0)}});return function(L){return O.apply(this,arguments)}}(),gt.postMessage({type:"cvr_startCapturing",id:b,instanceID:u._instanceID,body:{templateName:l}})}),yield u._promiseStartScan))})()}stopCapturing(){this._checkIsDisposed(),this._isa&&(this._isa.isCameraEnhancer&&(this._isa.getCameraView().setScanLaserVisible(!1),void 0!==this._isa.singleFrameMode&&"disabled"!==this._isa.singleFrameMode)?this._isa.off("singleFrameAcquired",this._singleFrameModeCallbackBind):(this._isa.stopFetching(),this._clearVerifyList(),this._averageProcessintTimeArray=[],this._averageTime=999,this._bPauseScan=!0,this._promiseStartScan=null,this._isa.setColourChannelUsageType(br.CCUT_AUTO)))}_clearVerifyList(){var l=this;return se(function*(){let u=At();const g=new Da;return Dt[u]=function(){var p=se(function*(m){if(m.success)return g.resolve();{let v=new Error(m.message);return v.stack=m.stack+"\n"+v.stack,g.reject(v)}});return function(m){return p.apply(this,arguments)}}(),gt.postMessage({type:"cvr_clearVerifyList",id:u,instanceID:l._instanceID}),g})()}_getIntermediateResult(){var l=this;return se(function*(){l._checkIsDisposed();let u=At();const g=new Da;return Dt[u]=function(){var p=se(function*(m){if(m.success)g.resolve(m.result);else{let v=new Error(m.message);v.stack=m.stack+"\n"+v.stack,g.reject(v)}});return function(m){return p.apply(this,arguments)}}(),gt.postMessage({type:"cvr_getIntermediateResult",id:u,instanceID:l._instanceID}),g})()}containsTask(l){var u=this;return se(function*(){return u._checkIsDisposed(),yield new Promise((g,p)=>{let m=At();Dt[m]=function(){var v=se(function*(y){if(y.success)return g(JSON.parse(y.tasks));{let b=new Error(y.message);return b.stack=y.stack+"\n"+b.stack,p(b)}});return function(y){return v.apply(this,arguments)}}(),gt.postMessage({type:"cvr_containsTask",id:m,instanceID:u._instanceID,body:{templateName:l}})})})()}_loopReadVideo(l){var u=this;return se(function*(){if(u._dynamsoft=!0,u.disposed||u._bPauseScan)return;if(u._isa.isBufferEmpty())if(u._isa.hasNextImageToFetch())for(let p of u._isaStateListenerSet)p.onImageSourceStateReceived&&p.onImageSourceStateReceived(Qh.ISS_BUFFER_EMPTY);else if(!u._isa.hasNextImageToFetch())for(let p of u._isaStateListenerSet)p.onImageSourceStateReceived&&p.onImageSourceStateReceived(Qh.ISS_EXHAUSTED);if(-1===u._minImageCaptureInterval||u._isa.isBufferEmpty())try{u._isa.isBufferEmpty()&&St._onLog&&St._onLog("buffer is empty so fetch image"),St._onLog&&St._onLog(`DCE: start fetching a frame: ${Date.now()}`),u._dsImage=u._isa.fetchImage(),St._onLog&&St._onLog(`DCE: finish fetching a frame: ${Date.now()}`),u._isa.setImageFetchInterval(u._averageTime)}catch(p){return void u._reRunCurrnetFunc(l)}else if(u._isa.setImageFetchInterval(u._averageTime-(u._dsImage&&u._dsImage.tag?u._dsImage.tag.timeSpent:0)),u._dsImage=u._isa.getImage(),u._dsImage.tag&&Date.now()-u._dsImage.tag.timeStamp>200)return void u._reRunCurrnetFunc(l);if(!u._dsImage)return void u._reRunCurrnetFunc(l);for(let p of u._resultReceiverSet)u._bNeedOutputOriginalImage&&p.onOriginalImageResultReceived&&p.onOriginalImageResultReceived({imageData:u._dsImage});const g=Date.now();u._captureDsimage(u._dsImage,l).then(function(){var p=se(function*(m){if(St._onLog&&St._onLog("no js handle time: "+(Date.now()-g)),u._bPauseScan)return void u._reRunCurrnetFunc(l);m.originalImageTag=u._dsImage.tag?u._dsImage.tag:null;for(let b of u._resultReceiverSet)if(b.isDce){const O=Date.now();if(b.onCapturedResultReceived(m,{isDetectVerifyOpen:u._bOpenDetectVerify,isNormalizeVerifyOpen:u._bOpenNormalizeVerify,isBarcodeVerifyOpen:u._bOpenBarcodeVerify,isLabelVerifyOpen:u._bOpenLabelVerify}),St._onLog){const L=Date.now()-O;L>10&&St._onLog(`draw result time: ${L}`)}}const v={originalImageHashId:m.originalImageHashId,originalImageTag:m.originalImageTag,errorCode:m.errorCode,errorString:m.errorString};for(let b of u._resultReceiverSet)b.onDecodedBarcodesReceived&&m.barcodeResultItems&&b.onDecodedBarcodesReceived(Object.assign(Object.assign({},v),{barcodeResultItems:m.barcodeResultItems.filter(O=>!O.isFilter)})),b.onRecognizedTextLinesReceived&&m.textLineResultItems&&b.onRecognizedTextLinesReceived(Object.assign(Object.assign({},v),{textLineResultItems:m.textLineResultItems.filter(O=>!O.isFilter)})),b.onDetectedQuadsReceived&&m.detectedQuadResultItems&&b.onDetectedQuadsReceived(Object.assign(Object.assign({},v),{detectedQuadResultItems:m.detectedQuadResultItems.filter(O=>!O.isFilter)})),b.onNormalizedImagesReceived&&m.normalizedImageResultItems&&b.onNormalizedImagesReceived(Object.assign(Object.assign({},v),{normalizedImageResultItems:m.normalizedImageResultItems.filter(O=>!O.isFilter)})),b.onParsedResultsReceived&&m.parsedResultItems&&b.onParsedResultsReceived(Object.assign(Object.assign({},v),{parsedResultItems:m.parsedResultItems.filter(O=>!O.isFilter)})),b.onCapturedResultReceived&&!b.isDce&&(m.items=m.items.filter(O=>!O.isFilter),m.barcodeResultItems&&(m.barcodeResultItems=m.barcodeResultItems.filter(O=>!O.isFilter)),m.textLineResultItems&&(m.textLineResultItems=m.textLineResultItems.filter(O=>!O.isFilter)),m.detectedQuadResultItems&&(m.detectedQuadResultItems=m.detectedQuadResultItems.filter(O=>!O.isFilter)),m.normalizedImageResultItems&&(m.normalizedImageResultItems=m.normalizedImageResultItems.filter(O=>!O.isFilter)),m.parsedResultItems&&(m.parsedResultItems=m.parsedResultItems.filter(O=>!O.isFilter)),b.onCapturedResultReceived(m));const y=Date.now();if(u._minImageCaptureInterval>-1&&(5===u._averageProcessintTimeArray.length&&u._averageProcessintTimeArray.shift(),5===u._averageFetchImageTimeArray.length&&u._averageFetchImageTimeArray.shift(),u._averageProcessintTimeArray.push(Date.now()-g),u._averageFetchImageTimeArray.push(u._dsImage&&u._dsImage.tag?u._dsImage.tag.timeSpent:0),u._averageTime=Math.min(...u._averageProcessintTimeArray)-Math.max(...u._averageFetchImageTimeArray),u._averageTime=u._averageTime>0?u._averageTime:0,St._onLog&&(St._onLog(`minImageCaptureInterval: ${u._minImageCaptureInterval}`),St._onLog(`averageProcessintTimeArray: ${u._averageProcessintTimeArray}`),St._onLog(`averageFetchImageTimeArray: ${u._averageFetchImageTimeArray}`),St._onLog(`averageTime: ${u._averageTime}`))),St._onLog){const b=Date.now()-y;b>10&&St._onLog(`fetch image calculate time: ${b}`)}St._onLog&&St._onLog(`time finish decode: ${Date.now()}`),St._onLog&&St._onLog("main time: "+(Date.now()-g)),St._onLog&&St._onLog("===================================================="),u._loopReadVideoTimeoutId&&clearTimeout(u._loopReadVideoTimeoutId),u._loopReadVideoTimeoutId=u._minImageCaptureInterval>0&&u._minImageCaptureInterval>=u._averageTime?setTimeout(()=>{u._loopReadVideo(l)},u._minImageCaptureInterval-u._averageTime):setTimeout(()=>{u._loopReadVideo(l)},Math.max(u._minImageCaptureInterval,0))});return function(m){return p.apply(this,arguments)}}()).catch(p=>{u._isa.stopFetching(),u._loopReadVideoTimeoutId&&clearTimeout(u._loopReadVideoTimeoutId),u._loopReadVideoTimeoutId=setTimeout(()=>{u._isa.startFetching(),u._loopReadVideo(l)},Math.max(u._minImageCaptureInterval,1e3)),"platform error"!==p.message&&setTimeout(()=>{throw p},0)})})()}_reRunCurrnetFunc(l){this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout(()=>{this._loopReadVideo(l)},0)}capture(l,u){var g=this;return se(function*(){var p,m;g._checkIsDisposed(),u||(u=g._currentSettings.CaptureVisionTemplates[0].Name);const v=yield g.containsTask(u);let y;if(yield Dr(v),v.includes("dlr")&&!(null===(p=pn.dlr)||void 0===p?void 0:p.bLoadConfusableCharsData)&&(yield null===(m=pn.dlr)||void 0===m?void 0:m.loadRecognitionData("ConfusableChars",je.dlr)),g._dynamsoft=!1,QS(l))y=yield g._captureDsimage(l,u);else if("string"==typeof l)y="data:image/"==l.substring(0,11)?yield g._captureBase64(l,u):yield g._captureUrl(l,u);else if(l instanceof Blob)y=yield g._captureBlob(l,u);else if(l instanceof HTMLImageElement)y=yield g._captureImage(l,u);else if(l instanceof HTMLCanvasElement)y=yield g._captureCanvas(l,u);else{if(!(l instanceof HTMLVideoElement))throw new TypeError("'capture(imageOrFile, templateName)': Type of 'imageOrFile' should be 'DSImageData', 'Url', 'Base64', 'Blob', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement'.");y=yield g._captureVideo(l,u)}return y})()}_captureDsimage(l,u){var g=this;return se(function*(){return yield g._captureInWorker(l,u)})()}_captureUrl(l,u){var g=this;return se(function*(){let p=yield JS(l,"blob");return yield g._captureBlob(p,u)})()}_captureBase64(l,u){var g=this;return se(function*(){l=l.substring(l.indexOf(",")+1);let p=atob(l),m=p.length,v=new Uint8Array(m);for(;m--;)v[m]=p.charCodeAt(m);return yield g._captureBlob(new Blob([v]),u)})()}_captureBlob(l,u){var g=this;return se(function*(){let p=null,m=null;if("undefined"!=typeof createImageBitmap)try{p=yield createImageBitmap(l)}catch(y){}var y;p||(m=yield(y=se(function*(b){return yield new Promise((O,L)=>{let N=URL.createObjectURL(b),B=new Image;B.src=N,B.onload=()=>{URL.revokeObjectURL(B.dbrObjUrl),O(B)},B.onerror=U=>{L(new Error("Can't convert blob to image : "+(U instanceof Event?U.type:U)))}})}),function(b){return y.apply(this,arguments)})(l));let v=yield g._captureImage(p||m,u);return p&&p.close(),v})()}_captureImage(l,u){var g=this;return se(function*(){let p,m,v=l instanceof HTMLImageElement?l.naturalWidth:l.width,y=l instanceof HTMLImageElement?l.naturalHeight:l.height,b=Math.max(v,y);b>g.maxCvsSideLength?(g._compressRate=g.maxCvsSideLength/b,p=Math.round(v*g._compressRate),m=Math.round(y*g._compressRate)):(p=v,m=y),g._canvas||(g._canvas=document.createElement("canvas"));const O=g._canvas;return O.width===p&&O.height===m||(O.width=p,O.height=m),O.ctx2d||(O.ctx2d=O.getContext("2d",{willReadFrequently:!0})),O.ctx2d.drawImage(l,0,0,v,y,0,0,p,m),l.dbrObjUrl&&URL.revokeObjectURL(l.dbrObjUrl),yield g._captureCanvas(O,u)})()}_captureCanvas(l,u){var g=this;return se(function*(){if(l.crossOrigin&&"anonymous"!=l.crossOrigin)throw"cors";if([l.width,l.height].includes(0))throw Error("The width or height of the 'canvas' is 0.");const p=l.ctx2d||l.getContext("2d",{willReadFrequently:!0}),m={bytes:Uint8Array.from(p.getImageData(0,0,l.width,l.height).data),width:l.width,height:l.height,stride:4*l.width,format:10};return yield g._captureInWorker(m,u)})()}_captureVideo(l,u){var g=this;return se(function*(){if(l.crossOrigin&&"anonymous"!=l.crossOrigin)throw"cors";let p,m,v=l.videoWidth,y=l.videoHeight,b=Math.max(v,y);b>g.maxCvsSideLength?(g._compressRate=g.maxCvsSideLength/b,p=Math.round(v*g._compressRate),m=Math.round(y*g._compressRate)):(p=v,m=y),g._canvas||(g._canvas=document.createElement("canvas"));const O=g._canvas;return O.width===p&&O.height===m||(O.width=p,O.height=m),O.ctx2d||(O.ctx2d=O.getContext("2d",{willReadFrequently:!0})),O.ctx2d.drawImage(l,0,0,v,y,0,0,p,m),yield g._captureCanvas(O,u)})()}_captureInWorker(l,u){var g=this;return se(function*(){const{bytes:p,width:m,height:v,stride:y,format:b}=l;let O=At();const L=new Da;return Dt[O]=function(){var N=se(function*(B){var U,W;if(!B.success){let Y=new Error(B.message);return Y.stack=B.stack+"\n"+Y.stack,L.reject(Y)}{const Y=Date.now();St._onLog&&(St._onLog(`get result time from worker: ${Y}`),St._onLog("worker to main time consume: "+(Y-B.workerReturnMsgTime)));try{const $=B.captureResult;l.bytes=B.bytes;for(let X of $.items)0!==g._compressRate&&AI(X,g._compressRate),X.type===Yt.CRIT_ORIGINAL_IMAGE?X.imageData=l:X.type===Yt.CRIT_NORMALIZED_IMAGE?null===(U=pn.ddn)||void 0===U||U.handleNormalizedImageResultItem(X):X.type===Yt.CRIT_PARSED_RESULT&&(null===(W=pn.dcp)||void 0===W||W.handleParsedResultItem(X));if(g._dynamsoft)for(let X of g._resultFilterSet)X.onDecodedBarcodesReceived($.items),X.onRecognizedTextLinesReceived($.items),X.onDetectedQuadsReceived($.items),X.onNormalizedImagesReceived($.items);const q=function(X){const Q={barcodeResultItems:[],textLineResultItems:[],detectedQuadResultItems:[],normalizedImageResultItems:[],parsedResultItems:[]};return X.items.forEach(pe=>{pe.type===Yt.CRIT_BARCODE?Q.barcodeResultItems.push(pe):pe.type===Yt.CRIT_TEXT_LINE?Q.textLineResultItems.push(pe):pe.type===Yt.CRIT_DETECTED_QUAD?Q.detectedQuadResultItems.push(pe):pe.type===Yt.CRIT_NORMALIZED_IMAGE?Q.normalizedImageResultItems.push(pe):pe.type===Yt.CRIT_PARSED_RESULT&&Q.parsedResultItems.push(pe)}),Q}($);if(q.barcodeResultItems.length&&($.barcodeResultItems=q.barcodeResultItems),q.textLineResultItems.length&&($.textLineResultItems=q.textLineResultItems),q.detectedQuadResultItems.length&&($.detectedQuadResultItems=q.detectedQuadResultItems),q.normalizedImageResultItems.length&&($.normalizedImageResultItems=q.normalizedImageResultItems),q.parsedResultItems.length&&($.parsedResultItems=q.parsedResultItems),!g._bPauseScan||!g._dynamsoft){const X=$.intermediateResult;if(X){let Q=0;for(let pe of g._intermediateResultReceiverSet){Q++;for(let ve of X){if("onTaskResultsReceived"===ve.info.callbackName){for(let Te of ve.intermediateResultUnits)Te.originalImageTag=l.tag?l.tag:null;pe[ve.info.callbackName]&&pe[ve.info.callbackName]({intermediateResultUnits:ve.intermediateResultUnits},ve.info)}else pe[ve.info.callbackName]&&pe[ve.info.callbackName](ve.result,ve.info);Q===g._intermediateResultReceiverSet.size&&delete ve.info.callbackName}}}$&&$.intermediateResult&&delete $.intermediateResult}return g._compressRate=0,L.resolve($)}catch($){return L.reject($)}}});return function(B){return N.apply(this,arguments)}}(),St._onLog&&St._onLog(`send buffer to worker: ${Date.now()}`),gt.postMessage({type:"cvr_capture",id:O,instanceID:g._instanceID,body:{bytes:p,width:m,height:v,stride:y,format:b,templateName:u||"",dynamsoft:g._dynamsoft}},[p.buffer]),L})()}initSettings(l){var u=this;return se(function*(){return u._checkIsDisposed(),l&&["string","object"].includes(typeof l)?("string"==typeof l?l.startsWith("{")?u._currentSettings=JSON.parse(l):l=yield JS(l,"text"):"object"==typeof l&&(u._currentSettings=l,l=JSON.stringify(l)),yield new Promise((g,p)=>{let m=At();Dt[m]=function(){var v=se(function*(y){if(y.success){const b=JSON.parse(y.response);if(0!==b.exception){let N=new Error(b.description?b.description:"Init Settings Failed.");return N.errorCode=b.exception,p(N)}let O=[],L=JSON.parse(l).CaptureVisionTemplates;for(let N=0;N{let m=At();Dt[m]=function(){var v=se(function*(y){if(y.success){const b=JSON.parse(y.settings);if(0!==b.errorCode){let O=new Error(b.errorString);return O.errorCode=b.errorCode,p(O)}return delete b.errorCode,delete b.errorString,g(b)}{let b=new Error(y.message);return b.stack=y.stack+"\n"+b.stack,p(b)}});return function(y){return v.apply(this,arguments)}}(),gt.postMessage({type:"cvr_outputSettings",id:m,instanceID:u._instanceID,body:{templateName:l||"*"}})})})()}outputSettingsToFile(l,u,g){var p=this;return se(function*(){const m=yield p.outputSettings(l),v=new Blob([JSON.stringify(m,null,2,function(y,b){return b instanceof Array?JSON.stringify(b):b},2)],{type:"application/json"});if(g){const y=document.createElement("a");y.href=URL.createObjectURL(v),u.endsWith(".json")&&(u=u.replace(".json","")),y.download=`${u}.json`,y.onclick=()=>{setTimeout(()=>{URL.revokeObjectURL(y.href)},500)},y.click()}return v})()}getSimplifiedSettings(l){var u=this;return se(function*(){u._checkIsDisposed(),l||(l=u._currentSettings.CaptureVisionTemplates[0].Name);const g=yield u.containsTask(l);return yield Dr(g),yield new Promise((p,m)=>{let v=At();Dt[v]=function(){var y=se(function*(b){if(b.success){const O=JSON.parse(b.settings,(L,N)=>uU&&"barcodeFormatIds"===L?BigInt(N):N);if(O.minImageCaptureInterval=u._minImageCaptureInterval,0!==O.code){let L=new Error(O.codeString);return L.errorCode=O.errorCode,m(L)}return delete O.code,delete O.codeString,p(O)}{let O=new Error(b.message);return O.stack=b.stack+"\n"+O.stack,m(O)}});return function(b){return y.apply(this,arguments)}}(),gt.postMessage({type:"cvr_getSimplifiedSettings",id:v,instanceID:u._instanceID,body:{templateName:l}})})})()}updateSettings(l,u){var g=this;return se(function*(){g._checkIsDisposed();const p=yield g.containsTask(l);return yield Dr(p),yield new Promise((m,v)=>{let y=At();Dt[y]=function(){var b=se(function*(O){if(O.success){const L=JSON.parse(O.response);if(u.minImageCaptureInterval&&u.minImageCaptureInterval>=-1&&(g._minImageCaptureInterval=u.minImageCaptureInterval),g._bNeedOutputOriginalImage=O.bNeedOutputOriginalImage,0!==L.exception){let N=new Error(L.description?L.description:"Update Settings Failed.");return N.errorCode=L.exception,v(N)}return g._currentSettings=yield g.outputSettings("*"),m(L)}{let L=new Error(O.message);return L.stack=O.stack+"\n"+L.stack,v(L)}});return function(O){return b.apply(this,arguments)}}(),gt.postMessage({type:"cvr_updateSettings",id:y,instanceID:g._instanceID,body:{settings:u,templateName:l}})})})()}resetSettings(){var l=this;return se(function*(){return l._checkIsDisposed(),yield new Promise((u,g)=>{let p=At();Dt[p]=function(){var m=se(function*(v){if(v.success){const y=JSON.parse(v.response);if(0!==y.exception){let b=new Error(y.description?y.description:"Reset Settings Failed.");return b.errorCode=y.exception,g(b)}return l._currentSettings=yield l.outputSettings("*"),u(y)}{let y=new Error(v.message);return y.stack=v.stack+"\n"+y.stack,g(y)}});return function(v){return m.apply(this,arguments)}}(),gt.postMessage({type:"cvr_resetSettings",id:p,instanceID:l._instanceID})})})()}getBufferedItemsManager(){return this._bufferdItemsManager||(this._bufferdItemsManager=new _U(this)),this._bufferdItemsManager}getIntermediateResultManager(l){if(this._checkIsDisposed(),!l&&0!==sn.bSupportIRTModule)throw new Error("The current license does not support the use of intermediate results.");return this._intermediateResultManager||(this._intermediateResultManager=new yU(this)),this._intermediateResultManager}contains(l,u){return function(g,p){let m=p.x,v=p.y,y=g[0].x,b=g[0].y,O=g[1].x,L=g[1].y,N=g[2].x,B=g[2].y,U=g[3].x,W=g[3].y,Y=Q(m,v,y,b,O,L),$=Q(m,v,O,L,N,B),q=Q(m,v,N,B,U,W),X=Q(m,v,U,W,y,b);function Q(pe,ve,Te,Ae,P,Ee){return(pe-Te)*(Ee-Ae)-(ve-Ae)*(P-Te)}return Y>=0&&$>=0&&q>=0&&X>=0||Y<=0&&$<=0&&q<=0&&X<=0}(l,u)}parseRequiredResources(l){var u=this;return se(function*(){return u._checkIsDisposed(),yield new Promise((g,p)=>{let m=At();Dt[m]=function(){var v=se(function*(y){if(y.success)return g(JSON.parse(y.resources));{let b=new Error(y.message);return b.stack=y.stack+"\n"+b.stack,p(b)}});return function(y){return v.apply(this,arguments)}}(),gt.postMessage({type:"cvr_parseRequiredResources",id:m,instanceID:u._instanceID,body:{templateName:l}})})})()}dispose(){var l=this;return se(function*(){l._checkIsDisposed(),l._promiseStartScan&&l.stopCapturing(),l._isa=null,l._resultReceiverSet.clear(),l._isaStateListenerSet.clear(),l._resultFilterSet.clear(),l.bDestroyed=!0;let u=At();Dt[u]=g=>{if(!g.success){let p=new Error(g.message);throw p.stack=g.stack+"\n"+p.stack,p}},gt.postMessage({type:"cvr_dispose",id:u,instanceID:l._instanceID})})()}_enableResultCrossVerification(l){var u=this;return se(function*(){return u._checkIsDisposed(),yield new Promise((g,p)=>{let m=At();Dt[m]=function(){var v=se(function*(y){if(y.success)return g(y.result);{let b=new Error(y.message);return b.stack=y.stack+"\n"+b.stack,p(b)}});return function(y){return v.apply(this,arguments)}}(),gt.postMessage({type:"cvr_enableResultCrossVerification",id:m,instanceID:u._instanceID,body:{verificationEnabled:l}})})})()}_enableResultDeduplication(l){var u=this;return se(function*(){return u._checkIsDisposed(),yield new Promise((g,p)=>{let m=At();Dt[m]=function(){var v=se(function*(y){if(y.success)return g(y.result);{let b=new Error(y.message);return b.stack=y.stack+"\n"+b.stack,p(b)}});return function(y){return v.apply(this,arguments)}}(),gt.postMessage({type:"cvr_enableResultDeduplication",id:m,instanceID:u._instanceID,body:{duplicateFilterEnabled:l}})})})()}_setDuplicateForgetTime(l){var u=this;return se(function*(){return u._checkIsDisposed(),yield new Promise((g,p)=>{let m=At();Dt[m]=function(){var v=se(function*(y){if(y.success)return g(y.result);{let b=new Error(y.message);return b.stack=y.stack+"\n"+b.stack,p(b)}});return function(y){return v.apply(this,arguments)}}(),gt.postMessage({type:"cvr_setDuplicateForgetTime",id:m,instanceID:u._instanceID,body:{duplicateForgetTime:l}})})})()}_getDuplicateForgetTime(l){var u=this;return se(function*(){return u._checkIsDisposed(),yield new Promise((g,p)=>{let m=At();Dt[m]=function(){var v=se(function*(y){if(y.success)return g(y.time);{let b=new Error(y.message);return b.stack=y.stack+"\n"+b.stack,p(b)}});return function(y){return v.apply(this,arguments)}}(),gt.postMessage({type:"cvr_getDuplicateForgetTime",id:m,instanceID:u._instanceID,body:{type:l}})})})()}_setThresholdValue(l,u,g){var p=this;return se(function*(){return yield Dr("ddn"),yield new Promise((m,v)=>{let y=At();Dt[y]=function(){var b=se(function*(O){if(O.success)return m();{let L=new Error(O.message);return L.stack=O.stack+"\n"+L.stack,v(L)}});return function(O){return b.apply(this,arguments)}}(),gt.postMessage({type:"ddn_setThresholdValue",id:y,instanceID:p._instanceID,body:{threshold:l,leftLimit:u,rightLimit:g}})})})()}_checkIsDisposed(){if(this.disposed)throw new Error('"CaptureVisionRouter" instance has been disposed')}}const e_="undefined"==typeof self,CU=(()=>{if(!e_&&document.currentScript){let f=document.currentScript.src,l=f.indexOf("?");if(-1!=l)f=f.substring(0,l);else{let u=f.indexOf("#");-1!=u&&(f=f.substring(0,u))}return f.substring(0,f.lastIndexOf("/")+1)}return"./"})();function j(f,l,u,g){if("a"===u&&!g)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof l?f!==l||!g:!l.has(f))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===u?g:"a"===u?g.call(f):g?g.value:l.get(f)}function Le(f,l,u,g,p){if("m"===g)throw new TypeError("Private method is not writable");if("a"===g&&!p)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof l?f!==l||!p:!l.has(f))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===g?p.call(f,u):p?p.value=u:l.set(f,u),u}let _c,Xr,Jh,ed,Ln;null==je.dce&&(je.dce=CU),$r.dce={wasm:!1,js:!1},pn.dce={},"function"==typeof SuppressedError&&SuppressedError,"undefined"!=typeof navigator&&(_c=navigator,Xr=_c.userAgent,Jh=_c.platform,ed=_c.mediaDevices),function(){if(!e_){const f={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:_c.vendor,search:"Apple",verSearch:["Version","iPhone OS","CPU OS"]},Firefox:null,Explorer:{search:"MSIE",verSearch:"MSIE"}},l={HarmonyOS:null,Android:null,iPhone:null,iPad:null,Windows:{str:Jh,search:"Win"},Mac:{str:Jh},Linux:{str:Jh}};let u="unknownBrowser",g=0,p="unknownOS";for(let m in f){const v=f[m]||{};let O=v.verStr||Xr,L=v.verSearch||m;if(L instanceof Array||(L=[L]),-1!=(v.str||Xr).indexOf(v.search||m)){u=m;for(let N of L){let B=O.indexOf(N);if(-1!=B){g=parseFloat(O.substring(B+N.length+1));break}}break}}for(let m in l){const v=l[m]||{};if(-1!=(v.str||Xr).indexOf(v.search||m)){p=m;break}}"Linux"==p&&-1!=Xr.indexOf("Windows NT")&&(p="HarmonyOS"),Ln={browser:u,version:g,OS:p}}e_&&(Ln={browser:"ssr",version:0,OS:"ssr"})}();const wU="undefined"!=typeof WebAssembly&&Xr&&!(/Safari/.test(Xr)&&!/Chrome/.test(Xr)&&/\(.+\s11_2_([2-6]).*\)/.test(Xr)),EU="undefined"!=typeof Worker,RI=!(!ed||!ed.getUserMedia),bU=function(){var f=se(function*(){let l=!1;if(RI)try{(yield ed.getUserMedia({video:!0})).getTracks().forEach(u=>{u.stop()}),l=!0}catch(u){}return l});return function(){return f.apply(this,arguments)}}();var DU={653:(f,l,u)=>{var g,p,m,v,y,b,O,L,N,B,W,Y,$,q,X,Q,pe,ve,Te,Ae,S,w,D,T,P=P||{version:"5.2.1"};if(l.fabric=P,"undefined"!=typeof document&&"undefined"!=typeof window)P.document=document instanceof("undefined"!=typeof HTMLDocument?HTMLDocument:Document)?document:document.implementation.createHTMLDocument(""),P.window=window;else{var Ee=new(u(192).JSDOM)(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]},resources:"usable"}).window;P.document=Ee.document,P.jsdomImplForWrapper=u(898).implForWrapper,P.nodeCanvas=u(245).Canvas,P.window=Ee,DOMParser=P.window.DOMParser}function Be(S,w){var D=S.canvas,T=w.targetCanvas,_=T.getContext("2d");_.translate(0,T.height),_.scale(1,-1),_.drawImage(D,0,D.height-T.height,T.width,T.height,0,0,T.width,T.height)}function et(S,w){var D=w.targetCanvas.getContext("2d"),T=w.destinationWidth,_=w.destinationHeight,C=T*_*4,I=new Uint8Array(this.imageBuffer,0,C),M=new Uint8ClampedArray(this.imageBuffer,0,C);S.readPixels(0,0,T,_,S.RGBA,S.UNSIGNED_BYTE,I);var x=new ImageData(M,T,_);D.putImageData(x,0,0)}P.isTouchSupported="ontouchstart"in P.window||"ontouchstart"in P.document||P.window&&P.window.navigator&&P.window.navigator.maxTouchPoints>0,P.isLikelyNode="undefined"!=typeof Buffer&&"undefined"==typeof window,P.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"],P.DPI=96,P.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",P.commaWsp="(?:\\s+,?\\s*|,\\s*)",P.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/gi,P.reNonWord=/[ \n\.,;!\?\-]/,P.fontPaths={},P.iMatrix=[1,0,0,1,0,0],P.svgNS="http://www.w3.org/2000/svg",P.perfLimitSizeTotal=2097152,P.maxCacheSideLimit=4096,P.minCacheSideLimit=256,P.charWidthsCache={},P.textureSize=2048,P.disableStyleCopyPaste=!1,P.enableGLFiltering=!0,P.devicePixelRatio=P.window.devicePixelRatio||P.window.webkitDevicePixelRatio||P.window.mozDevicePixelRatio||1,P.browserShadowBlurConstant=1,P.arcToSegmentsCache={},P.boundsOfCurveCache={},P.cachesBoundsOfCurve=!0,P.forceGLPutImageData=!1,P.initFilterBackend=function(){return P.enableGLFiltering&&P.isWebglSupported&&P.isWebglSupported(P.textureSize)?(console.log("max texture size: "+P.maxTextureSize),new P.WebglFilterBackend({tileSize:P.textureSize})):P.Canvas2dFilterBackend?new P.Canvas2dFilterBackend:void 0},"undefined"!=typeof document&&"undefined"!=typeof window&&(window.fabric=P),function(){function S(D,T){if(this.__eventListeners[D]){var _=this.__eventListeners[D];T?_[_.indexOf(T)]=!1:P.util.array.fill(_,!1)}}function w(D,T){var _=function(){T.apply(this,arguments),this.off(D,_)}.bind(this);this.on(D,_)}P.Observable={fire:function(D,T){if(!this.__eventListeners)return this;var _=this.__eventListeners[D];if(!_)return this;for(var C=0,I=_.length;C-1||!!w&&this._objects.some(function(D){return"function"==typeof D.contains&&D.contains(S,!0)})},complexity:function(){return this._objects.reduce(function(S,w){return S+(w.complexity?w.complexity():0)},0)}},P.CommonMethods={_setOptions:function(S){for(var w in S)this.set(w,S[w])},_initGradient:function(S,w){!S||!S.colorStops||S instanceof P.Gradient||this.set(w,new P.Gradient(S))},_initPattern:function(S,w,D){!S||!S.source||S instanceof P.Pattern?D&&D():this.set(w,new P.Pattern(S,D))},_setObject:function(S){for(var w in S)this._set(w,S[w])},set:function(S,w){return"object"==typeof S?this._setObject(S):this._set(S,w),this},_set:function(S,w){this[S]=w},toggle:function(S){var w=this.get(S);return"boolean"==typeof w&&this.set(S,!w),this},get:function(S){return this[S]}},g=l,p=Math.sqrt,m=Math.atan2,v=Math.pow,y=Math.PI/180,b=Math.PI/2,P.util={cos:function(S){if(0===S)return 1;switch(S<0&&(S=-S),S/b){case 1:case 3:return 0;case 2:return-1}return Math.cos(S)},sin:function(S){if(0===S)return 0;var w=1;switch(S<0&&(w=-1),S/b){case 1:return w;case 2:return 0;case 3:return-w}return Math.sin(S)},removeFromArray:function(S,w){var D=S.indexOf(w);return-1!==D&&S.splice(D,1),S},getRandomInt:function(S,w){return Math.floor(Math.random()*(w-S+1))+S},degreesToRadians:function(S){return S*y},radiansToDegrees:function(S){return S/y},rotatePoint:function(S,w,D){var T=new P.Point(S.x-w.x,S.y-w.y),_=P.util.rotateVector(T,D);return new P.Point(_.x,_.y).addEquals(w)},rotateVector:function(S,w){var D=P.util.sin(w),T=P.util.cos(w);return{x:S.x*T-S.y*D,y:S.x*D+S.y*T}},createVector:function(S,w){return new P.Point(w.x-S.x,w.y-S.y)},calcAngleBetweenVectors:function(S,w){return Math.acos((S.x*w.x+S.y*w.y)/(Math.hypot(S.x,S.y)*Math.hypot(w.x,w.y)))},getHatVector:function(S){return new P.Point(S.x,S.y).multiply(1/Math.hypot(S.x,S.y))},getBisector:function(S,w,D){var T=P.util.createVector(S,w),_=P.util.createVector(S,D),C=P.util.calcAngleBetweenVectors(T,_),I=C*(0===P.util.calcAngleBetweenVectors(P.util.rotateVector(T,C),_)?1:-1)/2;return{vector:P.util.getHatVector(P.util.rotateVector(T,I)),angle:C}},projectStrokeOnPoints:function(S,w,D){var T=[],_=w.strokeWidth/2,C=w.strokeUniform?new P.Point(1/w.scaleX,1/w.scaleY):new P.Point(1,1),I=function(M){var x=_/Math.hypot(M.x,M.y);return new P.Point(M.x*x*C.x,M.y*x*C.y)};return S.length<=1||S.forEach(function(M,x){var A,F,k=new P.Point(M.x,M.y);0===x?(F=S[x+1],A=D?I(P.util.createVector(F,k)).addEquals(k):S[S.length-1]):x===S.length-1?(A=S[x-1],F=D?I(P.util.createVector(A,k)).addEquals(k):S[0]):(A=S[x-1],F=S[x+1]);var V,H,G=P.util.getBisector(k,A,F),z=G.vector;if("miter"===w.strokeLineJoin&&(V=-_/Math.sin(G.angle/2),H=new P.Point(z.x*V*C.x,z.y*V*C.y),Math.hypot(H.x,H.y)/_<=w.strokeMiterLimit))return T.push(k.add(H)),void T.push(k.subtract(H));V=-_*Math.SQRT2,H=new P.Point(z.x*V*C.x,z.y*V*C.y),T.push(k.add(H)),T.push(k.subtract(H))}),T},transformPoint:function(S,w,D){return D?new P.Point(w[0]*S.x+w[2]*S.y,w[1]*S.x+w[3]*S.y):new P.Point(w[0]*S.x+w[2]*S.y+w[4],w[1]*S.x+w[3]*S.y+w[5])},makeBoundingBoxFromPoints:function(S,w){if(w)for(var D=0;D0&&(w>T?w-=T:w=0,D>T?D-=T:D=0);var _,C=!0,I=S.getImageData(w,D,2*T||1,2*T||1),M=I.data.length;for(_=3;_=ie?re-ie:2*Math.PI-(ie-re)}function C(H,G,z){for(var le=function(oe,he,fe,ne,te,ae,ge){var ue=Math.PI,me=ge*ue/180,Ie=P.util.sin(me),be=P.util.cos(me),Ce=0,Se=0,De=-be*oe*.5-Ie*he*.5,xe=-be*he*.5+Ie*oe*.5,Ve=(fe=Math.abs(fe))*fe,Me=(ne=Math.abs(ne))*ne,lt=xe*xe,It=De*De,Bi=Ve*Me-Ve*lt-Me*It,cs=0;if(Bi<0){var $a=Math.sqrt(1-Bi/(Ve*Me));fe*=$a,ne*=$a}else cs=(te===ae?-1:1)*Math.sqrt(Bi/(Ve*lt+Me*It));var Zt=cs*fe*xe/ne,Vi=-cs*ne*De/fe,Wc=be*Zt-Ie*Vi+.5*oe,Xa=Ie*Zt+be*Vi+.5*he,So=_(1,0,(De-Zt)/fe,(xe-Vi)/ne),qa=_((De-Zt)/fe,(xe-Vi)/ne,(-De-Zt)/fe,(-xe-Vi)/ne);0===ae&&qa>0?qa-=2*ue:1===ae&&qa<0&&(qa+=2*ue);for(var _T=Math.ceil(Math.abs(qa/ue*2)),Nd=[],zc=qa/_T,oj=8/3*Math.sin(zc/4)*Math.sin(zc/4)/Math.sin(zc/2),X_=So+zc,Yc=0;Yc<_T;Yc++)Nd[Yc]=T(So,X_,be,Ie,fe,ne,Wc,Xa,oj,Ce,Se),Ce=Nd[Yc][5],Se=Nd[Yc][6],So=X_,X_+=zc;return Nd}(z[6]-H,z[7]-G,z[1],z[2],z[4],z[5],z[3]),ee=0,J=le.length;eeIe)for(var Ce=1,Se=fe.length;Ce2;for(ee&&(ce=H[2].xH[z-2].x?1:ie.x===H[z-2].x?0:-1,le=ie.y>H[z-2].y?1:ie.y===H[z-2].y?0:-1),Z.push(["L",ie.x+ce*G,ie.y+le*G]),Z},P.util.getPathSegmentsInfo=V,P.util.getBoundsOfCurve=function(H,G,z,Z,ie,re,de,ce){var le;if(P.cachesBoundsOfCurve&&(le=S.call(arguments),P.boundsOfCurveCache[le]))return P.boundsOfCurveCache[le];var ee,J,oe,he,fe,ne,te,ae,ge=Math.sqrt,ue=Math.min,me=Math.max,Ie=Math.abs,be=[],Ce=[[],[]];J=6*H-12*z+6*ie,ee=-3*H+9*z-9*ie+3*de,oe=3*z-3*H;for(var Se=0;Se<2;++Se)if(Se>0&&(J=6*G-12*Z+6*re,ee=-3*G+9*Z-9*re+3*ce,oe=3*Z-3*G),Ie(ee)<1e-12){if(Ie(J)<1e-12)continue;0<(he=-oe/J)&&he<1&&be.push(he)}else(te=J*J-4*oe*ee)<0||(0<(fe=(-J+(ae=ge(te)))/(2*ee))&&fe<1&&be.push(fe),0<(ne=(-J-ae)/(2*ee))&&ne<1&&be.push(ne));for(var De,Ve,Me=be.length,lt=Me;Me--;)De=(Ve=1-(he=be[Me]))*Ve*Ve*H+3*Ve*Ve*he*z+3*Ve*he*he*ie+he*he*he*de,Ce[0][Me]=De,Ce[1][Me]=Ve*Ve*Ve*G+3*Ve*Ve*he*Z+3*Ve*he*he*re+he*he*he*ce;Ce[0][lt]=H,Ce[1][lt]=G,Ce[0][lt+1]=de,Ce[1][lt+1]=ce;var It=[{x:ue.apply(null,Ce[0]),y:ue.apply(null,Ce[1])},{x:me.apply(null,Ce[0]),y:me.apply(null,Ce[1])}];return P.cachesBoundsOfCurve&&(P.boundsOfCurveCache[le]=It),It},P.util.getPointOnPath=function(H,G,z){z||(z=V(H));for(var Z=0;G-z[Z].length>0&&Z1e-4;)oe=ae(ne),fe=ne,(he=I(ge.x,ge.y,oe.x,oe.y))+te>J?(ne-=ue,ue/=2):(ge=oe,ne+=ue,te+=he);return oe.angle=me(fe),oe}(re,G)}},P.util.transformPath=function(H,G,z){return z&&(G=P.util.multiplyTransformMatrices(G,[1,0,0,1,-z.x,-z.y])),H.map(function(Z){for(var ie=Z.slice(0),re={},de=1;de=C})}}}(),function(){function S(w,D,T){if(T)if(!P.isLikelyNode&&D instanceof Element)w=D;else if(D instanceof Array){w=[];for(var _=0,C=D.length;_57343)return w.charAt(D);if(55296<=T&&T<=56319){if(w.length<=D+1)throw"High surrogate without following low surrogate";var _=w.charCodeAt(D+1);if(56320>_||_>57343)throw"High surrogate without following low surrogate";return w.charAt(D)+w.charAt(D+1)}if(0===D)throw"Low surrogate without preceding high surrogate";var C=w.charCodeAt(D-1);if(55296>C||C>56319)throw"Low surrogate without preceding high surrogate";return!1}P.util.string={camelize:function(w){return w.replace(/-+(.)?/g,function(D,T){return T?T.toUpperCase():""})},capitalize:function(w,D){return w.charAt(0).toUpperCase()+(D?w.slice(1):w.slice(1).toLowerCase())},escapeXml:function(w){return w.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")},graphemeSplit:function(w){var D,T=0,_=[];for(T=0;T-1?function(F){return function(){var k=this.constructor.superclass;this.constructor.superclass=x;var V=M[F].apply(this,arguments);if(this.constructor.superclass=k,"initialize"!==F)return V}}(A):M[A],D&&(M.toString!==Object.prototype.toString&&(I.prototype.toString=M.toString),M.valueOf!==Object.prototype.valueOf&&(I.prototype.valueOf=M.valueOf))};function _(){}function C(I){for(var M=null,x=this;x.constructor.superclass;){var A=x.constructor.superclass.prototype[I];if(x[I]!==A){M=A;break}x=x.constructor.superclass.prototype}return M?arguments.length>1?M.apply(this,S.call(arguments,1)):M.call(this):console.log("tried to callSuper "+I+", method not found in prototype chain",this)}P.util.createClass=function(){var I=null,M=S.call(arguments,0);function x(){this.initialize.apply(this,arguments)}"function"==typeof M[0]&&(I=M.shift()),x.superclass=I,x.subclasses=[],I&&(_.prototype=I.prototype,x.prototype=new _,I.subclasses.push(x));for(var A=0,F=M.length;A-1||"touch"===S.pointerType},B="string"==typeof(N=P.document.createElement("div")).style.opacity,W=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,Y=function(S){return S},B?Y=function(S,w){return S.style.opacity=w,S}:"string"==typeof N.style.filter&&(Y=function(S,w){var D=S.style;return S.currentStyle&&!S.currentStyle.hasLayout&&(D.zoom=1),W.test(D.filter)?D.filter=D.filter.replace(W,w=w>=.9999?"":"alpha(opacity="+100*w+")"):D.filter+=" alpha(opacity="+100*w+")",S}),P.util.setStyle=function(S,w){var D=S.style;if(!D)return S;if("string"==typeof w)return S.style.cssText+=";"+w,w.indexOf("opacity")>-1?Y(S,w.match(/opacity:\s*(\d?\.?\d*)/)[1]):S;for(var T in w)"opacity"===T?Y(S,w[T]):D["float"===T||"cssFloat"===T?void 0===D.styleFloat?"cssFloat":"styleFloat":T]=w[T];return S},function(){var S,w,D,T,_=Array.prototype.slice,C=function(x){return _.call(x,0)};try{S=C(P.document.childNodes)instanceof Array}catch(x){}function I(x,A){var F=P.document.createElement(x);for(var k in A)"class"===k?F.className=A[k]:"for"===k?F.htmlFor=A[k]:F.setAttribute(k,A[k]);return F}function M(x){for(var A=0,F=0,k=P.document.documentElement,V=P.document.body||{scrollLeft:0,scrollTop:0};x&&(x.parentNode||x.host)&&((x=x.parentNode||x.host)===P.document?(A=V.scrollLeft||k.scrollLeft||0,F=V.scrollTop||k.scrollTop||0):(A+=x.scrollLeft||0,F+=x.scrollTop||0),1!==x.nodeType||"fixed"!==x.style.position););return{left:A,top:F}}S||(C=function(x){for(var A=new Array(x.length),F=x.length;F--;)A[F]=x[F];return A}),w=P.document.defaultView&&P.document.defaultView.getComputedStyle?function(x,A){var F=P.document.defaultView.getComputedStyle(x,null);return F?F[A]:void 0}:function(x,A){var F=x.style[A];return!F&&x.currentStyle&&(F=x.currentStyle[A]),F},T="userSelect"in(D=P.document.documentElement.style)?"userSelect":"MozUserSelect"in D?"MozUserSelect":"WebkitUserSelect"in D?"WebkitUserSelect":"KhtmlUserSelect"in D?"KhtmlUserSelect":"",P.util.makeElementUnselectable=function(x){return void 0!==x.onselectstart&&(x.onselectstart=P.util.falseFunction),T?x.style[T]="none":"string"==typeof x.unselectable&&(x.unselectable="on"),x},P.util.makeElementSelectable=function(x){return void 0!==x.onselectstart&&(x.onselectstart=null),T?x.style[T]="":"string"==typeof x.unselectable&&(x.unselectable=""),x},P.util.setImageSmoothing=function(x,A){x.imageSmoothingEnabled=x.imageSmoothingEnabled||x.webkitImageSmoothingEnabled||x.mozImageSmoothingEnabled||x.msImageSmoothingEnabled||x.oImageSmoothingEnabled,x.imageSmoothingEnabled=A},P.util.getById=function(x){return"string"==typeof x?P.document.getElementById(x):x},P.util.toArray=C,P.util.addClass=function(x,A){x&&-1===(" "+x.className+" ").indexOf(" "+A+" ")&&(x.className+=(x.className?" ":"")+A)},P.util.makeElement=I,P.util.wrapElement=function(x,A,F){return"string"==typeof A&&(A=I(A,F)),x.parentNode&&x.parentNode.replaceChild(A,x),A.appendChild(x),A},P.util.getScrollLeftTop=M,P.util.getElementOffset=function(x){var A,F,k=x&&x.ownerDocument,V={left:0,top:0},H={left:0,top:0},G={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!k)return H;for(var z in G)H[G[z]]+=parseInt(w(x,z),10)||0;return A=k.documentElement,void 0!==x.getBoundingClientRect&&(V=x.getBoundingClientRect()),F=M(x),{left:V.left+F.left-(A.clientLeft||0)+H.left,top:V.top+F.top-(A.clientTop||0)+H.top}},P.util.getNodeCanvas=function(x){var A=P.jsdomImplForWrapper(x);return A._canvas||A._image},P.util.cleanUpJsdomNode=function(x){if(P.isLikelyNode){var A=P.jsdomImplForWrapper(x);A&&(A._image=null,A._canvas=null,A._currentSrc=null,A._attributes=null,A._classList=null)}}}(),function(){function S(){}P.util.request=function(w,D){D||(D={});var M,x,T=D.method?D.method.toUpperCase():"GET",_=D.onComplete||function(){},C=new P.window.XMLHttpRequest,I=D.body||D.parameters;return C.onreadystatechange=function(){4===C.readyState&&(_(C),C.onreadystatechange=S)},"GET"===T&&(I=null,"string"==typeof D.parameters&&(x=D.parameters,w=(M=w)+(/\?/.test(M)?"&":"?")+x)),C.open(T,w,!0),"POST"!==T&&"PUT"!==T||C.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),C.send(I),C}}(),P.log=console.log,P.warn=console.warn,function(){var S=P.util.object.extend,w=P.util.object.clone,D=[];function T(){return!1}function _(x,A,F,k){return-F*Math.cos(x/k*(Math.PI/2))+F+A}P.util.object.extend(D,{cancelAll:function(){var x=this.splice(0);return x.forEach(function(A){A.cancel()}),x},cancelByCanvas:function(x){if(!x)return[];var A=this.filter(function(F){return"object"==typeof F.target&&F.target.canvas===x});return A.forEach(function(F){F.cancel()}),A},cancelByTarget:function(x){var A=this.findAnimationsByTarget(x);return A.forEach(function(F){F.cancel()}),A},findAnimationIndex:function(x){return this.indexOf(this.findAnimation(x))},findAnimation:function(x){return this.find(function(A){return A.cancel===x})},findAnimationsByTarget:function(x){return x?this.filter(function(A){return A.target===x}):[]}});var C=P.window.requestAnimationFrame||P.window.webkitRequestAnimationFrame||P.window.mozRequestAnimationFrame||P.window.oRequestAnimationFrame||P.window.msRequestAnimationFrame||function(x){return P.window.setTimeout(x,1e3/60)},I=P.window.cancelAnimationFrame||P.window.clearTimeout;function M(){return C.apply(P.window,arguments)}P.util.animate=function(x){x||(x={});var A,F=!1,k=function(){var V=P.runningAnimations.indexOf(A);return V>-1&&P.runningAnimations.splice(V,1)[0]};return A=S(w(x),{cancel:function(){return F=!0,k()},currentValue:"startValue"in x?x.startValue:0,completionRate:0,durationRate:0}),P.runningAnimations.push(A),M(function(V){var H,G=V||+new Date,z=x.duration||500,Z=G+z,ie=x.onChange||T,re=x.abort||T,de=x.onComplete||T,ce=x.easing||_,le="startValue"in x&&x.startValue.length>0,ee="startValue"in x?x.startValue:0,J="endValue"in x?x.endValue:100,oe=x.byValue||(le?ee.map(function(he,fe){return J[fe]-ee[fe]}):J-ee);x.onStart&&x.onStart(),function he(fe){var ne=(H=fe||+new Date)>Z?z:H-G,te=ne/z,ae=le?ee.map(function(ue,me){return ce(ne,ee[me],oe[me],z)}):ce(ne,ee,oe,z),ge=Math.abs(le?(ae[0]-ee[0])/oe[0]:(ae-ee)/oe);if(A.currentValue=le?ae.slice():ae,A.completionRate=ge,A.durationRate=te,!F){if(!re(ae,ge,te))return H>Z?(A.currentValue=le?J.slice():J,A.completionRate=1,A.durationRate=1,ie(le?J.slice():J,1,1),de(J,1,1),void k()):(ie(ae,ge,te),void M(he));k()}}(G)}),A.cancel},P.util.requestAnimFrame=M,P.util.cancelAnimFrame=function(){return I.apply(P.window,arguments)},P.runningAnimations=D}(),function(){function S(w,D,T){var _="rgba("+parseInt(w[0]+T*(D[0]-w[0]),10)+","+parseInt(w[1]+T*(D[1]-w[1]),10)+","+parseInt(w[2]+T*(D[2]-w[2]),10);return(_+=","+(w&&D?parseFloat(w[3]+T*(D[3]-w[3])):1))+")"}P.util.animateColor=function(w,D,T,_){var C=new P.Color(w).getSource(),I=new P.Color(D).getSource(),M=_.onComplete,x=_.onChange;return P.util.animate(P.util.object.extend(_=_||{},{duration:T||500,startValue:C,endValue:I,byValue:I,easing:function(A,F,k,V){return S(F,k,_.colorEasing?_.colorEasing(A,V):1-Math.cos(A/V*(Math.PI/2)))},onComplete:function(A,F,k){if(M)return M(S(I,I,0),F,k)},onChange:function(A,F,k){if(x){if(Array.isArray(A))return x(S(A,A,0),F,k);x(A,F,k)}}}))}}(),function(){function S(_,C,I,M){return _-1&&ae>-1&&ae-1)&&(J="stroke")}else{if("href"===ee||"xlink:href"===ee||"font"===ee)return J;if("imageSmoothing"===ee)return"optimizeQuality"===J;fe=ne?J.map(C):C(J,he)}}else J="";return!ne&&isNaN(fe)?J:fe}function H(ee){return new RegExp("^("+ee.join("|")+")\\b","i")}function G(ee,J){var he,fe,ne,te=[];for(fe=0,ne=J.length;fe1;)ue.shift(),me=w.util.multiplyTransformMatrices(me,ue[0]);return me}}();var re=new RegExp("^\\s*("+w.reNum+"+)\\s*,?\\s*("+w.reNum+"+)\\s*,?\\s*("+w.reNum+"+)\\s*,?\\s*("+w.reNum+"+)\\s*$");function de(ee){if(!w.svgViewBoxElementsRegEx.test(ee.nodeName))return{};var J,oe,he,fe,ne,te,ae=ee.getAttribute("viewBox"),ge=1,ue=1,me=ee.getAttribute("width"),Ie=ee.getAttribute("height"),be=ee.getAttribute("x")||0,Ce=ee.getAttribute("y")||0,Se=ee.getAttribute("preserveAspectRatio")||"",De=!ae||!(ae=ae.match(re)),xe=!me||!Ie||"100%"===me||"100%"===Ie,Ve=De&&xe,Me={},lt="",It=0,Bi=0;if(Me.width=0,Me.height=0,Me.toBeParsed=Ve,De&&(be||Ce)&&ee.parentNode&&"#document"!==ee.parentNode.nodeName&&(lt=" translate("+C(be)+" "+C(Ce)+") ",ne=(ee.getAttribute("transform")||"")+lt,ee.setAttribute("transform",ne),ee.removeAttribute("x"),ee.removeAttribute("y")),Ve)return Me;if(De)return Me.width=C(me),Me.height=C(Ie),Me;if(J=-parseFloat(ae[1]),oe=-parseFloat(ae[2]),he=parseFloat(ae[3]),fe=parseFloat(ae[4]),Me.minX=J,Me.minY=oe,Me.viewBoxWidth=he,Me.viewBoxHeight=fe,xe?(Me.width=he,Me.height=fe):(Me.width=C(me),Me.height=C(Ie),ge=Me.width/he,ue=Me.height/fe),"none"!==(Se=w.util.parsePreserveAspectRatioAttribute(Se)).alignX&&("meet"===Se.meetOrSlice&&(ue=ge=ge>ue?ue:ge),"slice"===Se.meetOrSlice&&(ue=ge=ge>ue?ge:ue),It=Me.width-he*ge,Bi=Me.height-fe*ge,"Mid"===Se.alignX&&(It/=2),"Mid"===Se.alignY&&(Bi/=2),"Min"===Se.alignX&&(It=0),"Min"===Se.alignY&&(Bi=0)),1===ge&&1===ue&&0===J&&0===oe&&0===be&&0===Ce)return Me;if((be||Ce)&&"#document"!==ee.parentNode.nodeName&&(lt=" translate("+C(be)+" "+C(Ce)+") "),ne=lt+" matrix("+ge+" 0 0 "+ue+" "+(J*ge+It)+" "+(oe*ue+Bi)+") ","svg"===ee.nodeName){for(te=ee.ownerDocument.createElementNS(w.svgNS,"g");ee.firstChild;)te.appendChild(ee.firstChild);ee.appendChild(te)}else(te=ee).removeAttribute("x"),te.removeAttribute("y"),ne=te.getAttribute("transform")+ne;return te.setAttribute("transform",ne),Me}function ce(ee,J){var oe="xlink:href",he=ie(ee,J.getAttribute(oe).slice(1));if(he&&he.getAttribute(oe)&&ce(ee,he),["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"].forEach(function(ne){he&&!J.hasAttribute(ne)&&he.hasAttribute(ne)&&J.setAttribute(ne,he.getAttribute(ne))}),!J.children.length)for(var fe=he.cloneNode(!0);fe.firstChild;)J.appendChild(fe.firstChild);J.removeAttribute(oe)}w.parseSVGDocument=function(ee,J,oe,he){if(ee){!function(be){for(var Ce=G(be,["use","svg:use"]),Se=0;Ce.length&&SeT.x&&this.y>T.y},gte:function(T){return this.x>=T.x&&this.y>=T.y},lerp:function(T,_){return void 0===_&&(_=.5),_=Math.max(Math.min(1,_),0),new D(this.x+(T.x-this.x)*_,this.y+(T.y-this.y)*_)},distanceFrom:function(T){var _=this.x-T.x,C=this.y-T.y;return Math.sqrt(_*_+C*C)},midPointFrom:function(T){return this.lerp(T)},min:function(T){return new D(Math.min(this.x,T.x),Math.min(this.y,T.y))},max:function(T){return new D(Math.max(this.x,T.x),Math.max(this.y,T.y))},toString:function(){return this.x+","+this.y},setXY:function(T,_){return this.x=T,this.y=_,this},setX:function(T){return this.x=T,this},setY:function(T){return this.y=T,this},setFromPoint:function(T){return this.x=T.x,this.y=T.y,this},swap:function(T){var _=this.x,C=this.y;this.x=T.x,this.y=T.y,T.x=_,T.y=C},clone:function(){return new D(this.x,this.y)}})}(l),function(S){var w=S.fabric||(S.fabric={});function D(T){this.status=T,this.points=[]}w.Intersection?w.warn("fabric.Intersection is already defined"):(w.Intersection=D,w.Intersection.prototype={constructor:D,appendPoint:function(T){return this.points.push(T),this},appendPoints:function(T){return this.points=this.points.concat(T),this}},w.Intersection.intersectLineLine=function(T,_,C,I){var M,x=(I.x-C.x)*(T.y-C.y)-(I.y-C.y)*(T.x-C.x),A=(_.x-T.x)*(T.y-C.y)-(_.y-T.y)*(T.x-C.x),F=(I.y-C.y)*(_.x-T.x)-(I.x-C.x)*(_.y-T.y);if(0!==F){var k=x/F,V=A/F;0<=k&&k<=1&&0<=V&&V<=1?(M=new D("Intersection")).appendPoint(new w.Point(T.x+k*(_.x-T.x),T.y+k*(_.y-T.y))):M=new D}else M=new D(0===x||0===A?"Coincident":"Parallel");return M},w.Intersection.intersectLinePolygon=function(T,_,C){var x,A,F=new D,k=C.length;for(A=0;A0&&(F.status="Intersection"),F},w.Intersection.intersectPolygonPolygon=function(T,_){var C,I=new D,M=T.length;for(C=0;C0&&(I.status="Intersection"),I},w.Intersection.intersectPolygonRectangle=function(T,_,C){var I=_.min(C),M=_.max(C),x=new w.Point(M.x,I.y),A=new w.Point(I.x,M.y),F=D.intersectLinePolygon(I,x,T),k=D.intersectLinePolygon(x,M,T),V=D.intersectLinePolygon(M,A,T),H=D.intersectLinePolygon(A,I,T),G=new D;return G.appendPoints(F.points),G.appendPoints(k.points),G.appendPoints(V.points),G.appendPoints(H.points),G.points.length>0&&(G.status="Intersection"),G})}(l),function(S){var w=S.fabric||(S.fabric={});function D(_){_?this._tryParsingColor(_):this.setSource([0,0,0,1])}function T(_,C,I){return I<0&&(I+=1),I>1&&(I-=1),I<1/6?_+6*(C-_)*I:I<.5?C:I<2/3?_+(C-_)*(2/3-I)*6:_}w.Color?w.warn("fabric.Color is already defined."):(w.Color=D,w.Color.prototype={_tryParsingColor:function(_){var C;_ in D.colorNameMap&&(_=D.colorNameMap[_]),"transparent"===_&&(C=[255,255,255,0]),C||(C=D.sourceFromHex(_)),C||(C=D.sourceFromRgb(_)),C||(C=D.sourceFromHsl(_)),C||(C=[0,0,0,1]),C&&this.setSource(C)},_rgbToHsl:function(_,C,I){var M,x,A,F=w.util.array.max([_/=255,C/=255,I/=255]),k=w.util.array.min([_,C,I]);if(A=(F+k)/2,F===k)M=x=0;else{var V=F-k;switch(x=A>.5?V/(2-F-k):V/(F+k),F){case _:M=(C-I)/V+(C0)-(ne<0)||+ne};function H(ne,te){var ae=ne.angle+k(Math.atan2(te.y,te.x))+360;return Math.round(ae%360/45)}function G(ne,te){var ae=te.transform.target,ge=ae.canvas,ue=w.util.object.clone(te);ue.target=ae,ge&&ge.fire("object:"+ne,ue),ae.fire(ne,te)}function z(ne,te){var ae=te.canvas,ge=ne[ae.uniScaleKey];return ae.uniformScaling&&!ge||!ae.uniformScaling&&ge}function Z(ne){return ne.originX===A&&ne.originY===A}function ie(ne,te,ae){var ge=ne.lockScalingX,ue=ne.lockScalingY;return!((!ge||!ue)&&(te||!ge&&!ue||!ae)&&(!ge||"x"!==te)&&(!ue||"y"!==te))}function re(ne,te,ae,ge){return{e:ne,transform:te,pointer:{x:ae,y:ge}}}function de(ne){return function(te,ae,ge,ue){var me=ae.target,Ie=me.getCenterPoint(),be=me.translateToOriginPoint(Ie,ae.originX,ae.originY),Ce=ne(te,ae,ge,ue);return me.setPositionByOrigin(be,ae.originX,ae.originY),Ce}}function ce(ne,te){return function(ae,ge,ue,me){var Ie=te(ae,ge,ue,me);return Ie&&G(ne,re(ae,ge,ue,me)),Ie}}function le(ne,te,ae,ge,ue){var me=ne.target,Ie=me.controls[ne.corner],be=me.canvas.getZoom(),Ce=me.padding/be,Se=me.toLocalPoint(new w.Point(ge,ue),te,ae);return Se.x>=Ce&&(Se.x-=Ce),Se.x<=-Ce&&(Se.x+=Ce),Se.y>=Ce&&(Se.y-=Ce),Se.y<=Ce&&(Se.y+=Ce),Se.x-=Ie.offsetX,Se.y-=Ie.offsetY,Se}function ee(ne){return ne.flipX!==ne.flipY}function J(ne,te,ae,ge,ue){if(0!==ne[te]){var me=ue/ne._getTransformedDimensions()[ge]*ne[ae];ne.set(ae,me)}}function oe(ne,te,ae,ge){var ue,me=te.target,Ie=me._getTransformedDimensions(0,me.skewY),be=le(te,te.originX,te.originY,ae,ge),Ce=Math.abs(2*be.x)-Ie.x,Se=me.skewX;Ce<2?ue=0:(ue=k(Math.atan2(Ce/me.scaleX,Ie.y/me.scaleY)),te.originX===C&&te.originY===x&&(ue=-ue),te.originX===M&&te.originY===I&&(ue=-ue),ee(me)&&(ue=-ue));var De=Se!==ue;if(De){var xe=me._getTransformedDimensions().y;me.set("skewX",ue),J(me,"skewY","scaleY","y",xe)}return De}function he(ne,te,ae,ge){var ue,me=te.target,Ie=me._getTransformedDimensions(me.skewX,0),be=le(te,te.originX,te.originY,ae,ge),Ce=Math.abs(2*be.y)-Ie.y,Se=me.skewY;Ce<2?ue=0:(ue=k(Math.atan2(Ce/me.scaleY,Ie.x/me.scaleX)),te.originX===C&&te.originY===x&&(ue=-ue),te.originX===M&&te.originY===I&&(ue=-ue),ee(me)&&(ue=-ue));var De=Se!==ue;if(De){var xe=me._getTransformedDimensions().x;me.set("skewY",ue),J(me,"skewX","scaleX","x",xe)}return De}function fe(ne,te,ae,ge,ue){var me,Ie,be,Ce,Se,De,xe=te.target,Ve=xe.lockScalingX,Me=xe.lockScalingY,lt=(ue=ue||{}).by,It=z(ne,xe),Bi=ie(xe,lt,It),cs=te.gestureScale;if(Bi)return!1;if(cs)Ie=te.scaleX*cs,be=te.scaleY*cs;else{if(me=le(te,te.originX,te.originY,ae,ge),Se="y"!==lt?V(me.x):1,De="x"!==lt?V(me.y):1,te.signX||(te.signX=Se),te.signY||(te.signY=De),xe.lockScalingFlip&&(te.signX!==Se||te.signY!==De))return!1;if(Ce=xe._getTransformedDimensions(),It&&!lt){var $a=Math.abs(me.x)+Math.abs(me.y),Zt=te.original,Vi=$a/(Math.abs(Ce.x*Zt.scaleX/xe.scaleX)+Math.abs(Ce.y*Zt.scaleY/xe.scaleY));Ie=Zt.scaleX*Vi,be=Zt.scaleY*Vi}else Ie=Math.abs(me.x*xe.scaleX/Ce.x),be=Math.abs(me.y*xe.scaleY/Ce.y);Z(te)&&(Ie*=2,be*=2),te.signX!==Se&&"y"!==lt&&(te.originX=F[te.originX],Ie*=-1,te.signX=Se),te.signY!==De&&"x"!==lt&&(te.originY=F[te.originY],be*=-1,te.signY=De)}var Wc=xe.scaleX,Xa=xe.scaleY;return lt?("x"===lt&&xe.set("scaleX",Ie),"y"===lt&&xe.set("scaleY",be)):(!Ve&&xe.set("scaleX",Ie),!Me&&xe.set("scaleY",be)),Wc!==xe.scaleX||Xa!==xe.scaleY}_.scaleCursorStyleHandler=function(ne,te,ae){var ge=z(ne,ae),ue="";if(0!==te.x&&0===te.y?ue="x":0===te.x&&0!==te.y&&(ue="y"),ie(ae,ue,ge))return"not-allowed";var me=H(ae,te);return D[me]+"-resize"},_.skewCursorStyleHandler=function(ne,te,ae){if(0!==te.x&&ae.lockSkewingY||0!==te.y&&ae.lockSkewingX)return"not-allowed";var ue=H(ae,te)%4;return T[ue]+"-resize"},_.scaleSkewCursorStyleHandler=function(ne,te,ae){return ne[ae.canvas.altActionKey]?_.skewCursorStyleHandler(ne,te,ae):_.scaleCursorStyleHandler(ne,te,ae)},_.rotationWithSnapping=ce("rotating",de(function(ne,te,ae,ge){var ue=te,me=ue.target,Ie=me.translateToOriginPoint(me.getCenterPoint(),ue.originX,ue.originY);if(me.lockRotation)return!1;var be,Ce=Math.atan2(ue.ey-Ie.y,ue.ex-Ie.x),Se=Math.atan2(ge-Ie.y,ae-Ie.x),De=k(Se-Ce+ue.theta);if(me.snapAngle>0){var xe=me.snapAngle,Ve=me.snapThreshold||xe,Me=Math.ceil(De/xe)*xe,lt=Math.floor(De/xe)*xe;Math.abs(De-lt)0?C:M:(Ie>0&&(ue=be===I?C:M),Ie<0&&(ue=be===I?M:C),ee(me)&&(ue=ue===C?M:C)),te.originX=ue,ce("skewing",de(oe))(ne,te,ae,ge))},_.skewHandlerY=function(ne,te,ae,ge){var ue,me=te.target,Ie=me.skewY,be=te.originX;return!me.lockSkewingY&&(0===Ie?ue=le(te,A,A,ae,ge).y>0?I:x:(Ie>0&&(ue=be===C?I:x),Ie<0&&(ue=be===C?x:I),ee(me)&&(ue=ue===I?x:I)),te.originY=ue,ce("skewing",de(he))(ne,te,ae,ge))},_.dragHandler=function(ne,te,ae,ge){var ue=te.target,me=ae-te.offsetX,Ie=ge-te.offsetY,be=!ue.get("lockMovementX")&&ue.left!==me,Ce=!ue.get("lockMovementY")&&ue.top!==Ie;return be&&ue.set("left",me),Ce&&ue.set("top",Ie),(be||Ce)&&G("moving",re(ne,te,ae,ge)),be||Ce},_.scaleOrSkewActionName=function(ne,te,ae){var ge=ne[ae.canvas.altActionKey];return 0===te.x?ge?"skewX":"scaleY":0===te.y?ge?"skewY":"scaleX":void 0},_.rotationStyleHandler=function(ne,te,ae){return ae.lockRotation?"not-allowed":te.cursorStyle},_.fireEvent=G,_.wrapWithFixedAnchor=de,_.wrapWithFireEvent=ce,_.getLocalPoint=le,w.controlsUtils=_}(l),w=(S=l).fabric||(S.fabric={}),D=w.util.degreesToRadians,(T=w.controlsUtils).renderCircleControl=function(_,C,I,M,x){M=M||{};var A,F=this.sizeX||M.cornerSize||x.cornerSize,k=this.sizeY||M.cornerSize||x.cornerSize,V=void 0!==M.transparentCorners?M.transparentCorners:x.transparentCorners,H=V?"stroke":"fill",G=!V&&(M.cornerStrokeColor||x.cornerStrokeColor),z=C,Z=I;_.save(),_.fillStyle=M.cornerColor||x.cornerColor,_.strokeStyle=M.cornerStrokeColor||x.cornerStrokeColor,F>k?(A=F,_.scale(1,k/F),Z=I*F/k):k>F?(A=k,_.scale(F/k,1),z=C*k/F):A=F,_.lineWidth=1,_.beginPath(),_.arc(z,Z,A/2,0,2*Math.PI,!1),_[H](),G&&_.stroke(),_.restore()},T.renderSquareControl=function(_,C,I,M,x){M=M||{};var A=this.sizeX||M.cornerSize||x.cornerSize,F=this.sizeY||M.cornerSize||x.cornerSize,k=void 0!==M.transparentCorners?M.transparentCorners:x.transparentCorners,V=k?"stroke":"fill",H=!k&&(M.cornerStrokeColor||x.cornerStrokeColor),G=A/2,z=F/2;_.save(),_.fillStyle=M.cornerColor||x.cornerColor,_.strokeStyle=M.cornerStrokeColor||x.cornerStrokeColor,_.lineWidth=1,_.translate(C,I),_.rotate(D(x.angle)),_[V+"Rect"](-G,-z,A,F),H&&_.strokeRect(-G,-z,A,F),_.restore()},function(S){var w=S.fabric||(S.fabric={});w.Control=function(D){for(var T in D)this[T]=D[T]},w.Control.prototype={visible:!0,actionName:"scale",angle:0,x:0,y:0,offsetX:0,offsetY:0,sizeX:null,sizeY:null,touchSizeX:null,touchSizeY:null,cursorStyle:"crosshair",withConnection:!1,actionHandler:function(){},mouseDownHandler:function(){},mouseUpHandler:function(){},getActionHandler:function(){return this.actionHandler},getMouseDownHandler:function(){return this.mouseDownHandler},getMouseUpHandler:function(){return this.mouseUpHandler},cursorStyleHandler:function(D,T){return T.cursorStyle},getActionName:function(D,T){return T.actionName},getVisibility:function(D,T){var _=D._controlsVisibility;return _&&void 0!==_[T]?_[T]:this.visible},setVisibility:function(D){this.visible=D},positionHandler:function(D,T){return w.util.transformPoint({x:this.x*D.x+this.offsetX,y:this.y*D.y+this.offsetY},T)},calcCornerCoords:function(D,T,_,C,I){var M,x,A,F,k=I?this.touchSizeX:this.sizeX,V=I?this.touchSizeY:this.sizeY;if(k&&V&&k!==V){var H=Math.atan2(V,k),G=Math.sqrt(k*k+V*V)/2,z=H-w.util.degreesToRadians(D),Z=Math.PI/2-H-w.util.degreesToRadians(D);M=G*w.util.cos(z),x=G*w.util.sin(z),A=G*w.util.cos(Z),F=G*w.util.sin(Z)}else G=.7071067812*(k&&V?k:T),z=w.util.degreesToRadians(45-D),M=A=G*w.util.cos(z),x=F=G*w.util.sin(z);return{tl:{x:_-F,y:C-A},tr:{x:_+M,y:C-x},bl:{x:_-M,y:C+x},br:{x:_+F,y:C+A}}},render:function(D,T,_,C,I){"circle"===((C=C||{}).cornerStyle||I.cornerStyle)?w.controlsUtils.renderCircleControl.call(this,D,T,_,C,I):w.controlsUtils.renderSquareControl.call(this,D,T,_,C,I)}}}(l),function(){function S(D,T){var _,C,I,M,x=D.getAttribute("style"),A=D.getAttribute("offset")||0;if(A=(A=parseFloat(A)/(/%$/.test(A)?100:1))<0?0:A>1?1:A,x){var F=x.split(/\s*;\s*/);for(""===F[F.length-1]&&F.pop(),M=F.length;M--;){var k=F[M].split(/\s*:\s*/),V=k[0].trim(),H=k[1].trim();"stop-color"===V?_=H:"stop-opacity"===V&&(I=H)}}return _||(_=D.getAttribute("stop-color")||"rgb(0,0,0)"),I||(I=D.getAttribute("stop-opacity")),C=(_=new P.Color(_)).getAlpha(),I=isNaN(parseFloat(I))?1:parseFloat(I),I*=C*T,{offset:A,color:_.toRgb(),opacity:I}}var w=P.util.object.clone;P.Gradient=P.util.createClass({offsetX:0,offsetY:0,gradientTransform:null,gradientUnits:"pixels",type:"linear",initialize:function(D){D||(D={}),D.coords||(D.coords={});var T,_=this;Object.keys(D).forEach(function(C){_[C]=D[C]}),this.id?this.id+="_"+P.Object.__uid++:this.id=P.Object.__uid++,T={x1:D.coords.x1||0,y1:D.coords.y1||0,x2:D.coords.x2||0,y2:D.coords.y2||0},"radial"===this.type&&(T.r1=D.coords.r1||0,T.r2=D.coords.r2||0),this.coords=T,this.colorStops=D.colorStops.slice()},addColorStop:function(D){for(var T in D){var _=new P.Color(D[T]);this.colorStops.push({offset:parseFloat(T),color:_.toRgb(),opacity:_.getAlpha()})}return this},toObject:function(D){var T={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return P.util.populateWithProperties(this,T,D),T},toSVG:function(D,T){var _,C,I,M,x=w(this.coords,!0),A=(T=T||{},w(this.colorStops,!0)),F=x.r1>x.r2,k=this.gradientTransform?this.gradientTransform.concat():P.iMatrix.concat(),V=-this.offsetX,H=-this.offsetY,G=!!T.additionalTransform,z="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox";if(A.sort(function(de,ce){return de.offset-ce.offset}),"objectBoundingBox"===z?(V/=D.width,H/=D.height):(V+=D.width/2,H+=D.height/2),"path"===D.type&&"percentage"!==this.gradientUnits&&(V-=D.pathOffset.x,H-=D.pathOffset.y),k[4]-=V,k[5]-=H,M='id="SVGID_'+this.id+'" gradientUnits="'+z+'"',M+=' gradientTransform="'+(G?T.additionalTransform+" ":"")+P.util.matrixToSVG(k)+'" ',"linear"===this.type?I=["\n']:"radial"===this.type&&(I=["\n']),"radial"===this.type){if(F)for((A=A.concat()).reverse(),_=0,C=A.length;_0){var ie=Z/Math.max(x.r1,x.r2);for(_=0,C=A.length;_\n')}return I.push("linear"===this.type?"\n":"\n"),I.join("")},toLive:function(D){var T,_,C,I=P.util.object.clone(this.coords);if(this.type){for("linear"===this.type?T=D.createLinearGradient(I.x1,I.y1,I.x2,I.y2):"radial"===this.type&&(T=D.createRadialGradient(I.x1,I.y1,I.r1,I.x2,I.y2,I.r2)),_=0,C=this.colorStops.length;_1?1:I,isNaN(I)&&(I=1);var M,x,A,F,ie,re,de,ce,le,ee,k=D.getElementsByTagName("stop"),V="userSpaceOnUse"===D.getAttribute("gradientUnits")?"pixels":"percentage",H=D.getAttribute("gradientTransform")||"",G=[],z=0,Z=0;for("linearGradient"===D.nodeName||"LINEARGRADIENT"===D.nodeName?(M="linear",x={x1:(ie=D).getAttribute("x1")||0,y1:ie.getAttribute("y1")||0,x2:ie.getAttribute("x2")||"100%",y2:ie.getAttribute("y2")||0}):(M="radial",x=function(ie){return{x1:ie.getAttribute("fx")||ie.getAttribute("cx")||"50%",y1:ie.getAttribute("fy")||ie.getAttribute("cy")||"50%",r1:0,x2:ie.getAttribute("cx")||"50%",y2:ie.getAttribute("cy")||"50%",r2:ie.getAttribute("r")||"50%"}}(D)),A=k.length;A--;)G.push(S(k[A],I));return F=P.parseTransformAttribute(H),re=x,de=C,ce=V,Object.keys(re).forEach(function(J){"Infinity"===(le=re[J])?ee=1:"-Infinity"===le?ee=0:(ee=parseFloat(re[J],10),"string"==typeof le&&/^(\d+\.\d+)%|(\d+)%$/.test(le)&&(ee*=.01,"pixels"===ce&&("x1"!==J&&"x2"!==J&&"r2"!==J||(ee*=de.viewBoxWidth||de.width),"y1"!==J&&"y2"!==J||(ee*=de.viewBoxHeight||de.height)))),re[J]=ee}),"pixels"===V&&(z=-T.left,Z=-T.top),new P.Gradient({id:D.getAttribute("id"),type:M,coords:x,colorStops:G,gradientUnits:V,gradientTransform:F,offsetX:z,offsetY:Z})}})}(),q=P.util.toFixed,P.Pattern=P.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,crossOrigin:"",patternTransform:null,initialize:function(S,w){if(S||(S={}),this.id=P.Object.__uid++,this.setOptions(S),!S.source||S.source&&"string"!=typeof S.source)w&&w(this);else{var D=this;this.source=P.util.createImage(),P.util.loadImage(S.source,function(T,_){D.source=T,w&&w(D,_)},null,this.crossOrigin)}},toObject:function(S){var w,D,T=P.Object.NUM_FRACTION_DIGITS;return"string"==typeof this.source.src?w=this.source.src:"object"==typeof this.source&&this.source.toDataURL&&(w=this.source.toDataURL()),D={type:"pattern",source:w,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:q(this.offsetX,T),offsetY:q(this.offsetY,T),patternTransform:this.patternTransform?this.patternTransform.concat():null},P.util.populateWithProperties(this,D,S),D},toSVG:function(S){var w="function"==typeof this.source?this.source():this.source,D=w.width/S.width,T=w.height/S.height,_=this.offsetX/S.width,C=this.offsetY/S.height,I="";return"repeat-x"!==this.repeat&&"no-repeat"!==this.repeat||(T=1,C&&(T+=Math.abs(C))),"repeat-y"!==this.repeat&&"no-repeat"!==this.repeat||(D=1,_&&(D+=Math.abs(_))),w.src?I=w.src:w.toDataURL&&(I=w.toDataURL()),'\n\n\n'},setOptions:function(S){for(var w in S)this[w]=S[w]},toLive:function(S){var w=this.source;return w&&(void 0===w.src||w.complete&&0!==w.naturalWidth&&0!==w.naturalHeight)?S.createPattern(w,this.repeat):""}}),function(S){var w=S.fabric||(S.fabric={}),D=w.util.toFixed;w.Shadow?w.warn("fabric.Shadow is already defined."):(w.Shadow=w.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1,initialize:function(T){for(var _ in"string"==typeof T&&(T=this._parseShadow(T)),T)this[_]=T[_];this.id=w.Object.__uid++},_parseShadow:function(T){var _=T.trim(),C=w.Shadow.reOffsetsAndBlur.exec(_)||[];return{color:(_.replace(w.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)").trim(),offsetX:parseFloat(C[1],10)||0,offsetY:parseFloat(C[2],10)||0,blur:parseFloat(C[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(T){var _=40,C=40,I=w.Object.NUM_FRACTION_DIGITS,M=w.util.rotateVector({x:this.offsetX,y:this.offsetY},w.util.degreesToRadians(-T.angle)),x=new w.Color(this.color);return T.width&&T.height&&(_=100*D((Math.abs(M.x)+this.blur)/T.width,I)+20,C=100*D((Math.abs(M.y)+this.blur)/T.height,I)+20),T.flipX&&(M.x*=-1),T.flipY&&(M.y*=-1),'\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var T={},_=w.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke","nonScaling"].forEach(function(C){this[C]!==_[C]&&(T[C]=this[C])},this),T}}),w.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(\d+(?:\.\d*)?(?:px)?)?(?:\s?|$)(?:$|\s)/)}(l),function(){if(P.StaticCanvas)P.warn("fabric.StaticCanvas is already defined.");else{var S=P.util.object.extend,w=P.util.getElementOffset,D=P.util.removeFromArray,T=P.util.toFixed,_=P.util.transformPoint,C=P.util.invertTransform,I=P.util.getNodeCanvas,M=P.util.createCanvasElement,x=new Error("Could not initialize `canvas` element");P.StaticCanvas=P.util.createClass(P.CommonMethods,{initialize:function(A,F){F||(F={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(A,F)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:P.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(A,F){var k=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(A),this._initOptions(F),this.interactive||this._initRetinaScaling(),F.overlayImage&&this.setOverlayImage(F.overlayImage,k),F.backgroundImage&&this.setBackgroundImage(F.backgroundImage,k),F.backgroundColor&&this.setBackgroundColor(F.backgroundColor,k),F.overlayColor&&this.setOverlayColor(F.overlayColor,k),this.calcOffset()},_isRetinaScaling:function(){return P.devicePixelRatio>1&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?Math.max(1,P.devicePixelRatio):1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var A=P.devicePixelRatio;this.__initRetinaScaling(A,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(A,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(A,F,k){F.setAttribute("width",this.width*A),F.setAttribute("height",this.height*A),k.scale(A,A)},calcOffset:function(){return this._offset=w(this.lowerCanvasEl),this},setOverlayImage:function(A,F,k){return this.__setBgOverlayImage("overlayImage",A,F,k)},setBackgroundImage:function(A,F,k){return this.__setBgOverlayImage("backgroundImage",A,F,k)},setOverlayColor:function(A,F){return this.__setBgOverlayColor("overlayColor",A,F)},setBackgroundColor:function(A,F){return this.__setBgOverlayColor("backgroundColor",A,F)},__setBgOverlayImage:function(A,F,k,V){return"string"==typeof F?P.util.loadImage(F,function(H,G){if(H){var z=new P.Image(H,V);this[A]=z,z.canvas=this}k&&k(H,G)},this,V&&V.crossOrigin):(V&&F.setOptions(V),this[A]=F,F&&(F.canvas=this),k&&k(F,!1)),this},__setBgOverlayColor:function(A,F,k){return this[A]=F,this._initGradient(F,A),this._initPattern(F,A,k),this},_createCanvasElement:function(){var A=M();if(!A||(A.style||(A.style={}),void 0===A.getContext))throw x;return A},_initOptions:function(A){var F=this.lowerCanvasEl;this._setOptions(A),this.width=this.width||parseInt(F.width,10)||0,this.height=this.height||parseInt(F.height,10)||0,this.lowerCanvasEl.style&&(F.width=this.width,F.height=this.height,F.style.width=this.width+"px",F.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(A){this.lowerCanvasEl=A&&A.getContext?A:P.util.getById(A)||this._createCanvasElement(),P.util.addClass(this.lowerCanvasEl,"lower-canvas"),this._originalCanvasStyle=this.lowerCanvasEl.style,this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(A,F){return this.setDimensions({width:A},F)},setHeight:function(A,F){return this.setDimensions({height:A},F)},setDimensions:function(A,F){var k;for(var V in F=F||{},A)k=A[V],F.cssOnly||(this._setBackstoreDimension(V,A[V]),k+="px",this.hasLostContext=!0),F.backstoreOnly||this._setCssDimension(V,k);return this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop),this._initRetinaScaling(),this.calcOffset(),F.cssOnly||this.requestRenderAll(),this},_setBackstoreDimension:function(A,F){return this.lowerCanvasEl[A]=F,this.upperCanvasEl&&(this.upperCanvasEl[A]=F),this.cacheCanvasEl&&(this.cacheCanvasEl[A]=F),this[A]=F,this},_setCssDimension:function(A,F){return this.lowerCanvasEl.style[A]=F,this.upperCanvasEl&&(this.upperCanvasEl.style[A]=F),this.wrapperEl&&(this.wrapperEl.style[A]=F),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(A){var F,k,V,H=this._activeObject,G=this.backgroundImage,z=this.overlayImage;for(this.viewportTransform=A,k=0,V=this._objects.length;k\n'),this._setSVGBgOverlayColor(k,"background"),this._setSVGBgOverlayImage(k,"backgroundImage",F),this._setSVGObjects(k,F),this.clipPath&&k.push("\n"),this._setSVGBgOverlayColor(k,"overlay"),this._setSVGBgOverlayImage(k,"overlayImage",F),k.push(""),k.join("")},_setSVGPreamble:function(A,F){F.suppressPreamble||A.push('\n','\n')},_setSVGHeader:function(A,F){var k,V=F.width||this.width,H=F.height||this.height,G='viewBox="0 0 '+this.width+" "+this.height+'" ',z=P.Object.NUM_FRACTION_DIGITS;F.viewBox?G='viewBox="'+F.viewBox.x+" "+F.viewBox.y+" "+F.viewBox.width+" "+F.viewBox.height+'" ':this.svgViewportTransformation&&(G='viewBox="'+T(-(k=this.viewportTransform)[4]/k[0],z)+" "+T(-k[5]/k[3],z)+" "+T(this.width/k[0],z)+" "+T(this.height/k[3],z)+'" '),A.push("\n',"Created with Fabric.js ",P.version,"\n","\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(F),"\n")},createSVGClipPathMarkup:function(A){var F=this.clipPath;return F?(F.clipPathId="CLIPPATH_"+P.Object.__uid++,'\n'+this.clipPath.toClipPathSVG(A.reviver)+"\n"):""},createSVGRefElementsMarkup:function(){var A=this;return["background","overlay"].map(function(F){var k=A[F+"Color"];if(k&&k.toLive){var V=A[F+"Vpt"],H=A.viewportTransform;return k.toSVG({width:A.width/(V?H[0]:1),height:A.height/(V?H[3]:1)},{additionalTransform:V?P.util.matrixToSVG(H):""})}}).join("")},createSVGFontFacesMarkup:function(){var A,F,k,V,H,G,z,Z,ie="",re={},de=P.fontPaths,ce=[];for(this._objects.forEach(function ee(J){ce.push(J),J._objects&&J._objects.forEach(ee)}),z=0,Z=ce.length;z',"\n",ie,"","\n"].join("")),ie},_setSVGObjects:function(A,F){var k,V,H,G=this._objects;for(V=0,H=G.length;V\n")}else A.push('\n")},sendToBack:function(A){if(!A)return this;var F,k,V,H=this._activeObject;if(A===H&&"activeSelection"===A.type)for(F=(V=H._objects).length;F--;)D(this._objects,k=V[F]),this._objects.unshift(k);else D(this._objects,A),this._objects.unshift(A);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(A){if(!A)return this;var F,k,V,H=this._activeObject;if(A===H&&"activeSelection"===A.type)for(V=H._objects,F=0;F0+ie&&(G=H-1,D(this._objects,V),this._objects.splice(G,0,V)),ie++;else 0!==(H=this._objects.indexOf(A))&&(G=this._findNewLowerIndex(A,H,F),D(this._objects,A),this._objects.splice(G,0,A));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(A,F,k){var V,H;if(k){for(V=F,H=F-1;H>=0;--H)if(A.intersectsWithObject(this._objects[H])||A.isContainedWithinObject(this._objects[H])||this._objects[H].isContainedWithinObject(A)){V=H;break}}else V=F-1;return V},bringForward:function(A,F){if(!A)return this;var k,V,H,G,z,Z=this._activeObject,ie=0;if(A===Z&&"activeSelection"===A.type)for(k=(z=Z._objects).length;k--;)(H=this._objects.indexOf(V=z[k]))"}}),S(P.StaticCanvas.prototype,P.Observable),S(P.StaticCanvas.prototype,P.Collection),S(P.StaticCanvas.prototype,P.DataURLExporter),S(P.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(A){var F=M();if(!F||!F.getContext)return null;var k=F.getContext("2d");return k&&"setLineDash"===A?void 0!==k.setLineDash:null}}),P.StaticCanvas.prototype.toJSON=P.StaticCanvas.prototype.toObject,P.isLikelyNode&&(P.StaticCanvas.prototype.createPNGStream=function(){var A=I(this.lowerCanvasEl);return A&&A.createPNGStream()},P.StaticCanvas.prototype.createJPEGStream=function(A){var F=I(this.lowerCanvasEl);return F&&F.createJPEGStream(A)})}}(),P.BaseBrush=P.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeMiterLimit:10,strokeDashArray:null,limitedToCanvasSize:!1,_setBrushStyles:function(S){S.strokeStyle=this.color,S.lineWidth=this.width,S.lineCap=this.strokeLineCap,S.miterLimit=this.strokeMiterLimit,S.lineJoin=this.strokeLineJoin,S.setLineDash(this.strokeDashArray||[])},_saveAndTransform:function(S){var w=this.canvas.viewportTransform;S.save(),S.transform(w[0],w[1],w[2],w[3],w[4],w[5])},_setShadow:function(){if(this.shadow){var S=this.canvas,w=this.shadow,D=S.contextTop,T=S.getZoom();S&&S._isRetinaScaling()&&(T*=P.devicePixelRatio),D.shadowColor=w.color,D.shadowBlur=w.blur*T,D.shadowOffsetX=w.offsetX*T,D.shadowOffsetY=w.offsetY*T}},needsFullRender:function(){return new P.Color(this.color).getAlpha()<1||!!this.shadow},_resetShadow:function(){var S=this.canvas.contextTop;S.shadowColor="",S.shadowBlur=S.shadowOffsetX=S.shadowOffsetY=0},_isOutSideCanvas:function(S){return S.x<0||S.x>this.canvas.getWidth()||S.y<0||S.y>this.canvas.getHeight()}}),P.PencilBrush=P.util.createClass(P.BaseBrush,{decimate:.4,drawStraightLine:!1,straightLineKey:"shiftKey",initialize:function(S){this.canvas=S,this._points=[]},needsFullRender:function(){return this.callSuper("needsFullRender")||this._hasStraightLine},_drawSegment:function(S,w,D){var T=w.midPointFrom(D);return S.quadraticCurveTo(w.x,w.y,T.x,T.y),T},onMouseDown:function(S,w){this.canvas._isMainEvent(w.e)&&(this.drawStraightLine=w.e[this.straightLineKey],this._prepareForDrawing(S),this._captureDrawingPath(S),this._render())},onMouseMove:function(S,w){if(this.canvas._isMainEvent(w.e)&&(this.drawStraightLine=w.e[this.straightLineKey],(!0!==this.limitedToCanvasSize||!this._isOutSideCanvas(S))&&this._captureDrawingPath(S)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{var D=this._points,T=D.length,_=this.canvas.contextTop;this._saveAndTransform(_),this.oldEnd&&(_.beginPath(),_.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=this._drawSegment(_,D[T-2],D[T-1],!0),_.stroke(),_.restore()}},onMouseUp:function(S){return!this.canvas._isMainEvent(S.e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)},_prepareForDrawing:function(S){var w=new P.Point(S.x,S.y);this._reset(),this._addPoint(w),this.canvas.contextTop.moveTo(w.x,w.y)},_addPoint:function(S){return!(this._points.length>1&&S.eq(this._points[this._points.length-1])||(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(S),0))},_reset:function(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1},_captureDrawingPath:function(S){var w=new P.Point(S.x,S.y);return this._addPoint(w)},_render:function(S){var w,D,T=this._points[0],_=this._points[1];if(this._saveAndTransform(S=S||this.canvas.contextTop),S.beginPath(),2===this._points.length&&T.x===_.x&&T.y===_.y){var C=this.width/1e3;T=new P.Point(T.x,T.y),_=new P.Point(_.x,_.y),T.x-=C,_.x+=C}for(S.moveTo(T.x,T.y),w=1,D=this._points.length;w=_&&M.push(I=S[D]);return M.push(S[C]),M},_finalizeAndAddPath:function(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));var S=this.convertPointsToSVGPath(this._points);if(this._isEmptySVGPath(S))this.canvas.requestRenderAll();else{var w=this.createPath(S);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:w}),this.canvas.add(w),this.canvas.requestRenderAll(),w.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:w})}}}),P.CircleBrush=P.util.createClass(P.BaseBrush,{width:10,initialize:function(S){this.canvas=S,this.points=[]},drawDot:function(S){var w=this.addPoint(S),D=this.canvas.contextTop;this._saveAndTransform(D),this.dot(D,w),D.restore()},dot:function(S,w){S.fillStyle=w.fill,S.beginPath(),S.arc(w.x,w.y,w.radius,0,2*Math.PI,!1),S.closePath(),S.fill()},onMouseDown:function(S){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(S)},_render:function(){var S,w,D=this.canvas.contextTop,T=this.points;for(this._saveAndTransform(D),S=0,w=T.length;S0&&!this.preserveObjectStacking){C=[],I=[];for(var x=0,A=this._objects.length;x1&&(this._activeObject._objects=I),C.push.apply(C,I)}else C=this._objects;return C},renderAll:function(){return!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),this.renderCanvas(this.contextContainer,this._chooseObjectsToRender()),this},renderTopLayer:function(_){_.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(_),this.contextTopDirty=!0),_.restore()},renderTop:function(){var _=this.contextTop;return this.clearContext(_),this.renderTopLayer(_),this.fire("after:render"),this},_normalizePointer:function(_,C){var I=_.calcTransformMatrix(),M=P.util.invertTransform(I),x=this.restorePointerVpt(C);return P.util.transformPoint(x,M)},isTargetTransparent:function(_,C,I){if(_.shouldCache()&&_._cacheCanvas&&_!==this._activeObject){var M=this._normalizePointer(_,{x:C,y:I}),x=Math.max(_.cacheTranslationX+M.x*_.zoomX,0),A=Math.max(_.cacheTranslationY+M.y*_.zoomY,0);return P.util.isTransparent(_._cacheContext,Math.round(x),Math.round(A),this.targetFindTolerance)}var F=this.contextCache,k=_.selectionBackgroundColor,V=this.viewportTransform;return _.selectionBackgroundColor="",this.clearContext(F),F.save(),F.transform(V[0],V[1],V[2],V[3],V[4],V[5]),_.render(F),F.restore(),_.selectionBackgroundColor=k,P.util.isTransparent(F,C,I,this.targetFindTolerance)},_isSelectionKeyPressed:function(_){return Array.isArray(this.selectionKey)?!!this.selectionKey.find(function(C){return!0===_[C]}):_[this.selectionKey]},_shouldClearSelection:function(_,C){var I=this.getActiveObjects(),M=this._activeObject;return!C||C&&M&&I.length>1&&-1===I.indexOf(C)&&M!==C&&!this._isSelectionKeyPressed(_)||C&&!C.evented||C&&!C.selectable&&M&&M!==C},_shouldCenterTransform:function(_,C,I){var M;if(_)return"scale"===C||"scaleX"===C||"scaleY"===C||"resizing"===C?M=this.centeredScaling||_.centeredScaling:"rotate"===C&&(M=this.centeredRotation||_.centeredRotation),M?!I:I},_getOriginFromCorner:function(_,C){var I={x:_.originX,y:_.originY};return"ml"===C||"tl"===C||"bl"===C?I.x="right":"mr"!==C&&"tr"!==C&&"br"!==C||(I.x="left"),"tl"===C||"mt"===C||"tr"===C?I.y="bottom":"bl"!==C&&"mb"!==C&&"br"!==C||(I.y="top"),I},_getActionFromCorner:function(_,C,I,M){if(!C||!_)return"drag";var x=M.controls[C];return x.getActionName(I,x,M)},_setupCurrentTransform:function(_,C,I){if(C){var M=this.getPointer(_),x=C.__corner,A=C.controls[x],F=I&&x?A.getActionHandler(_,C,A):P.controlsUtils.dragHandler,k=this._getActionFromCorner(I,x,_,C),V=this._getOriginFromCorner(C,x),H=_[this.centeredKey],G={target:C,action:k,actionHandler:F,corner:x,scaleX:C.scaleX,scaleY:C.scaleY,skewX:C.skewX,skewY:C.skewY,offsetX:M.x-C.left,offsetY:M.y-C.top,originX:V.x,originY:V.y,ex:M.x,ey:M.y,lastX:M.x,lastY:M.y,theta:w(C.angle),width:C.width*C.scaleX,shiftKey:_.shiftKey,altKey:H,original:P.util.saveObjectTransform(C)};this._shouldCenterTransform(C,k,H)&&(G.originX="center",G.originY="center"),G.original.originX=V.x,G.original.originY=V.y,this._currentTransform=G,this._beforeTransform(_)}},setCursor:function(_){this.upperCanvasEl.style.cursor=_},_drawSelection:function(_){var C=this._groupSelector,I=new P.Point(C.ex,C.ey),M=P.util.transformPoint(I,this.viewportTransform),x=new P.Point(C.ex+C.left,C.ey+C.top),A=P.util.transformPoint(x,this.viewportTransform),F=Math.min(M.x,A.x),k=Math.min(M.y,A.y),V=Math.max(M.x,A.x),H=Math.max(M.y,A.y),G=this.selectionLineWidth/2;this.selectionColor&&(_.fillStyle=this.selectionColor,_.fillRect(F,k,V-F,H-k)),this.selectionLineWidth&&this.selectionBorderColor&&(_.lineWidth=this.selectionLineWidth,_.strokeStyle=this.selectionBorderColor,F+=G,k+=G,V-=G,H-=G,P.Object.prototype._setLineDash.call(this,_,this.selectionDashArray),_.strokeRect(F,k,V-F,H-k))},findTarget:function(_,C){if(!this.skipTargetFind){var I,M,x=this.getPointer(_,!0),A=this._activeObject,F=this.getActiveObjects(),k=D(_),V=F.length>1&&!C||1===F.length;if(this.targets=[],V&&A._findTargetCorner(x,k)||F.length>1&&!C&&A===this._searchPossibleTargets([A],x))return A;if(1===F.length&&A===this._searchPossibleTargets([A],x)){if(!this.preserveObjectStacking)return A;I=A,M=this.targets,this.targets=[]}var H=this._searchPossibleTargets(this._objects,x);return _[this.altSelectionKey]&&H&&I&&H!==I&&(H=I,this.targets=M),H}},_checkTarget:function(_,C,I){if(C&&C.visible&&C.evented&&C.containsPoint(_)&&(!this.perPixelTargetFind&&!C.perPixelTargetFind||C.isEditing||!this.isTargetTransparent(C,I.x,I.y)))return!0},_searchPossibleTargets:function(_,C){for(var I,M,x=_.length;x--;){var A=_[x],F=A.group?this._normalizePointer(A.group,C):C;if(this._checkTarget(F,A,C)){(I=_[x]).subTargetCheck&&I instanceof P.Group&&(M=this._searchPossibleTargets(I._objects,C))&&this.targets.push(M);break}}return I},restorePointerVpt:function(_){return P.util.transformPoint(_,P.util.invertTransform(this.viewportTransform))},getPointer:function(_,C){if(this._absolutePointer&&!C)return this._absolutePointer;if(this._pointer&&C)return this._pointer;var I,M=S(_),x=this.upperCanvasEl,A=x.getBoundingClientRect(),F=A.width||0,k=A.height||0;F&&k||("top"in A&&"bottom"in A&&(k=Math.abs(A.top-A.bottom)),"right"in A&&"left"in A&&(F=Math.abs(A.right-A.left))),this.calcOffset(),M.x=M.x-this._offset.left,M.y=M.y-this._offset.top,C||(M=this.restorePointerVpt(M));var V=this.getRetinaScaling();return 1!==V&&(M.x/=V,M.y/=V),{x:M.x*(I=0===F||0===k?{width:1,height:1}:{width:x.width/F,height:x.height/k}).width,y:M.y*I.height}},_createUpperCanvas:function(){var _=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,""),C=this.lowerCanvasEl,I=this.upperCanvasEl;I?I.className="":(I=this._createCanvasElement(),this.upperCanvasEl=I),P.util.addClass(I,"upper-canvas "+_),this.wrapperEl.appendChild(I),this._copyCanvasStyle(C,I),this._applyCanvasStyle(I),this.contextTop=I.getContext("2d")},getTopContext:function(){return this.contextTop},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=P.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),P.util.setStyle(this.wrapperEl,{width:this.width+"px",height:this.height+"px",position:"relative"}),P.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(_){var C=this.width||_.width,I=this.height||_.height;P.util.setStyle(_,{position:"absolute",width:C+"px",height:I+"px",left:0,top:0,"touch-action":this.allowTouchScrolling?"manipulation":"none","-ms-touch-action":this.allowTouchScrolling?"manipulation":"none"}),_.width=C,_.height=I,P.util.makeElementUnselectable(_)},_copyCanvasStyle:function(_,C){C.style.cssText=_.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},getActiveObject:function(){return this._activeObject},getActiveObjects:function(){var _=this._activeObject;return _?"activeSelection"===_.type&&_._objects?_._objects.slice(0):[_]:[]},_onObjectRemoved:function(_){_===this._activeObject&&(this.fire("before:selection:cleared",{target:_}),this._discardActiveObject(),this.fire("selection:cleared",{target:_}),_.fire("deselected")),_===this._hoveredTarget&&(this._hoveredTarget=null,this._hoveredTargets=[]),this.callSuper("_onObjectRemoved",_)},_fireSelectionEvents:function(_,C){var I=!1,M=this.getActiveObjects(),x=[],A=[];_.forEach(function(F){-1===M.indexOf(F)&&(I=!0,F.fire("deselected",{e:C,target:F}),A.push(F))}),M.forEach(function(F){-1===_.indexOf(F)&&(I=!0,F.fire("selected",{e:C,target:F}),x.push(F))}),_.length>0&&M.length>0?I&&this.fire("selection:updated",{e:C,selected:x,deselected:A}):M.length>0?this.fire("selection:created",{e:C,selected:x}):_.length>0&&this.fire("selection:cleared",{e:C,deselected:A})},setActiveObject:function(_,C){var I=this.getActiveObjects();return this._setActiveObject(_,C),this._fireSelectionEvents(I,C),this},_setActiveObject:function(_,C){return this._activeObject!==_&&!!this._discardActiveObject(C,_)&&!_.onSelect({e:C})&&(this._activeObject=_,!0)},_discardActiveObject:function(_,C){var I=this._activeObject;if(I){if(I.onDeselect({e:_,object:C}))return!1;this._activeObject=null}return!0},discardActiveObject:function(_){var C=this.getActiveObjects(),I=this.getActiveObject();return C.length&&this.fire("before:selection:cleared",{target:I,e:_}),this._discardActiveObject(_),this._fireSelectionEvents(C,_),this},dispose:function(){var _=this.wrapperEl;return this.removeListeners(),_.removeChild(this.upperCanvasEl),_.removeChild(this.lowerCanvasEl),this.contextCache=null,this.contextTop=null,["upperCanvasEl","cacheCanvasEl"].forEach(function(C){P.util.cleanUpJsdomNode(this[C]),this[C]=void 0}.bind(this)),_.parentNode&&_.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,P.StaticCanvas.prototype.dispose.call(this),this},clear:function(){return this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(_){var C=this._activeObject;C&&C._renderControls(_)},_toObject:function(_,C,I){var M=this._realizeGroupTransformOnObject(_),x=this.callSuper("_toObject",_,C,I);return this._unwindGroupTransformOnObject(_,M),x},_realizeGroupTransformOnObject:function(_){if(_.group&&"activeSelection"===_.group.type&&this._activeObject===_.group){var C={};return["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"].forEach(function(I){C[I]=_[I]}),P.util.addTransformToObject(_,this._activeObject.calcOwnMatrix()),C}return null},_unwindGroupTransformOnObject:function(_,C){C&&_.set(C)},_setSVGObject:function(_,C,I){var M=this._realizeGroupTransformOnObject(C);this.callSuper("_setSVGObject",_,C,I),this._unwindGroupTransformOnObject(C,M)},setViewportTransform:function(_){this.renderOnAddRemove&&this._activeObject&&this._activeObject.isEditing&&this._activeObject.clearContextTop(),P.StaticCanvas.prototype.setViewportTransform.call(this,_)}}),P.StaticCanvas)"prototype"!==T&&(P.Canvas[T]=P.StaticCanvas[T])}(),function(){var S=P.util.addListener,w=P.util.removeListener,D={passive:!1};function T(_,C){return _.button&&_.button===C-1}P.util.object.extend(P.Canvas.prototype,{mainTouchId:null,_initEventListeners:function(){this.removeListeners(),this._bindEvents(),this.addOrRemove(S,"add")},_getEventPrefix:function(){return this.enablePointerEvents?"pointer":"mouse"},addOrRemove:function(_,C){var I=this.upperCanvasEl,M=this._getEventPrefix();_(P.window,"resize",this._onResize),_(I,M+"down",this._onMouseDown),_(I,M+"move",this._onMouseMove,D),_(I,M+"out",this._onMouseOut),_(I,M+"enter",this._onMouseEnter),_(I,"wheel",this._onMouseWheel),_(I,"contextmenu",this._onContextMenu),_(I,"dblclick",this._onDoubleClick),_(I,"dragover",this._onDragOver),_(I,"dragenter",this._onDragEnter),_(I,"dragleave",this._onDragLeave),_(I,"drop",this._onDrop),this.enablePointerEvents||_(I,"touchstart",this._onTouchStart,D),"undefined"!=typeof eventjs&&C in eventjs&&(eventjs[C](I,"gesture",this._onGesture),eventjs[C](I,"drag",this._onDrag),eventjs[C](I,"orientation",this._onOrientationChange),eventjs[C](I,"shake",this._onShake),eventjs[C](I,"longpress",this._onLongPress))},removeListeners:function(){this.addOrRemove(w,"remove");var _=this._getEventPrefix();w(P.document,_+"up",this._onMouseUp),w(P.document,"touchend",this._onTouchEnd,D),w(P.document,_+"move",this._onMouseMove,D),w(P.document,"touchmove",this._onMouseMove,D)},_bindEvents:function(){this.eventsBound||(this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this._onDoubleClick=this._onDoubleClick.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDragEnter=this._simpleEventHandler.bind(this,"dragenter"),this._onDragLeave=this._simpleEventHandler.bind(this,"dragleave"),this._onDrop=this._onDrop.bind(this),this.eventsBound=!0)},_onGesture:function(_,C){this.__onTransformGesture&&this.__onTransformGesture(_,C)},_onDrag:function(_,C){this.__onDrag&&this.__onDrag(_,C)},_onMouseWheel:function(_){this.__onMouseWheel(_)},_onMouseOut:function(_){var C=this._hoveredTarget;this.fire("mouse:out",{target:C,e:_}),this._hoveredTarget=null,C&&C.fire("mouseout",{e:_});var I=this;this._hoveredTargets.forEach(function(M){I.fire("mouse:out",{target:C,e:_}),M&&C.fire("mouseout",{e:_})}),this._hoveredTargets=[],this._iTextInstances&&this._iTextInstances.forEach(function(M){M.isEditing&&M.hiddenTextarea.focus()})},_onMouseEnter:function(_){this._currentTransform||this.findTarget(_)||(this.fire("mouse:over",{target:null,e:_}),this._hoveredTarget=null,this._hoveredTargets=[])},_onOrientationChange:function(_,C){this.__onOrientationChange&&this.__onOrientationChange(_,C)},_onShake:function(_,C){this.__onShake&&this.__onShake(_,C)},_onLongPress:function(_,C){this.__onLongPress&&this.__onLongPress(_,C)},_onDragOver:function(_){_.preventDefault();var C=this._simpleEventHandler("dragover",_);this._fireEnterLeaveEvents(C,_)},_onDrop:function(_){return this._simpleEventHandler("drop:before",_),this._simpleEventHandler("drop",_)},_onContextMenu:function(_){return this.stopContextMenu&&(_.stopPropagation(),_.preventDefault()),!1},_onDoubleClick:function(_){this._cacheTransformEventData(_),this._handleEvent(_,"dblclick"),this._resetTransformEventData(_)},getPointerId:function(_){var C=_.changedTouches;return C?C[0]&&C[0].identifier:this.enablePointerEvents?_.pointerId:-1},_isMainEvent:function(_){return!0===_.isPrimary||!1!==_.isPrimary&&("touchend"===_.type&&0===_.touches.length||!_.changedTouches||_.changedTouches[0].identifier===this.mainTouchId)},_onTouchStart:function(_){_.preventDefault(),null===this.mainTouchId&&(this.mainTouchId=this.getPointerId(_)),this.__onMouseDown(_),this._resetTransformEventData();var C=this.upperCanvasEl,I=this._getEventPrefix();S(P.document,"touchend",this._onTouchEnd,D),S(P.document,"touchmove",this._onMouseMove,D),w(C,I+"down",this._onMouseDown)},_onMouseDown:function(_){this.__onMouseDown(_),this._resetTransformEventData();var C=this.upperCanvasEl,I=this._getEventPrefix();w(C,I+"move",this._onMouseMove,D),S(P.document,I+"up",this._onMouseUp),S(P.document,I+"move",this._onMouseMove,D)},_onTouchEnd:function(_){if(!(_.touches.length>0)){this.__onMouseUp(_),this._resetTransformEventData(),this.mainTouchId=null;var C=this._getEventPrefix();w(P.document,"touchend",this._onTouchEnd,D),w(P.document,"touchmove",this._onMouseMove,D);var I=this;this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(function(){S(I.upperCanvasEl,C+"down",I._onMouseDown),I._willAddMouseDown=0},400)}},_onMouseUp:function(_){this.__onMouseUp(_),this._resetTransformEventData();var C=this.upperCanvasEl,I=this._getEventPrefix();this._isMainEvent(_)&&(w(P.document,I+"up",this._onMouseUp),w(P.document,I+"move",this._onMouseMove,D),S(C,I+"move",this._onMouseMove,D))},_onMouseMove:function(_){!this.allowTouchScrolling&&_.preventDefault&&_.preventDefault(),this.__onMouseMove(_)},_onResize:function(){this.calcOffset()},_shouldRender:function(_){var C=this._activeObject;return!!(!!C!=!!_||C&&_&&C!==_)||!1},__onMouseUp:function(_){var C,I=this._currentTransform,M=this._groupSelector,x=!1,A=!M||0===M.left&&0===M.top;if(this._cacheTransformEventData(_),C=this._target,this._handleEvent(_,"up:before"),T(_,3))this.fireRightClick&&this._handleEvent(_,"up",3,A);else{if(T(_,2))return this.fireMiddleClick&&this._handleEvent(_,"up",2,A),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)this._onMouseUpInDrawingMode(_);else if(this._isMainEvent(_)){if(I&&(this._finalizeCurrentTransform(_),x=I.actionPerformed),!A){var F=C===this._activeObject;this._maybeGroupObjects(_),x||(x=this._shouldRender(C)||!F&&C===this._activeObject)}var k,V;if(C){if(k=C._findTargetCorner(this.getPointer(_,!0),P.util.isTouchEvent(_)),C.selectable&&C!==this._activeObject&&"up"===C.activeOn)this.setActiveObject(C,_),x=!0;else{var H=C.controls[k],G=H&&H.getMouseUpHandler(_,C,H);G&&G(_,I,(V=this.getPointer(_)).x,V.y)}C.isMoving=!1}if(I&&(I.target!==C||I.corner!==k)){var z=I.target&&I.target.controls[I.corner],Z=z&&z.getMouseUpHandler(_,C,H);V=V||this.getPointer(_),Z&&Z(_,I,V.x,V.y)}this._setCursorFromEvent(_,C),this._handleEvent(_,"up",1,A),this._groupSelector=null,this._currentTransform=null,C&&(C.__corner=0),x?this.requestRenderAll():A||this.renderTop()}}},_simpleEventHandler:function(_,C){var I=this.findTarget(C),M=this.targets,x={e:C,target:I,subTargets:M};if(this.fire(_,x),I&&I.fire(_,x),!M)return I;for(var A=0;A1&&(w=new P.ActiveSelection(D.reverse(),{canvas:this}),this.setActiveObject(w,S))},_collectObjects:function(S){for(var w,D=[],T=this._groupSelector.ex,_=this._groupSelector.ey,C=T+this._groupSelector.left,I=_+this._groupSelector.top,M=new P.Point(X(T,C),X(_,I)),x=new P.Point(Q(T,C),Q(_,I)),A=!this.selectionFullyContained,F=T===C&&_===I,k=this._objects.length;k--&&!((w=this._objects[k])&&w.selectable&&w.visible&&(A&&w.intersectsWithRect(M,x,!0)||w.isContainedWithinRect(M,x,!0)||A&&w.containsPoint(M,null,!0)||A&&w.containsPoint(x,null,!0))&&(D.push(w),F)););return D.length>1&&(D=D.filter(function(V){return!V.onSelect({e:S})})),D},_maybeGroupObjects:function(S){this.selection&&this._groupSelector&&this._groupSelectedObjects(S),this.setCursor(this.defaultCursor),this._groupSelector=null}}),P.util.object.extend(P.StaticCanvas.prototype,{toDataURL:function(S){S||(S={});var w=S.format||"png",D=S.quality||1,T=(S.multiplier||1)*(S.enableRetinaScaling?this.getRetinaScaling():1),_=this.toCanvasElement(T,S);return P.util.toDataURL(_,w,D)},toCanvasElement:function(S,w){var D=((w=w||{}).width||this.width)*(S=S||1),T=(w.height||this.height)*S,_=this.getZoom(),C=this.width,I=this.height,M=_*S,x=this.viewportTransform,k=this.interactive,V=[M,0,0,M,(x[4]-(w.left||0))*S,(x[5]-(w.top||0))*S],H=this.enableRetinaScaling,G=P.util.createCanvasElement(),z=this.contextTop;return G.width=D,G.height=T,this.contextTop=null,this.enableRetinaScaling=!1,this.interactive=!1,this.viewportTransform=V,this.width=D,this.height=T,this.calcViewportBoundaries(),this.renderCanvas(G.getContext("2d"),this._objects),this.viewportTransform=x,this.width=C,this.height=I,this.calcViewportBoundaries(),this.interactive=k,this.enableRetinaScaling=H,this.contextTop=z,G}}),P.util.object.extend(P.StaticCanvas.prototype,{loadFromJSON:function(S,w,D){if(S){var T="string"==typeof S?JSON.parse(S):P.util.object.clone(S),_=this,C=T.clipPath,I=this.renderOnAddRemove;return this.renderOnAddRemove=!1,delete T.clipPath,this._enlivenObjects(T.objects,function(M){_.clear(),_._setBgOverlay(T,function(){C?_._enlivenObjects([C],function(x){_.clipPath=x[0],_.__setupCanvas.call(_,T,M,I,w)}):_.__setupCanvas.call(_,T,M,I,w)})},D),this}},__setupCanvas:function(S,w,D,T){var _=this;w.forEach(function(C,I){_.insertAt(C,I)}),this.renderOnAddRemove=D,delete S.objects,delete S.backgroundImage,delete S.overlayImage,delete S.background,delete S.overlay,this._setOptions(S),this.renderAll(),T&&T()},_setBgOverlay:function(S,w){var D={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(S.backgroundImage||S.overlayImage||S.background||S.overlay){var T=function(){D.backgroundImage&&D.overlayImage&&D.backgroundColor&&D.overlayColor&&w&&w()};this.__setBgOverlay("backgroundImage",S.backgroundImage,D,T),this.__setBgOverlay("overlayImage",S.overlayImage,D,T),this.__setBgOverlay("backgroundColor",S.background,D,T),this.__setBgOverlay("overlayColor",S.overlay,D,T)}else w&&w()},__setBgOverlay:function(S,w,D,T){var _=this;if(!w)return D[S]=!0,void(T&&T());"backgroundImage"===S||"overlayImage"===S?P.util.enlivenObjects([w],function(C){_[S]=C[0],D[S]=!0,T&&T()}):this["set"+P.util.string.capitalize(S,!0)](w,function(){D[S]=!0,T&&T()})},_enlivenObjects:function(S,w,D){S&&0!==S.length?P.util.enlivenObjects(S,function(T){w&&w(T)},null,D):w&&w([])},_toDataURL:function(S,w){this.clone(function(D){w(D.toDataURL(S))})},_toDataURLWithMultiplier:function(S,w,D){this.clone(function(T){D(T.toDataURLWithMultiplier(S,w))})},clone:function(S,w){var D=JSON.stringify(this.toJSON(w));this.cloneWithoutData(function(T){T.loadFromJSON(D,function(){S&&S(T)})})},cloneWithoutData:function(S){var w=P.util.createCanvasElement();w.width=this.width,w.height=this.height;var D=new P.Canvas(w);this.backgroundImage?(D.setBackgroundImage(this.backgroundImage.src,function(){D.renderAll(),S&&S(D)}),D.backgroundImageOpacity=this.backgroundImageOpacity,D.backgroundImageStretch=this.backgroundImageStretch):S&&S(D)}}),function(S){var w=S.fabric||(S.fabric={}),D=w.util.object.extend,T=w.util.object.clone,_=w.util.toFixed,C=w.util.string.capitalize,I=w.util.degreesToRadians;w.Object||(w.Object=w.util.createClass(w.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,touchCornerSize:24,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgb(178,204,255)",borderDashArray:null,cornerColor:"rgb(178,204,255)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,minScaleLimit:0,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,perPixelTargetFind:!1,includeDefaultValues:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:!w.isLikelyNode,statefullCache:!1,noScaleCache:!0,strokeUniform:!1,dirty:!0,__corner:0,paintFirst:"fill",activeOn:"down",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),colorProperties:"fill stroke backgroundColor".split(" "),clipPath:void 0,inverted:!1,absolutePositioned:!1,initialize:function(x){x&&this.setOptions(x)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=w.util.createCanvasElement(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0},_limitCacheSize:function(x){var A=w.perfLimitSizeTotal,F=x.width,k=x.height,V=w.maxCacheSideLimit,H=w.minCacheSideLimit;if(F<=V&&k<=V&&F*k<=A)return Fie&&(x.zoomX/=F/ie,x.width=ie,x.capped=!0),k>re&&(x.zoomY/=k/re,x.height=re,x.capped=!0),x},_getCacheCanvasDimensions:function(){var x=this.getTotalObjectScaling(),A=this._getTransformedDimensions(0,0),F=A.x*x.scaleX/this.scaleX,k=A.y*x.scaleY/this.scaleY;return{width:F+2,height:k+2,zoomX:x.scaleX,zoomY:x.scaleY,x:F,y:k}},_updateCacheCanvas:function(){var x=this.canvas;if(this.noScaleCache&&x&&x._currentTransform){var F=x._currentTransform.action;if(this===x._currentTransform.target&&F.slice&&"scale"===F.slice(0,5))return!1}var k,V,H=this._cacheCanvas,G=this._limitCacheSize(this._getCacheCanvasDimensions()),z=w.minCacheSideLimit,Z=G.width,ie=G.height,re=G.zoomX,de=G.zoomY,ce=Z!==this.cacheWidth||ie!==this.cacheHeight,ee=ce||this.zoomX!==re||this.zoomY!==de,J=0,oe=0,he=!1;if(ce){var fe=this._cacheCanvas.width,ne=this._cacheCanvas.height,te=Z>fe||ie>ne;he=te||(Z<.9*fe||ie<.9*ne)&&fe>z&&ne>z,te&&!G.capped&&(Z>z||ie>z)&&(J=.1*Z,oe=.1*ie)}return this instanceof w.Text&&this.path&&(ee=!0,he=!0,J+=this.getHeightOfLine(0)*this.zoomX,oe+=this.getHeightOfLine(0)*this.zoomY),!!ee&&(he?(H.width=Math.ceil(Z+J),H.height=Math.ceil(ie+oe)):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,H.width,H.height)),k=G.x/2,V=G.y/2,this.cacheTranslationX=Math.round(H.width/2-k)+k,this.cacheTranslationY=Math.round(H.height/2-V)+V,this.cacheWidth=Z,this.cacheHeight=ie,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(re,de),this.zoomX=re,this.zoomY=de,!0)},setOptions:function(x){this._setOptions(x),this._initGradient(x.fill,"fill"),this._initGradient(x.stroke,"stroke"),this._initPattern(x.fill,"fill"),this._initPattern(x.stroke,"stroke")},transform:function(x){var F=this.calcTransformMatrix(!(this.group&&!this.group._transformDone||this.group&&this.canvas&&x===this.canvas.contextTop));x.transform(F[0],F[1],F[2],F[3],F[4],F[5])},toObject:function(x){var A=w.Object.NUM_FRACTION_DIGITS,F={type:this.type,version:w.version,originX:this.originX,originY:this.originY,left:_(this.left,A),top:_(this.top,A),width:_(this.width,A),height:_(this.height,A),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:_(this.strokeWidth,A),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeDashOffset:this.strokeDashOffset,strokeLineJoin:this.strokeLineJoin,strokeUniform:this.strokeUniform,strokeMiterLimit:_(this.strokeMiterLimit,A),scaleX:_(this.scaleX,A),scaleY:_(this.scaleY,A),angle:_(this.angle,A),flipX:this.flipX,flipY:this.flipY,opacity:_(this.opacity,A),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,backgroundColor:this.backgroundColor,fillRule:this.fillRule,paintFirst:this.paintFirst,globalCompositeOperation:this.globalCompositeOperation,skewX:_(this.skewX,A),skewY:_(this.skewY,A)};return this.clipPath&&!this.clipPath.excludeFromExport&&(F.clipPath=this.clipPath.toObject(x),F.clipPath.inverted=this.clipPath.inverted,F.clipPath.absolutePositioned=this.clipPath.absolutePositioned),w.util.populateWithProperties(this,F,x),this.includeDefaultValues||(F=this._removeDefaultValues(F)),F},toDatalessObject:function(x){return this.toObject(x)},_removeDefaultValues:function(x){var A=w.util.getKlass(x.type).prototype;return A.stateProperties.forEach(function(F){"left"!==F&&"top"!==F&&(x[F]===A[F]&&delete x[F],Array.isArray(x[F])&&Array.isArray(A[F])&&0===x[F].length&&0===A[F].length&&delete x[F])}),x},toString:function(){return"#"},getObjectScaling:function(){if(!this.group)return{scaleX:this.scaleX,scaleY:this.scaleY};var x=w.util.qrDecompose(this.calcTransformMatrix());return{scaleX:Math.abs(x.scaleX),scaleY:Math.abs(x.scaleY)}},getTotalObjectScaling:function(){var x=this.getObjectScaling(),A=x.scaleX,F=x.scaleY;if(this.canvas){var k=this.canvas.getZoom(),V=this.canvas.getRetinaScaling();A*=k*V,F*=k*V}return{scaleX:A,scaleY:F}},getObjectOpacity:function(){var x=this.opacity;return this.group&&(x*=this.group.getObjectOpacity()),x},_set:function(x,A){var k=this[x]!==A,V=!1;return("scaleX"===x||"scaleY"===x)&&(A=this._constrainScale(A)),"scaleX"===x&&A<0?(this.flipX=!this.flipX,A*=-1):"scaleY"===x&&A<0?(this.flipY=!this.flipY,A*=-1):"shadow"!==x||!A||A instanceof w.Shadow?"dirty"===x&&this.group&&this.group.set("dirty",A):A=new w.Shadow(A),this[x]=A,k&&(V=this.group&&this.group.isOnACache(),this.cacheProperties.indexOf(x)>-1?(this.dirty=!0,V&&this.group.set("dirty",!0)):V&&this.stateProperties.indexOf(x)>-1&&this.group.set("dirty",!0)),this},setOnGroup:function(){},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:w.iMatrix.concat()},isNotVisible:function(){return 0===this.opacity||!this.width&&!this.height&&0===this.strokeWidth||!this.visible},render:function(x){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(x.save(),this._setupCompositeOperation(x),this.drawSelectionBackground(x),this.transform(x),this._setOpacity(x),this._setShadow(x,this),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(x)):(this._removeCacheCanvas(),this.dirty=!1,this.drawObject(x),this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"})),x.restore())},renderCache:function(x){x=x||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,x.forClipping),this.dirty=!1)},_removeCacheCanvas:function(){this._cacheCanvas=null,this._cacheContext=null,this.cacheWidth=0,this.cacheHeight=0},hasStroke:function(){return this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth},hasFill:function(){return this.fill&&"transparent"!==this.fill},needsItsOwnCache:function(){return!("stroke"!==this.paintFirst||!this.hasFill()||!this.hasStroke()||"object"!=typeof this.shadow)||!!this.clipPath},shouldCache:function(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.group||!this.group.isOnACache()),this.ownCaching},willDrawShadow:function(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)},drawClipPathOnCache:function(x,A){if(x.save(),x.globalCompositeOperation=A.inverted?"destination-out":"destination-in",A.absolutePositioned){var F=w.util.invertTransform(this.calcTransformMatrix());x.transform(F[0],F[1],F[2],F[3],F[4],F[5])}A.transform(x),x.scale(1/A.zoomX,1/A.zoomY),x.drawImage(A._cacheCanvas,-A.cacheTranslationX,-A.cacheTranslationY),x.restore()},drawObject:function(x,A){var F=this.fill,k=this.stroke;A?(this.fill="black",this.stroke="",this._setClippingProperties(x)):this._renderBackground(x),this._render(x),this._drawClipPath(x,this.clipPath),this.fill=F,this.stroke=k},_drawClipPath:function(x,A){A&&(A.canvas=this.canvas,A.shouldCache(),A._transformDone=!0,A.renderCache({forClipping:!0}),this.drawClipPathOnCache(x,A))},drawCacheOnCanvas:function(x){x.scale(1/this.zoomX,1/this.zoomY),x.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(x){if(this.isNotVisible())return!1;if(this._cacheCanvas&&this._cacheContext&&!x&&this._updateCacheCanvas())return!0;if(this.dirty||this.clipPath&&this.clipPath.absolutePositioned||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&this._cacheContext&&!x){var A=this.cacheWidth/this.zoomX,F=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-A/2,-F/2,A,F)}return!0}return!1},_renderBackground:function(x){if(this.backgroundColor){var A=this._getNonTransformedDimensions();x.fillStyle=this.backgroundColor,x.fillRect(-A.x/2,-A.y/2,A.x,A.y),this._removeShadow(x)}},_setOpacity:function(x){this.group&&!this.group._transformDone?x.globalAlpha=this.getObjectOpacity():x.globalAlpha*=this.opacity},_setStrokeStyles:function(x,A){var F=A.stroke;F&&(x.lineWidth=A.strokeWidth,x.lineCap=A.strokeLineCap,x.lineDashOffset=A.strokeDashOffset,x.lineJoin=A.strokeLineJoin,x.miterLimit=A.strokeMiterLimit,F.toLive?"percentage"===F.gradientUnits||F.gradientTransform||F.patternTransform?this._applyPatternForTransformedGradient(x,F):(x.strokeStyle=F.toLive(x,this),this._applyPatternGradientTransform(x,F)):x.strokeStyle=A.stroke)},_setFillStyles:function(x,A){var F=A.fill;F&&(F.toLive?(x.fillStyle=F.toLive(x,this),this._applyPatternGradientTransform(x,A.fill)):x.fillStyle=F)},_setClippingProperties:function(x){x.globalAlpha=1,x.strokeStyle="transparent",x.fillStyle="#000000"},_setLineDash:function(x,A){A&&0!==A.length&&(1&A.length&&A.push.apply(A,A),x.setLineDash(A))},_renderControls:function(x,A){var F,k,V,H=this.getViewportTransform(),G=this.calcTransformMatrix();k=void 0!==(A=A||{}).hasBorders?A.hasBorders:this.hasBorders,V=void 0!==A.hasControls?A.hasControls:this.hasControls,G=w.util.multiplyTransformMatrices(H,G),F=w.util.qrDecompose(G),x.save(),x.translate(F.translateX,F.translateY),x.lineWidth=1*this.borderScaleFactor,this.group||(x.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(F.angle-=180),x.rotate(I(this.group?F.angle:this.angle)),A.forActiveSelection||this.group?k&&this.drawBordersInGroup(x,F,A):k&&this.drawBorders(x,A),V&&this.drawControls(x,A),x.restore()},_setShadow:function(x){if(this.shadow){var A,F=this.shadow,k=this.canvas,V=k&&k.viewportTransform[0]||1,H=k&&k.viewportTransform[3]||1;A=F.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),k&&k._isRetinaScaling()&&(V*=w.devicePixelRatio,H*=w.devicePixelRatio),x.shadowColor=F.color,x.shadowBlur=F.blur*w.browserShadowBlurConstant*(V+H)*(A.scaleX+A.scaleY)/4,x.shadowOffsetX=F.offsetX*V*A.scaleX,x.shadowOffsetY=F.offsetY*H*A.scaleY}},_removeShadow:function(x){this.shadow&&(x.shadowColor="",x.shadowBlur=x.shadowOffsetX=x.shadowOffsetY=0)},_applyPatternGradientTransform:function(x,A){if(!A||!A.toLive)return{offsetX:0,offsetY:0};var F=A.gradientTransform||A.patternTransform,k=-this.width/2+A.offsetX||0,V=-this.height/2+A.offsetY||0;return"percentage"===A.gradientUnits?x.transform(this.width,0,0,this.height,k,V):x.transform(1,0,0,1,k,V),F&&x.transform(F[0],F[1],F[2],F[3],F[4],F[5]),{offsetX:k,offsetY:V}},_renderPaintInOrder:function(x){"stroke"===this.paintFirst?(this._renderStroke(x),this._renderFill(x)):(this._renderFill(x),this._renderStroke(x))},_render:function(){},_renderFill:function(x){this.fill&&(x.save(),this._setFillStyles(x,this),"evenodd"===this.fillRule?x.fill("evenodd"):x.fill(),x.restore())},_renderStroke:function(x){if(this.stroke&&0!==this.strokeWidth){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(x),x.save(),this.strokeUniform&&this.group){var A=this.getObjectScaling();x.scale(1/A.scaleX,1/A.scaleY)}else this.strokeUniform&&x.scale(1/this.scaleX,1/this.scaleY);this._setLineDash(x,this.strokeDashArray),this._setStrokeStyles(x,this),x.stroke(),x.restore()}},_applyPatternForTransformedGradient:function(x,A){var F,k=this._limitCacheSize(this._getCacheCanvasDimensions()),V=w.util.createCanvasElement(),H=this.canvas.getRetinaScaling(),G=k.x/this.scaleX/H,z=k.y/this.scaleY/H;V.width=G,V.height=z,(F=V.getContext("2d")).beginPath(),F.moveTo(0,0),F.lineTo(G,0),F.lineTo(G,z),F.lineTo(0,z),F.closePath(),F.translate(G/2,z/2),F.scale(k.zoomX/this.scaleX/H,k.zoomY/this.scaleY/H),this._applyPatternGradientTransform(F,A),F.fillStyle=A.toLive(x),F.fill(),x.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),x.scale(H*this.scaleX/k.zoomX,H*this.scaleY/k.zoomY),x.strokeStyle=F.createPattern(V,"no-repeat")},_findCenterFromElement:function(){return{x:this.left+this.width/2,y:this.top+this.height/2}},_assignTransformMatrixProps:function(){if(this.transformMatrix){var x=w.util.qrDecompose(this.transformMatrix);this.flipX=!1,this.flipY=!1,this.set("scaleX",x.scaleX),this.set("scaleY",x.scaleY),this.angle=x.angle,this.skewX=x.skewX,this.skewY=0}},_removeTransformMatrix:function(x){var A=this._findCenterFromElement();this.transformMatrix&&(this._assignTransformMatrixProps(),A=w.util.transformPoint(A,this.transformMatrix)),this.transformMatrix=null,x&&(this.scaleX*=x.scaleX,this.scaleY*=x.scaleY,this.cropX=x.cropX,this.cropY=x.cropY,A.x+=x.offsetLeft,A.y+=x.offsetTop,this.width=x.width,this.height=x.height),this.setPositionByOrigin(A,"center","center")},clone:function(x,A){var F=this.toObject(A);this.constructor.fromObject?this.constructor.fromObject(F,x):w.Object._fromObject("Object",F,x)},cloneAsImage:function(x,A){var F=this.toCanvasElement(A);return x&&x(new w.Image(F)),this},toCanvasElement:function(x){x||(x={});var A=w.util,F=A.saveObjectTransform(this),k=this.group,V=this.shadow,H=Math.abs,G=(x.multiplier||1)*(x.enableRetinaScaling?w.devicePixelRatio:1);delete this.group,x.withoutTransform&&A.resetObjectTransform(this),x.withoutShadow&&(this.shadow=null);var z,Z,re,de=w.util.createCanvasElement(),ce=this.getBoundingRect(!0,!0),le=this.shadow,ee={x:0,y:0};le&&(Z=le.blur,z=le.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),ee.x=2*Math.round(H(le.offsetX)+Z)*H(z.scaleX),ee.y=2*Math.round(H(le.offsetY)+Z)*H(z.scaleY)),re=ce.height+ee.y,de.width=Math.ceil(ce.width+ee.x),de.height=Math.ceil(re);var J=new w.StaticCanvas(de,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1});"jpeg"===x.format&&(J.backgroundColor="#fff"),this.setPositionByOrigin(new w.Point(J.width/2,J.height/2),"center","center");var oe=this.canvas;J.add(this);var he=J.toCanvasElement(G||1,x);return this.shadow=V,this.set("canvas",oe),k&&(this.group=k),this.set(F).setCoords(),J._objects=[],J.dispose(),J=null,he},toDataURL:function(x){return x||(x={}),w.util.toDataURL(this.toCanvasElement(x),x.format||"png",x.quality||1)},isType:function(x){return arguments.length>1?Array.from(arguments).includes(this.type):this.type===x},complexity:function(){return 1},toJSON:function(x){return this.toObject(x)},rotate:function(x){var A=("center"!==this.originX||"center"!==this.originY)&&this.centeredRotation;return A&&this._setOriginToCenter(),this.set("angle",x),A&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},getLocalPointer:function(x,A){A=A||this.canvas.getPointer(x);var F=new w.Point(A.x,A.y),k=this._getLeftTopCoords();return this.angle&&(F=w.util.rotatePoint(F,k,I(-this.angle))),{x:F.x-k.x,y:F.y-k.y}},_setupCompositeOperation:function(x){this.globalCompositeOperation&&(x.globalCompositeOperation=this.globalCompositeOperation)},dispose:function(){w.runningAnimations&&w.runningAnimations.cancelByTarget(this)}}),w.util.createAccessors&&w.util.createAccessors(w.Object),D(w.Object.prototype,w.Observable),w.Object.NUM_FRACTION_DIGITS=2,w.Object.ENLIVEN_PROPS=["clipPath"],w.Object._fromObject=function(x,A,F,k){var V=w[x];A=T(A,!0),w.util.enlivenPatterns([A.fill,A.stroke],function(H){void 0!==H[0]&&(A.fill=H[0]),void 0!==H[1]&&(A.stroke=H[1]),w.util.enlivenObjectEnlivables(A,A,function(){var G=k?new V(A[k],A):new V(A);F&&F(G)})})},w.Object.__uid=0)}(l),pe=P.util.degreesToRadians,ve={left:-.5,center:0,right:.5},Te={top:-.5,center:0,bottom:.5},P.util.object.extend(P.Object.prototype,{translateToGivenOrigin:function(S,w,D,T,_){var C,I,M,x=S.x,A=S.y;return"string"==typeof w?w=ve[w]:w-=.5,"string"==typeof T?T=ve[T]:T-=.5,"string"==typeof D?D=Te[D]:D-=.5,"string"==typeof _?_=Te[_]:_-=.5,I=_-D,((C=T-w)||I)&&(M=this._getTransformedDimensions(),x=S.x+C*M.x,A=S.y+I*M.y),new P.Point(x,A)},translateToCenterPoint:function(S,w,D){var T=this.translateToGivenOrigin(S,w,D,"center","center");return this.angle?P.util.rotatePoint(T,S,pe(this.angle)):T},translateToOriginPoint:function(S,w,D){var T=this.translateToGivenOrigin(S,"center","center",w,D);return this.angle?P.util.rotatePoint(T,S,pe(this.angle)):T},getCenterPoint:function(){var S=new P.Point(this.left,this.top);return this.translateToCenterPoint(S,this.originX,this.originY)},getPointByOrigin:function(S,w){var D=this.getCenterPoint();return this.translateToOriginPoint(D,S,w)},toLocalPoint:function(S,w,D){var T,_,C=this.getCenterPoint();return T=void 0!==w&&void 0!==D?this.translateToGivenOrigin(C,"center","center",w,D):new P.Point(this.left,this.top),_=new P.Point(S.x,S.y),this.angle&&(_=P.util.rotatePoint(_,C,-pe(this.angle))),_.subtractEquals(T)},setPositionByOrigin:function(S,w,D){var T=this.translateToCenterPoint(S,w,D),_=this.translateToOriginPoint(T,this.originX,this.originY);this.set("left",_.x),this.set("top",_.y)},adjustPosition:function(S){var w,D,T=pe(this.angle),_=this.getScaledWidth(),C=P.util.cos(T)*_,I=P.util.sin(T)*_;this.left+=C*((D="string"==typeof S?ve[S]:S-.5)-(w="string"==typeof this.originX?ve[this.originX]:this.originX-.5)),this.top+=I*(D-w),this.setCoords(),this.originX=S},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var S=this.getCenterPoint();this.originX="center",this.originY="center",this.left=S.x,this.top=S.y},_resetOrigin:function(){var S=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=S.x,this.top=S.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}}),function(){var S=P.util,w=S.degreesToRadians,D=S.multiplyTransformMatrices,T=S.transformPoint;S.object.extend(P.Object.prototype,{oCoords:null,aCoords:null,lineCoords:null,ownMatrixCache:null,matrixCache:null,controls:{},_getCoords:function(_,C){return C?_?this.calcACoords():this.calcLineCoords():(this.aCoords&&this.lineCoords||this.setCoords(!0),_?this.aCoords:this.lineCoords)},getCoords:function(_,C){return I=this._getCoords(_,C),[new P.Point(I.tl.x,I.tl.y),new P.Point(I.tr.x,I.tr.y),new P.Point(I.br.x,I.br.y),new P.Point(I.bl.x,I.bl.y)];var I},intersectsWithRect:function(_,C,I,M){var x=this.getCoords(I,M);return"Intersection"===P.Intersection.intersectPolygonRectangle(x,_,C).status},intersectsWithObject:function(_,C,I){return"Intersection"===P.Intersection.intersectPolygonPolygon(this.getCoords(C,I),_.getCoords(C,I)).status||_.isContainedWithinObject(this,C,I)||this.isContainedWithinObject(_,C,I)},isContainedWithinObject:function(_,C,I){for(var M=this.getCoords(C,I),A=0,F=_._getImageLines(C?_.aCoords:_.lineCoords);A<4;A++)if(!_.containsPoint(M[A],F))return!1;return!0},isContainedWithinRect:function(_,C,I,M){var x=this.getBoundingRect(I,M);return x.left>=_.x&&x.left+x.width<=C.x&&x.top>=_.y&&x.top+x.height<=C.y},containsPoint:function(_,C,I,M){var x=this._getCoords(I,M),A=(C=C||this._getImageLines(x),this._findCrossPoints(_,C));return 0!==A&&A%2==1},isOnScreen:function(_){if(!this.canvas)return!1;var C=this.canvas.vptCoords.tl,I=this.canvas.vptCoords.br;return!!this.getCoords(!0,_).some(function(M){return M.x<=I.x&&M.x>=C.x&&M.y<=I.y&&M.y>=C.y})||!!this.intersectsWithRect(C,I,!0,_)||this._containsCenterOfCanvas(C,I,_)},_containsCenterOfCanvas:function(_,C,I){return!!this.containsPoint({x:(_.x+C.x)/2,y:(_.y+C.y)/2},null,!0,I)},isPartiallyOnScreen:function(_){if(!this.canvas)return!1;var C=this.canvas.vptCoords.tl,I=this.canvas.vptCoords.br;return!!this.intersectsWithRect(C,I,!0,_)||this.getCoords(!0,_).every(function(M){return(M.x>=I.x||M.x<=C.x)&&(M.y>=I.y||M.y<=C.y)})&&this._containsCenterOfCanvas(C,I,_)},_getImageLines:function(_){return{topline:{o:_.tl,d:_.tr},rightline:{o:_.tr,d:_.br},bottomline:{o:_.br,d:_.bl},leftline:{o:_.bl,d:_.tl}}},_findCrossPoints:function(_,C){var I,M,x,A=0;for(var F in C)if(!((x=C[F]).o.y<_.y&&x.d.y<_.y||x.o.y>=_.y&&x.d.y>=_.y||(x.o.x===x.d.x&&x.o.x>=_.x?M=x.o.x:(I=(x.d.y-x.o.y)/(x.d.x-x.o.x),M=-(_.y-0*_.x-(x.o.y-I*x.o.x))/(0-I)),M>=_.x&&(A+=1),2!==A)))break;return A},getBoundingRect:function(_,C){var I=this.getCoords(_,C);return S.makeBoundingBoxFromPoints(I)},getScaledWidth:function(){return this._getTransformedDimensions().x},getScaledHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(_){return Math.abs(_)\n')}},toSVG:function(D){return this._createBaseSVGMarkup(this._toSVG(D),{reviver:D})},toClipPathSVG:function(D){return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(D),{reviver:D})},_createBaseClipPathSVGMarkup:function(D,T){var _=(T=T||{}).reviver,I=[this.getSvgTransform(!0,T.additionalTransform||""),this.getSvgCommons()].join(""),M=D.indexOf("COMMON_PARTS");return D[M]=I,_?_(D.join("")):D.join("")},_createBaseSVGMarkup:function(D,T){var _,C,I=(T=T||{}).noStyle,M=T.reviver,x=I?"":'style="'+this.getSvgStyles()+'" ',A=T.withShadow?'style="'+this.getSvgFilter()+'" ':"",F=this.clipPath,k=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",V=F&&F.absolutePositioned,H=this.stroke,G=this.fill,z=this.shadow,Z=[],ie=D.indexOf("COMMON_PARTS"),re=T.additionalTransform;return F&&(F.clipPathId="CLIPPATH_"+P.Object.__uid++,C='\n'+F.toClipPathSVG(M)+"\n"),V&&Z.push("\n"),Z.push("\n"),_=[x,k,I?"":this.addPaintOrder()," ",re?'transform="'+re+'" ':""].join(""),D[ie]=_,G&&G.toLive&&Z.push(G.toSVG(this)),H&&H.toLive&&Z.push(H.toSVG(this)),z&&Z.push(z.toSVG(this)),F&&Z.push(C),Z.push(D.join("")),Z.push("\n"),V&&Z.push("\n"),M?M(Z.join("")):Z.join("")},addPaintOrder:function(){return"fill"!==this.paintFirst?' paint-order="'+this.paintFirst+'" ':""}})}(),function(){var S=P.util.object.extend,w="stateProperties";function D(_,C,I){var M={};I.forEach(function(x){M[x]=_[x]}),S(_[C],M,!0)}function T(_,C,I){if(_===C)return!0;if(Array.isArray(_)){if(!Array.isArray(C)||_.length!==C.length)return!1;for(var M=0,x=_.length;M=0;A--)if(this.isControlVisible(C=x[A])&&(_=this._getImageLines(D?this.oCoords[C].touchCorner:this.oCoords[C].corner),0!==(T=this._findCrossPoints({x:I,y:M},_))&&T%2==1))return this.__corner=C,C;return!1},forEachControl:function(w){for(var D in this.controls)w(this.controls[D],D,this)},_setCornerCoords:function(){var w=this.oCoords;for(var D in w){var T=this.controls[D];w[D].corner=T.calcCornerCoords(this.angle,this.cornerSize,w[D].x,w[D].y,!1),w[D].touchCorner=T.calcCornerCoords(this.angle,this.touchCornerSize,w[D].x,w[D].y,!0)}},drawSelectionBackground:function(w){if(!this.selectionBackgroundColor||this.canvas&&!this.canvas.interactive||this.canvas&&this.canvas._activeObject!==this)return this;w.save();var D=this.getCenterPoint(),T=this._calculateCurrentDimensions(),_=this.canvas.viewportTransform;return w.translate(D.x,D.y),w.scale(1/_[0],1/_[3]),w.rotate(S(this.angle)),w.fillStyle=this.selectionBackgroundColor,w.fillRect(-T.x/2,-T.y/2,T.x,T.y),w.restore(),this},drawBorders:function(w,D){D=D||{};var T=this._calculateCurrentDimensions(),_=this.borderScaleFactor,C=T.x+_,I=T.y+_,M=void 0!==D.hasControls?D.hasControls:this.hasControls,x=!1;return w.save(),w.strokeStyle=D.borderColor||this.borderColor,this._setLineDash(w,D.borderDashArray||this.borderDashArray),w.strokeRect(-C/2,-I/2,C,I),M&&(w.beginPath(),this.forEachControl(function(A,F,k){A.withConnection&&A.getVisibility(k,F)&&(x=!0,w.moveTo(A.x*C,A.y*I),w.lineTo(A.x*C+A.offsetX,A.y*I+A.offsetY))}),x&&w.stroke()),w.restore(),this},drawBordersInGroup:function(w,D,T){T=T||{};var _=P.util.sizeAfterTransform(this.width,this.height,D),C=this.strokeWidth,I=this.strokeUniform,M=this.borderScaleFactor,x=_.x+C*(I?this.canvas.getZoom():D.scaleX)+M,A=_.y+C*(I?this.canvas.getZoom():D.scaleY)+M;return w.save(),this._setLineDash(w,T.borderDashArray||this.borderDashArray),w.strokeStyle=T.borderColor||this.borderColor,w.strokeRect(-x/2,-A/2,x,A),w.restore(),this},drawControls:function(w,D){D=D||{},w.save();var T,_,C=this.canvas.getRetinaScaling();return w.setTransform(C,0,0,C,0,0),w.strokeStyle=w.fillStyle=D.cornerColor||this.cornerColor,this.transparentCorners||(w.strokeStyle=D.cornerStrokeColor||this.cornerStrokeColor),this._setLineDash(w,D.cornerDashArray||this.cornerDashArray),this.setCoords(),this.group&&(T=this.group.calcTransformMatrix()),this.forEachControl(function(I,M,x){_=x.oCoords[M],I.getVisibility(x,M)&&(T&&(_=P.util.transformPoint(_,T)),I.render(w,_.x,_.y,D,x))}),w.restore(),this},isControlVisible:function(w){return this.controls[w]&&this.controls[w].getVisibility(this,w)},setControlVisible:function(w,D){return this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[w]=D,this},setControlsVisibility:function(w){for(var D in w||(w={}),w)this.setControlVisible(D,w[D]);return this},onDeselect:function(){},onSelect:function(){}})}(),P.util.object.extend(P.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(S,w){var D=function(){},T=(w=w||{}).onComplete||D,_=w.onChange||D,C=this;return P.util.animate({target:this,startValue:S.left,endValue:this.getCenterPoint().x,duration:this.FX_DURATION,onChange:function(I){S.set("left",I),C.requestRenderAll(),_()},onComplete:function(){S.setCoords(),T()}})},fxCenterObjectV:function(S,w){var D=function(){},T=(w=w||{}).onComplete||D,_=w.onChange||D,C=this;return P.util.animate({target:this,startValue:S.top,endValue:this.getCenterPoint().y,duration:this.FX_DURATION,onChange:function(I){S.set("top",I),C.requestRenderAll(),_()},onComplete:function(){S.setCoords(),T()}})},fxRemove:function(S,w){var D=function(){},T=(w=w||{}).onComplete||D,_=w.onChange||D,C=this;return P.util.animate({target:this,startValue:S.opacity,endValue:0,duration:this.FX_DURATION,onChange:function(I){S.set("opacity",I),C.requestRenderAll(),_()},onComplete:function(){C.remove(S),T()}})}}),P.util.object.extend(P.Object.prototype,{animate:function(){if(arguments[0]&&"object"==typeof arguments[0]){var S,D=[],T=[];for(S in arguments[0])D.push(S);for(var _=0,C=D.length;_-1||_&&C.colorProperties.indexOf(_[1])>-1,M=_?this.get(_[0])[_[1]]:this.get(S);"from"in D||(D.from=M),I||(w=~w.indexOf("=")?M+parseFloat(w.replace("=","")):parseFloat(w));var x={target:this,startValue:D.from,endValue:w,byValue:D.by,easing:D.easing,duration:D.duration,abort:D.abort&&function(A,F,k){return D.abort.call(C,A,F,k)},onChange:function(A,F,k){_?C[_[0]][_[1]]=A:C.set(S,A),T||D.onChange&&D.onChange(A,F,k)},onComplete:function(A,F,k){T||(C.setCoords(),D.onComplete&&D.onComplete(A,F,k))}};return I?P.util.animateColor(x.startValue,x.endValue,x.duration,x):P.util.animate(x)}}),function(S){var w=S.fabric||(S.fabric={}),D=w.util.object.extend,T=w.util.object.clone,_={x1:1,x2:1,y1:1,y2:1};function C(I,M){var x=I.origin,A=I.axis1,F=I.axis2,k=I.dimension,V=M.nearest,H=M.center,G=M.farthest;return function(){switch(this.get(x)){case V:return Math.min(this.get(A),this.get(F));case H:return Math.min(this.get(A),this.get(F))+.5*this.get(k);case G:return Math.max(this.get(A),this.get(F))}}}w.Line?w.warn("fabric.Line is already defined"):(w.Line=w.util.createClass(w.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,cacheProperties:w.Object.prototype.cacheProperties.concat("x1","x2","y1","y2"),initialize:function(I,M){I||(I=[0,0,0,0]),this.callSuper("initialize",M),this.set("x1",I[0]),this.set("y1",I[1]),this.set("x2",I[2]),this.set("y2",I[3]),this._setWidthHeight(M)},_setWidthHeight:function(I){I||(I={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in I?I.left:this._getLeftToOriginX(),this.top="top"in I?I.top:this._getTopToOriginY()},_set:function(I,M){return this.callSuper("_set",I,M),void 0!==_[I]&&this._setWidthHeight(),this},_getLeftToOriginX:C({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:C({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(I){I.beginPath();var M=this.calcLinePoints();I.moveTo(M.x1,M.y1),I.lineTo(M.x2,M.y2),I.lineWidth=this.strokeWidth;var x=I.strokeStyle;I.strokeStyle=this.stroke||I.fillStyle,this.stroke&&this._renderStroke(I),I.strokeStyle=x},_findCenterFromElement:function(){return{x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2}},toObject:function(I){return D(this.callSuper("toObject",I),this.calcLinePoints())},_getNonTransformedDimensions:function(){var I=this.callSuper("_getNonTransformedDimensions");return"butt"===this.strokeLineCap&&(0===this.width&&(I.y-=this.strokeWidth),0===this.height&&(I.x-=this.strokeWidth)),I},calcLinePoints:function(){var I=this.x1<=this.x2?-1:1,M=this.y1<=this.y2?-1:1;return{x1:I*this.width*.5,x2:I*this.width*-.5,y1:M*this.height*.5,y2:M*this.height*-.5}},_toSVG:function(){var I=this.calcLinePoints();return["\n']}}),w.Line.ATTRIBUTE_NAMES=w.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),w.Line.fromElement=function(I,M,x){x=x||{};var A=w.parseAttributes(I,w.Line.ATTRIBUTE_NAMES);M(new w.Line([A.x1||0,A.y1||0,A.x2||0,A.y2||0],D(A,x)))},w.Line.fromObject=function(I,M){var x=T(I,!0);x.points=[I.x1,I.y1,I.x2,I.y2],w.Object._fromObject("Line",x,function(A){delete A.points,M&&M(A)},"points")})}(l),function(S){var w=S.fabric||(S.fabric={}),D=w.util.degreesToRadians;w.Circle?w.warn("fabric.Circle is already defined."):(w.Circle=w.util.createClass(w.Object,{type:"circle",radius:0,startAngle:0,endAngle:360,cacheProperties:w.Object.prototype.cacheProperties.concat("radius","startAngle","endAngle"),_set:function(T,_){return this.callSuper("_set",T,_),"radius"===T&&this.setRadius(_),this},toObject:function(T){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(T))},_toSVG:function(){var T,_=(this.endAngle-this.startAngle)%360;if(0===_)T=["\n'];else{var C=D(this.startAngle),I=D(this.endAngle),M=this.radius;T=['180?"1":"0")+" 1"," "+w.util.cos(I)*M+" "+w.util.sin(I)*M,'" ',"COMMON_PARTS"," />\n"]}return T},_render:function(T){T.beginPath(),T.arc(0,0,this.radius,D(this.startAngle),D(this.endAngle),!1),this._renderPaintInOrder(T)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(T){return this.radius=T,this.set("width",2*T).set("height",2*T)}}),w.Circle.ATTRIBUTE_NAMES=w.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),w.Circle.fromElement=function(T,_){var C,I=w.parseAttributes(T,w.Circle.ATTRIBUTE_NAMES);if(!("radius"in(C=I)&&C.radius>=0))throw new Error("value of `r` attribute is required and can not be negative");I.left=(I.left||0)-I.radius,I.top=(I.top||0)-I.radius,_(new w.Circle(I))},w.Circle.fromObject=function(T,_){w.Object._fromObject("Circle",T,_)})}(l),function(S){var w=S.fabric||(S.fabric={});w.Triangle?w.warn("fabric.Triangle is already defined"):(w.Triangle=w.util.createClass(w.Object,{type:"triangle",width:100,height:100,_render:function(D){var T=this.width/2,_=this.height/2;D.beginPath(),D.moveTo(-T,_),D.lineTo(0,-_),D.lineTo(T,_),D.closePath(),this._renderPaintInOrder(D)},_toSVG:function(){var D=this.width/2,T=this.height/2;return["']}}),w.Triangle.fromObject=function(D,T){return w.Object._fromObject("Triangle",D,T)})}(l),function(S){var w=S.fabric||(S.fabric={}),D=2*Math.PI;w.Ellipse?w.warn("fabric.Ellipse is already defined."):(w.Ellipse=w.util.createClass(w.Object,{type:"ellipse",rx:0,ry:0,cacheProperties:w.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(T){this.callSuper("initialize",T),this.set("rx",T&&T.rx||0),this.set("ry",T&&T.ry||0)},_set:function(T,_){switch(this.callSuper("_set",T,_),T){case"rx":this.rx=_,this.set("width",2*_);break;case"ry":this.ry=_,this.set("height",2*_)}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(T){return this.callSuper("toObject",["rx","ry"].concat(T))},_toSVG:function(){return["\n']},_render:function(T){T.beginPath(),T.save(),T.transform(1,0,0,this.ry/this.rx,0,0),T.arc(0,0,this.rx,0,D,!1),T.restore(),this._renderPaintInOrder(T)}}),w.Ellipse.ATTRIBUTE_NAMES=w.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),w.Ellipse.fromElement=function(T,_){var C=w.parseAttributes(T,w.Ellipse.ATTRIBUTE_NAMES);C.left=(C.left||0)-C.rx,C.top=(C.top||0)-C.ry,_(new w.Ellipse(C))},w.Ellipse.fromObject=function(T,_){w.Object._fromObject("Ellipse",T,_)})}(l),function(S){var w=S.fabric||(S.fabric={}),D=w.util.object.extend;w.Rect?w.warn("fabric.Rect is already defined"):(w.Rect=w.util.createClass(w.Object,{stateProperties:w.Object.prototype.stateProperties.concat("rx","ry"),type:"rect",rx:0,ry:0,cacheProperties:w.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(T){this.callSuper("initialize",T),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(T){var _=this.rx?Math.min(this.rx,this.width/2):0,C=this.ry?Math.min(this.ry,this.height/2):0,I=this.width,M=this.height,x=-this.width/2,A=-this.height/2,F=0!==_||0!==C,k=.4477152502;T.beginPath(),T.moveTo(x+_,A),T.lineTo(x+I-_,A),F&&T.bezierCurveTo(x+I-k*_,A,x+I,A+k*C,x+I,A+C),T.lineTo(x+I,A+M-C),F&&T.bezierCurveTo(x+I,A+M-k*C,x+I-k*_,A+M,x+I-_,A+M),T.lineTo(x+_,A+M),F&&T.bezierCurveTo(x+k*_,A+M,x,A+M-k*C,x,A+M-C),T.lineTo(x,A+C),F&&T.bezierCurveTo(x,A+k*C,x+k*_,A,x+_,A),T.closePath(),this._renderPaintInOrder(T)},toObject:function(T){return this.callSuper("toObject",["rx","ry"].concat(T))},_toSVG:function(){return["\n']}}),w.Rect.ATTRIBUTE_NAMES=w.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),w.Rect.fromElement=function(T,_,C){if(!T)return _(null);C=C||{};var I=w.parseAttributes(T,w.Rect.ATTRIBUTE_NAMES);I.left=I.left||0,I.top=I.top||0,I.height=I.height||0,I.width=I.width||0;var M=new w.Rect(D(C?w.util.object.clone(C):{},I));M.visible=M.visible&&M.width>0&&M.height>0,_(M)},w.Rect.fromObject=function(T,_){return w.Object._fromObject("Rect",T,_)})}(l),function(S){var w=S.fabric||(S.fabric={}),D=w.util.object.extend,T=w.util.array.min,_=w.util.array.max,C=w.util.toFixed,I=w.util.projectStrokeOnPoints;w.Polyline?w.warn("fabric.Polyline is already defined"):(w.Polyline=w.util.createClass(w.Object,{type:"polyline",points:null,exactBoundingBox:!1,cacheProperties:w.Object.prototype.cacheProperties.concat("points"),initialize:function(M,x){x=x||{},this.points=M||[],this.callSuper("initialize",x),this._setPositionDimensions(x)},_projectStrokeOnPoints:function(){return I(this.points,this,!0)},_setPositionDimensions:function(M){var x,A=this._calcDimensions(M),F=this.exactBoundingBox?this.strokeWidth:0;this.width=A.width-F,this.height=A.height-F,M.fromSVG||(x=this.translateToGivenOrigin({x:A.left-this.strokeWidth/2+F/2,y:A.top-this.strokeWidth/2+F/2},"left","top",this.originX,this.originY)),void 0===M.left&&(this.left=M.fromSVG?A.left:x.x),void 0===M.top&&(this.top=M.fromSVG?A.top:x.y),this.pathOffset={x:A.left+this.width/2+F/2,y:A.top+this.height/2+F/2}},_calcDimensions:function(){var M=this.exactBoundingBox?this._projectStrokeOnPoints():this.points,x=T(M,"x")||0,A=T(M,"y")||0;return{left:x,top:A,width:(_(M,"x")||0)-x,height:(_(M,"y")||0)-A}},toObject:function(M){return D(this.callSuper("toObject",M),{points:this.points.concat()})},_toSVG:function(){for(var M=[],x=this.pathOffset.x,A=this.pathOffset.y,F=w.Object.NUM_FRACTION_DIGITS,k=0,V=this.points.length;k\n']},commonRender:function(M){var x,A=this.points.length,F=this.pathOffset.x,k=this.pathOffset.y;if(!A||isNaN(this.points[A-1].y))return!1;M.beginPath(),M.moveTo(this.points[0].x-F,this.points[0].y-k);for(var V=0;V"},toObject:function(M){return _(this.callSuper("toObject",M),{path:this.path.map(function(x){return x.slice()})})},toDatalessObject:function(M){var x=this.toObject(["sourcePath"].concat(M));return x.sourcePath&&delete x.path,x},_toSVG:function(){return["\n"]},_getOffsetTransform:function(){var M=w.Object.NUM_FRACTION_DIGITS;return" translate("+I(-this.pathOffset.x,M)+", "+I(-this.pathOffset.y,M)+")"},toClipPathSVG:function(M){var x=this._getOffsetTransform();return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:M,additionalTransform:x})},toSVG:function(M){var x=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:M,additionalTransform:x})},complexity:function(){return this.path.length},_calcDimensions:function(){for(var M,x,A=[],F=[],k=0,V=0,H=0,G=0,z=0,Z=this.path.length;z"},addWithUpdate:function(_){var C=!!this.group;return this._restoreObjectsState(),w.util.resetObjectTransform(this),_&&(C&&w.util.removeTransformFromObject(_,this.group.calcTransformMatrix()),this._objects.push(_),_.group=this,_._set("canvas",this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.dirty=!0,C?this.group.addWithUpdate():this.setCoords(),this},removeWithUpdate:function(_){return this._restoreObjectsState(),w.util.resetObjectTransform(this),this.remove(_),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(_){this.dirty=!0,_.group=this,_._set("canvas",this.canvas)},_onObjectRemoved:function(_){this.dirty=!0,delete _.group},_set:function(_,C){var I=this._objects.length;if(this.useSetOnGroup)for(;I--;)this._objects[I].setOnGroup(_,C);if("canvas"===_)for(;I--;)this._objects[I]._set(_,C);w.Object.prototype._set.call(this,_,C)},toObject:function(_){var C=this.includeDefaultValues,I=this._objects.filter(function(x){return!x.excludeFromExport}).map(function(x){var A=x.includeDefaultValues;x.includeDefaultValues=C;var F=x.toObject(_);return x.includeDefaultValues=A,F}),M=w.Object.prototype.toObject.call(this,_);return M.objects=I,M},toDatalessObject:function(_){var C,I=this.sourcePath;if(I)C=I;else{var M=this.includeDefaultValues;C=this._objects.map(function(A){var F=A.includeDefaultValues;A.includeDefaultValues=M;var k=A.toDatalessObject(_);return A.includeDefaultValues=F,k})}var x=w.Object.prototype.toDatalessObject.call(this,_);return x.objects=C,x},render:function(_){this._transformDone=!0,this.callSuper("render",_),this._transformDone=!1},shouldCache:function(){var _=w.Object.prototype.shouldCache.call(this);if(_)for(var C=0,I=this._objects.length;C\n"],I=0,M=this._objects.length;I\n"),C},getSvgStyles:function(){var C=this.visible?"":" visibility: hidden;";return[void 0!==this.opacity&&1!==this.opacity?"opacity: "+this.opacity+";":"",this.getSvgFilter(),C].join("")},toClipPathSVG:function(_){for(var C=[],I=0,M=this._objects.length;I"},shouldCache:function(){return!1},isOnACache:function(){return!1},_renderControls:function(D,T,_){D.save(),D.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,this.callSuper("_renderControls",D,T),void 0===(_=_||{}).hasControls&&(_.hasControls=!1),_.forActiveSelection=!0;for(var C=0,I=this._objects.length;C\n','\t\n',"\n"),x=' clip-path="url(#imageCrop_'+F+')" '}if(this.imageSmoothing||(A='" image-rendering="optimizeSpeed'),_.push("\t\n"),this.stroke||this.strokeDashArray){var k=this.fill;this.fill=null,D=["\t\n'],this.fill=k}return"fill"!==this.paintFirst?T.concat(D,_):T.concat(_,D)},getSrc:function(D){var T=D?this._element:this._originalElement;return T?T.toDataURL?T.toDataURL():this.srcFromAttribute?T.getAttribute("src"):T.src:this.src||""},setSrc:function(D,T,_){return P.util.loadImage(D,function(C,I){this.setElement(C,_),this._setWidthHeight(),T&&T(this,I)},this,_&&_.crossOrigin),this},toString:function(){return'#'},applyResizeFilters:function(){var D=this.resizeFilter,T=this.minimumScaleTrigger,_=this.getTotalObjectScaling(),C=_.scaleX,I=_.scaleY,M=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!D||C>T&&I>T)return this._element=M,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=C,void(this._lastScaleY=I);P.filterBackend||(P.filterBackend=P.initFilterBackend());var x=P.util.createCanvasElement(),A=this._filteredEl?this.cacheKey+"_filtered":this.cacheKey,F=M.width,k=M.height;x.width=F,x.height=k,this._element=x,this._lastScaleX=D.scaleX=C,this._lastScaleY=D.scaleY=I,P.filterBackend.applyFilters([D],M,F,k,this._element,A),this._filterScalingX=x.width/this._originalElement.width,this._filterScalingY=x.height/this._originalElement.height},applyFilters:function(D){if(D=(D=D||this.filters||[]).filter(function(M){return M&&!M.isNeutralState()}),this.set("dirty",!0),this.removeTexture(this.cacheKey+"_filtered"),0===D.length)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;var T=this._originalElement,_=T.naturalWidth||T.width,C=T.naturalHeight||T.height;if(this._element===this._originalElement){var I=P.util.createCanvasElement();I.width=_,I.height=C,this._element=I,this._filteredEl=I}else this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,_,C),this._lastScaleX=1,this._lastScaleY=1;return P.filterBackend||(P.filterBackend=P.initFilterBackend()),P.filterBackend.applyFilters(D,this._originalElement,_,C,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height),this},_render:function(D){P.util.setImageSmoothing(D,this.imageSmoothing),!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(D),this._renderPaintInOrder(D)},drawCacheOnCanvas:function(D){P.util.setImageSmoothing(D,this.imageSmoothing),P.Object.prototype.drawCacheOnCanvas.call(this,D)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(D){var T=this._element;if(T){var _=this._filterScalingX,C=this._filterScalingY,I=this.width,M=this.height,x=Math.min,A=Math.max,F=A(this.cropX,0),k=A(this.cropY,0),V=T.naturalWidth||T.width,H=T.naturalHeight||T.height,G=F*_,z=k*C,Z=x(I*_,V-G),ie=x(M*C,H-z),re=-I/2,de=-M/2,ce=x(I,V/_-F),le=x(M,H/C-k);T&&D.drawImage(T,G,z,Z,ie,re,de,ce,le)}},_needsResize:function(){var D=this.getTotalObjectScaling();return D.scaleX!==this._lastScaleX||D.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(D,T){this.setElement(P.util.getById(D),T),P.util.addClass(this.getElement(),P.Image.CSS_CANVAS)},_initConfig:function(D){D||(D={}),this.setOptions(D),this._setWidthHeight(D)},_initFilters:function(D,T){D&&D.length?P.util.enlivenObjects(D,function(_){T&&T(_)},"fabric.Image.filters"):T&&T()},_setWidthHeight:function(D){D||(D={});var T=this.getElement();this.width=D.width||T.naturalWidth||T.width||0,this.height=D.height||T.naturalHeight||T.height||0},parsePreserveAspectRatioAttribute:function(){var D,T=P.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||""),_=this._element.width,C=this._element.height,I=1,M=1,x=0,A=0,F=0,k=0,V=this.width,H=this.height,G={width:V,height:H};return!T||"none"===T.alignX&&"none"===T.alignY?(I=V/_,M=H/C):("meet"===T.meetOrSlice&&(D=(V-_*(I=M=P.util.findScaleToFit(this._element,G)))/2,"Min"===T.alignX&&(x=-D),"Max"===T.alignX&&(x=D),D=(H-C*M)/2,"Min"===T.alignY&&(A=-D),"Max"===T.alignY&&(A=D)),"slice"===T.meetOrSlice&&(D=_-V/(I=M=P.util.findScaleToCover(this._element,G)),"Mid"===T.alignX&&(F=D/2),"Max"===T.alignX&&(F=D),D=C-H/M,"Mid"===T.alignY&&(k=D/2),"Max"===T.alignY&&(k=D),_=V/I,C=H/M)),{width:_,height:C,scaleX:I,scaleY:M,offsetLeft:x,offsetTop:A,cropX:F,cropY:k}}}),P.Image.CSS_CANVAS="canvas-img",P.Image.prototype.getSvgSrc=P.Image.prototype.getSrc,P.Image.fromObject=function(D,T){var _=P.util.object.clone(D);P.util.loadImage(_.src,function(C,I){I?T&&T(null,!0):P.Image.prototype._initFilters.call(_,_.filters,function(M){_.filters=M||[],P.Image.prototype._initFilters.call(_,[_.resizeFilter],function(x){_.resizeFilter=x[0],P.util.enlivenObjectEnlivables(_,_,function(){var A=new P.Image(C,_);T(A,!1)})})})},null,_.crossOrigin)},P.Image.fromURL=function(D,T,_){P.util.loadImage(D,function(C,I){T&&T(new P.Image(C,_),I)},null,_&&_.crossOrigin)},P.Image.ATTRIBUTE_NAMES=P.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin image-rendering".split(" ")),P.Image.fromElement=function(D,T,_){var C=P.parseAttributes(D,P.Image.ATTRIBUTE_NAMES);P.Image.fromURL(C["xlink:href"],T,w(_?P.util.object.clone(_):{},C))})}(l),P.util.object.extend(P.Object.prototype,{_getAngleValueForStraighten:function(){var S=this.angle%360;return S>0?90*Math.round((S-1)/90):90*Math.round(S/90)},straighten:function(){return this.rotate(this._getAngleValueForStraighten())},fxStraighten:function(S){var w=function(){},D=(S=S||{}).onComplete||w,T=S.onChange||w,_=this;return P.util.animate({target:this,startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(C){_.rotate(C),T()},onComplete:function(){_.setCoords(),D()}})}}),P.util.object.extend(P.StaticCanvas.prototype,{straightenObject:function(S){return S.straighten(),this.requestRenderAll(),this},fxStraightenObject:function(S){return S.fxStraighten({onChange:this.requestRenderAllBound})}}),function(){function S(D,T){var _="precision "+T+" float;\nvoid main(){}",C=D.createShader(D.FRAGMENT_SHADER);return D.shaderSource(C,_),D.compileShader(C),!!D.getShaderParameter(C,D.COMPILE_STATUS)}function w(D){D&&D.tileSize&&(this.tileSize=D.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}P.isWebglSupported=function(D){if(P.isLikelyNode)return!1;D=D||P.WebglFilterBackend.prototype.tileSize;var T=document.createElement("canvas"),_=T.getContext("webgl")||T.getContext("experimental-webgl"),C=!1;if(_){P.maxTextureSize=_.getParameter(_.MAX_TEXTURE_SIZE),C=P.maxTextureSize>=D;for(var I=["highp","mediump","lowp"],M=0;M<3;M++)if(S(_,I[M])){P.webGlPrecision=I[M];break}}return this.isSupported=C,C},P.WebglFilterBackend=w,w.prototype={tileSize:2048,resources:{},setupGLContext:function(D,T){this.dispose(),this.createWebGLCanvas(D,T),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(D,T)},chooseFastestCopyGLTo2DMethod:function(D,T){var _,C=void 0!==window.performance;try{new ImageData(1,1),_=!0}catch(H){_=!1}var I="undefined"!=typeof ArrayBuffer,M="undefined"!=typeof Uint8ClampedArray;if(C&&_&&I&&M){var x=P.util.createCanvasElement(),A=new ArrayBuffer(D*T*4);if(P.forceGLPutImageData)return this.imageBuffer=A,void(this.copyGLTo2D=et);var F,k,V={imageBuffer:A,destinationWidth:D,destinationHeight:T,targetCanvas:x};x.width=D,x.height=T,F=window.performance.now(),Be.call(V,this.gl,V),k=window.performance.now()-F,F=window.performance.now(),et.call(V,this.gl,V),k>window.performance.now()-F?(this.imageBuffer=A,this.copyGLTo2D=et):this.copyGLTo2D=Be}},createWebGLCanvas:function(D,T){var _=P.util.createCanvasElement();_.width=D,_.height=T;var C={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},I=_.getContext("webgl",C);I||(I=_.getContext("experimental-webgl",C)),I&&(I.clearColor(0,0,0,0),this.canvas=_,this.gl=I)},applyFilters:function(D,T,_,C,I,M){var x,A=this.gl;M&&(x=this.getCachedTexture(M,T));var V,H,Z,ie,F={originalWidth:T.width||T.originalWidth,originalHeight:T.height||T.originalHeight,sourceWidth:_,sourceHeight:C,destinationWidth:_,destinationHeight:C,context:A,sourceTexture:this.createTexture(A,_,C,!x&&T),targetTexture:this.createTexture(A,_,C),originalTexture:x||this.createTexture(A,_,C,!x&&T),passes:D.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:I},k=A.createFramebuffer();return A.bindFramebuffer(A.FRAMEBUFFER,k),D.forEach(function(V){V&&V.applyTo(F)}),ie=(V=F).destinationHeight,(H=V.targetCanvas).width===(Z=V.destinationWidth)&&H.height===ie||(H.width=Z,H.height=ie),this.copyGLTo2D(A,F),A.bindTexture(A.TEXTURE_2D,null),A.deleteTexture(F.sourceTexture),A.deleteTexture(F.targetTexture),A.deleteFramebuffer(k),I.getContext("2d").setTransform(1,0,0,1,0,0),F},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(D,T,_,C){var I=D.createTexture();return D.bindTexture(D.TEXTURE_2D,I),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_MAG_FILTER,D.NEAREST),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_MIN_FILTER,D.NEAREST),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_WRAP_S,D.CLAMP_TO_EDGE),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_WRAP_T,D.CLAMP_TO_EDGE),C?D.texImage2D(D.TEXTURE_2D,0,D.RGBA,D.RGBA,D.UNSIGNED_BYTE,C):D.texImage2D(D.TEXTURE_2D,0,D.RGBA,T,_,0,D.RGBA,D.UNSIGNED_BYTE,null),I},getCachedTexture:function(D,T){if(this.textureCache[D])return this.textureCache[D];var _=this.createTexture(this.gl,T.width,T.height,T);return this.textureCache[D]=_,_},evictCachesForKey:function(D){this.textureCache[D]&&(this.gl.deleteTexture(this.textureCache[D]),delete this.textureCache[D])},copyGLTo2D:Be,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var D=this.gl,T={renderer:"",vendor:""};if(!D)return T;var _=D.getExtension("WEBGL_debug_renderer_info");if(_){var C=D.getParameter(_.UNMASKED_RENDERER_WEBGL),I=D.getParameter(_.UNMASKED_VENDOR_WEBGL);C&&(T.renderer=C.toLowerCase()),I&&(T.vendor=I.toLowerCase())}return this.gpuInfo=T,T}}}(),function(){var S=function(){};function w(){}P.Canvas2dFilterBackend=w,w.prototype={evictCachesForKey:S,dispose:S,clearWebGLCaches:S,resources:{},applyFilters:function(D,T,_,C,I){var M=I.getContext("2d");M.drawImage(T,0,0,_,C);var x={sourceWidth:_,sourceHeight:C,imageData:M.getImageData(0,0,_,C),originalEl:T,originalImageData:M.getImageData(0,0,_,C),canvasEl:I,ctx:M,filterBackend:this};return D.forEach(function(A){A.applyTo(x)}),x.imageData.width===_&&x.imageData.height===C||(I.width=x.imageData.width,I.height=x.imageData.height),M.putImageData(x.imageData,0,0),x}}}(),P.Image=P.Image||{},P.Image.filters=P.Image.filters||{},P.Image.filters.BaseFilter=P.util.createClass({type:"BaseFilter",vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvoid main() {\nvTexCoord = aPosition;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:"precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D uTexture;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\n}",initialize:function(S){S&&this.setOptions(S)},setOptions:function(S){for(var w in S)this[w]=S[w]},createProgram:function(S,w,D){w=w||this.fragmentSource,D=D||this.vertexSource,"highp"!==P.webGlPrecision&&(w=w.replace(/precision highp float/g,"precision "+P.webGlPrecision+" float"));var T=S.createShader(S.VERTEX_SHADER);if(S.shaderSource(T,D),S.compileShader(T),!S.getShaderParameter(T,S.COMPILE_STATUS))throw new Error("Vertex shader compile error for "+this.type+": "+S.getShaderInfoLog(T));var _=S.createShader(S.FRAGMENT_SHADER);if(S.shaderSource(_,w),S.compileShader(_),!S.getShaderParameter(_,S.COMPILE_STATUS))throw new Error("Fragment shader compile error for "+this.type+": "+S.getShaderInfoLog(_));var C=S.createProgram();if(S.attachShader(C,T),S.attachShader(C,_),S.linkProgram(C),!S.getProgramParameter(C,S.LINK_STATUS))throw new Error('Shader link error for "${this.type}" '+S.getProgramInfoLog(C));var I=this.getAttributeLocations(S,C),M=this.getUniformLocations(S,C)||{};return M.uStepW=S.getUniformLocation(C,"uStepW"),M.uStepH=S.getUniformLocation(C,"uStepH"),{program:C,attributeLocations:I,uniformLocations:M}},getAttributeLocations:function(S,w){return{aPosition:S.getAttribLocation(w,"aPosition")}},getUniformLocations:function(){return{}},sendAttributeData:function(S,w,D){var T=w.aPosition,_=S.createBuffer();S.bindBuffer(S.ARRAY_BUFFER,_),S.enableVertexAttribArray(T),S.vertexAttribPointer(T,2,S.FLOAT,!1,0,0),S.bufferData(S.ARRAY_BUFFER,D,S.STATIC_DRAW)},_setupFrameBuffer:function(S){var w,D,T=S.context;S.passes>1?(D=S.destinationHeight,S.sourceWidth===(w=S.destinationWidth)&&S.sourceHeight===D||(T.deleteTexture(S.targetTexture),S.targetTexture=S.filterBackend.createTexture(T,w,D)),T.framebufferTexture2D(T.FRAMEBUFFER,T.COLOR_ATTACHMENT0,T.TEXTURE_2D,S.targetTexture,0)):(T.bindFramebuffer(T.FRAMEBUFFER,null),T.finish())},_swapTextures:function(S){S.passes--,S.pass++;var w=S.targetTexture;S.targetTexture=S.sourceTexture,S.sourceTexture=w},isNeutralState:function(){var S=this.mainParameter,w=P.Image.filters[this.type].prototype;if(S){if(Array.isArray(w[S])){for(var D=w[S].length;D--;)if(this[S][D]!==w[S][D])return!1;return!0}return w[S]===this[S]}return!1},applyTo:function(S){S.webgl?(this._setupFrameBuffer(S),this.applyToWebGL(S),this._swapTextures(S)):this.applyTo2d(S)},retrieveShader:function(S){return S.programCache.hasOwnProperty(this.type)||(S.programCache[this.type]=this.createProgram(S.context)),S.programCache[this.type]},applyToWebGL:function(S){var w=S.context,D=this.retrieveShader(S);w.bindTexture(w.TEXTURE_2D,0===S.pass&&S.originalTexture?S.originalTexture:S.sourceTexture),w.useProgram(D.program),this.sendAttributeData(w,D.attributeLocations,S.aPosition),w.uniform1f(D.uniformLocations.uStepW,1/S.sourceWidth),w.uniform1f(D.uniformLocations.uStepH,1/S.sourceHeight),this.sendUniformData(w,D.uniformLocations),w.viewport(0,0,S.destinationWidth,S.destinationHeight),w.drawArrays(w.TRIANGLE_STRIP,0,4)},bindAdditionalTexture:function(S,w,D){S.activeTexture(D),S.bindTexture(S.TEXTURE_2D,w),S.activeTexture(S.TEXTURE0)},unbindAdditionalTexture:function(S,w){S.activeTexture(w),S.bindTexture(S.TEXTURE_2D,null),S.activeTexture(S.TEXTURE0)},getMainParameter:function(){return this[this.mainParameter]},setMainParameter:function(S){this[this.mainParameter]=S},sendUniformData:function(){},createHelpLayer:function(S){if(!S.helpLayer){var w=document.createElement("canvas");w.width=S.sourceWidth,w.height=S.sourceHeight,S.helpLayer=w}},toObject:function(){var S={type:this.type},w=this.mainParameter;return w&&(S[w]=this[w]),S},toJSON:function(){return this.toObject()}}),P.Image.filters.BaseFilter.fromObject=function(S,w){var D=new P.Image.filters[S.type](S);return w&&w(D),D},function(S){var w=S.fabric||(S.fabric={}),D=w.Image.filters;D.ColorMatrix=(0,w.util.createClass)(D.BaseFilter,{type:"ColorMatrix",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nuniform mat4 uColorMatrix;\nuniform vec4 uConstants;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor *= uColorMatrix;\ncolor += uConstants;\ngl_FragColor = color;\n}",matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:"matrix",colorsOnly:!0,initialize:function(_){this.callSuper("initialize",_),this.matrix=this.matrix.slice(0)},applyTo2d:function(_){var C,I,M,x,A,F=_.imageData.data,k=F.length,V=this.matrix,H=this.colorsOnly;for(A=0;A=he||k<0||k>=oe||(I+=ce[H=4*(V*oe+k)]*(G=le[re*ee+ie]),M+=ce[H+1]*G,x+=ce[H+2]*G,te||(A+=ce[H+3]*G));ne[F]=I,ne[F+1]=M,ne[F+2]=x,ne[F+3]=te?ce[F+3]:A}C.imageData=fe},getUniformLocations:function(C,I){return{uMatrix:C.getUniformLocation(I,"uMatrix"),uOpaque:C.getUniformLocation(I,"uOpaque"),uHalfSize:C.getUniformLocation(I,"uHalfSize"),uSize:C.getUniformLocation(I,"uSize")}},sendUniformData:function(C,I){C.uniform1fv(I.uMatrix,this.matrix)},toObject:function(){return D(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),w.Image.filters.Convolute.fromObject=w.Image.filters.BaseFilter.fromObject}(l),function(S){var w=S.fabric||(S.fabric={}),D=w.Image.filters;D.Grayscale=(0,w.util.createClass)(D.BaseFilter,{type:"Grayscale",fragmentSource:{average:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat average = (color.r + color.b + color.g) / 3.0;\ngl_FragColor = vec4(average, average, average, color.a);\n}",lightness:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\ngl_FragColor = vec4(average, average, average, col.a);\n}",luminosity:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\ngl_FragColor = vec4(average, average, average, col.a);\n}"},mode:"average",mainParameter:"mode",applyTo2d:function(_){var C,I,M=_.imageData.data,x=M.length,A=this.mode;for(C=0;CH[0]&&x>H[1]&&A>H[2]&&M 0.0) {\n"+this.fragmentSource[_]+"}\n}"},retrieveShader:function(_){var C,I=this.type+"_"+this.mode;return _.programCache.hasOwnProperty(I)||(C=this.buildSource(this.mode),_.programCache[I]=this.createProgram(_.context,C)),_.programCache[I]},applyTo2d:function(_){var C,I,M,x,A,F,k,V=_.imageData.data,H=V.length,G=1-this.alpha;C=(k=new w.Color(this.color).getSource())[0]*this.alpha,I=k[1]*this.alpha,M=k[2]*this.alpha;for(var z=0;z=k||V<=-k)return 0;if(V<1.1920929e-7&&V>-1.1920929e-7)return 1;var H=(V*=Math.PI)/k;return M(V)/V*M(H)/H}},applyTo2d:function(k){var V=k.imageData,H=this.scaleX,G=this.scaleY;this.rcpScaleX=1/H,this.rcpScaleY=1/G;var z,Z=V.width,ie=V.height,re=I(Z*H),de=I(ie*G);"sliceHack"===this.resizeType?z=this.sliceByTwo(k,Z,ie,re,de):"hermite"===this.resizeType?z=this.hermiteFastResize(k,Z,ie,re,de):"bilinear"===this.resizeType?z=this.bilinearFiltering(k,Z,ie,re,de):"lanczos"===this.resizeType&&(z=this.lanczosResize(k,Z,ie,re,de)),k.imageData=z},sliceByTwo:function(k,V,H,G,z){var Z,ie,re=k.imageData,ce=!1,le=!1,ee=.5*V,J=.5*H,oe=w.filterBackend.resources,he=0,fe=0,ne=V,te=0;for(oe.sliceByTwo||(oe.sliceByTwo=document.createElement("canvas")),((Z=oe.sliceByTwo).width<1.5*V||Z.height=V)){Me=T(1e3*C(me-ne.x)),fe[Me]||(fe[Me]={});for(var It=te.y-he;It<=te.y+he;It++)It<0||It>=H||(lt=T(1e3*C(It-ne.y)),fe[Me][lt]||(fe[Me][lt]=de(_(D(Me*ee,2)+D(lt*J,2))/1e3)),(Ie=fe[Me][lt])>0&&(Ce+=Ie,Se+=Ie*Z[be=4*(It*V+me)],De+=Ie*Z[be+1],xe+=Ie*Z[be+2],Ve+=Ie*Z[be+3]))}re[be=4*(ue*G+ge)]=Se/Ce,re[be+1]=De/Ce,re[be+2]=xe/Ce,re[be+3]=Ve/Ce}return++ge1&&Me<-1||(fe=2*Me*Me*Me-3*Me*Me+1)>0&&(me+=fe*ce[3+(Ve=4*(xe+be*V))],te+=fe,ce[Ve+3]<255&&(fe=fe*ce[Ve+3]/250),ae+=fe*ce[Ve],ge+=fe*ce[Ve+1],ue+=fe*ce[Ve+2],ne+=fe)}ee[he]=ae/ne,ee[he+1]=ge/ne,ee[he+2]=ue/ne,ee[he+3]=me/te}return le},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),w.Image.filters.Resize.fromObject=w.Image.filters.BaseFilter.fromObject}(l),function(S){var w=S.fabric||(S.fabric={}),D=w.Image.filters;D.Contrast=(0,w.util.createClass)(D.BaseFilter,{type:"Contrast",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uContrast;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\ncolor.rgb = contrastF * (color.rgb - 0.5) + 0.5;\ngl_FragColor = color;\n}",contrast:0,mainParameter:"contrast",applyTo2d:function(_){if(0!==this.contrast){var C,I=_.imageData.data,M=I.length,x=Math.floor(255*this.contrast),A=259*(x+255)/(255*(259-x));for(C=0;C1&&(C=1/this.aspectRatio):this.aspectRatio<1&&(C=this.aspectRatio),_=C*this.blur*.12,this.horizontal?I[0]=_:I[1]=_,I}}),D.Blur.fromObject=w.Image.filters.BaseFilter.fromObject}(l),function(S){var w=S.fabric||(S.fabric={}),D=w.Image.filters;D.Gamma=(0,w.util.createClass)(D.BaseFilter,{type:"Gamma",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec3 uGamma;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec3 correction = (1.0 / uGamma);\ncolor.r = pow(color.r, correction.r);\ncolor.g = pow(color.g, correction.g);\ncolor.b = pow(color.b, correction.b);\ngl_FragColor = color;\ngl_FragColor.rgb *= color.a;\n}",gamma:[1,1,1],mainParameter:"gamma",initialize:function(_){this.gamma=[1,1,1],D.BaseFilter.prototype.initialize.call(this,_)},applyTo2d:function(_){var C,I=_.imageData.data,M=this.gamma,x=I.length,A=1/M[0],F=1/M[1],k=1/M[2];for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),C=0,x=256;C'},_getCacheCanvasDimensions:function(){var _=this.callSuper("_getCacheCanvasDimensions"),C=this.fontSize;return _.width+=C*_.zoomX,_.height+=C*_.zoomY,_},_render:function(_){var C=this.path;C&&!C.isNotVisible()&&C._render(_),this._setTextStyles(_),this._renderTextLinesBackground(_),this._renderTextDecoration(_,"underline"),this._renderText(_),this._renderTextDecoration(_,"overline"),this._renderTextDecoration(_,"linethrough")},_renderText:function(_){"stroke"===this.paintFirst?(this._renderTextStroke(_),this._renderTextFill(_)):(this._renderTextFill(_),this._renderTextStroke(_))},_setTextStyles:function(_,C,I){if(_.textBaseline="alphabetical",this.path)switch(this.pathAlign){case"center":_.textBaseline="middle";break;case"ascender":_.textBaseline="top";break;case"descender":_.textBaseline="bottom"}_.font=this._getFontDeclaration(C,I)},calcTextWidth:function(){for(var _=this.getLineWidth(0),C=1,I=this._textLines.length;C_&&(_=M)}return _},_renderTextLine:function(_,C,I,M,x,A){this._renderChars(_,C,I,M,x,A)},_renderTextLinesBackground:function(_){if(this.textBackgroundColor||this.styleHas("textBackgroundColor")){for(var C,I,M,x,A,F,k,V=_.fillStyle,H=this._getLeftOffset(),G=this._getTopOffset(),z=0,Z=0,ie=this.path,re=0,de=this._textLines.length;re=0:CF?G%=F:G<0&&(G+=F),this._setGraphemeOnPath(G,x=H[C],A),G+=x.kernedWidth}return{width:k,numOfSpaces:0}},_setGraphemeOnPath:function(_,C,I){var x=this.path,A=w.util.getPointOnPath(x.path,_+C.kernedWidth/2,x.segmentsInfo);C.renderLeft=A.x-I.x,C.renderTop=A.y-I.y,C.angle=A.angle+("right"===this.pathSide?Math.PI:0)},_getGraphemeBox:function(_,C,I,M,x){var A,F=this.getCompleteStyleDeclaration(C,I),k=M?this.getCompleteStyleDeclaration(C,I-1):{},V=this._measureChar(_,F,M,k),H=V.kernedWidth,G=V.width;0!==this.charSpacing&&(G+=A=this._getWidthOfCharSpacing(),H+=A);var z={width:G,left:0,height:F.fontSize,kernedWidth:H,deltaY:F.deltaY};if(I>0&&!x){var Z=this.__charBounds[C][I-1];z.left=Z.left+Z.width+V.kernedWidth-V.width}return z},getHeightOfLine:function(_){if(this.__lineHeights[_])return this.__lineHeights[_];for(var C=this._textLines[_],I=this.getHeightOfChar(_,0),M=1,x=C.length;M0){var ue=ee+A+z;"rtl"===this.direction&&(ue=this.width-ue-Z),H&&le&&(_.fillStyle=le,_.fillRect(ue,G+fe*M+F,Z,this.fontSize/15)),z=ie.left,Z=ie.width,H=re,le=ce,M=x,F=k}else Z+=ie.kernedWidth;ue=ee+A+z,"rtl"===this.direction&&(ue=this.width-ue-Z),_.fillStyle=ce,re&&ce&&_.fillRect(ue,G+fe*M+F,Z-he,this.fontSize/15),J+=I}else J+=I;this._removeShadow(_)}},_getFontDeclaration:function(_,C){var I=_||this,M=this.fontFamily,x=w.Text.genericFonts.indexOf(M.toLowerCase())>-1,A=void 0===M||M.indexOf("'")>-1||M.indexOf(",")>-1||M.indexOf('"')>-1||x?I.fontFamily:'"'+I.fontFamily+'"';return[w.isLikelyNode?I.fontWeight:I.fontStyle,w.isLikelyNode?I.fontStyle:I.fontWeight,C?this.CACHE_FONT_SIZE+"px":I.fontSize+"px",A].join(" ")},render:function(_){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._shouldClearDimensionCache()&&this.initDimensions(),this.callSuper("render",_)))},_splitTextIntoLines:function(_){for(var C=_.split(this._reNewline),I=new Array(C.length),M=["\n"],x=[],A=0;A-1&&(w.underline=!0),w.textDecoration.indexOf("line-through")>-1&&(w.linethrough=!0),w.textDecoration.indexOf("overline")>-1&&(w.overline=!0),delete w.textDecoration)}P.IText=P.util.createClass(P.Text,P.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],inCompositionMode:!1,initialize:function(w,D){this.callSuper("initialize",w,D),this.initBehavior()},setSelectionStart:function(w){w=Math.max(w,0),this._updateAndFire("selectionStart",w)},setSelectionEnd:function(w){w=Math.min(w,this.text.length),this._updateAndFire("selectionEnd",w)},_updateAndFire:function(w,D){this[w]!==D&&(this._fireSelectionChanged(),this[w]=D),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},initDimensions:function(){this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this.callSuper("initDimensions")},render:function(w){this.clearContextTop(),this.callSuper("render",w),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(w){this.callSuper("_render",w)},clearContextTop:function(w){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var D=this.canvas.contextTop,T=this.canvas.viewportTransform;D.save(),D.transform(T[0],T[1],T[2],T[3],T[4],T[5]),this.transform(D),this._clearTextArea(D),w||D.restore()}},renderCursorOrSelection:function(){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var w=this._getCursorBoundaries(),D=this.canvas.contextTop;this.clearContextTop(!0),this.selectionStart===this.selectionEnd?this.renderCursor(w,D):this.renderSelection(w,D),D.restore()}},_clearTextArea:function(w){var D=this.width+4,T=this.height+4;w.clearRect(-D/2,-T/2,D,T)},_getCursorBoundaries:function(w){void 0===w&&(w=this.selectionStart);var D=this._getLeftOffset(),T=this._getTopOffset(),_=this._getCursorBoundariesOffsets(w);return{left:D,top:T,leftOffset:_.left,topOffset:_.top}},_getCursorBoundariesOffsets:function(w){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;var D,T,_,C,I=0,M=0,x=this.get2DCursorLocation(w);_=x.charIndex,T=x.lineIndex;for(var A=0;A0?M:0)},"rtl"===this.direction&&(C.left*=-1),this.cursorOffsetCache=C,this.cursorOffsetCache},renderCursor:function(w,D){var T=this.get2DCursorLocation(),_=T.lineIndex,C=T.charIndex>0?T.charIndex-1:0,I=this.getValueOfPropertyAt(_,C,"fontSize"),M=this.scaleX*this.canvas.getZoom(),x=this.cursorWidth/M,A=w.topOffset,F=this.getValueOfPropertyAt(_,C,"deltaY");A+=(1-this._fontSizeFraction)*this.getHeightOfLine(_)/this.lineHeight-I*(1-this._fontSizeFraction),this.inCompositionMode&&this.renderSelection(w,D),D.fillStyle=this.cursorColor||this.getValueOfPropertyAt(_,C,"fill"),D.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,D.fillRect(w.left+w.leftOffset-x/2,A+w.top+F,x,I)},renderSelection:function(w,D){for(var T=this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,_=this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd,C=-1!==this.textAlign.indexOf("justify"),I=this.get2DCursorLocation(T),M=this.get2DCursorLocation(_),x=I.lineIndex,A=M.lineIndex,F=I.charIndex<0?0:I.charIndex,k=M.charIndex<0?0:M.charIndex,V=x;V<=A;V++){var H,G=this._getLineLeftOffset(V)||0,z=this.getHeightOfLine(V),Z=0,ie=0;if(V===x&&(Z=this.__charBounds[x][F].left),V>=x&&V1)&&(z/=this.lineHeight);var de=w.left+G+Z,ce=ie-Z,le=z,ee=0;this.inCompositionMode?(D.fillStyle=this.compositionColor||"black",le=1,ee=z):D.fillStyle=this.selectionColor,"rtl"===this.direction&&(de=this.width-de-ce),D.fillRect(de,w.top+w.topOffset+ee,ce,le),w.topOffset+=H}},getCurrentCharFontSize:function(){var w=this._getCurrentCharIndex();return this.getValueOfPropertyAt(w.l,w.c,"fontSize")},getCurrentCharColor:function(){var w=this._getCurrentCharIndex();return this.getValueOfPropertyAt(w.l,w.c,"fill")},_getCurrentCharIndex:function(){var w=this.get2DCursorLocation(this.selectionStart,!0);return{l:w.lineIndex,c:w.charIndex>0?w.charIndex-1:0}}}),P.IText.fromObject=function(w,D){if(S(w),w.styles)for(var T in w.styles)for(var _ in w.styles[T])S(w.styles[T][_]);P.Object._fromObject("IText",w,D,"text")}}(),Ae=P.util.object.clone,P.util.object.extend(P.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1},initAddedHandler:function(){var S=this;this.on("added",function(){var w=S.canvas;w&&(w._hasITextHandlers||(w._hasITextHandlers=!0,S._initCanvasHandlers(w)),w._iTextInstances=w._iTextInstances||[],w._iTextInstances.push(S))})},initRemovedHandler:function(){var S=this;this.on("removed",function(){var w=S.canvas;w&&(w._iTextInstances=w._iTextInstances||[],P.util.removeFromArray(w._iTextInstances,S),0===w._iTextInstances.length&&(w._hasITextHandlers=!1,S._removeCanvasHandlers(w)))})},_initCanvasHandlers:function(S){S._mouseUpITextHandler=function(){S._iTextInstances&&S._iTextInstances.forEach(function(w){w.__isMousedown=!1})},S.on("mouse:up",S._mouseUpITextHandler)},_removeCanvasHandlers:function(S){S.off("mouse:up",S._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(S,w,D,T){var _;return _={isAborted:!1,abort:function(){this.isAborted=!0}},S.animate("_currentCursorOpacity",w,{duration:D,onComplete:function(){_.isAborted||S[T]()},onChange:function(){S.canvas&&S.selectionStart===S.selectionEnd&&S.renderCursorOrSelection()},abort:function(){return _.isAborted}}),_},_onTickComplete:function(){var S=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout(function(){S._currentTickCompleteState=S._animateCursor(S,0,this.cursorDuration/2,"_tick")},100)},initDelayedCursor:function(S){var w=this,D=S?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout(function(){w._tick()},D)},abortCursorAnimation:function(){var S=this._currentTickState||this._currentTickCompleteState,w=this.canvas;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,S&&w&&w.clearContext(w.contextTop||w.contextContainer)},selectAll:function(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this},getSelectedText:function(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")},findWordBoundaryLeft:function(S){var w=0,D=S-1;if(this._reSpace.test(this._text[D]))for(;this._reSpace.test(this._text[D]);)w++,D--;for(;/\S/.test(this._text[D])&&D>-1;)w++,D--;return S-w},findWordBoundaryRight:function(S){var w=0,D=S;if(this._reSpace.test(this._text[D]))for(;this._reSpace.test(this._text[D]);)w++,D++;for(;/\S/.test(this._text[D])&&D-1;)w++,D--;return S-w},findLineBoundaryRight:function(S){for(var w=0,D=S;!/\n/.test(this._text[D])&&D0&&Tthis.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=w):(this.selectionStart=w,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===D&&this.selectionEnd===T||(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},fromStringToGraphemeSelection:function(S,w,D){var T=D.slice(0,S),_=P.util.string.graphemeSplit(T).length;if(S===w)return{selectionStart:_,selectionEnd:_};var C=D.slice(S,w);return{selectionStart:_,selectionEnd:_+P.util.string.graphemeSplit(C).length}},fromGraphemeToStringSelection:function(S,w,D){var T=D.slice(0,S).join("").length;return S===w?{selectionStart:T,selectionEnd:T}:{selectionStart:T,selectionEnd:T+D.slice(S,w).join("").length}},_updateTextarea:function(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){var S=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=S.selectionStart,this.hiddenTextarea.selectionEnd=S.selectionEnd}this.updateTextareaPosition()}},updateFromTextArea:function(){if(this.hiddenTextarea){this.cursorOffsetCache={},this.text=this.hiddenTextarea.value,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords());var S=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value);this.selectionEnd=this.selectionStart=S.selectionEnd,this.inCompositionMode||(this.selectionStart=S.selectionStart),this.updateTextareaPosition()}},updateTextareaPosition:function(){if(this.selectionStart===this.selectionEnd){var S=this._calcTextareaPosition();this.hiddenTextarea.style.left=S.left,this.hiddenTextarea.style.top=S.top}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var S=this.inCompositionMode?this.compositionStart:this.selectionStart,w=this._getCursorBoundaries(S),D=this.get2DCursorLocation(S),C=this.getValueOfPropertyAt(D.lineIndex,D.charIndex,"fontSize")*this.lineHeight,I=w.leftOffset,M=this.calcTransformMatrix(),x={x:w.left+I,y:w.top+w.topOffset+C},A=this.canvas.getRetinaScaling(),F=this.canvas.upperCanvasEl,k=F.width/A,V=F.height/A,H=k-C,G=V-C,z=F.clientWidth/k,Z=F.clientHeight/V;return x=P.util.transformPoint(x,M),(x=P.util.transformPoint(x,this.canvas.viewportTransform)).x*=z,x.y*=Z,x.x<0&&(x.x=0),x.x>H&&(x.x=H),x.y<0&&(x.y=0),x.y>G&&(x.y=G),x.x+=this.canvas._offset.left,x.y+=this.canvas._offset.top,{left:x.x+"px",top:x.y+"px",fontSize:C+"px",charHeight:C}},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var S=this._textBeforeEdit!==this.text,w=this.hiddenTextarea;return this.selected=!1,this.isEditing=!1,this.selectionEnd=this.selectionStart,w&&(w.blur&&w.blur(),w.parentNode&&w.parentNode.removeChild(w)),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this.fire("editing:exited"),S&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),S&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var S in this.styles)this._textLines[S]||delete this.styles[S]},removeStyleFromTo:function(S,w){var D,T,_=this.get2DCursorLocation(S,!0),C=this.get2DCursorLocation(w,!0),I=_.lineIndex,M=_.charIndex,x=C.lineIndex,A=C.charIndex;if(I!==x){if(this.styles[I])for(D=M;D=A&&(T[F-V]=T[k],delete T[k])}},shiftLineStyles:function(S,w){var D=Ae(this.styles);for(var T in this.styles){var _=parseInt(T,10);_>S&&(this.styles[_+w]=D[_],D[_-w]||delete this.styles[_])}},restartCursorIfNeeded:function(){this._currentTickState&&!this._currentTickState.isAborted&&this._currentTickCompleteState&&!this._currentTickCompleteState.isAborted||this.initDelayedCursor()},insertNewlineStyleObject:function(S,w,D,T){var _,C={},I=!1,M=this._unwrappedTextLines[S].length===w;for(var x in D||(D=1),this.shiftLineStyles(S,D),this.styles[S]&&(_=this.styles[S][0===w?w:w-1]),this.styles[S]){var A=parseInt(x,10);A>=w&&(I=!0,C[A-w]=this.styles[S][x],M&&0===w||delete this.styles[S][x])}var F=!1;for(I&&!M&&(this.styles[S+D]=C,F=!0),F&&D--;D>0;)T&&T[D-1]?this.styles[S+D]={0:Ae(T[D-1])}:_?this.styles[S+D]={0:Ae(_)}:delete this.styles[S+D],D--;this._forceClearCache=!0},insertCharStyleObject:function(S,w,D,T){this.styles||(this.styles={});var _=this.styles[S],C=_?Ae(_):{};for(var I in D||(D=1),C){var M=parseInt(I,10);M>=w&&(_[M+D]=C[M],C[M-D]||delete _[M])}if(this._forceClearCache=!0,T)for(;D--;)Object.keys(T[D]).length&&(this.styles[S]||(this.styles[S]={}),this.styles[S][w+D]=Ae(T[D]));else if(_)for(var x=_[w?w-1:1];x&&D--;)this.styles[S][w+D]=Ae(x)},insertNewStyleBlock:function(S,w,D){for(var T=this.get2DCursorLocation(w,!0),_=[0],C=0,I=0;I0&&(this.insertCharStyleObject(T.lineIndex,T.charIndex,_[0],D),D=D&&D.slice(_[0]+1)),C&&this.insertNewlineStyleObject(T.lineIndex,T.charIndex+_[0],C),I=1;I0?this.insertCharStyleObject(T.lineIndex+I,0,_[I],D):D&&this.styles[T.lineIndex+I]&&D[0]&&(this.styles[T.lineIndex+I][0]=D[0]),D=D&&D.slice(_[I]+1);_[I]>0&&this.insertCharStyleObject(T.lineIndex+I,0,_[I],D)},setSelectionStartEndWithShift:function(S,w,D){D<=S?(w===S?this._selectionDirection="left":"right"===this._selectionDirection&&(this._selectionDirection="left",this.selectionEnd=S),this.selectionStart=D):D>S&&DS?this.selectionStart=S:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>S?this.selectionEnd=S:this.selectionEnd<0&&(this.selectionEnd=0)}}),P.util.object.extend(P.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(S){if(this.canvas){this.__newClickTime=+new Date;var w=S.pointer;this.isTripleClick(w)&&(this.fire("tripleclick",S),this._stopEvent(S.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=w,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(S){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===S.x&&this.__lastPointer.y===S.y},_stopEvent:function(S){S.preventDefault&&S.preventDefault(),S.stopPropagation&&S.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(S){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(S.e))},tripleClickHandler:function(S){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(S.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(S){!this.canvas||!this.editable||S.e.button&&1!==S.e.button||(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(S.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(S){!this.canvas||!this.editable||S.e.button&&1!==S.e.button||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(S){if(this.__isMousedown=!1,!(!this.editable||this.group||S.transform&&S.transform.actionPerformed||S.e.button&&1!==S.e.button)){if(this.canvas){var w=this.canvas._activeObject;if(w&&w!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(S.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(S){var w=this.getSelectionStartFromPointer(S);S.shiftKey?this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,w):(this.selectionStart=w,this.selectionEnd=w),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(S){for(var w,D=this.getLocalPointer(S),T=0,_=0,C=0,I=0,M=0,x=0,A=this._textLines.length;x0&&(I+=this._textLines[x-1].length+this.missingNewlineOffset(x-1));_=this._getLineLeftOffset(M)*this.scaleX,w=this._textLines[M],"rtl"===this.direction&&(D.x=this.width*this.scaleX-D.x+_);for(var F=0,k=w.length;FS.x-w||I<0?0:1);return this.flipX&&(M=_-M),M>this._text.length&&(M=this._text.length),M}}),P.util.object.extend(P.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=P.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var S=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+S.top+"; left: "+S.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding\uff70top: "+S.fontSize+";",this.hiddenTextareaContainer?this.hiddenTextareaContainer.appendChild(this.hiddenTextarea):P.document.body.appendChild(this.hiddenTextarea),P.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),P.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),P.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),P.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),P.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),P.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),P.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),P.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),P.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(P.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},keysMapRtl:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorLeft",36:"moveCursorRight",37:"moveCursorRight",38:"moveCursorUp",39:"moveCursorLeft",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(S){if(this.isEditing){var w="rtl"===this.direction?this.keysMapRtl:this.keysMap;if(S.keyCode in w)this[w[S.keyCode]](S);else{if(!(S.keyCode in this.ctrlKeysMapDown)||!S.ctrlKey&&!S.metaKey)return;this[this.ctrlKeysMapDown[S.keyCode]](S)}S.stopImmediatePropagation(),S.preventDefault(),S.keyCode>=33&&S.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(S){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:S.keyCode in this.ctrlKeysMapUp&&(S.ctrlKey||S.metaKey)&&(this[this.ctrlKeysMapUp[S.keyCode]](S),S.stopImmediatePropagation(),S.preventDefault(),this.canvas&&this.canvas.requestRenderAll())},onInput:function(S){var w=this.fromPaste;if(this.fromPaste=!1,S&&S.stopPropagation(),this.isEditing){var D,T,_,C,I,M=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,x=this._text.length,A=M.length,F=A-x,k=this.selectionStart,V=this.selectionEnd,H=k!==V;if(""===this.hiddenTextarea.value)return this.styles={},this.updateFromTextArea(),this.fire("changed"),void(this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll()));var G=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),z=k>G.selectionStart;H?(D=this._text.slice(k,V),F+=V-k):A0&&(T+=(D=this.__charBounds[S][w-1]).left+D.width),T},getDownCursorOffset:function(S,w){var D=this._getSelectionForOffset(S,w),T=this.get2DCursorLocation(D),_=T.lineIndex;if(_===this._textLines.length-1||S.metaKey||34===S.keyCode)return this._text.length-D;var C=T.charIndex,I=this._getWidthBeforeCursor(_,C),M=this._getIndexOnLine(_+1,I);return this._textLines[_].slice(C).length+M+1+this.missingNewlineOffset(_)},_getSelectionForOffset:function(S,w){return S.shiftKey&&this.selectionStart!==this.selectionEnd&&w?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(S,w){var D=this._getSelectionForOffset(S,w),T=this.get2DCursorLocation(D),_=T.lineIndex;if(0===_||S.metaKey||33===S.keyCode)return-D;var C=T.charIndex,I=this._getWidthBeforeCursor(_,C),M=this._getIndexOnLine(_-1,I),x=this._textLines[_].slice(0,C),A=this.missingNewlineOffset(_-1);return-this._textLines[_-1].length+M-x.length+(1-A)},_getIndexOnLine:function(S,w){for(var D,T,_=this._textLines[S],C=this._getLineLeftOffset(S),I=0,M=0,x=_.length;Mw){T=!0;var F=C,k=Math.abs(C-D-w);I=Math.abs(F-w)=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",S)},moveCursorUp:function(S){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",S)},_moveCursorUpOrDown:function(S,w){var D=this["get"+S+"CursorOffset"](w,"right"===this._selectionDirection);w.shiftKey?this.moveCursorWithShift(D):this.moveCursorWithoutShift(D),0!==D&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(S){return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,"left"===this._selectionDirection?this.selectionStart+S:this.selectionEnd+S),0!==S},moveCursorWithoutShift:function(S){return S<0?(this.selectionStart+=S,this.selectionEnd=this.selectionStart):(this.selectionEnd+=S,this.selectionStart=this.selectionEnd),0!==S},moveCursorLeft:function(S){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",S)},_move:function(S,w,D){var T;if(S.altKey)T=this["findWordBoundary"+D](this[w]);else{if(!S.metaKey&&35!==S.keyCode&&36!==S.keyCode)return this[w]+="Left"===D?-1:1,!0;T=this["findLineBoundary"+D](this[w])}if(void 0!==typeof T&&this[w]!==T)return this[w]=T,!0},_moveLeft:function(S,w){return this._move(S,w,"Left")},_moveRight:function(S,w){return this._move(S,w,"Right")},moveCursorLeftWithoutShift:function(S){var w=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(w=this._moveLeft(S,"selectionStart")),this.selectionEnd=this.selectionStart,w},moveCursorLeftWithShift:function(S){return"right"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveLeft(S,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection="left",this._moveLeft(S,"selectionStart")):void 0},moveCursorRight:function(S){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",S)},_moveCursorLeftOrRight:function(S,w){var D="moveCursor"+S+"With";this._currentCursorOpacity=1,this[D+=w.shiftKey?"Shift":"outShift"](w)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(S){return"left"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveRight(S,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection="right",this._moveRight(S,"selectionEnd")):void 0},moveCursorRightWithoutShift:function(S){var w=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(w=this._moveRight(S,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,w},removeChars:function(S,w){void 0===w&&(w=S+1),this.removeStyleFromTo(S,w),this._text.splice(S,w-S),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(S,w,D,T){void 0===T&&(T=D),T>D&&this.removeStyleFromTo(D,T);var _=P.util.string.graphemeSplit(S);this.insertNewStyleBlock(_,D,w),this._text=[].concat(this._text.slice(0,D),_,this._text.slice(T)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),function(){var S=P.util.toFixed,w=/ +/g;P.util.object.extend(P.Text.prototype,{_toSVG:function(){var D=this._getSVGLeftTopOffsets(),T=this._getSVGTextAndBg(D.textTop,D.textLeft);return this._wrapSVGTextAndBg(T)},toSVG:function(D){return this._createBaseSVGMarkup(this._toSVG(),{reviver:D,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(D){var T=this.getSvgTextDecoration(this);return[D.textBgRects.join(""),'\t\t",D.textSpans.join(""),"\n"]},_getSVGTextAndBg:function(D,T){var _,C=[],I=[],M=D;this._setSVGBg(I);for(var x=0,A=this._textLines.length;x",P.util.string.escapeXml(D),""].join("")},_setSVGTextLineText:function(D,T,_,C){var I,M,x,A,F,k=this.getHeightOfLine(T),V=-1!==this.textAlign.indexOf("justify"),H="",G=0,z=this._textLines[T];C+=k*(1-this._fontSizeFraction)/this.lineHeight;for(var Z=0,ie=z.length-1;Z<=ie;Z++)F=Z===ie||this.charSpacing,H+=z[Z],x=this.__charBounds[T][Z],0===G?(_+=x.kernedWidth-x.width,G+=x.width):G+=x.kernedWidth,V&&!F&&this._reSpaceAndTab.test(z[Z])&&(F=!0),F||(I=I||this.getCompleteStyleDeclaration(T,Z),M=this.getCompleteStyleDeclaration(T,Z+1),F=this._hasStyleChangedForSvg(I,M)),F&&(A=this._getStyleDeclaration(T,Z)||{},D.push(this._createTextCharSpan(H,A,_,C)),H="",I=M,_+=G,G=0)},_pushTextBgRect:function(D,T,_,C,I,M){var x=P.Object.NUM_FRACTION_DIGITS;D.push("\t\t\n')},_setSVGTextLineBg:function(D,T,_,C){for(var I,M,x=this._textLines[T],A=this.getHeightOfLine(T)/this.lineHeight,F=0,k=0,V=this.getValueOfPropertyAt(T,0,"textBackgroundColor"),H=0,G=x.length;Hthis.width&&this._set("width",this.dynamicMinWidth),-1!==this.textAlign.indexOf("justify")&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(D){for(var T=0,_=0,C=0,I={},M=0;M0?(_=0,C++,T++):!this.splitByGrapheme&&this._reSpaceAndTab.test(D.graphemeText[C])&&M>0&&(_++,C++),I[M]={line:T,offset:_},C+=D.graphemeLines[M].length,_+=D.graphemeLines[M].length;return I},styleHas:function(D,T){if(this._styleMap&&!this.isWrapping){var _=this._styleMap[T];_&&(T=_.line)}return w.Text.prototype.styleHas.call(this,D,T)},isEmptyStyles:function(D){if(!this.styles)return!0;var T,_,C=0,I=!1,M=this._styleMap[D],x=this._styleMap[D+1];for(var A in M&&(D=M.line,C=M.offset),x&&(I=x.line===D,T=x.offset),_=void 0===D?this.styles:{line:this.styles[D]})for(var F in _[A])if(F>=C&&(!I||F_&&!ie?(x.push(A),A=[],I=G,ie=!0):I+=re,ie||M||A.push(H),A=A.concat(k),z=M?0:this._measureWord([H],T,V),V++,ie=!1,G>Z&&(Z=G);return de&&x.push(A),Z+C>this.dynamicMinWidth&&(this.dynamicMinWidth=Z-re+C),x},isEndOfWrapping:function(D){return!this._styleMap[D+1]||this._styleMap[D+1].line!==this._styleMap[D].line},missingNewlineOffset:function(D){return this.splitByGrapheme?this.isEndOfWrapping(D)?1:0:1},_splitTextIntoLines:function(D){for(var T=w.Text.prototype._splitTextIntoLines.call(this,D),_=this._wrapText(T.lines,this.width),C=new Array(_.length),I=0;I<_.length;I++)C[I]=_[I].join("");return T.lines=C,T.graphemeLines=_,T},getMinWidth:function(){return Math.max(this.minWidth,this.dynamicMinWidth)},_removeExtraneousStyles:function(){var D={};for(var T in this._styleMap)this._textLines[T]&&(D[this._styleMap[T].line]=1);for(var T in this.styles)D[T]||delete this.styles[T]},toObject:function(D){return this.callSuper("toObject",["minWidth","splitByGrapheme"].concat(D))}}),w.Textbox.fromObject=function(D,T){return w.Object._fromObject("Textbox",D,T,"text")}}(l),function(){var S=P.controlsUtils,w=S.scaleSkewCursorStyleHandler,D=S.scaleCursorStyleHandler,T=S.scalingEqually,_=S.scalingYOrSkewingX,C=S.scalingXOrSkewingY,I=S.scaleOrSkewActionName,M=P.Object.prototype.controls;if(M.ml=new P.Control({x:-.5,y:0,cursorStyleHandler:w,actionHandler:C,getActionName:I}),M.mr=new P.Control({x:.5,y:0,cursorStyleHandler:w,actionHandler:C,getActionName:I}),M.mb=new P.Control({x:0,y:.5,cursorStyleHandler:w,actionHandler:_,getActionName:I}),M.mt=new P.Control({x:0,y:-.5,cursorStyleHandler:w,actionHandler:_,getActionName:I}),M.tl=new P.Control({x:-.5,y:-.5,cursorStyleHandler:D,actionHandler:T}),M.tr=new P.Control({x:.5,y:-.5,cursorStyleHandler:D,actionHandler:T}),M.bl=new P.Control({x:-.5,y:.5,cursorStyleHandler:D,actionHandler:T}),M.br=new P.Control({x:.5,y:.5,cursorStyleHandler:D,actionHandler:T}),M.mtr=new P.Control({x:0,y:-.5,actionHandler:S.rotationWithSnapping,cursorStyleHandler:S.rotationStyleHandler,offsetY:-40,withConnection:!0,actionName:"rotate"}),P.Textbox){var x=P.Textbox.prototype.controls={};x.mtr=M.mtr,x.tr=M.tr,x.br=M.br,x.tl=M.tl,x.bl=M.bl,x.mt=M.mt,x.mb=M.mb,x.mr=new P.Control({x:.5,y:0,actionHandler:S.changeWidth,cursorStyleHandler:w,actionName:"resizing"}),x.ml=new P.Control({x:-.5,y:0,actionHandler:S.changeWidth,cursorStyleHandler:w,actionName:"resizing"})}}()},192:()=>{},898:()=>{},245:()=>{}},OI={};function mo(f){var l=OI[f];if(void 0!==l)return l.exports;var u=OI[f]={exports:{}};return DU[f](u,u.exports,mo),u.exports}mo.d=(f,l)=>{for(var u in l)mo.o(l,u)&&!mo.o(f,u)&&Object.defineProperty(f,u,{enumerable:!0,get:l[u]})},mo.o=(f,l)=>Object.prototype.hasOwnProperty.call(f,l);var MI={};(()=>{let f;mo.d(MI,{R:()=>f}),f="undefined"!=typeof document&&"undefined"!=typeof window?mo(653).fabric:{version:"5.2.1"}})();var Fn,gi,Os,LI,ct=MI.R;(function(f){f[f.DIMT_RECTANGLE=1]="DIMT_RECTANGLE",f[f.DIMT_QUADRILATERAL=2]="DIMT_QUADRILATERAL",f[f.DIMT_TEXT=4]="DIMT_TEXT",f[f.DIMT_ARC=8]="DIMT_ARC",f[f.DIMT_IMAGE=16]="DIMT_IMAGE",f[f.DIMT_POLYGON=32]="DIMT_POLYGON",f[f.DIMT_LINE=64]="DIMT_LINE",f[f.DIMT_GROUP=128]="DIMT_GROUP"})(Fn||(Fn={})),function(f){f[f.DIS_DEFAULT=1]="DIS_DEFAULT",f[f.DIS_SELECTED=2]="DIS_SELECTED"}(gi||(gi={})),function(f){f[f.EF_ENHANCED_FOCUS=4]="EF_ENHANCED_FOCUS",f[f.EF_AUTO_ZOOM=16]="EF_AUTO_ZOOM",f[f.EF_TAP_TO_FOCUS=64]="EF_TAP_TO_FOCUS"}(Os||(Os={})),function(f){f.GREY="grey",f.GREY32="grey32",f.RGBA="rgba",f.RBGA="rbga",f.GRBA="grba",f.GBRA="gbra",f.BRGA="brga",f.BGRA="bgra"}(LI||(LI={}));const Sa=f=>"number"==typeof f&&!Number.isNaN(f),t_=f=>"string"==typeof f;var td,vc,Ia,n_,Sr,nd;(function(f){f[f.ARC=0]="ARC",f[f.IMAGE=1]="IMAGE",f[f.LINE=2]="LINE",f[f.POLYGON=3]="POLYGON",f[f.QUAD=4]="QUAD",f[f.RECT=5]="RECT",f[f.TEXT=6]="TEXT",f[f.GROUP=7]="GROUP"})(Sr||(Sr={})),function(f){f[f.DEFAULT=0]="DEFAULT",f[f.SELECTED=1]="SELECTED"}(nd||(nd={}));class ni{get mediaType(){return new Map([["rect",Fn.DIMT_RECTANGLE],["quad",Fn.DIMT_QUADRILATERAL],["text",Fn.DIMT_TEXT],["arc",Fn.DIMT_ARC],["image",Fn.DIMT_IMAGE],["polygon",Fn.DIMT_POLYGON],["line",Fn.DIMT_LINE],["group",Fn.DIMT_GROUP]]).get(this._mediaType)}get styleSelector(){switch(j(this,vc,"f")){case gi.DIS_DEFAULT:return"default";case gi.DIS_SELECTED:return"selected"}}set drawingStyleId(l){this.styleId=l}get drawingStyleId(){return this.styleId}set coordinateBase(l){if(!["view","image"].includes(l))throw new Error("Invalid 'coordinateBase'.");this._drawingLayer&&("image"===j(this,Ia,"f")&&"view"===l?this.updateCoordinateBaseFromImageToView():"view"===j(this,Ia,"f")&&"image"===l&&this.updateCoordinateBaseFromViewToImage()),Le(this,Ia,l,"f")}get coordinateBase(){return j(this,Ia,"f")}get drawingLayerId(){return this._drawingLayerId}constructor(l,u){if(td.add(this),vc.set(this,void 0),Ia.set(this,"image"),this._zIndex=null,this._drawingLayer=null,this._drawingLayerId=null,this._mapState_StyleId=new Map,this.mapEvent_Callbacks=new Map([["selected",new Map],["deselected",new Map],["mousedown",new Map],["mouseup",new Map],["dblclick",new Map],["mouseover",new Map],["mouseout",new Map]]),this.mapNoteName_Content=new Map([]),this.isDrawingItem=!0,null!=u&&!Sa(u))throw new TypeError("Invalid 'drawingStyleId'.");l&&this._setFabricObject(l),this.setState(gi.DIS_DEFAULT),this.styleId=u}_setFabricObject(l){this._fabricObject=l,this._fabricObject.on("selected",()=>{this.setState(gi.DIS_SELECTED)}),this._fabricObject.on("deselected",()=>{this._fabricObject.canvas&&this._fabricObject.canvas.getActiveObjects().includes(this._fabricObject)?this.setState(gi.DIS_SELECTED):this.setState(gi.DIS_DEFAULT),"textbox"===this._fabricObject.type&&(this._fabricObject.isEditing&&this._fabricObject.exitEditing(),this._fabricObject.selected=!1)}),l.getDrawingItem=()=>this}_getFabricObject(){return this._fabricObject}setState(l){Le(this,vc,l,"f")}getState(){return j(this,vc,"f")}_on(l,u){if(!u)return;const g=l.toLowerCase(),p=this.mapEvent_Callbacks.get(g);if(!p)throw new Error(`Event '${l}' does not exist.`);let m=p.get(u);m||(m=v=>{const y=v.e;if(!y)return void(u&&u.apply(this,[{targetItem:this,itemClientX:null,itemClientY:null,itemPageX:null,itemPageY:null}]));const b={targetItem:this,itemClientX:null,itemClientY:null,itemPageX:null,itemPageY:null};if(this._drawingLayer){let O,L,N,B;const U=y.target.getBoundingClientRect();O=U.left,L=U.top,N=O+window.scrollX,B=L+window.scrollY;const{width:W,height:Y}=this._drawingLayer.fabricCanvas.lowerCanvasEl.getBoundingClientRect(),$=this._drawingLayer.width,q=this._drawingLayer.height,X=W/Y,Q=$/q,pe=this._drawingLayer._getObjectFit();let ve,Te,Ae,P,Ee=1;if("contain"===pe)Xnull!==f&&"object"==typeof f&&!Array.isArray(f),i_=f=>!!t_(f)&&""!==f,s_=f=>!(!er(f)||!rn(f.left)||f.left<0||!rn(f.top)||f.top<0||!rn(f.right)||f.right<0||!rn(f.bottom)||f.bottom<0||f.left>=f.right||f.top>=f.bottom||!Gm(f.isMeasuredInPercentage)),NI=f=>!!er(f)&&!!jm(f.points)&&0!=f.points.length&&!f.points.some(l=>!Ea(l)),SU=Ea,kI=f=>!!er(f)&&!!jm(f.points)&&0!=f.points.length&&4==f.points.length&&!f.points.some(l=>!Ea(l)),qr=f=>!(!er(f)||!rn(f.x)||!rn(f.y)||!rn(f.width)||f.width<0||!rn(f.height)||f.height<0||"isMeasuredInPercentage"in f&&!Gm(f.isMeasuredInPercentage)),BI=f=>!(!FI(f)||"id"in f&&!Sa(f.id)||"lineWidth"in f&&!Sa(f.lineWidth)||"fillStyle"in f&&!i_(f.fillStyle)||"strokeStyle"in f&&!i_(f.strokeStyle)||"paintMode"in f&&!["fill","stroke","strokeAndFill"].includes(f.paintMode)||"fontFamily"in f&&!i_(f.fontFamily)||"fontSize"in f&&!Sa(f.fontSize));class id{static convert(l,u,g){const p={x:0,y:0,width:u,height:g};if(!l)return p;if(qr(l))l.isMeasuredInPercentage?(p.x=l.x/100*u,p.y=l.y/100*g,p.width=l.width/100*u,p.height=l.height/100*g):(p.x=l.x,p.y=l.y,p.width=l.width,p.height=l.height);else{if(!s_(l))throw TypeError("Invalid region.");l.isMeasuredInPercentage?(p.x=l.left/100*u,p.y=l.top/100*g,p.width=(l.right-l.left)/100*u,p.height=(l.bottom-l.top)/100*g):(p.x=l.left,p.y=l.top,p.width=l.right-l.left,p.height=l.bottom-l.top)}return p.x=Math.round(p.x),p.y=Math.round(p.y),p.width=Math.round(p.width),p.height=Math.round(p.height),p}}var _o,rd;class VI{constructor(){_o.set(this,new Map),rd.set(this,!1)}get disposed(){return j(this,rd,"f")}on(l,u){l=l.toLowerCase();const g=j(this,_o,"f").get(l);if(g){if(g.includes(u))return;g.push(u)}else j(this,_o,"f").set(l,[u])}off(l,u){l=l.toLowerCase();const g=j(this,_o,"f").get(l);if(!g)return;const p=g.indexOf(u);-1!==p&&g.splice(p,1)}offAll(l){l=l.toLowerCase();const u=j(this,_o,"f").get(l);u&&(u.length=0)}fire(l,u=[],g={async:!1,copy:!0}){u||(u=[]),l=l.toLowerCase();const p=j(this,_o,"f").get(l);if(p&&p.length){g=Object.assign({async:!1,copy:!0},g);for(let m of p){if(!m)continue;let v=[];if(g.copy)for(let b of u){try{b=JSON.parse(JSON.stringify(b))}catch(O){}v.push(b)}else v=u;let y=!1;if(g.async)setTimeout(()=>{this.disposed||p.includes(m)&&m.apply(g.target,v)},0);else try{y=m.apply(g.target,v)}catch(b){}if(!0===y)break}}}dispose(){Le(this,rd,!0,"f")}}function IU(f,l,u){return(u.x-f.x)*(l.y-f.y)==(l.x-f.x)*(u.y-f.y)&&Math.min(f.x,l.x)<=u.x&&u.x<=Math.max(f.x,l.x)&&Math.min(f.y,l.y)<=u.y&&u.y<=Math.max(f.y,l.y)}function o_(f){return Math.abs(f)<1e-6?0:f<0?-1:1}function sd(f,l,u,g){let p=f[0]*(u[1]-l[1])+l[0]*(f[1]-u[1])+u[0]*(l[1]-f[1]),m=f[0]*(g[1]-l[1])+l[0]*(f[1]-g[1])+g[0]*(l[1]-f[1]);return!((p^m)>=0&&0!==p&&0!==m||(p=u[0]*(f[1]-g[1])+g[0]*(u[1]-f[1])+f[0]*(g[1]-u[1]),m=u[0]*(l[1]-g[1])+g[0]*(u[1]-l[1])+l[0]*(g[1]-u[1]),(p^m)>=0&&0!==p&&0!==m))}_o=new WeakMap,rd=new WeakMap;const a_=function(){var f=se(function*(l){if("string"!=typeof l)throw new TypeError("Invalid url.");const u=yield fetch(l);if(!u.ok)throw Error("Network Error: "+u.statusText);const g=yield u.text();if(!g.trim().startsWith("<"))throw Error("Unable to get valid HTMLElement.");const p=document.createElement("div");p.insertAdjacentHTML("beforeend",g);for(let m=0;m0?y-1:p,c_),actionName:"modifyPolygon",pointIndex:y}),m},{}),Le(this,Ls,JSON.parse(JSON.stringify(l)),"f"),this._mediaType="polygon"}extendSet(l,u){if("vertices"===l){const g=this._fabricObject;if(g.group){const m=g.group;g.points=u.map(v=>({x:v.x-m.left-m.width/2,y:v.y-m.top-m.height/2})),m.addWithUpdate()}else g.points=u;const p=g.points.length-1;return g.controls=g.points.reduce(function(m,v,y){return m["p"+y]=new ct.Control({positionHandler:l_,actionHandler:u_(y>0?y-1:p,c_),actionName:"modifyPolygon",pointIndex:y}),m},{}),g._setPositionDimensions({}),!0}}extendGet(l){if("vertices"===l){const u=[],g=this._fabricObject;if(g.selectable&&!g.group)for(let p in g.oCoords)u.push({x:g.oCoords[p].x,y:g.oCoords[p].y});else for(let p of g.points){const y=ct.util.transformPoint({x:p.x-g.pathOffset.x,y:p.y-g.pathOffset.y},g.calcTransformMatrix());u.push({x:y.x,y:y.y})}return u}}updateCoordinateBaseFromImageToView(){const l=this.get("vertices").map(u=>({x:this.convertPropFromViewToImage(u.x),y:this.convertPropFromViewToImage(u.y)}));this.set("vertices",l)}updateCoordinateBaseFromViewToImage(){const l=this.get("vertices").map(u=>({x:this.convertPropFromImageToView(u.x),y:this.convertPropFromImageToView(u.y)}));this.set("vertices",l)}setPosition(l){this.setPolygon(l)}getPosition(){return this.getPolygon()}updatePosition(){j(this,Ls,"f")&&this.setPolygon(j(this,Ls,"f"))}setPolygon(l){if(!NI(l))throw new TypeError("Invalid 'polygon'.");if(this._drawingLayer){if("view"===this.coordinateBase){const u=l.points.map(g=>({x:this.convertPropFromViewToImage(g.x),y:this.convertPropFromViewToImage(g.y)}));this.set("vertices",u)}else{if("image"!==this.coordinateBase)throw new Error("Invalid 'coordinateBase'.");this.set("vertices",l.points)}this._drawingLayer.renderAll()}else Le(this,Ls,JSON.parse(JSON.stringify(l)),"f")}getPolygon(){if(this._drawingLayer){if("view"===this.coordinateBase)return{points:this.get("vertices").map(l=>({x:this.convertPropFromImageToView(l.x),y:this.convertPropFromImageToView(l.y)}))};if("image"===this.coordinateBase)return{points:this.get("vertices")};throw new Error("Invalid 'coordinateBase'.")}return j(this,Ls,"f")?JSON.parse(JSON.stringify(j(this,Ls,"f"))):null}}Ls=new WeakMap;const jI=f=>{let l=f.split("\n").map(g=>g.split("\t"));return(u=>{for(let g=0;;g++){let p=-1;for(let m=0;mp&&(p=v.length)}if(-1===p)break;for(let m=0;m=u[m].length-1)continue;let v=" ".repeat(p+2-u[m][g].length);u[m][g]=u[m][g].concat(v)}}})(l),(u=>{let g="";for(let p=0;p({x:this.convertPropFromViewToImage(g.x),y:this.convertPropFromViewToImage(g.y)}));this.set("vertices",u)}else{if("image"!==this.coordinateBase)throw new Error("Invalid 'coordinateBase'.");this.set("vertices",l.points)}this._drawingLayer.renderAll()}else Le(this,ks,JSON.parse(JSON.stringify(l)),"f")}getQuad(){if(this._drawingLayer){if("view"===this.coordinateBase)return{points:this.get("vertices").map(l=>({x:this.convertPropFromImageToView(l.x),y:this.convertPropFromImageToView(l.y)}))};if("image"===this.coordinateBase)return{points:this.get("vertices")};throw new Error("Invalid 'coordinateBase'.")}return j(this,ks,"f")?JSON.parse(JSON.stringify(j(this,ks,"f"))):null}}ks=new WeakMap;class AU extends ni{constructor(l){super(new ct.Group(l.map(u=>u._getFabricObject()))),this._fabricObject.on("selected",()=>{this.setState(gi.DIS_SELECTED);const u=this._fabricObject._objects;for(let g of u)setTimeout(()=>{g&&g.fire("selected")},0);setTimeout(()=>{this._fabricObject&&this._fabricObject.canvas&&(this._fabricObject.dirty=!0,this._fabricObject.canvas.renderAll())},0)}),this._fabricObject.on("deselected",()=>{this.setState(gi.DIS_DEFAULT);const u=this._fabricObject._objects;for(let g of u)setTimeout(()=>{g&&g.fire("deselected")},0);setTimeout(()=>{this._fabricObject&&this._fabricObject.canvas&&(this._fabricObject.dirty=!0,this._fabricObject.canvas.renderAll())},0)}),this._mediaType="group"}extendSet(l,u){return!1}extendGet(l){}updateCoordinateBaseFromImageToView(){}updateCoordinateBaseFromViewToImage(){}setPosition(){}getPosition(){}updatePosition(){}getChildDrawingItems(){return this._fabricObject._objects.map(l=>l.getDrawingItem())}setChildDrawingItems(l){if(!l||!l.isDrawingItem)throw TypeError("Illegal drawing item.");this._drawingLayer?this._drawingLayer._updateGroupItem(this,l,"add"):this._fabricObject.addWithUpdate(l._getFabricObject())}removeChildItem(l){l&&l.isDrawingItem&&(this._drawingLayer?this._drawingLayer._updateGroupItem(this,l,"remove"):this._fabricObject.removeWithUpdate(l._getFabricObject()))}}class we{static createDrawingStyle(l){if(!BI(l))throw new Error("Invalid style definition.");let u,g=we.USER_START_STYLE_ID;for(;j(we,Bs,"f",xa).has(g);)g++;u=g;const p=JSON.parse(JSON.stringify(l));p.id=u;for(let m in j(we,Bs,"f",d_))p.hasOwnProperty(m)||(p[m]=j(we,Bs,"f",d_)[m]);return j(we,Bs,"f",xa).set(u,p),p.id}static _getDrawingStyle(l,u){if("number"!=typeof l)throw new Error("Invalid style id.");const g=j(we,Bs,"f",xa).get(l);return g?u?JSON.parse(JSON.stringify(g)):g:null}static getDrawingStyle(l){return this._getDrawingStyle(l,!0)}static getAllDrawingStyles(){return JSON.parse(JSON.stringify(Array.from(j(we,Bs,"f",xa).values())))}static _updateDrawingStyle(l,u){if(!BI(u))throw new Error("Invalid style definition.");const g=j(we,Bs,"f",xa).get(l);if(g)for(let p in u)g.hasOwnProperty(p)&&(g[p]=u[p])}static updateDrawingStyle(l,u){this._updateDrawingStyle(l,u)}}Bs=we,we.STYLE_BLUE_STROKE=1,we.STYLE_GREEN_STROKE=2,we.STYLE_ORANGE_STROKE=3,we.STYLE_YELLOW_STROKE=4,we.STYLE_BLUE_STROKE_FILL=5,we.STYLE_GREEN_STROKE_FILL=6,we.STYLE_ORANGE_STROKE_FILL=7,we.STYLE_YELLOW_STROKE_FILL=8,we.STYLE_BLUE_STROKE_TRANSPARENT=9,we.STYLE_GREEN_STROKE_TRANSPARENT=10,we.STYLE_ORANGE_STROKE_TRANSPARENT=11,we.USER_START_STYLE_ID=1024,xa={value:new Map([[we.STYLE_BLUE_STROKE,{id:we.STYLE_BLUE_STROKE,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.3)",strokeStyle:"rgba(73, 173, 245, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}],[we.STYLE_GREEN_STROKE,{id:we.STYLE_GREEN_STROKE,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.3)",strokeStyle:"rgba(73, 245, 73, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[we.STYLE_ORANGE_STROKE,{id:we.STYLE_ORANGE_STROKE,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.3)",strokeStyle:"rgba(254, 180, 32, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[we.STYLE_YELLOW_STROKE,{id:we.STYLE_YELLOW_STROKE,lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}],[we.STYLE_BLUE_STROKE_FILL,{id:we.STYLE_BLUE_STROKE_FILL,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.3)",strokeStyle:"rgba(73, 173, 245, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[we.STYLE_GREEN_STROKE_FILL,{id:we.STYLE_GREEN_STROKE_FILL,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.3)",strokeStyle:"rgba(73, 245, 73, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[we.STYLE_ORANGE_STROKE_FILL,{id:we.STYLE_ORANGE_STROKE_FILL,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.3)",strokeStyle:"rgba(254, 180, 32, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[we.STYLE_YELLOW_STROKE_FILL,{id:we.STYLE_YELLOW_STROKE_FILL,lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[we.STYLE_BLUE_STROKE_TRANSPARENT,{id:we.STYLE_BLUE_STROKE_TRANSPARENT,lineWidth:4,fillStyle:"rgba(73, 245, 73, 0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[we.STYLE_GREEN_STROKE_TRANSPARENT,{id:we.STYLE_GREEN_STROKE_TRANSPARENT,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[we.STYLE_ORANGE_STROKE_TRANSPARENT,{id:we.STYLE_ORANGE_STROKE_TRANSPARENT,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}]])},d_={value:{lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}},"undefined"!=typeof document&&"undefined"!=typeof window&&(ct.StaticCanvas.prototype.dispose=function(){return this.isRendering&&(ct.util.cancelAnimFrame(this.isRendering),this.isRendering=0),this.forEachObject(function(f){f.dispose&&f.dispose()}),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose&&this.backgroundImage.dispose(),this.backgroundImage=null,this.overlayImage&&this.overlayImage.dispose&&this.overlayImage.dispose(),this.overlayImage=null,this._iTextInstances=null,this.contextContainer=null,this.lowerCanvasEl.classList.remove("lower-canvas"),delete this._originalCanvasStyle,this.lowerCanvasEl.setAttribute("width",this.width),this.lowerCanvasEl.setAttribute("height",this.height),ct.util.cleanUpJsdomNode(this.lowerCanvasEl),this.lowerCanvasEl=void 0,this},ct.Object.prototype.transparentCorners=!1,ct.Object.prototype.cornerSize=20,ct.Object.prototype.touchCornerSize=100,ct.Object.prototype.cornerColor="rgb(254,142,20)",ct.Object.prototype.cornerStyle="circle",ct.Object.prototype.strokeUniform=!0,ct.Object.prototype.hasBorders=!1,ct.Canvas.prototype.containerClass="",ct.Canvas.prototype.getPointer=function(f,l){if(this._absolutePointer&&!l)return this._absolutePointer;if(this._pointer&&l)return this._pointer;var u,g=this.upperCanvasEl,p=ct.util.getPointer(f,g),m=g.getBoundingClientRect(),v=m.width||0,y=m.height||0;v&&y||("top"in m&&"bottom"in m&&(y=Math.abs(m.top-m.bottom)),"right"in m&&"left"in m&&(v=Math.abs(m.right-m.left))),this.calcOffset(),p.x=p.x-this._offset.left,p.y=p.y-this._offset.top,l||(p=this.restorePointerVpt(p));var b=this.getRetinaScaling();if(1!==b&&(p.x/=b,p.y/=b),0!==v&&0!==y){var O=window.getComputedStyle(g).objectFit,L=g.width,N=g.height;u={width:L/v,height:N/y};var $=L/N,q=v/y;return"contain"===O?$>q?{x:p.x*u.width,y:(p.y-(y-v/$)/2)*u.width}:{x:(p.x-(v-y*$)/2)*u.height,y:p.y*u.height}:"cover"===O?$>q?{x:(L-u.height*v)/2+p.x*u.height,y:p.y*u.height}:{x:p.x*u.width,y:(N-u.width*y)/2+p.y*u.width}:{x:p.x*u.width,y:p.y*u.height}}return{x:p.x*(u={width:1,height:1}).width,y:p.y*u.height}},ct.Canvas.prototype._onTouchStart=function(f){var l=this.findTarget(f);!this.allowTouchScrolling&&f.cancelable&&f.preventDefault&&f.preventDefault(),l&&f.cancelable&&f.preventDefault&&f.preventDefault(),null===this.mainTouchId&&(this.mainTouchId=this.getPointerId(f)),this.__onMouseDown(f),this._resetTransformEventData();var u=this.upperCanvasEl,g=this._getEventPrefix();ct.util.addListener(ct.document,"touchend",this._onTouchEnd,{passive:!1}),ct.util.addListener(ct.document,"touchmove",this._onMouseMove,{passive:!1}),ct.util.removeListener(u,g+"down",this._onMouseDown)},ct.Textbox.prototype._wrapLine=function(f,l,u,g){const p=f.match(/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff66-\uff9f]/g);var v=0,y=this.splitByGrapheme||!(!p||!p.length),b=[],O=[],L=y?ct.util.string.graphemeSplit(f):f.split(this._wordJoiners),N="",B=0,U=y?"":" ",W=0,Y=0,$=0,q=!0,X=this._getWidthOfCharSpacing();g=g||0,0===L.length&&L.push([]),u-=g;for(var Q=0;Qu&&!q?(b.push(O),O=[],v=W,q=!0):v+=X,q||y||O.push(U),O=O.concat(N),Y=y?0:this._measureWord([U],l,B),B++,q=!1,W>$&&($=W);return Q&&b.push(O),$+g>this.dynamicMinWidth&&(this.dynamicMinWidth=$-X+g),b});class Wt{get width(){return this.fabricCanvas.width}get height(){return this.fabricCanvas.height}set _allowMultiSelect(l){this.fabricCanvas.selection=l,this.fabricCanvas.renderAll()}get _allowMultiSelect(){return this.fabricCanvas.selection}constructor(l,u,g){if(this.mapType_StateAndStyleId=new Map,this.mode="viewer",this.onSelectionChanged=null,this._arrDrwaingItem=[],this._arrFabricObject=[],this._visible=!0,l.hasOwnProperty("getFabricCanvas"))this.fabricCanvas=l.getFabricCanvas();else{let v=this.fabricCanvas=new ct.Canvas(l,Object.assign(g,{allowTouchScrolling:!0,selection:!1}));v.setDimensions({width:"100%",height:"100%"},{cssOnly:!0}),v.lowerCanvasEl.className="",v.upperCanvasEl.className="",v.on("selection:created",function(y){const b=y.selected,O=[];for(let L of b){const N=L.getDrawingItem()._drawingLayer;N&&!O.includes(N)&&O.push(N)}for(let L of O){const N=[];for(let B of b){const U=B.getDrawingItem();U._drawingLayer===L&&N.push(U)}setTimeout(()=>{L.onSelectionChanged&&L.onSelectionChanged(N,[])},0)}}),v.on("before:selection:cleared",function(y){const b=this.getActiveObjects(),O=[];for(let L of b){const N=L.getDrawingItem()._drawingLayer;N&&!O.includes(N)&&O.push(N)}for(let L of O){const N=[];for(let B of b){const U=B.getDrawingItem();U._drawingLayer===L&&N.push(U)}setTimeout(()=>{const B=[];for(let U of N)L.hasDrawingItem(U)&&B.push(U);B.length>0&&L.onSelectionChanged&&L.onSelectionChanged([],B)},0)}}),v.on("selection:updated",function(y){const b=y.selected,O=y.deselected,L=[];for(let N of b){const B=N.getDrawingItem()._drawingLayer;B&&!L.includes(B)&&L.push(B)}for(let N of O){const B=N.getDrawingItem()._drawingLayer;B&&!L.includes(B)&&L.push(B)}for(let N of L){const B=[],U=[];for(let W of b){const Y=W.getDrawingItem();Y._drawingLayer===N&&B.push(Y)}for(let W of O){const Y=W.getDrawingItem();Y._drawingLayer===N&&U.push(Y)}setTimeout(()=>{N.onSelectionChanged&&N.onSelectionChanged(B,U)},0)}}),v.wrapperEl.style.position="absolute",l.getFabricCanvas=()=>this.fabricCanvas}let p,m;switch(this.id=u,u){case Wt.DDN_LAYER_ID:p=we.getDrawingStyle(we.STYLE_BLUE_STROKE),m=we.getDrawingStyle(we.STYLE_BLUE_STROKE_FILL);break;case Wt.DBR_LAYER_ID:p=we.getDrawingStyle(we.STYLE_ORANGE_STROKE),m=we.getDrawingStyle(we.STYLE_ORANGE_STROKE_FILL);break;case Wt.DLR_LAYER_ID:p=we.getDrawingStyle(we.STYLE_GREEN_STROKE),m=we.getDrawingStyle(we.STYLE_GREEN_STROKE_FILL);break;default:p=we.getDrawingStyle(we.STYLE_YELLOW_STROKE),m=we.getDrawingStyle(we.STYLE_YELLOW_STROKE_FILL)}for(let v of ni.arrMediaTypes)this.mapType_StateAndStyleId.set(v,{default:p.id,selected:m.id})}getId(){return this.id}setVisible(l){if(l){for(let u of this._arrFabricObject)u.visible=!0,u.hasControls=!0;this._visible=!0}else{for(let u of this._arrFabricObject)u.visible=!1,u.hasControls=!1;this._visible=!1}this.fabricCanvas.renderAll()}isVisible(){return this._visible}_getItemCurrentStyle(l){return l.styleId?we.getDrawingStyle(l.styleId):we.getDrawingStyle(l._mapState_StyleId.get(l.styleSelector))||null}_changeMediaTypeCurStyleInStyleSelector(l,u,g,p){const m=this.getDrawingItems(v=>v._mediaType===l);for(let v of m)v.styleSelector===u&&this._changeItemStyle(v,g,!0);p||this.fabricCanvas.renderAll()}_changeItemStyle(l,u,g){if(!l||!u)return;const p=l._getFabricObject();"number"==typeof l.styleId&&(u=we.getDrawingStyle(l.styleId)),p.strokeWidth=u.lineWidth,"fill"===u.paintMode?(p.fill=u.fillStyle,p.stroke=u.fillStyle):"stroke"===u.paintMode?(p.fill="transparent",p.stroke=u.strokeStyle):"strokeAndFill"===u.paintMode&&(p.fill=u.fillStyle,p.stroke=u.strokeStyle),p.fontFamily&&(p.fontFamily=u.fontFamily),p.fontSize&&(p.fontSize=u.fontSize),p.group||(p.dirty=!0),g||this.fabricCanvas.renderAll()}_updateGroupItem(l,u,g){if(!l||!u)return;const p=l.getChildDrawingItems();if("add"===g){if(p.includes(u))return;const m=u._getFabricObject();if(this.fabricCanvas.getObjects().includes(m)){if(!this._arrFabricObject.includes(m))throw new Error("Existed in other drawing layers.");u._zIndex=null}else{let v;if(u.styleId)v=we.getDrawingStyle(u.styleId);else{const y=this.mapType_StateAndStyleId.get(u._mediaType);v=we.getDrawingStyle(y[l.styleSelector]);const b=()=>{this._changeItemStyle(u,we.getDrawingStyle(this.mapType_StateAndStyleId.get(u._mediaType).selected),!0)},O=()=>{this._changeItemStyle(u,we.getDrawingStyle(this.mapType_StateAndStyleId.get(u._mediaType).default),!0)};u._on("selected",b),u._on("deselected",O),u._funcChangeStyleToSelected=b,u._funcChangeStyleToDefault=O}u._drawingLayer=this,u._drawingLayerId=this.id,this._changeItemStyle(u,v,!0)}l._fabricObject.addWithUpdate(u._getFabricObject())}else{if("remove"!==g||!p.includes(u))return;u._zIndex=null,u._drawingLayer=null,u._drawingLayerId=null,u._off("selected",u._funcChangeStyleToSelected),u._off("deselected",u._funcChangeStyleToDefault),u._funcChangeStyleToSelected=null,u._funcChangeStyleToDefault=null,l._fabricObject.removeWithUpdate(u._getFabricObject())}this.fabricCanvas.renderAll()}_addDrawingItem(l,u){if(!(l instanceof ni))throw new TypeError("Invalid 'drawingItem'.");if(l._drawingLayer){if(l._drawingLayer==this)return;throw new Error("This drawing item has existed in other layer.")}let g=l._getFabricObject();const p=this.fabricCanvas.getObjects();let m,v;if(p.includes(g)){if(this._arrFabricObject.includes(g))return;throw new Error("Existed in other drawing layers.")}if("group"===l._mediaType){m=l.getChildDrawingItems();for(let O of m)if(O._drawingLayer&&O._drawingLayer!==this)throw new Error("The childItems of DT_Group have existed in other drawing layers.")}if(u&&"object"==typeof u&&!Array.isArray(u))for(let O in u)g.set(O,u[O]);if(m){for(let O of m){const L=this.mapType_StateAndStyleId.get(O._mediaType);for(let N of ni.arrStyleSelectors)O._mapState_StyleId.set(N,L[N]);if(O.styleId)v=we.getDrawingStyle(O.styleId);else{v=we.getDrawingStyle(L.default);const N=()=>{this._changeItemStyle(O,we.getDrawingStyle(this.mapType_StateAndStyleId.get(O._mediaType).selected),!0)},B=()=>{this._changeItemStyle(O,we.getDrawingStyle(this.mapType_StateAndStyleId.get(O._mediaType).default),!0)};O._on("selected",N),O._on("deselected",B),O._funcChangeStyleToSelected=N,O._funcChangeStyleToDefault=B}O._drawingLayer=this,O._drawingLayerId=this.id,this._changeItemStyle(O,v,!0)}g.dirty=!0,this.fabricCanvas.renderAll()}else{const O=this.mapType_StateAndStyleId.get(l._mediaType);for(let L of ni.arrStyleSelectors)l._mapState_StyleId.set(L,O[L]);if(l.styleId)v=we.getDrawingStyle(l.styleId);else{v=we.getDrawingStyle(O.default);const L=()=>{this._changeItemStyle(l,we.getDrawingStyle(this.mapType_StateAndStyleId.get(l._mediaType).selected))},N=()=>{this._changeItemStyle(l,we.getDrawingStyle(this.mapType_StateAndStyleId.get(l._mediaType).default))};l._on("selected",L),l._on("deselected",N),l._funcChangeStyleToSelected=L,l._funcChangeStyleToDefault=N}this._changeItemStyle(l,v)}l._zIndex=this.id,l._drawingLayer=this,l._drawingLayerId=this.id;const y=this._arrFabricObject.length;let b=p.length;if(y)b=p.indexOf(this._arrFabricObject[y-1])+1;else for(let O=0;Ov.toLowerCase()):u=ni.arrMediaTypes,g?g.forEach(v=>v.toLowerCase()):g=ni.arrStyleSelectors;const p=we.getDrawingStyle(l);if(!p)throw new Error(`The 'drawingStyle' with id '${l}' doesn't exist.`);let m;for(let v of u)if(m=this.mapType_StateAndStyleId.get(v),m)for(let y of g){this._changeMediaTypeCurStyleInStyleSelector(v,y,p,!0),m[y]=l;for(let b of this._arrDrwaingItem)b._mediaType===v&&b._mapState_StyleId.set(y,l)}this.fabricCanvas.renderAll()}setDefaultStyle(l,u,g){const p=[];g&Fn.DIMT_RECTANGLE&&p.push("rect"),g&Fn.DIMT_QUADRILATERAL&&p.push("quad"),g&Fn.DIMT_TEXT&&p.push("text"),g&Fn.DIMT_ARC&&p.push("arc"),g&Fn.DIMT_IMAGE&&p.push("image"),g&Fn.DIMT_POLYGON&&p.push("polygon"),g&Fn.DIMT_LINE&&p.push("line");const m=[];u&gi.DIS_DEFAULT&&m.push("default"),u&gi.DIS_SELECTED&&m.push("selected"),this._setDefaultStyle(l,p.length?p:null,m.length?m:null)}setMode(l){if("viewer"===(l=l.toLowerCase())){for(let u of this._arrDrwaingItem)u._setEditable(!1);this.fabricCanvas.discardActiveObject(),this.fabricCanvas.renderAll(),this.mode="viewer"}else{if("editor"!==l)throw new RangeError("Invalid value.");for(let u of this._arrDrwaingItem)u._setEditable(!0);this.mode="editor"}this._manager._switchPointerEvent()}getMode(){return this.mode}_setDimensions(l,u){this.fabricCanvas.setDimensions(l,u)}_setObjectFit(l){if(l=l.toLowerCase(),!["contain","cover"].includes(l))throw new Error(`Unsupported value '${l}'.`);this.fabricCanvas.lowerCanvasEl.style.objectFit=l,this.fabricCanvas.upperCanvasEl.style.objectFit=l}_getObjectFit(){return this.fabricCanvas.lowerCanvasEl.style.objectFit}renderAll(){for(let l of this._arrDrwaingItem){const u=this._getItemCurrentStyle(l);this._changeItemStyle(l,u,!0)}this.fabricCanvas.renderAll()}dispose(){this.clearDrawingItems(),1===this._manager._arrDrawingLayer.length&&(this.fabricCanvas.wrapperEl.style.pointerEvents="none",this.fabricCanvas.dispose(),this._arrDrwaingItem.length=0,this._arrFabricObject.length=0)}}Wt.DDN_LAYER_ID=1,Wt.DBR_LAYER_ID=2,Wt.DLR_LAYER_ID=3,Wt.USER_DEFINED_LAYER_BASE_ID=100,Wt.TIP_LAYER_ID=999;class RU{constructor(){this._arrDrawingLayer=[]}createDrawingLayer(l,u){if(this.getDrawingLayer(u))throw new Error("Existed drawing layer id.");const g=new Wt(l,u,{enableRetinaScaling:!1});return g._manager=this,this._arrDrawingLayer.push(g),this._switchPointerEvent(),g}deleteDrawingLayer(l){const u=this.getDrawingLayer(l);if(!u)return;const g=this._arrDrawingLayer;u.dispose(),g.splice(g.indexOf(u),1),this._switchPointerEvent()}clearDrawingLayers(){for(let l of this._arrDrawingLayer)l.dispose();this._arrDrawingLayer.length=0}getDrawingLayer(l){for(let u of this._arrDrawingLayer)if(u.getId()===l)return u;return null}getAllDrawingLayers(){return Array.from(this._arrDrawingLayer)}getSelectedDrawingItems(){if(!this._arrDrawingLayer.length)return;const l=this._getFabricCanvas().getActiveObjects(),u=[];for(let g of l)u.push(g.getDrawingItem());return u}setDimensions(l,u){this._arrDrawingLayer.length&&this._arrDrawingLayer[0]._setDimensions(l,u)}setObjectFit(l){for(let u of this._arrDrawingLayer)u&&u._setObjectFit(l)}getObjectFit(){return this._arrDrawingLayer.length?this._arrDrawingLayer[0]._getObjectFit():null}setVisible(l){this._arrDrawingLayer.length&&(this._getFabricCanvas().wrapperEl.style.display=l?"block":"none")}_getFabricCanvas(){return this._arrDrawingLayer.length?this._arrDrawingLayer[0].fabricCanvas:null}_switchPointerEvent(){if(this._arrDrawingLayer.length)for(let l of this._arrDrawingLayer)l.getMode()}}class OU extends TU{constructor(l,u,g,p,m){super(l,{x:u,y:g,width:p,height:0},m),Aa.set(this,void 0),yc.set(this,void 0),this._fabricObject.paddingTop=15,this._fabricObject.calcTextHeight=function(){for(var v=0,y=0,b=this._textLines.length;y=0&&Le(this,yc,setTimeout(()=>{this.set("visible",!1),this._drawingLayer&&this._drawingLayer.renderAll()},j(this,Aa,"f")),"f")}getDuration(){return j(this,Aa,"f")}}Aa=new WeakMap,yc=new WeakMap,pi=new WeakMap,Cc=new WeakMap,wc=new WeakMap,Ec=new WeakMap,Ra=new WeakSet,GI=function(f,l,u,g,p,m){const v=new OU(f,l,u,g,m);return v.coordinateBase=p,v},HI=function(f,l){l.hasDrawingItem(f)||l.addDrawingItems([f])},WI=function(){this._tip&&this._drawingLayerOfTip.removeDrawingItems([this._tip])},zI=function(){if(!this._tip)return;const f=j(this,pi,"f");this._tip.coordinateBase=f.coordinateBase,this._tip.setTextRect({x:f.topLeftPoint.x,y:f.topLeftPoint.y,width:f.width,height:0}),this._tip.set("width",this._tip.get("width")),this._tip._drawingLayer&&this._tip._drawingLayer.renderAll()};class m_ extends HTMLElement{constructor(){super(),od.set(this,void 0);const l=document.createElement("template").content,u=document.createElement("div");u.setAttribute("class","wrapper"),l.appendChild(u),Le(this,od,u,"f");const g=document.createElement("slot");g.setAttribute("name","single-frame-input-container"),u.append(g);const p=document.createElement("slot");p.setAttribute("name","content"),u.append(p);const m=document.createElement("slot");m.setAttribute("name","drawing-layer"),u.append(m);const v=document.createElement("style");v.textContent='\n.wrapper {\n position: relative;\n width: 100%;\n height: 100%;\n}\n::slotted(canvas[slot="content"]) {\n object-fit: contain;\n pointer-events: none;\n}\n::slotted(div[slot="single-frame-input-container"]) {\n width: 1px;\n height: 1px;\n overflow: hidden;\n pointer-events: none;\n}\n::slotted(*) {\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n}\n ',l.appendChild(v),this.attachShadow({mode:"open"}).appendChild(l.cloneNode(!0))}getWrapper(){return j(this,od,"f")}setElement(l,u){if(!(u instanceof HTMLElement))throw new TypeError("Invalid 'el'.");if(!["content","single-frame-input-container","drawing-layer"].includes(l))throw new TypeError("Invalid 'slot'.");this.removeElement(l),u.setAttribute("slot",l),this.appendChild(u)}getElement(l){if(!["content","single-frame-input-container","drawing-layer"].includes(l))throw new TypeError("Invalid 'slot'.");return this.querySelector(`[slot="${l}"]`)}removeElement(l){var u;if(!["content","single-frame-input-container","drawing-layer"].includes(l))throw new TypeError("Invalid 'slot'.");null===(u=this.querySelectorAll(`[slot="${l}"]`))||void 0===u||u.forEach(g=>g.remove())}}od=new WeakMap,customElements.get("dce-component")||customElements.define("dce-component",m_);class Oa extends HTMLElement{constructor(){super();const l=window._dce_default_template.content;this.attachShadow({mode:"open"}).appendChild(l.cloneNode(!0))}showScanLaser(){const l=this.shadowRoot.querySelector(".dce-scanlight");l&&(l.style.display="")}hideScanLaser(){const l=this.shadowRoot.querySelector(".dce-scanlight");l&&(l.style.display="none")}getElement(l){return this.shadowRoot.querySelector(l)}getVideoContainer(){return this.shadowRoot.querySelector(".dce-video-container")}getScanAreaEl(){return this.shadowRoot.querySelector(".dce-scanarea")}getScanLightEl(){return this.shadowRoot.querySelector(".dce-scanlight")}getLoadingBackgroundEl(){return this.shadowRoot.querySelector(".dce-bg-loading")}getCameraBackgroundEl(){return this.shadowRoot.querySelector(".dce-bg-camera")}getCameraSelectEl(){return this.shadowRoot.querySelector(".dce-sel-camera")}getResolutionSelectEl(){return this.shadowRoot.querySelector(".dce-sel-resolution")}getResolutionOptionEl(){return this.shadowRoot.querySelector(".dce-opt-gotResolution")}getCloseBtnEl(){return this.shadowRoot.querySelector(".dce-btn-close")}getDLRSelectEl(){return this.shadowRoot.querySelector(".dlr-sel-minletter")}getDLROptionEl(){return this.shadowRoot.querySelector(".dlr-opt-gotMinLtr")}}class on extends class MU{constructor(){Ra.add(this),pi.set(this,void 0),Cc.set(this,void 0),wc.set(this,void 0),Ec.set(this,!0),this._drawingLayerManager=new RU}createDrawingLayerBaseCvs(l,u,g="contain"){if("number"!=typeof l||l<=1)throw new Error("Invalid 'width'.");if("number"!=typeof u||u<=1)throw new Error("Invalid 'height'.");if(!["contain","cover"].includes(g))throw new Error("Unsupported 'objectFit'.");const p=document.createElement("canvas");return p.width==l&&p.height==u||(p.width=l,p.height=u),p.style.objectFit=g,p}_createDrawingLayer(l,u,g,p){if(!this._layerBaseCvs){let y;try{y=this.getContentDimensions()}catch(b){if("Invalid content dimensions."!==(b.message||b))throw b}u||(u=(null==y?void 0:y.width)||1280),g||(g=(null==y?void 0:y.height)||720),p||(p=(null==y?void 0:y.objectFit)||"contain"),this._layerBaseCvs=this.createDrawingLayerBaseCvs(u,g,p)}const m=this._layerBaseCvs,v=this._drawingLayerManager.createDrawingLayer(m,l);return this._innerComponent.getElement("drawing-layer")||this._innerComponent.setElement("drawing-layer",m.parentElement),v}createDrawingLayer(){let l;for(let u=Wt.USER_DEFINED_LAYER_BASE_ID;;u++)if(!this._drawingLayerManager.getDrawingLayer(u)&&u!==Wt.TIP_LAYER_ID){l=u;break}return this._createDrawingLayer(l)}deleteDrawingLayer(l){var u;this._drawingLayerManager.deleteDrawingLayer(l),this._drawingLayerManager.getAllDrawingLayers().length||(null===(u=this._innerComponent)||void 0===u||u.removeElement("drawing-layer"),this._layerBaseCvs=null)}deleteUserDefinedDrawingLayer(l){if("number"!=typeof l)throw new TypeError("Invalid id.");if(ll.getId()>=0&&l.getId()!==Wt.TIP_LAYER_ID)}updateDrawingLayers(l){((u,g,p)=>{if(!(u<=1||g<=1)){if(!["contain","cover"].includes(p))throw new Error("Unsupported 'objectFit'.");this._drawingLayerManager.setDimensions({width:u,height:g},{backstoreOnly:!0}),this._drawingLayerManager.setObjectFit(p)}})(l.width,l.height,l.objectFit)}getSelectedDrawingItems(){return this._drawingLayerManager.getSelectedDrawingItems()}setTipConfig(l){if(!(FI(u=l)&&SU(u.topLeftPoint)&&Sa(u.width))||u.width<=0||!Sa(u.duration)||"coordinateBase"in u&&!["view","image"].includes(u.coordinateBase))throw new Error("Invalid tip config.");var u;Le(this,pi,JSON.parse(JSON.stringify(l)),"f"),j(this,pi,"f").coordinateBase||(j(this,pi,"f").coordinateBase="view"),Le(this,wc,l.duration,"f"),j(this,Ra,"m",zI).call(this)}getTipConfig(){return j(this,pi,"f")?j(this,pi,"f"):null}setTipVisible(l){if("boolean"!=typeof l)throw new TypeError("Invalid value.");this._tip&&(this._tip.set("visible",l),this._drawingLayerOfTip&&this._drawingLayerOfTip.renderAll()),Le(this,Ec,l,"f")}isTipVisible(){return j(this,Ec,"f")}updateTipMessage(l){if(!j(this,pi,"f"))throw new Error("Tip config is not set.");this._tipStyleId||(this._tipStyleId=we.createDrawingStyle({fillStyle:"#FFFFFF",paintMode:"fill",fontFamily:"Open Sans",fontSize:40})),this._drawingLayerOfTip||(this._drawingLayerOfTip=this._drawingLayerManager.getDrawingLayer(Wt.TIP_LAYER_ID)||this._createDrawingLayer(Wt.TIP_LAYER_ID)),this._tip?this._tip.set("text",l):this._tip=j(this,Ra,"m",GI).call(this,l,j(this,pi,"f").topLeftPoint.x,j(this,pi,"f").topLeftPoint.y,j(this,pi,"f").width,j(this,pi,"f").coordinateBase,this._tipStyleId),j(this,Ra,"m",HI).call(this,this._tip,this._drawingLayerOfTip),this._tip.set("visible",j(this,Ec,"f")),this._drawingLayerOfTip&&this._drawingLayerOfTip.renderAll(),j(this,Cc,"f")&&clearTimeout(j(this,Cc,"f")),j(this,wc,"f")>=0&&Le(this,Cc,setTimeout(()=>{j(this,Ra,"m",WI).call(this)},j(this,wc,"f")),"f")}}{static get engineResourcePath(){return sn.engineResourcePaths.dce}static set defaultUIElementURL(l){on._defaultUIElementURL=l}static get defaultUIElementURL(){var l;return null===(l=on._defaultUIElementURL)||void 0===l?void 0:l.replace("@engineResourcePath/",on.engineResourcePath)}static createInstance(l){return se(function*(){customElements.get(on.uiComponentName)||customElements.define(on.uiComponentName,Oa);const u=new on;return yield u.setUIElement(l||on.defaultUIElementURL),u})()}static _transformCoordinates(l,u,g,p,m,v,y){const O=y/m;l.x=Math.round(l.x/(v/p)+u),l.y=Math.round(l.y/O+g)}set _singleFrameMode(l){if(!["disabled","image","camera"].includes(l))throw new Error("Invalid value.");if(l!==j(this,Ic,"f")){if(Le(this,Ic,l,"f"),j(this,Rt,"m",mi).call(this))Le(this,mn,null,"f"),this._videoContainer=null,this._innerComponent.removeElement("content"),this._innerComponent&&(this._innerComponent.addEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.setAttribute("title","Take a photo")),this._bgCamera&&(this._bgCamera.style.display="block");else if(this._innerComponent&&(this._innerComponent.removeEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.removeAttribute("title")),this._bgCamera&&(this._bgCamera.style.display="none"),!j(this,mn,"f")){const u=document.createElement("video");u.style.position="absolute",u.style.left="0",u.style.top="0",u.style.width="100%",u.style.height="100%",u.style.objectFit=this.getVideoFit(),u.setAttribute("autoplay","true"),u.setAttribute("playsinline","true"),u.setAttribute("muted","true"),["iPhone","iPad","Mac"].includes(Ln.OS)&&u.setAttribute("poster","data:image/gif;base64,R0lGODlhAQABAIEAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAgEAAEEBAA7"),Le(this,mn,u,"f");const g=document.createElement("div");g.append(u),g.style.overflow="hidden",this._videoContainer=g,this._innerComponent.setElement("content",g)}j(this,Rt,"m",mi).call(this)||this._hideDefaultSelection?(this._selCam&&(this._selCam.style.display="none"),this._selRsl&&(this._selRsl.style.display="none"),this._selMinLtr&&(this._selMinLtr.style.display="none")):(this._selCam&&(this._selCam.style.display="block"),this._selRsl&&(this._selRsl.style.display="block"),this._selMinLtr&&(this._selMinLtr.style.display="block"),this._stopLoading())}}get _singleFrameMode(){return j(this,Ic,"f")}get disposed(){return j(this,f_,"f")}constructor(){var l;super(),l=this,Rt.add(this),bc.set(this,void 0),Dc.set(this,void 0),Sc.set(this,void 0),this.containerClassName="dce-video-container",mn.set(this,void 0),this.videoFit="contain",this._hideDefaultSelection=!1,this._divScanArea=null,this._divScanLight=null,this._bgLoading=null,this._selCam=null,this._bgCamera=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._selMinLtr=null,this._optGotMinLtr=null,ad.set(this,null),this.regionMaskFillStyle="rgba(0,0,0,0.5)",this.regionMaskStrokeStyle="rgb(254,142,20)",this.regionMaskLineWidth=6,ld.set(this,!1),cd.set(this,!1),Vs.set(this,{width:0,height:0}),this._updateLayersTimeout=500,this._videoResizeListener=()=>{j(this,Rt,"m",xc).call(this),this._updateLayersTimeoutId&&clearTimeout(this._updateLayersTimeoutId),this._updateLayersTimeoutId=setTimeout(()=>{this.disposed||(this.eventHandler.fire("videoEl:resized",null,{async:!1}),this.eventHandler.fire("content:updated",null,{async:!1}),this.isScanLaserVisible()&&j(this,Rt,"m",p_).call(this))},this._updateLayersTimeout)},this._windowResizeListener=()=>{on._onLog&&on._onLog("window resize event triggered."),j(this,Vs,"f").width===document.documentElement.clientWidth&&j(this,Vs,"f").height===document.documentElement.clientHeight||(j(this,Vs,"f").width=document.documentElement.clientWidth,j(this,Vs,"f").height=document.documentElement.clientHeight,this._videoResizeListener())},Ic.set(this,"disabled"),this._clickIptSingleFrameMode=()=>{if(!j(this,Rt,"m",mi).call(this))return;let u;if(this._singleFrameInputContainer)u=this._singleFrameInputContainer.firstElementChild;else{u=document.createElement("input"),u.setAttribute("type","file"),"camera"===this._singleFrameMode?(u.setAttribute("capture",""),u.setAttribute("accept","image/*")):"image"===this._singleFrameMode&&(u.removeAttribute("capture"),u.setAttribute("accept",".jpg,.jpeg,.icon,.gif,.svg,.webp,.png,.bmp")),u.addEventListener("change",se(function*(){const p=u.files[0];u.value="";{const m=function(){var U=se(function*(W){let Y=null,$=null;if("undefined"!=typeof createImageBitmap)try{if(Y=yield createImageBitmap(W),Y)return Y}catch(X){}var q;return Y||($=yield(q=W,new Promise((X,Q)=>{let pe=URL.createObjectURL(q),ve=new Image;ve.src=pe,ve.onload=()=>{URL.revokeObjectURL(ve.src),X(ve)},ve.onerror=Te=>{Q(new Error("Can't convert blob to image : "+(Te instanceof Event?Te.type:Te)))}}))),$});return function(Y){return U.apply(this,arguments)}}(),v=(U,W,Y,$)=>{U.width==Y&&U.height==$||(U.width=Y,U.height=$);const q=U.getContext("2d");q.clearRect(0,0,U.width,U.height),q.drawImage(W,0,0)},y=yield m(p),b=y instanceof HTMLImageElement?y.naturalWidth:y.width,O=y instanceof HTMLImageElement?y.naturalHeight:y.height;let L=l._cvsSingleFrameMode;const N=null==L?void 0:L.width,B=null==L?void 0:L.height;L||(L=document.createElement("canvas"),l._cvsSingleFrameMode=L),v(L,y,b,O),l._innerComponent.setElement("content",L),N===L.width&&B===L.height||l.eventHandler.fire("content:updated",null,{async:!1})}l._onSingleFrameAcquired&&setTimeout(()=>{l._onSingleFrameAcquired(l._cvsSingleFrameMode)},0)})),u.style.position="absolute",u.style.top="-9999px",u.style.backgroundColor="transparent",u.style.color="transparent";const g=document.createElement("div");g.append(u),this._innerComponent.setElement("single-frame-input-container",g),this._singleFrameInputContainer=g}null==u||u.click()},Tc.set(this,[]),this._capturedResultReceiver={onCapturedResultReceived:(u,g)=>{var p,m,v,y;if(this.disposed||(this.clearAllInnerDrawingItems(),!u))return;const b=u.originalImageTag;if(!b)return;const O=u.items;if(!(null==O?void 0:O.length))return;const L=(null===(p=b.cropRegion)||void 0===p?void 0:p.left)||0,N=(null===(m=b.cropRegion)||void 0===m?void 0:m.top)||0,B=(null===(v=b.cropRegion)||void 0===v?void 0:v.right)?b.cropRegion.right-L:b.originalWidth,U=(null===(y=b.cropRegion)||void 0===y?void 0:y.bottom)?b.cropRegion.bottom-N:b.originalHeight,W=b.currentWidth,Y=b.currentHeight,$=(Q,pe,ve,Te,Ae,P,Ee,Be,et=[],S)=>{pe.forEach(D=>on._transformCoordinates(D,ve,Te,Ae,P,Ee,Be));const w=new xU({points:[{x:pe[0].x,y:pe[0].y},{x:pe[1].x,y:pe[1].y},{x:pe[2].x,y:pe[2].y},{x:pe[3].x,y:pe[3].y}]},S);for(let D of et)w.addNote(D);Q.addDrawingItems([w]),j(this,Tc,"f").push(w)};let q,X;for(let Q of O)switch(Q.type){case Yt.CRIT_ORIGINAL_IMAGE:break;case Yt.CRIT_BARCODE:q=this.getDrawingLayer(Wt.DBR_LAYER_ID),X=[{name:"format",content:Q.formatString},{name:"text",content:Q.text}],(null==g?void 0:g.isBarcodeVerifyOpen)?Q.verified?$(q,Q.location.points,L,N,B,U,W,Y,X):$(q,Q.location.points,L,N,B,U,W,Y,X,we.STYLE_ORANGE_STROKE_TRANSPARENT):$(q,Q.location.points,L,N,B,U,W,Y,X);break;case Yt.CRIT_TEXT_LINE:q=this.getDrawingLayer(Wt.DLR_LAYER_ID),X=[{name:"text",content:Q.text}],g.isLabelVerifyOpen?Q.verified?$(q,Q.location.points,L,N,B,U,W,Y,X):$(q,Q.location.points,L,N,B,U,W,Y,X,we.STYLE_GREEN_STROKE_TRANSPARENT):$(q,Q.location.points,L,N,B,U,W,Y,X);break;case Yt.CRIT_DETECTED_QUAD:q=this.getDrawingLayer(Wt.DDN_LAYER_ID),(null==g?void 0:g.isDetectVerifyOpen)?Q.verified?$(q,Q.location.points,L,N,B,U,W,Y,[]):$(q,Q.location.points,L,N,B,U,W,Y,[],we.STYLE_BLUE_STROKE_TRANSPARENT):$(q,Q.location.points,L,N,B,U,W,Y,[]);break;case Yt.CRIT_NORMALIZED_IMAGE:q=this.getDrawingLayer(Wt.DDN_LAYER_ID),(null==g?void 0:g.isNormalizeVerifyOpen)?Q.verified?$(q,Q.location.points,L,N,B,U,W,Y,[]):$(q,Q.location.points,L,N,B,U,W,Y,[],we.STYLE_BLUE_STROKE_TRANSPARENT):$(q,Q.location.points,L,N,B,U,W,Y,[]);break;case Yt.CRIT_PARSED_RESULT:break;default:throw new Error("Illegal item type.")}}},f_.set(this,!1),this.eventHandler=new VI,this.eventHandler.on("content:updated",()=>{j(this,bc,"f")&&clearTimeout(j(this,bc,"f")),Le(this,bc,setTimeout(()=>{if(this.disposed)return;let u;this._updateVideoContainer();try{u=this.getContentDimensions()}catch(g){if("Invalid content dimensions."===(g.message||g))return;throw g}this.updateDrawingLayers(u),this.updateConvertedRegion(u)},0),"f")}),this.eventHandler.on("videoEl:resized",()=>{j(this,Dc,"f")&&clearTimeout(j(this,Dc,"f")),Le(this,Dc,setTimeout(()=>{this.disposed||this._updateVideoContainer()},0),"f")})}_setUIElement(l){l instanceof HTMLTemplateElement?(window._dce_default_template=l,this.UIElement=new Oa):this.UIElement=l,this._unbindUI(),this._bindUI()}setUIElement(l){var u=this;return se(function*(){let g;if(g="string"==typeof l?yield a_(l):l,g instanceof HTMLDivElement&&0==g.childElementCount){const p=yield a_(on.defaultUIElementURL);p instanceof HTMLTemplateElement?(window._dce_default_template=p,g.append(new Oa)):g.append(p),u._setUIElement(g)}else u._setUIElement(g)})()}getUIElement(){return this.UIElement}_bindUI(){var l;if(!this.UIElement)throw new Error("Need to set 'UIElement'.");if(this._innerComponent)return;let u,g=this.UIElement;if(g instanceof Oa?u=g.getElement(`.${this.containerClassName}`):g instanceof HTMLDivElement&&1===g.childElementCount&&g.firstElementChild instanceof Oa?(u=g.firstElementChild.getElement(`.${this.containerClassName}`),g=g.firstElementChild):u=g.classList.contains(this.containerClassName)?g:g.querySelector(`.${this.containerClassName}`),!u)throw Error(`Can not find the element with class '${this.containerClassName}'.`);if(this._innerComponent=new m_,u.appendChild(this._innerComponent),!j(this,Rt,"m",mi).call(this)){const p=document.createElement("video");p.style.position="absolute",p.style.left="0",p.style.top="0",p.style.width="100%",p.style.height="100%",p.style.objectFit=this.getVideoFit(),p.setAttribute("autoplay","true"),p.setAttribute("playsinline","true"),p.setAttribute("muted","true"),["iPhone","iPad","Mac"].includes(Ln.OS)&&p.setAttribute("poster","data:image/gif;base64,R0lGODlhAQABAIEAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAgEAAEEBAA7"),Le(this,mn,p,"f");const m=document.createElement("div");m.append(p),m.style.overflow="hidden",this._videoContainer=m,this._innerComponent.setElement("content",m)}if(g instanceof Oa?(this._selRsl=g.getElement(".dce-sel-resolution"),this._selMinLtr=g.getElement(".dlr-sel-minletter"),this._divScanArea=g.getElement(".dce-scanarea"),this._divScanLight=g.getElement(".dce-scanlight"),this._bgLoading=g.getElement(".dce-bg-loading"),this._bgCamera=g.getElement(".dce-bg-camera"),this._selCam=g.getElement(".dce-sel-camera"),this._optGotRsl=g.getElement(".dce-opt-gotResolution"),this._btnClose=g.getElement(".dce-btn-close"),this._optGotMinLtr=g.getElement(".dlr-opt-gotMinLtr")):(this._selRsl=g.querySelector(".dce-sel-resolution"),this._selMinLtr=g.querySelector(".dlr-sel-minletter"),this._divScanArea=g.querySelector(".dce-scanarea"),this._divScanLight=g.querySelector(".dce-scanlight"),this._bgLoading=g.querySelector(".dce-bg-loading"),this._bgCamera=g.querySelector(".dce-bg-camera"),this._selCam=g.querySelector(".dce-sel-camera"),this._optGotRsl=g.querySelector(".dce-opt-gotResolution"),this._btnClose=g.querySelector(".dce-btn-close"),this._optGotMinLtr=g.querySelector(".dlr-opt-gotMinLtr")),this._selRsl&&(this._hideDefaultSelection||j(this,Rt,"m",mi).call(this)||this._selRsl.options.length||(this._selRsl.innerHTML=['','','',''].join(""),this._optGotRsl=this._selRsl.options[0])),this._selMinLtr&&(this._hideDefaultSelection||j(this,Rt,"m",mi).call(this)||this._selMinLtr.options.length||(this._selMinLtr.innerHTML=['','','','','','','','','','',''].join(""),this._optGotMinLtr=this._selMinLtr.options[0])),this.isScanLaserVisible()||j(this,Rt,"m",xc).call(this),j(this,Rt,"m",mi).call(this)&&(this._innerComponent&&(this._innerComponent.addEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.setAttribute("title","Take a photo")),this._bgCamera&&(this._bgCamera.style.display="block")),j(this,Rt,"m",mi).call(this)||this._hideDefaultSelection?(this._selCam&&(this._selCam.style.display="none"),this._selRsl&&(this._selRsl.style.display="none"),this._selMinLtr&&(this._selMinLtr.style.display="none")):(this._selCam&&(this._selCam.style.display="block"),this._selRsl&&(this._selRsl.style.display="block"),this._selMinLtr&&(this._selMinLtr.style.display="block"),this._stopLoading()),window.ResizeObserver){this._resizeObserver||(this._resizeObserver=new ResizeObserver(m=>{var v;on._onLog&&on._onLog("resize observer triggered.");for(let y of m)y.target===(null===(v=this._innerComponent)||void 0===v?void 0:v.getWrapper())&&this._videoResizeListener()}));const p=null===(l=this._innerComponent)||void 0===l?void 0:l.getWrapper();p&&this._resizeObserver.observe(p)}j(this,Vs,"f").width=document.documentElement.clientWidth,j(this,Vs,"f").height=document.documentElement.clientHeight,window.addEventListener("resize",this._windowResizeListener)}_unbindUI(){var l,u,g,p;j(this,Rt,"m",mi).call(this)?(this._innerComponent&&(this._innerComponent.removeEventListener("click",this._clickIptSingleFrameMode),this._innerComponent.removeAttribute("title")),this._bgCamera&&(this._bgCamera.style.display="none")):this._stopLoading(),j(this,Rt,"m",xc).call(this),null===(l=this._drawingLayerManager)||void 0===l||l.clearDrawingLayers(),null===(u=this._innerComponent)||void 0===u||u.removeElement("drawing-layer"),this._layerBaseCvs=null,this._drawingLayerOfMask=null,this._drawingLayerOfTip=null,null===(g=this._innerComponent)||void 0===g||g.remove(),this._innerComponent=null,Le(this,mn,null,"f"),null===(p=this._videoContainer)||void 0===p||p.remove(),this._videoContainer=null,this._selCam=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._selMinLtr=null,this._optGotMinLtr=null,this._divScanArea=null,this._divScanLight=null,this._singleFrameInputContainer&&(this._singleFrameInputContainer.remove(),this._singleFrameInputContainer=null),window.ResizeObserver&&this._resizeObserver&&this._resizeObserver.disconnect(),window.removeEventListener("resize",this._windowResizeListener)}_startLoading(){this._bgLoading&&(this._bgLoading.style.display="",this._bgLoading.style.animationPlayState="")}_stopLoading(){this._bgLoading&&(this._bgLoading.style.display="none",this._bgLoading.style.animationPlayState="paused")}_renderCamerasInfo(l,u){if(!this._selCam)return;let g;this._selCam.textContent="";for(let p of u){const m=document.createElement("option");m.value=p.deviceId,m.innerText=p.label,this._selCam.append(m),p.deviceId&&l&&l.deviceId==p.deviceId&&(g=m)}this._selCam.value=g?g.value:""}_renderResolutionInfo(l){this._optGotRsl&&(this._optGotRsl.setAttribute("data-width",l.width),this._optGotRsl.setAttribute("data-height",l.height),this._optGotRsl.innerText="got "+l.width+"x"+l.height,this._selRsl&&this._optGotRsl.parentNode==this._selRsl&&(this._selRsl.value="got"))}getVideoElement(){return j(this,mn,"f")}isVideoLoaded(){return!!j(this,mn,"f")&&4==j(this,mn,"f").readyState}setVideoFit(l){if(l=l.toLowerCase(),!["contain","cover"].includes(l))throw new Error(`Unsupported value '${l}'.`);if(this.videoFit=l,!j(this,mn,"f")||(j(this,mn,"f").style.objectFit=l,j(this,Rt,"m",mi).call(this)))return;let u;this._updateVideoContainer();try{u=this.getContentDimensions()}catch(g){if("Invalid content dimensions."===(g.message||g))return;throw g}j(this,Rt,"m",hd).call(this,u,this.getConvertedRegion()),this.updateDrawingLayers(u)}getVideoFit(){return this.videoFit}getContentDimensions(){var l,u,g,p;let m,v,y;if(j(this,Rt,"m",mi).call(this)?(m=null===(g=this._cvsSingleFrameMode)||void 0===g?void 0:g.width,v=null===(p=this._cvsSingleFrameMode)||void 0===p?void 0:p.height,y="contain"):(m=null===(l=j(this,mn,"f"))||void 0===l?void 0:l.videoWidth,v=null===(u=j(this,mn,"f"))||void 0===u?void 0:u.videoHeight,y=this.getVideoFit()),!m||!v)throw new Error("Invalid content dimensions.");return{width:m,height:v,objectFit:y}}updateConvertedRegion(l){const u=id.convert(this.scanRegion,l.width,l.height);Le(this,ad,u,"f"),j(this,Sc,"f")&&clearTimeout(j(this,Sc,"f")),Le(this,Sc,setTimeout(()=>{let g;try{g=this.getContentDimensions()}catch(p){if("Invalid content dimensions."===(p.message||p))return;throw p}j(this,Rt,"m",ud).call(this,g,u),j(this,Rt,"m",hd).call(this,g,u)},0),"f")}getConvertedRegion(){return j(this,ad,"f")}setScanRegion(l){if(null!=l&&!s_(l)&&!qr(l))throw TypeError("Invalid 'region'.");let u;this.scanRegion=l?JSON.parse(JSON.stringify(l)):null;try{u=this.getContentDimensions()}catch(g){if("Invalid content dimensions."===(g.message||g))return;throw g}this.updateConvertedRegion(u)}getScanRegion(){return JSON.parse(JSON.stringify(this.scanRegion))}getVisibleRegionOfVideo(l){if(!this.isVideoLoaded())throw new Error("The video is not loaded.");const u=j(this,mn,"f").videoWidth,g=j(this,mn,"f").videoHeight,p=this.getVideoFit(),{width:m,height:v}=this._innerComponent.getBoundingClientRect();if(m<=0||v<=0)throw new Error("Unable to get video dimensions. Video may not be rendered on the page.");let y;const b={x:0,y:0,width:u,height:g,isMeasuredInPercentage:!1};if("cover"===p&&(m/v1){const p=j(this,mn,"f").videoWidth,m=j(this,mn,"f").videoHeight,{width:v,height:y}=this._innerComponent.getBoundingClientRect(),b=p/m;if(v/yl.remove()),j(this,Tc,"f").length=0}dispose(){this._unbindUI(),delete window._dce_default_template,this.__proto__=null;for(let l in this)delete this[l];Object.defineProperty(this,"disposed",{value:!0})}}function K(f,l,u,g){if("a"===u&&!g)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof l?f!==l||!g:!l.has(f))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===u?g:"a"===u?g.call(f):g?g.value:l.get(f)}function mt(f,l,u,g,p){if("m"===g)throw new TypeError("Private method is not writable");if("a"===g&&!p)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof l?f!==l||!p:!l.has(f))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===g?p.call(f,u):p?p.value=u:l.set(f,u),u}bc=new WeakMap,Dc=new WeakMap,Sc=new WeakMap,mn=new WeakMap,ad=new WeakMap,ld=new WeakMap,cd=new WeakMap,Vs=new WeakMap,Ic=new WeakMap,Tc=new WeakMap,f_=new WeakMap,Rt=new WeakSet,mi=function(){return"disabled"!==this._singleFrameMode},ud=function(f,l){!l||0===l.x&&0===l.y&&l.width===f.width&&l.height===f.height?this.clearScanRegionMask():this.setScanRegionMask(l.x,l.y,l.width,l.height)},YI=function(){this._drawingLayerOfMask&&this._drawingLayerOfMask.setVisible(!0)},g_=function(){this._drawingLayerOfMask&&this._drawingLayerOfMask.setVisible(!1)},p_=function(){this._divScanLight&&"none"==this._divScanLight.style.display&&(this._divScanLight.style.display="block")},xc=function(){this._divScanLight&&(this._divScanLight.style.display="none")},hd=function(f,l){if(!this._divScanArea||!this._innerComponent.getElement("content"))return;const{width:u,height:g,objectFit:p}=f;l||(l={x:0,y:0,width:u,height:g});const{width:m,height:v}=this._innerComponent.getBoundingClientRect();if(m<=0||v<=0)return;const y=m/v,b=u/g;let O,L,N,B,U=1;if("contain"===p)yb+O*m[L],0);g.push(y)}}return g}static identity(){return[1,0,0,0,1,0,0,0,1]}static translate(l,u,g){return je.multiply(l,[1,0,0,0,1,0,u,g,1])}static rotate(l,u){var g=Math.cos(u),p=Math.sin(u);return je.multiply(l,[g,-p,0,p,g,0,0,0,1])}static scale(l,u,g){return je.multiply(l,[u,0,0,0,g,0,0,0,1])}};var _t,Qr,Jr,fd,Ma,Oc,Mc,La,gd,vo,pd,v_,Pe,nt,wt,md,_d,Mt,Ni,es,Fa,vd,Ir,ts,_i,Pa,Na,Lc,yd,ka,yo,ns,is,y_,_n,C_,Co,XI,Cd,wd,qI,ir,w_,E_,Ba,Fc,Ed,vi,Va,b_,D_,ZI;!function(f){f.GREY="grey",f.GREY32="grey32",f.RGBA="rgba",f.RBGA="rbga",f.GRBA="grba",f.GBRA="gbra",f.BRGA="brga",f.BGRA="bgra"}(_t||(_t={}));class qe{static get version(){return"1.1.0"}static checkWebGLSupport(){return null===document.createElement("canvas").getContext("webgl")?(nr(qe,Qr,!1,"f",Jr),!1):(nr(qe,Qr,!0,"f",Jr),!0)}get disposed(){return Xn(this,gd,"f")}constructor(){fd.set(this,_t.RGBA),Ma.set(this,null),Oc.set(this,null),Mc.set(this,null),this.useWebGLByDefault=!0,this._reusedCvs=null,this._reusedWebGLCvs=null,La.set(this,null),gd.set(this,!1)}drawImage(l,u,g,p,m,v){if(this.disposed)throw Error("The 'ImageDataGetter' instance has been disposed.");if(!g||!p)throw new Error("Invalid 'sourceWidth' or 'sourceHeight'.");if(null==Xn(qe,Qr,"f",Jr)&&qe.checkWebGLSupport(),(null==v?void 0:v.bUseWebGL)&&!Xn(qe,Qr,"f",Jr))throw new Error("Your browser or machine may not support WebGL.");if(u instanceof HTMLVideoElement&&4!==u.readyState||u instanceof HTMLImageElement&&!u.complete)throw new Error("The source is not loaded.");let y;qe._onLog&&(y=Date.now(),qe._onLog("drawImage(), START: "+y));let b=0,O=0,L=g,N=p,B=0,U=0,W=g,Y=p;m&&(m.sx&&(b=Math.round(m.sx)),m.sy&&(O=Math.round(m.sy)),m.sWidth&&(L=Math.round(m.sWidth)),m.sHeight&&(N=Math.round(m.sHeight)),m.dx&&(B=Math.round(m.dx)),m.dy&&(U=Math.round(m.dy)),m.dWidth&&(W=Math.round(m.dWidth)),m.dHeight&&(Y=Math.round(m.dHeight)));let $,q=_t.RGBA;if((null==v?void 0:v.pixelFormat)&&(q=v.pixelFormat),(null==v?void 0:v.bufferContainer)&&($=v.bufferContainer,$.length<4*W*Y))throw new Error("Unexpected size of the 'bufferContainer'.");const X=l;if(!Xn(qe,Qr,"f",Jr)||!(this.useWebGLByDefault&&null==(null==v?void 0:v.bUseWebGL)||(null==v?void 0:v.bUseWebGL))){qe._onLog&&qe._onLog("drawImage() in context2d."),X.ctx2d||(X.ctx2d=X.getContext("2d",{willReadFrequently:!0}));const Q=X.ctx2d;if(!Q)throw new Error("Unable to get 'CanvasRenderingContext2D' from canvas.");return(X.width{const C=_.createBuffer();_.bindBuffer(_.ARRAY_BUFFER,C),_.bufferData(_.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),_.STATIC_DRAW);const I=_.createBuffer();return _.bindBuffer(_.ARRAY_BUFFER,I),_.bufferData(_.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),_.STATIC_DRAW),{positions:C,texCoords:I}},Ee=_=>{const C=_.createTexture();return _.bindTexture(_.TEXTURE_2D,C),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_MAG_FILTER,_.LINEAR),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_MIN_FILTER,_.LINEAR),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_WRAP_S,_.CLAMP_TO_EDGE),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_WRAP_T,_.CLAMP_TO_EDGE),C},Be=(_,C)=>{const I=_.createProgram();if(C.forEach(M=>_.attachShader(I,M)),_.linkProgram(I),!_.getProgramParameter(I,_.LINK_STATUS)){const M=new Error(`An error occured linking the program: ${_.getProgramInfoLog(I)}.`);throw M.name="WebGLError",M}return _.useProgram(I),I},et=(_,C,I)=>{const M=_.createShader(C);if(_.shaderSource(M,I),_.compileShader(M),!_.getShaderParameter(M,_.COMPILE_STATUS)){const x=new Error(`An error occured compiling the shader: ${_.getShaderInfoLog(M)}.`);throw x.name="WebGLError",x}return M},S="\n attribute vec2 a_position;\n attribute vec2 a_texCoord;\n \n uniform mat3 u_matrix;\n uniform mat3 u_textureMatrix;\n \n varying vec2 v_texCoord;\n void main(void) {\n gl_Position = vec4((u_matrix * vec3(a_position, 1)).xy, 0, 1.0);\n v_texCoord = vec4((u_textureMatrix * vec3(a_texCoord, 1)).xy, 0, 1.0).xy;\n }\n ";let w="rgb";["rgba","rbga","grba","gbra","brga","bgra"].includes(q)&&(w=q.slice(0,3));const D=`\n precision mediump float;\n varying vec2 v_texCoord;\n uniform sampler2D u_image;\n uniform float uColorFactor;\n \n void main() {\n vec4 sample = texture2D(u_image, v_texCoord);\n float grey = 0.21 * sample.r + 0.71 * sample.g + 0.07 * sample.b;\n gl_FragColor = vec4(sample.${w} * (1.0 - uColorFactor) + (grey * uColorFactor), sample.a);\n }\n `,T=Be(Q,[et(Q,Q.VERTEX_SHADER,S),et(Q,Q.FRAGMENT_SHADER,D)]);nr(this,Oc,{program:T,attribLocations:{vertexPosition:Q.getAttribLocation(T,"a_position"),texPosition:Q.getAttribLocation(T,"a_texCoord")},uniformLocations:{uSampler:Q.getUniformLocation(T,"u_image"),uColorFactor:Q.getUniformLocation(T,"uColorFactor"),uMatrix:Q.getUniformLocation(T,"u_matrix"),uTextureMatrix:Q.getUniformLocation(T,"u_textureMatrix")}},"f"),nr(this,Mc,P(Q),"f"),nr(this,Ma,Ee(Q),"f"),nr(this,fd,q,"f")}const pe=(P,Ee,Be)=>{P.bindBuffer(P.ARRAY_BUFFER,Ee),P.enableVertexAttribArray(Be),P.vertexAttribPointer(Be,2,P.FLOAT,!1,0,0)},Te=(P,Ee,Be,et)=>{P.clearColor(0,0,0,1),P.clearDepth(1),P.enable(P.DEPTH_TEST),P.depthFunc(P.LEQUAL),P.clear(P.COLOR_BUFFER_BIT|P.DEPTH_BUFFER_BIT),pe(P,Be.positions,Ee.attribLocations.vertexPosition),pe(P,Be.texCoords,Ee.attribLocations.texPosition),P.activeTexture(P.TEXTURE0),P.bindTexture(P.TEXTURE_2D,et),P.uniform1i(Ee.uniformLocations.uSampler,0),P.uniform1f(Ee.uniformLocations.uColorFactor,[_t.GREY,_t.GREY32].includes(q)?1:0);let S,w,D=Kr.translate(Kr.identity(),-1,-1);D=Kr.scale(D,2,2),D=Kr.scale(D,1/P.canvas.width,1/P.canvas.height),S=Kr.translate(D,B,U),S=Kr.scale(S,W,Y),P.uniformMatrix3fv(Ee.uniformLocations.uMatrix,!1,S),w=Kr.translate(Kr.identity(),b/g,O/p),w=Kr.scale(w,L/g,N/p),P.uniformMatrix3fv(Ee.uniformLocations.uTextureMatrix,!1,w),P.drawArrays(P.TRIANGLES,0,6)};((P,Ee,Be)=>{const et=P.RGBA,S=P.RGBA,w=P.UNSIGNED_BYTE;P.bindTexture(P.TEXTURE_2D,Ee),P.texImage2D(P.TEXTURE_2D,0,et,S,w,Be)})(Q,Xn(this,Ma,"f"),u),Te(Q,Xn(this,Oc,"f"),Xn(this,Mc,"f"),Xn(this,Ma,"f"));const Ae=$||new Uint8Array(4*W*Y);if(Q.readPixels(B,U,W,Y,Q.RGBA,Q.UNSIGNED_BYTE,Ae),255!==Ae[3]){qe._onLog&&qe._onLog("Incorrect WebGL drawing .");const P=new Error("WebGL error: incorrect drawing.");throw P.name="WebGLError",P}return qe._onLog&&qe._onLog("drawImage() in WebGL end. Costs: "+(Date.now()-y)),{context:Q,pixelFormat:q===_t.GREY?_t.GREY32:q,bUseWebGL:!0}}catch(Q){if(this.forceLoseContext(),null==(null==v?void 0:v.bUseWebGL))return qe._onLog&&qe._onLog("'drawImage()' in WebGL failed, try again in context2d."),this.useWebGLByDefault=!1,this.drawImage(l,u,g,p,m,Object.assign({},v,{bUseWebGL:!1}));throw Q.name="WebGLError",Q}}readCvsData(l,u,g){if(!(l instanceof CanvasRenderingContext2D||l instanceof WebGLRenderingContext))throw new Error("Invalid 'context'.");let p,m=0,v=0,y=l.canvas.width,b=l.canvas.height;if(u&&(u.x&&(m=u.x),u.y&&(v=u.y),u.width&&(y=u.width),u.height&&(b=u.height)),(null==g?void 0:g.length)<4*y*b)throw new Error("Unexpected size of the 'bufferContainer'.");if(l instanceof WebGLRenderingContext){const O=l;g?(O.readPixels(m,v,y,b,O.RGBA,O.UNSIGNED_BYTE,g),p=new Uint8Array(g.buffer,0,4*y*b)):(p=new Uint8Array(4*y*b),O.readPixels(m,v,y,b,O.RGBA,O.UNSIGNED_BYTE,p))}else if(l instanceof CanvasRenderingContext2D){let O;O=l.getImageData(m,v,y,b),p=new Uint8Array(O.data.buffer),null==g||g.set(p)}return p}transformPixelFormat(l,u,g,p){let m,v;if(qe._onLog&&(m=Date.now(),qe._onLog("transformPixelFormat(), START: "+m)),u===g)return qe._onLog&&qe._onLog("transformPixelFormat() end. Costs: "+(Date.now()-m)),p?new Uint8Array(l):l;const y=[_t.RGBA,_t.RBGA,_t.GRBA,_t.GBRA,_t.BRGA,_t.BGRA];if(y.includes(u))if(g===_t.GREY){v=new Uint8Array(l.length/4);for(let b=0;bu||p.sy>g||p.sx+p.sWidth>u||p.sy+p.sHeight>g)throw new Error("Invalid position.");if(l instanceof HTMLVideoElement&&4!==l.readyState||l instanceof HTMLImageElement&&!l.complete)throw new Error("The source is not loaded.");let v;qe._onLog&&(v=Date.now(),qe._onLog("getImageData(), START: "+v));const y=Math.round(p.sx),b=Math.round(p.sy),O=Math.round(p.sWidth),L=Math.round(p.sHeight),N=Math.round(p.dWidth),B=Math.round(p.dHeight);let U=_t.RGBA;(null==m?void 0:m.pixelFormat)&&(U=m.pixelFormat);let W,Y,$,q=null;if((null==m?void 0:m.bufferContainer)&&(q=m.bufferContainer),Xn(qe,Qr,"f",Jr)&&(this.useWebGLByDefault&&null==(null==m?void 0:m.bUseWebGL)||(null==m?void 0:m.bUseWebGL))){qe._onLog&&qe._onLog("getImageData() in WebGL."),this._reusedWebGLCvs||(this._reusedWebGLCvs=document.createElement("canvas")),W=this._reusedWebGLCvs;try{if(q)if(U===_t.GREY){if($=new Uint8Array(4*N*B),Y=this.drawImage(W,l,u,g,{sx:y,sy:b,sWidth:O,sHeight:L,dWidth:N,dHeight:B},{pixelFormat:U,bUseWebGL:!0,bufferContainer:$}),$=this.transformPixelFormat($,Y.pixelFormat,U),q){if(q.length<$.length)throw new Error("Unexpected size of the 'bufferContainer'.");q.set($)}}else Y=this.drawImage(W,l,u,g,{sx:y,sy:b,sWidth:O,sHeight:L,dWidth:N,dHeight:B},{pixelFormat:U,bUseWebGL:!0,bufferContainer:q}),$=new Uint8Array(q.buffer,0,4*N*B),$=this.transformPixelFormat($,Y.pixelFormat,U);else U===_t.GREY?((!Xn(this,La,"f")||Xn(this,La,"f").length<4*N*B)&&nr(this,La,new Uint8Array(4*N*B),"f"),$=new Uint8Array(Xn(this,La,"f").buffer,0,4*N*B)):$=new Uint8Array(4*N*B),Y=this.drawImage(W,l,u,g,{sx:y,sy:b,sWidth:O,sHeight:L,dWidth:N,dHeight:B},{pixelFormat:U,bUseWebGL:!0,bufferContainer:$}),$=this.transformPixelFormat($,Y.pixelFormat,U)}catch(X){if("WebGLError"===X.name&&(this.forceLoseContext(),null==(null==m?void 0:m.bUseWebGL)))return qe._onLog&&qe._onLog("getImageData() in WebGL failed, try again in context2d."),this.useWebGLByDefault=!1,this.getImageData(l,u,g,{sx:y,sy:b,sWidth:O,sHeight:L,dWidth:N,dHeight:B},Object.assign({},m,{bUseWebGL:!1}));throw X}}else if(qe._onLog&&qe._onLog("getImageData() in context2d."),this._reusedCvs||(this._reusedCvs=document.createElement("canvas")),W=this._reusedCvs,Y=this.drawImage(W,l,u,g,{sx:y,sy:b,sWidth:O,sHeight:L,dWidth:N,dHeight:B},{pixelFormat:_t.RGBA,bUseWebGL:!1}),$=this.readCvsData(Y.context,{width:N,height:B},null),$=this.transformPixelFormat($,Y.pixelFormat,U),q){if(q.length<$.length)throw new Error("Unexpected size of the 'bufferContainer'.");q.set($)}return qe._onLog&&qe._onLog("getImageData() end. Costs: "+(Date.now()-v)),{data:$,pixelFormat:U,width:N,height:B,bUseWebGL:Y.bUseWebGL}}convertDataToCvs(l,u,g,p){if(!(l instanceof Uint8Array||l instanceof Uint8ClampedArray))throw new TypeError("Invalid 'data'.");if("number"!=typeof u||u<=0)throw new Error("Invalid 'width'.");if("number"!=typeof g||g<=0)throw new Error("Invalid 'height'.");const m=document.createElement("canvas");let v;if(m.width=u,m.height=g,p===_t.GREY){v=new Uint8ClampedArray(4*u*g);for(let b=0;b{p.disposed||v.apply(g.target,y)},0);else try{b=v.apply(g.target,y)}catch(O){}if(!0===b)break}}})()}dispose(){mt(this,pd,!0,"f")}}vo=new WeakMap,pd=new WeakMap;const ii=(f,l,u,g)=>{if(!u)return f;let p=l+Math.round((f-l)/u)*u;return g&&(p=Math.min(p,g)),p};class We{static get version(){return"2.0.7"}static isStorageAvailable(l){let u;try{u=window[l];const g="__storage_test__";return u.setItem(g,g),u.removeItem(g),!0}catch(g){return g instanceof DOMException&&(22===g.code||1014===g.code||"QuotaExceededError"===g.name||"NS_ERROR_DOM_QUOTA_REACHED"===g.name)&&u&&0!==u.length}}static findBestRearCameraInIOS(l,u){if(!l||!l.length)return null;let g=!1;if((null==u?void 0:u.getMainCamera)&&(g=!0),g){const p=["\ud6c4\uba74 \uce74\uba54\ub77c","\u80cc\u9762\u30ab\u30e1\u30e9","\u5f8c\u7f6e\u93e1\u982d","\u540e\u7f6e\u76f8\u673a","\u0e01\u0e25\u0e49\u0e2d\u0e07\u0e14\u0e49\u0e32\u0e19\u0e2b\u0e25\u0e31\u0e07","\u092c\u0948\u0915 \u0915\u0948\u092e\u0930\u093e","\u0627\u0644\u0643\u0627\u0645\u064a\u0631\u0627 \u0627\u0644\u062e\u0644\u0641\u064a\u0629","\u05de\u05e6\u05dc\u05de\u05d4 \u05d0\u05d7\u05d5\u05e8\u05d9\u05ea","\u043a\u0430\u043c\u0435\u0440\u0430 \u043d\u0430 \u0437\u0430\u0434\u043d\u0435\u0439 \u043f\u0430\u043d\u0435\u043b\u0438","\u0437\u0430\u0434\u043d\u044f \u043a\u0430\u043c\u0435\u0440\u0430","\u0437\u0430\u0434\u043d\u0430 \u043a\u0430\u043c\u0435\u0440\u0430","\u0430\u0440\u0442\u049b\u044b \u043a\u0430\u043c\u0435\u0440\u0430","\u03c0\u03af\u03c3\u03c9 \u03ba\u03ac\u03bc\u03b5\u03c1\u03b1","zadn\xed fotoapar\xe1t","zadn\xe1 kamera","tylny aparat","takakamera","stra\u017enja kamera","r\xfcckkamera","kamera p\xe5 baksidan","kamera belakang","kamera bak","h\xe1ts\xf3 kamera","fotocamera (posteriore)","c\xe2mera traseira","c\xe2mara traseira","c\xe1mara trasera","c\xe0mera posterior","cam\xe9ra arri\xe8re","camer\u0103 spate","camera m\u1eb7t sau","camera aan achterzijde","bagsidekamera","back camera","arka kamera"],m=l.find(v=>p.includes(v.label.toLowerCase()));return null==m?void 0:m.deviceId}{const p=["\ud6c4\uba74","\u80cc\u9762","\u5f8c\u7f6e","\u540e\u7f6e","\u0e32\u0e19\u0e2b\u0e25\u0e31\u0e07","\u092c\u0948\u0915","\u062e\u0644\u0641\u064a\u0629","\u05d0\u05d7\u05d5\u05e8\u05d9\u05ea","\u0437\u0430\u0434\u043d\u044f\u044f","\u0437\u0430\u0434\u043d\u0435\u0439","\u0437\u0430\u0434\u043d\u0430","\u03c0\u03af\u03c3\u03c9","zadn\xed","zadn\xe1","tylny","trasera","traseira","taka","stra\u017enja","spate","sau","r\xfcck","posteriore","posterior","h\xe1ts\xf3","belakang","baksidan","bakre","bak","bagside","back","a\u0440\u0442\u049b\u044b","arri\xe8re","arka","achterzijde"],m=["\ud2b8\ub9ac\ud50c","\u4e09\u955c\u5934","\u4e09\u93e1\u982d","\u30c8\u30ea\u30d7\u30eb","\u0e2a\u0e32\u0e21","\u091f\u094d\u0930\u093f\u092a\u0932","\u062b\u0644\u0627\u062b\u064a\u0629","\u05de\u05e9\u05d5\u05dc\u05e9\u05ea","\u04af\u0448\u0442\u0456\u043a","\u0442\u0440\u043e\u0439\u043d\u0430\u044f","\u0442\u0440\u043e\u0439\u043d\u0430","\u043f\u043e\u0442\u0440\u043e\u0454\u043d\u0430","\u03c4\u03c1\u03b9\u03c0\u03bb\u03ae","\xfc\xe7l\xfc","tr\xf3jobiektywowy","trostruka","trojn\xfd","trojit\xe1","trippelt","trippel","tripl\u0103","triple","tripla","tiga","kolmois","ba camera"],v=["\ub4c0\uc5bc \uc640\uc774\ub4dc","\u96d9\u5ee3\u89d2","\u53cc\u5e7f\u89d2","\u30c7\u30e5\u30a2\u30eb\u5e83\u89d2","\u0e04\u0e39\u0e48\u0e14\u0e49\u0e32\u0e19\u0e2b\u0e25\u0e31\u0e07\u0e21\u0e38\u0e21\u0e01\u0e27\u0e49\u0e32\u0e07","\u0921\u094d\u092f\u0941\u0905\u0932 \u0935\u093e\u0907\u0921","\u0645\u0632\u062f\u0648\u062c\u0629 \u0639\u0631\u064a\u0636\u0629","\u05db\u05e4\u05d5\u05dc\u05d4 \u05e8\u05d7\u05d1\u05d4","\u049b\u043e\u0441 \u043a\u0435\u04a3 \u0431\u04b1\u0440\u044b\u0448\u0442\u044b","\u0437\u0434\u0432\u043e\u0454\u043d\u0430 \u0448\u0438\u0440\u043e\u043a\u043e\u043a\u0443\u0442\u043d\u0430","\u0434\u0432\u043e\u0439\u043d\u0430\u044f \u0448\u0438\u0440\u043e\u043a\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0430\u044f","\u0434\u0432\u043e\u0439\u043d\u0430 \u0448\u0438\u0440\u043e\u043a\u043e\u044a\u0433\u044a\u043b\u043d\u0430","\u03b4\u03b9\u03c0\u03bb\u03ae \u03b5\u03c5\u03c1\u03b5\u03af\u03b1","\xe7ift geni\u015f","laajakulmainen kaksois","k\xe9p r\u1ed9ng m\u1eb7t sau","kett\u0151s, sz\xe9les l\xe1t\xf3sz\xf6g\u0171","grande angular dupla","ganda","dwuobiektywowy","dwikamera","dvostruka \u0161iroka","du\xe1ln\xed \u0161iroko\xfahl\xfd","du\xe1lna \u0161irokouhl\xe1","dupla grande-angular","dubl\u0103","dubbel vidvinkel","dual-weitwinkel","dual wide","dual con gran angular","dual","double","doppia con grandangolo","doble","dobbelt vidvinkelkamera"],y=l.filter(L=>{const N=L.label.toLowerCase();return p.some(B=>N.includes(B))});if(!y.length)return null;const b=y.find(L=>{const N=L.label.toLowerCase();return m.some(B=>N.includes(B))});if(b)return b.deviceId;const O=y.find(L=>{const N=L.label.toLowerCase();return v.some(B=>N.includes(B))});return O?O.deviceId:y[0].deviceId}}static findBestRearCamera(l,u){if(!l||!l.length)return null;if(["iPhone","iPad","Mac"].includes(jn.OS))return We.findBestRearCameraInIOS(l,{getMainCamera:null==u?void 0:u.getMainCameraInIOS});const g=["\ud6c4","\u80cc\u9762","\u80cc\u7f6e","\u5f8c\u9762","\u5f8c\u7f6e","\u540e\u9762","\u540e\u7f6e","\u0e32\u0e19\u0e2b\u0e25\u0e31\u0e07","\u0e2b\u0e25\u0e31\u0e07","\u092c\u0948\u0915","\u062e\u0644\u0641\u064a\u0629","\u05d0\u05d7\u05d5\u05e8\u05d9\u05ea","\u0437\u0430\u0434\u043d\u044f\u044f","\u0437\u0430\u0434\u043d\u044f","\u0437\u0430\u0434\u043d\u0435\u0439","\u0437\u0430\u0434\u043d\u0430","\u03c0\u03af\u03c3\u03c9","zadn\xed","zadn\xe1","tylny","tr\xe1s","trasera","traseira","taka","stra\u017enja","spate","sau","r\xfcck","rear","posteriore","posterior","h\xe1ts\xf3","darrere","belakang","baksidan","bakre","bak","bagside","back","a\u0440\u0442\u049b\u044b","arri\xe8re","arka","achterzijde"];for(let p of l){const m=p.label.toLowerCase();if(m&&g.some(v=>m.includes(v))&&/\b0(\b)?/.test(m))return p.deviceId}return["Android","HarmonyOS"].includes(jn.OS)?l[l.length-1].deviceId:null}static findBestCamera(l,u,g){return l&&l.length?"environment"===u?this.findBestRearCamera(l,g):"user"===u?null:u?void 0:null:null}static playVideo(l,u,g){return se(function*(){if(!l)throw new Error("Invalid 'videoEl'.");if(!u)throw new Error("Invalid 'source'.");return new Promise(function(){var p=se(function*(m,v){let y;const b=()=>{l.removeEventListener("loadstart",B),l.removeEventListener("abort",U),l.removeEventListener("play",W),l.removeEventListener("error",Y),l.removeEventListener("loadedmetadata",X)};let O=!1;const L=()=>{O=!0,y&&clearTimeout(y),b(),m(l)},N=Q=>{y&&clearTimeout(y),b(),v(Q)},B=()=>{l.addEventListener("abort",U,{once:!0})},U=()=>{const Q=new Error("Video playing was interrupted.");Q.name="AbortError",N(Q)},W=()=>{L()},Y=()=>{N(new Error(`Video error ${l.error.code}: ${l.error.message}.`))};let $;const q=new Promise(Q=>{$=Q}),X=()=>{$()};if(l.addEventListener("loadstart",B,{once:!0}),l.addEventListener("play",W,{once:!0}),l.addEventListener("error",Y,{once:!0}),l.addEventListener("loadedmetadata",X,{once:!0}),"string"==typeof u||u instanceof String?l.src=u:l.srcObject=u,l.autoplay&&(yield new Promise(Q=>{setTimeout(Q,1e3)})),!O){g&&(y=setTimeout(()=>{b(),v(new Error("Failed to play video. Timeout."))},g));try{l.src&&(yield l.load()),yield l.play(),L()}catch(Q){console.warn("1st play error: "+((null==Q?void 0:Q.message)||Q))}if(!O){yield q;try{yield l.play(),L()}catch(Q){console.warn("2rd play error: "+((null==Q?void 0:Q.message)||Q)),N(Q)}}}});return function(m,v){return p.apply(this,arguments)}}())})()}static testCameraAccess(l){return se(function*(){var u,g;if(!(null===(g=null===(u=null==window?void 0:window.navigator)||void 0===u?void 0:u.mediaDevices)||void 0===g?void 0:g.getUserMedia))return{ok:!1,errorName:"InsecureContext",errorMessage:"Insecure context."};let p;try{p=l?yield navigator.mediaDevices.getUserMedia(l):yield navigator.mediaDevices.getUserMedia({video:!0})}catch(m){return{ok:!1,errorName:m.name,errorMessage:m.message}}finally{null==p||p.getTracks().forEach(m=>{m.stop()})}return{ok:!0}})()}get state(){if(!K(this,_i,"f"))return"closed";if("pending"===K(this,_i,"f"))return"opening";if("fulfilled"===K(this,_i,"f"))return"opened";throw new Error("Unknown state.")}set ifSaveLastUsedCamera(l){l?We.isStorageAvailable("localStorage")?mt(this,Fa,!0,"f"):(mt(this,Fa,!1,"f"),console.warn("Local storage is unavailable")):mt(this,Fa,!1,"f")}get ifSaveLastUsedCamera(){return K(this,Fa,"f")}get isVideoPlaying(){return!(!K(this,nt,"f")||K(this,nt,"f").paused)&&"opened"===this.state}set tapFocusEventBoundEl(l){var u,g,p;if(!(l instanceof HTMLElement)&&null!=l)throw new TypeError("Invalid 'element'.");null===(u=K(this,yo,"f"))||void 0===u||u.removeEventListener("click",K(this,ka,"f")),null===(g=K(this,yo,"f"))||void 0===g||g.removeEventListener("touchend",K(this,ka,"f")),null===(p=K(this,yo,"f"))||void 0===p||p.removeEventListener("touchmove",K(this,yd,"f")),mt(this,yo,l,"f"),l&&(window.TouchEvent&&["Android","HarmonyOS","iPhone","iPad"].includes(jn.OS)?(l.addEventListener("touchend",K(this,ka,"f")),l.addEventListener("touchmove",K(this,yd,"f"))):l.addEventListener("click",K(this,ka,"f")))}get tapFocusEventBoundEl(){return K(this,yo,"f")}get disposed(){return K(this,wd,"f")}constructor(l){var g,p,u=this;Pe.add(this),nt.set(this,null),wt.set(this,void 0),md.set(this,()=>{"opened"===this.state&&K(this,_n,"f").fire("resumed",null,{target:this,async:!1})}),_d.set(this,()=>{K(this,_n,"f").fire("paused",null,{target:this,async:!1})}),Mt.set(this,void 0),Ni.set(this,void 0),this.cameraOpenTimeout=15e3,this._arrCameras=[],es.set(this,void 0),Fa.set(this,!1),this.ifSkipCameraInspection=!1,this.selectIOSRearMainCameraAsDefault=!1,vd.set(this,void 0),Ir.set(this,!0),ts.set(this,void 0),_i.set(this,void 0),Pa.set(this,!1),this._focusParameters={maxTimeout:400,minTimeout:300,kTimeout:void 0,oldDistance:null,fds:null,isDoingFocus:0,taskBackToContinous:null,curFocusTaskId:0,focusCancelableTime:1500,defaultFocusAreaSizeRatio:6,focusBackToContinousTime:5e3,tapFocusMinDistance:null,tapFocusMaxDistance:null,focusArea:null,tempBufferContainer:null,defaultTempBufferContainerLenRatio:1/4},Na.set(this,!1),this._focusSupported=!0,this.calculateCoordInVideo=(m,v)=>{let y,b;const O=window.getComputedStyle(K(this,nt,"f")).objectFit,L=this.getResolution(),N=K(this,nt,"f").getBoundingClientRect(),B=N.left,U=N.top,{width:W,height:Y}=K(this,nt,"f").getBoundingClientRect();if(W<=0||Y<=0)throw new Error("Unable to get video dimensions. Video may not be rendered on the page.");const $=W/Y,q=L.width/L.height;let X=1;if("contain"===O)q>$?(X=W/L.width,y=(m-B)/X,b=(v-U-(Y-W/q)/2)/X):(X=Y/L.height,b=(v-U)/X,y=(m-B-(W-Y*q)/2)/X);else{if("cover"!==O)throw new Error("Unsupported object-fit.");q>$?(X=Y/L.height,b=(v-U)/X,y=(m-B+(Y*q-W)/2)/X):(X=W/L.width,y=(m-B)/X,b=(v-U+(W/q-Y)/2)/X)}return{x:y,y:b}},Lc.set(this,!1),yd.set(this,()=>{mt(this,Lc,!0,"f")}),ka.set(this,function(){var m=se(function*(v){var y;if(K(u,Lc,"f"))return void mt(u,Lc,!1,"f");if(!(K(u,Na,"f")&&u.isVideoPlaying&&K(u,wt,"f")&&u._focusSupported))return;if(!u._focusParameters.fds&&(u._focusParameters.fds=null===(y=u.getCameraCapabilities())||void 0===y?void 0:y.focusDistance,!u._focusParameters.fds))return void(u._focusSupported=!1);if(null==u._focusParameters.kTimeout&&(u._focusParameters.kTimeout=(u._focusParameters.maxTimeout-u._focusParameters.minTimeout)/(1/u._focusParameters.fds.min-1/u._focusParameters.fds.max)),1==u._focusParameters.isDoingFocus)return;let b,O;if(u._focusParameters.taskBackToContinous&&(clearTimeout(u._focusParameters.taskBackToContinous),u._focusParameters.taskBackToContinous=null),v instanceof MouseEvent)b=v.clientX,O=v.clientY;else{if(!(v instanceof TouchEvent))throw new Error("Unknown event type.");if(!v.changedTouches.length)return;b=v.changedTouches[0].clientX,O=v.changedTouches[0].clientY}const L=u.getResolution(),N=2*Math.round(Math.min(L.width,L.height)/u._focusParameters.defaultFocusAreaSizeRatio/2);let B;try{B=u.calculateCoordInVideo(b,O)}catch(q){}if(B.x<0||B.x>L.width||B.y<0||B.y>L.height)return;const U={x:B.x+"px",y:B.y+"px"},W=N+"px",Y=W;let $;We._onLog&&($=Date.now());try{yield K(u,Pe,"m",b_).call(u,U,W,Y,u._focusParameters.tapFocusMinDistance,u._focusParameters.tapFocusMaxDistance)}catch(q){if(We._onLog)throw We._onLog(q),q}We._onLog&&We._onLog(`Tap focus costs: ${Date.now()-$} ms`),u._focusParameters.taskBackToContinous=setTimeout(()=>{var q;We._onLog&&We._onLog("Back to continuous focus."),null===(q=K(u,wt,"f"))||void 0===q||q.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{})},u._focusParameters.focusBackToContinousTime),K(u,_n,"f").fire("tapfocus",null,{target:u,async:!1})});return function(v){return m.apply(this,arguments)}}()),yo.set(this,null),ns.set(this,1),is.set(this,{x:0,y:0}),this.updateVideoElWhenSoftwareScaled=()=>{if(!K(this,nt,"f"))return;const m=K(this,ns,"f");if(m<1)throw new RangeError("Invalid scale value.");if(1===m)K(this,nt,"f").style.transform="";else{const v=window.getComputedStyle(K(this,nt,"f")).objectFit,y=K(this,nt,"f").videoWidth,b=K(this,nt,"f").videoHeight,{width:O,height:L}=K(this,nt,"f").getBoundingClientRect();if(O<=0||L<=0)throw new Error("Unable to get video dimensions. Video may not be rendered on the page.");const N=O/L,B=y/b;let U=1;"contain"===v?U=NN?L/(y/m):O/(b/m));const W=U*(1-1/m)*(y/2-K(this,is,"f").x),Y=U*(1-1/m)*(b/2-K(this,is,"f").y);K(this,nt,"f").style.transform=`translate(${W}px, ${Y}px) scale(${m})`}},y_.set(this,function(){if(!(this.data instanceof Uint8Array||this.data instanceof Uint8ClampedArray))throw new TypeError("Invalid data.");if("number"!=typeof this.width||this.width<=0)throw new Error("Invalid width.");if("number"!=typeof this.height||this.height<=0)throw new Error("Invalid height.");const m=document.createElement("canvas");let v;if(m.width=this.width,m.height=this.height,this.pixelFormat===_t.GREY){v=new Uint8ClampedArray(this.width*this.height*4);for(let b=0;bsetTimeout(b,300)),!u.isVideoPlaying){We._onLog&&We._onLog("document visible. 1st open failed. 2rd resume start."),y=!1;try{yield u.resume(),y=!0}catch(b){We._onLog&&We._onLog("document visible. 2rd resume video failed, try open instead.")}y||(yield K(u,Pe,"m",Ba).call(u))}}}else"hidden"===document.visibilityState&&(We._onLog&&We._onLog("document hidden. video paused: "+(null===(v=K(u,nt,"f"))||void 0===v?void 0:v.paused)),"opening"==u.state||"opened"==u.state&&u.isVideoPlaying&&u.pause())})),wd.set(this,!1),(null===(p=null===(g=null==window?void 0:window.navigator)||void 0===g?void 0:g.mediaDevices)||void 0===p?void 0:p.getUserMedia)||setTimeout(()=>{We.onWarning&&We.onWarning("The browser is too old or the page is loaded from an insecure origin.")},0),this.defaultConstraints={video:{facingMode:{ideal:"environment"}}},this.resetMediaStreamConstraints(),l instanceof HTMLVideoElement&&this.setVideoEl(l),mt(this,_n,new LU,"f"),this.imageDataGetter=new qe,document.addEventListener("visibilitychange",K(this,Cd,"f"))}setVideoEl(l){if(!(l&&l instanceof HTMLVideoElement))throw new Error("Invalid 'videoEl'.");l.addEventListener("play",K(this,md,"f")),l.addEventListener("pause",K(this,_d,"f")),mt(this,nt,l,"f")}getVideoEl(){return K(this,nt,"f")}releaseVideoEl(){var l,u;null===(l=K(this,nt,"f"))||void 0===l||l.removeEventListener("play",K(this,md,"f")),null===(u=K(this,nt,"f"))||void 0===u||u.removeEventListener("pause",K(this,_d,"f")),mt(this,nt,null,"f")}isVideoLoaded(){return!!K(this,nt,"f")&&4==K(this,nt,"f").readyState}open(){var l=this;return se(function*(){if(K(l,ts,"f")&&!K(l,Ir,"f")){if("pending"===K(l,_i,"f"))return K(l,ts,"f");if("fulfilled"===K(l,_i,"f"))return}K(l,_n,"f").fire("before:open",null,{target:l}),yield K(l,Pe,"m",Ba).call(l),K(l,_n,"f").fire("played",null,{target:l,async:!1}),K(l,_n,"f").fire("opened",null,{target:l,async:!1})})()}close(){var l=this;return se(function*(){if("closed"===l.state)return;K(l,_n,"f").fire("before:close",null,{target:l});const u=K(l,ts,"f");if(K(l,Pe,"m",Ed).call(l),u&&"pending"===K(l,_i,"f")){try{yield u}catch(g){}if(!1===K(l,Ir,"f")){const g=new Error("'close()' was interrupted.");throw g.name="AbortError",g}}mt(l,ts,null,"f"),mt(l,_i,null,"f"),K(l,_n,"f").fire("closed",null,{target:l,async:!1})})()}pause(){if(!this.isVideoLoaded())throw new Error("Video is not loaded.");if("opened"!==this.state)throw new Error("Camera or video is not open.");K(this,nt,"f").pause()}resume(){var l=this;return se(function*(){if(!l.isVideoLoaded())throw new Error("Video is not loaded.");if("opened"!==l.state)throw new Error("Camera or video is not open.");yield K(l,nt,"f").play()})()}setCamera(l){var u=this;return se(function*(){if("string"!=typeof l)throw new TypeError("Invalid 'deviceId'.");if("object"!=typeof K(u,Mt,"f").video&&(K(u,Mt,"f").video={}),delete K(u,Mt,"f").video.facingMode,K(u,Mt,"f").video.deviceId={exact:l},!("closed"===u.state||u.videoSrc||"opening"===u.state&&K(u,Ir,"f"))){K(u,_n,"f").fire("before:camera:change",[],{target:u,async:!1}),yield K(u,Pe,"m",Fc).call(u);try{u.resetSoftwareScale()}catch(g){}return K(u,Ni,"f")}})()}switchToFrontCamera(l){var u=this;return se(function*(){if("object"!=typeof K(u,Mt,"f").video&&(K(u,Mt,"f").video={}),(null==l?void 0:l.resolution)&&(K(u,Mt,"f").video.width={ideal:l.resolution.width},K(u,Mt,"f").video.height={ideal:l.resolution.height}),delete K(u,Mt,"f").video.deviceId,K(u,Mt,"f").video.facingMode={exact:"user"},mt(u,es,null,"f"),!("closed"===u.state||u.videoSrc||"opening"===u.state&&K(u,Ir,"f"))){K(u,_n,"f").fire("before:camera:change",[],{target:u,async:!1}),K(u,Pe,"m",Fc).call(u);try{u.resetSoftwareScale()}catch(g){}return K(u,Ni,"f")}})()}getCamera(){var l;if(K(this,Ni,"f"))return K(this,Ni,"f");{let u=(null===(l=K(this,Mt,"f").video)||void 0===l?void 0:l.deviceId)||"";if(u){u=u.exact||u.ideal||u;for(let g of this._arrCameras)if(g.deviceId===u)return JSON.parse(JSON.stringify(g))}return{deviceId:"",label:"",_checked:!1}}}_getCameras(l){var u=this;return se(function*(){var g,p;if(!(null===(p=null===(g=null==window?void 0:window.navigator)||void 0===g?void 0:g.mediaDevices)||void 0===p?void 0:p.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let m;if(l){let b=yield navigator.mediaDevices.getUserMedia({video:!0});m=(yield navigator.mediaDevices.enumerateDevices()).filter(O=>"videoinput"===O.kind),b.getTracks().forEach(O=>{O.stop()})}else m=(yield navigator.mediaDevices.enumerateDevices()).filter(b=>"videoinput"===b.kind);const v=[],y=[];if(u._arrCameras)for(let b of u._arrCameras)b._checked&&y.push(b);for(let b=0;b"videoinput"===m.kind);return l._getCameras(!(!p||!p.length||p[0].deviceId))})()}getAllCameras(){var l=this;return se(function*(){return l.getCameras()})()}setResolution(l,u,g){var p=this;return se(function*(){if("number"!=typeof l||l<=0)throw new TypeError("Invalid 'width'.");if("number"!=typeof u||u<=0)throw new TypeError("Invalid 'height'.");if("object"!=typeof K(p,Mt,"f").video&&(K(p,Mt,"f").video={}),g?(K(p,Mt,"f").video.width={exact:l},K(p,Mt,"f").video.height={exact:u}):(K(p,Mt,"f").video.width={ideal:l},K(p,Mt,"f").video.height={ideal:u}),"closed"===p.state||p.videoSrc||"opening"===p.state&&K(p,Ir,"f"))return null;K(p,_n,"f").fire("before:resolution:change",[],{target:p,async:!1}),yield K(p,Pe,"m",Fc).call(p);try{p.resetSoftwareScale()}catch(v){}const m=p.getResolution();return{width:m.width,height:m.height}})()}getResolution(){if("opened"===this.state&&this.videoSrc&&K(this,nt,"f"))return{width:K(this,nt,"f").videoWidth,height:K(this,nt,"f").videoHeight};if(K(this,wt,"f")){const l=K(this,wt,"f").getSettings();return{width:l.width,height:l.height}}if(this.isVideoLoaded())return{width:K(this,nt,"f").videoWidth,height:K(this,nt,"f").videoHeight};{const l={width:0,height:0};let u=K(this,Mt,"f").video.width||0,g=K(this,Mt,"f").video.height||0;return u&&(l.width=u.exact||u.ideal||u),g&&(l.height=g.exact||g.ideal||g),l}}getResolutions(l){var u=this;return se(function*(){var g,p,m,v,y,b,O,L,N,B,U;if(!(null===(p=null===(g=null==window?void 0:window.navigator)||void 0===g?void 0:g.mediaDevices)||void 0===p?void 0:p.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let W="";const Y=($,q)=>{const X=K(u,Co,"f").get($);if(!X||!X.length)return!1;for(let Q of X)if(Q.width===q.width&&Q.height===q.height)return!0;return!1};if(u._mediaStream){W=null===(U=K(u,Ni,"f"))||void 0===U?void 0:U.deviceId;let $=K(u,Co,"f").get(W);if($&&!l)return JSON.parse(JSON.stringify($));$=[],K(u,Co,"f").set(W,$),mt(u,Pa,!0,"f");try{for(let q of u.detectedResolutions){yield K(u,wt,"f").applyConstraints({width:{ideal:q.width},height:{ideal:q.height}}),K(u,Pe,"m",ir).call(u);const X=K(u,wt,"f").getSettings(),Q={width:X.width,height:X.height};Y(W,Q)||$.push({width:Q.width,height:Q.height})}}catch(q){throw K(u,Pe,"m",Ed).call(u),mt(u,Pa,!1,"f"),q}try{yield K(u,Pe,"m",Ba).call(u)}catch(q){if("AbortError"===q.name)return $;throw q}finally{mt(u,Pa,!1,"f")}return $}{const $=function(){var Q=se(function*(pe,ve,Te){const Ae={video:{deviceId:{exact:pe},width:{ideal:ve},height:{ideal:Te}}};let P=null;try{P=yield navigator.mediaDevices.getUserMedia(Ae)}catch(et){return null}if(!P)return null;const Ee=P.getVideoTracks();let Be=null;try{const et=Ee[0].getSettings();Be={width:et.width,height:et.height}}catch(et){const S=document.createElement("video");S.srcObject=P,Be={width:S.videoWidth,height:S.videoHeight},S.srcObject=null}return Ee.forEach(et=>{et.stop()}),Be});return function(ve,Te,Ae){return Q.apply(this,arguments)}}();let q=(null===(y=null===(v=null===(m=K(u,Mt,"f"))||void 0===m?void 0:m.video)||void 0===v?void 0:v.deviceId)||void 0===y?void 0:y.exact)||(null===(L=null===(O=null===(b=K(u,Mt,"f"))||void 0===b?void 0:b.video)||void 0===O?void 0:O.deviceId)||void 0===L?void 0:L.ideal)||(null===(B=null===(N=K(u,Mt,"f"))||void 0===N?void 0:N.video)||void 0===B?void 0:B.deviceId);if(!q)return[];let X=K(u,Co,"f").get(q);if(X&&!l)return JSON.parse(JSON.stringify(X));X=[],K(u,Co,"f").set(q,X);for(let Q of u.detectedResolutions){const pe=yield $(q,Q.width,Q.height);pe&&!Y(q,pe)&&X.push({width:pe.width,height:pe.height})}return X}})()}setMediaStreamConstraints(l,u){var g=this;return se(function*(){if(null===(p=l)||"[object Object]"!==Object.prototype.toString.call(p))throw new TypeError("Invalid 'mediaStreamConstraints'.");var p;mt(g,Mt,JSON.parse(JSON.stringify(l)),"f"),mt(g,es,null,"f"),u&&K(g,Pe,"m",Fc).call(g)})()}getMediaStreamConstraints(){return JSON.parse(JSON.stringify(K(this,Mt,"f")))}resetMediaStreamConstraints(){mt(this,Mt,this.defaultConstraints?JSON.parse(JSON.stringify(this.defaultConstraints)):null,"f")}getCameraCapabilities(){if(!K(this,wt,"f")||"opened"!==this.state)throw new Error("Camera is not open.");return K(this,wt,"f").getCapabilities?K(this,wt,"f").getCapabilities():{}}getCameraSettings(){if(!K(this,wt,"f")||"opened"!==this.state)throw new Error("Camera is not open.");return K(this,wt,"f").getSettings()}turnOnTorch(){var l=this;return se(function*(){if(!K(l,wt,"f")||"opened"!==l.state)throw new Error("Camera is not open.");const u=l.getCameraCapabilities();if(!(null==u?void 0:u.torch))throw Error("Not supported.");yield K(l,wt,"f").applyConstraints({advanced:[{torch:!0}]})})()}turnOffTorch(){var l=this;return se(function*(){if(!K(l,wt,"f")||"opened"!==l.state)throw new Error("Camera is not open.");const u=l.getCameraCapabilities();if(!(null==u?void 0:u.torch))throw Error("Not supported.");yield K(l,wt,"f").applyConstraints({advanced:[{torch:!1}]})})()}setColorTemperature(l,u){var g=this;return se(function*(){var p;if("number"!=typeof l)throw new TypeError("Invalid 'value'.");if(!K(g,wt,"f")||"opened"!==g.state)throw new Error("Camera is not open.");const m=null===(p=g.getCameraCapabilities())||void 0===p?void 0:p.colorTemperature;if(!m)throw Error("Not supported.");return u&&(lm.max&&(l=m.max),l=ii(l,m.min,m.step,m.max)),yield K(g,wt,"f").applyConstraints({advanced:[{colorTemperature:l,whiteBalanceMode:"manual"}]}),l})()}getColorTemperature(){return this.getCameraSettings().colorTemperature||0}setExposureCompensation(l,u){var g=this;return se(function*(){var p;if("number"!=typeof l)throw new TypeError("Invalid 'value'.");if(!K(g,wt,"f")||"opened"!==g.state)throw new Error("Camera is not open.");const m=null===(p=g.getCameraCapabilities())||void 0===p?void 0:p.exposureCompensation;if(!m)throw Error("Not supported.");return u&&(lm.max&&(l=m.max),l=ii(l,m.min,m.step,m.max)),yield K(g,wt,"f").applyConstraints({advanced:[{exposureCompensation:l}]}),l})()}getExposureCompensation(){return this.getCameraSettings().exposureCompensation||0}setFrameRate(l,u){var g=this;return se(function*(){var p;if("number"!=typeof l)throw new TypeError("Invalid 'value'.");if(!K(g,wt,"f")||"opened"!==g.state)throw new Error("Camera is not open.");let m=null===(p=g.getCameraCapabilities())||void 0===p?void 0:p.frameRate;if(!m)throw Error("Not supported.");u&&(lm.max&&(l=m.max));const v=g.getResolution();return yield K(g,wt,"f").applyConstraints({width:{ideal:Math.max(v.width,v.height)},frameRate:l}),l})()}getFrameRate(){return this.getCameraSettings().frameRate}setFocus(l,u){var g=this;return se(function*(){if("object"!=typeof l||Array.isArray(l)||null==l)throw new TypeError("Invalid 'settings'.");if(!K(g,wt,"f")||"opened"!==g.state)throw new Error("Camera is not open.");const p=g.getCameraCapabilities(),m=null==p?void 0:p.focusMode,v=null==p?void 0:p.focusDistance;if(!m)throw Error("Not supported.");if("string"!=typeof l.mode)throw TypeError("Invalid 'mode'.");const y=l.mode.toLowerCase();if(!m.includes(y))throw Error("Unsupported focus mode.");if("manual"===y){if(!v)throw Error("Manual focus unsupported.");if(l.hasOwnProperty("distance")){let b=l.distance;u&&(bv.max&&(b=v.max),b=ii(b,v.min,v.step,v.max)),g._focusParameters.focusArea=null,yield K(g,wt,"f").applyConstraints({advanced:[{focusMode:y,focusDistance:b}]})}else{if(!l.area)throw new Error("'distance' or 'area' should be specified in 'manual' mode.");{const b=l.area.centerPoint;let O=l.area.width,L=l.area.height;if(!O||!L){const N=g.getResolution();O||(O=2*Math.round(Math.min(N.width,N.height)/g._focusParameters.defaultFocusAreaSizeRatio/2)+"px"),L||(L=2*Math.round(Math.min(N.width,N.height)/g._focusParameters.defaultFocusAreaSizeRatio/2)+"px")}g._focusParameters.focusArea={centerPoint:{x:b.x,y:b.y},width:O,height:L},yield K(g,Pe,"m",b_).call(g,b,O,L)}}}else g._focusParameters.focusArea=null,yield K(g,wt,"f").applyConstraints({advanced:[{focusMode:y}]})})()}getFocus(){const l=this.getCameraSettings(),u=l.focusMode;return u?"manual"===u?this._focusParameters.focusArea?{mode:"manual",area:JSON.parse(JSON.stringify(this._focusParameters.focusArea))}:{mode:"manual",distance:l.focusDistance}:{mode:u}:null}enableTapToFocus(){var l=this;return se(function*(){mt(l,Na,!0,"f")})()}disableTapToFocus(){mt(this,Na,!1,"f")}isTapToFocusEnabled(){return K(this,Na,"f")}setZoom(l){var u=this;return se(function*(){if("object"!=typeof l||Array.isArray(l)||null==l)throw new TypeError("Invalid 'settings'.");if("number"!=typeof l.factor)throw new TypeError("Illegal type of 'factor'.");if(l.factor<1)throw new RangeError("Invalid 'factor'.");if("opened"!==u.state)throw new Error("Video is not playing.");l.centerPoint?K(u,Pe,"m",D_).call(u,l.centerPoint):u.resetScaleCenter();try{if(K(u,Pe,"m",ZI).call(u,K(u,is,"f"))){const g=yield u.setHardwareScale(l.factor,!0);let p=u.getHardwareScale();1==p&&1!=g&&(p=g),u.setSoftwareScale(l.factor>p?l.factor/p:1)}else yield u.setHardwareScale(1),u.setSoftwareScale(l.factor)}catch(g){const p=g.message||g;if("Not supported."!==p&&"Camera is not open."!==p)throw g;u.setSoftwareScale(l.factor)}})()}getZoom(){if("opened"!==this.state)throw new Error("Video is not playing.");let l=1;try{l=this.getHardwareScale()}catch(u){if("Camera is not open."!==(u.message||u))throw u}return{factor:l*K(this,ns,"f")}}resetZoom(){var l=this;return se(function*(){yield l.setZoom({factor:1})})()}setHardwareScale(l,u){var g=this;return se(function*(){var p;if("number"!=typeof l)throw new TypeError("Invalid 'value'.");if(l<1)throw new RangeError("Invalid 'value'.");if(!K(g,wt,"f")||"opened"!==g.state)throw new Error("Camera is not open.");const m=null===(p=g.getCameraCapabilities())||void 0===p?void 0:p.zoom;if(!m)throw Error("Not supported.");return u&&(lm.max&&(l=m.max),l=ii(l,m.min,m.step,m.max)),yield K(g,wt,"f").applyConstraints({advanced:[{zoom:l}]}),l})()}getHardwareScale(){return this.getCameraSettings().zoom||1}setSoftwareScale(l,u){if("number"!=typeof l)throw new TypeError("Invalid 'value'.");if(l<1)throw new RangeError("Invalid 'value'.");if("opened"!==this.state)throw new Error("Video is not playing.");u&&K(this,Pe,"m",D_).call(this,u),mt(this,ns,l,"f"),this.updateVideoElWhenSoftwareScaled()}getSoftwareScale(){return K(this,ns,"f")}resetScaleCenter(){if("opened"!==this.state)throw new Error("Video is not playing.");const l=this.getResolution();mt(this,is,{x:l.width/2,y:l.height/2},"f")}resetSoftwareScale(){this.setSoftwareScale(1),this.resetScaleCenter()}getFrameData(l){if(this.disposed)throw Error("The 'Camera' instance has been disposed.");if(!this.isVideoLoaded()||K(this,Pa,"f"))return null;const u=Date.now();We._onLog&&We._onLog("getFrameData() START: "+u);const g=K(this,nt,"f").videoWidth,p=K(this,nt,"f").videoHeight;let m={sx:0,sy:0,sWidth:g,sHeight:p,dWidth:g,dHeight:p};(null==l?void 0:l.position)&&(m=JSON.parse(JSON.stringify(l.position)));let v=_t.RGBA;(null==l?void 0:l.pixelFormat)&&(v=l.pixelFormat);let y=K(this,ns,"f");(null==l?void 0:l.scale)&&(y=l.scale);let b=K(this,is,"f");if(null==l?void 0:l.scaleCenter){if("string"!=typeof l.scaleCenter.x||"string"!=typeof l.scaleCenter.y)throw new Error("Invalid scale center.");let B=0,U=0;if(l.scaleCenter.x.endsWith("px"))B=parseFloat(l.scaleCenter.x);else{if(!l.scaleCenter.x.endsWith("%"))throw new Error("Invalid scale center.");B=parseFloat(l.scaleCenter.x)/100*g}if(l.scaleCenter.y.endsWith("px"))U=parseFloat(l.scaleCenter.y);else{if(!l.scaleCenter.y.endsWith("%"))throw new Error("Invalid scale center.");U=parseFloat(l.scaleCenter.y)/100*p}if(isNaN(B)||isNaN(U))throw new Error("Invalid scale center.");b.x=Math.round(B),b.y=Math.round(U)}let O=null;if((null==l?void 0:l.bufferContainer)&&(O=l.bufferContainer),0==g||0==p)return null;1!==y&&(m.sWidth=Math.round(m.sWidth/y),m.sHeight=Math.round(m.sHeight/y),m.sx=Math.round((1-1/y)*b.x+m.sx/y),m.sy=Math.round((1-1/y)*b.y+m.sy/y));const L=this.imageDataGetter.getImageData(K(this,nt,"f"),g,p,m,{pixelFormat:v,bufferContainer:O});if(!L)return null;const N=Date.now();return We._onLog&&We._onLog("getFrameData() END: "+N),{data:L.data,width:L.width,height:L.height,pixelFormat:L.pixelFormat,timeSpent:N-u,timeStamp:N,toCanvas:K(this,y_,"f")}}on(l,u){if(!K(this,C_,"f").includes(l.toLowerCase()))throw new Error(`Event '${l}' does not exist.`);K(this,_n,"f").on(l,u)}off(l,u){K(this,_n,"f").off(l,u)}dispose(){var l=this;return se(function*(){l.tapFocusEventBoundEl=null,yield l.close(),l.releaseVideoEl(),K(l,_n,"f").dispose(),l.imageDataGetter.dispose(),document.removeEventListener("visibilitychange",K(l,Cd,"f")),mt(l,wd,!0,"f")})()}}var Pc,bd,Ua,wo,Dd,ja,KI,QI,vt,S_,I_,Fe,ke,Nc,rs,Eo,Sd,Id,Td,kc,bo,xd,ss,yi,qt,Ne,Tr,T_,Lt,JI,eT,x_,A_;nt=new WeakMap,wt=new WeakMap,md=new WeakMap,_d=new WeakMap,Mt=new WeakMap,Ni=new WeakMap,es=new WeakMap,Fa=new WeakMap,vd=new WeakMap,Ir=new WeakMap,ts=new WeakMap,_i=new WeakMap,Pa=new WeakMap,Na=new WeakMap,Lc=new WeakMap,yd=new WeakMap,ka=new WeakMap,yo=new WeakMap,ns=new WeakMap,is=new WeakMap,y_=new WeakMap,_n=new WeakMap,C_=new WeakMap,Co=new WeakMap,XI=new WeakMap,Cd=new WeakMap,wd=new WeakMap,Pe=new WeakSet,qI=function(){var f=se(function*(){var l=this;const u=this.getMediaStreamConstraints();if("boolean"==typeof u.video&&(u.video={}),!u.video.deviceId)if(K(this,es,"f"))delete u.video.facingMode,u.video.deviceId={exact:K(this,es,"f")};else if(this.ifSaveLastUsedCamera&&We.isStorageAvailable&&window.localStorage.getItem("dce_last_camera_id")){delete u.video.facingMode,u.video.deviceId={ideal:window.localStorage.getItem("dce_last_camera_id")};const g=JSON.parse(window.localStorage.getItem("dce_last_apply_width")),p=JSON.parse(window.localStorage.getItem("dce_last_apply_height"));g&&p&&(u.video.width=g,u.video.height=p)}else if(!this.ifSkipCameraInspection){const g=function(){var v=se(function*(y){let b=null;return"environment"===y&&["Android","HarmonyOS","iPhone","iPad"].includes(jn.OS)?(yield l._getCameras(!1),K(l,Pe,"m",ir).call(l),b=We.findBestCamera(l._arrCameras,"environment",{getMainCameraInIOS:l.selectIOSRearMainCameraAsDefault})):y||["Android","HarmonyOS","iPhone","iPad"].includes(jn.OS)||(yield l._getCameras(!1),K(l,Pe,"m",ir).call(l),b=We.findBestCamera(l._arrCameras,null,{getMainCameraInIOS:l.selectIOSRearMainCameraAsDefault})),b});return function(b){return v.apply(this,arguments)}}();let p=u.video.facingMode;p instanceof Array&&p.length&&(p=p[0]),"object"==typeof p&&(p=p.exact||p.ideal);const m=yield g(p);m&&(delete u.video.facingMode,u.video.deviceId={exact:m})}return u});return function(){return f.apply(this,arguments)}}(),ir=function(){if(K(this,Ir,"f")){const f=new Error("The operation was interrupted.");throw f.name="AbortError",f}},w_=function(){var f=se(function*(l){var g,p,u=this;if(!(null===(p=null===(g=null==window?void 0:window.navigator)||void 0===g?void 0:g.mediaDevices)||void 0===p?void 0:p.getUserMedia))throw new Error("Failed to access the camera because the browser is too old or the page is loaded from an insecure origin.");let m;try{We._onLog&&We._onLog("======try getUserMedia========");let v=[0,500,1e3,2e3],y=null;const b=function(){var O=se(function*(L){for(let N of v){N&&(yield new Promise(B=>setTimeout(B,N)),K(u,Pe,"m",ir).call(u));try{We._onLog&&We._onLog("ask "+JSON.stringify(L)),m=yield navigator.mediaDevices.getUserMedia(L),K(u,Pe,"m",ir).call(u);break}catch(B){if("NotFoundError"===B.name||"NotAllowedError"===B.name||"AbortError"===B.name||"OverconstrainedError"===B.name)throw B;y=B,We._onLog&&We._onLog(B.message||B)}}});return function(N){return O.apply(this,arguments)}}();if(yield b(l),m||"object"!=typeof l.video||(l.video.deviceId&&(delete l.video.deviceId,yield b(l)),!m&&l.video.facingMode&&(delete l.video.facingMode,yield b(l)),m||!l.video.width&&!l.video.height||(delete l.video.width,delete l.video.height,yield b(l))),!m)throw y;return m}catch(v){throw null==m||m.getTracks().forEach(y=>{y.stop()}),"NotFoundError"===v.name&&(DOMException?v=new DOMException("No camera available, please use a device with an accessible camera.",v.name):(v=new Error("No camera available, please use a device with an accessible camera.")).name="NotFoundError"),v}});return function(u){return f.apply(this,arguments)}}(),E_=function(){this._mediaStream&&(this._mediaStream.getTracks().forEach(f=>{f.stop()}),this._mediaStream=null),mt(this,wt,null,"f")},Ba=function(){var f=se(function*(){var l=this;mt(this,Ir,!1,"f");const u=mt(this,vd,Symbol(),"f");if(K(this,ts,"f")&&"pending"===K(this,_i,"f")){try{yield K(this,ts,"f")}catch(p){}K(this,Pe,"m",ir).call(this)}return u!==K(this,vd,"f")?void 0:mt(this,ts,se(function*(){mt(l,_i,"pending","f");try{if(l.videoSrc){if(!K(l,nt,"f"))throw new Error("'videoEl' should be set.");yield We.playVideo(K(l,nt,"f"),l.videoSrc,l.cameraOpenTimeout),K(l,Pe,"m",ir).call(l)}else{let p=yield K(l,Pe,"m",qI).call(l);K(l,Pe,"m",E_).call(l);let m=yield K(l,Pe,"m",w_).call(l,p);yield l._getCameras(!1),K(l,Pe,"m",ir).call(l);const v=()=>{const L=m.getVideoTracks();let N,B;if(L.length&&(N=L[0]),N){const U=N.getSettings();if(U)for(let W of l._arrCameras)if(U.deviceId===W.deviceId){W._checked=!0,W.label=N.label,B=W;break}}return B},y=K(l,Mt,"f");if("object"==typeof y.video){let L=y.video.facingMode;if(L instanceof Array&&L.length&&(L=L[0]),"object"==typeof L&&(L=L.exact||L.ideal),!(K(l,es,"f")||l.ifSaveLastUsedCamera&&We.isStorageAvailable&&window.localStorage.getItem("dce_last_camera_id")||l.ifSkipCameraInspection||y.video.deviceId)){const N=v(),B=We.findBestCamera(l._arrCameras,L,{getMainCameraInIOS:l.selectIOSRearMainCameraAsDefault});B&&B!=(null==N?void 0:N.deviceId)&&(m.getTracks().forEach(U=>{U.stop()}),p.video.deviceId={exact:B},m=yield K(l,Pe,"m",w_).call(l,p),K(l,Pe,"m",ir).call(l))}}const b=v();(null==b?void 0:b.deviceId)&&(mt(l,es,b&&b.deviceId,"f"),l.ifSaveLastUsedCamera&&We.isStorageAvailable&&(window.localStorage.setItem("dce_last_camera_id",K(l,es,"f")),"object"==typeof p.video&&p.video.width&&p.video.height&&(window.localStorage.setItem("dce_last_apply_width",JSON.stringify(p.video.width)),window.localStorage.setItem("dce_last_apply_height",JSON.stringify(p.video.height))))),K(l,nt,"f")&&(yield We.playVideo(K(l,nt,"f"),m,l.cameraOpenTimeout),K(l,Pe,"m",ir).call(l)),l._mediaStream=m;const O=m.getVideoTracks();(null==O?void 0:O.length)&&mt(l,wt,O[0],"f"),mt(l,Ni,b,"f")}}catch(p){throw K(l,Pe,"m",Ed).call(l),mt(l,_i,null,"f"),p}mt(l,_i,"fulfilled","f")})(),"f")});return function(){return f.apply(this,arguments)}}(),Fc=function(){var f=se(function*(){var l;if("closed"===this.state||this.videoSrc)return;const u=null===(l=K(this,Ni,"f"))||void 0===l?void 0:l.deviceId,g=this.getResolution();yield K(this,Pe,"m",Ba).call(this);const p=this.getResolution();u&&u!==K(this,Ni,"f").deviceId&&K(this,_n,"f").fire("camera:changed",[K(this,Ni,"f").deviceId,u],{target:this,async:!1}),g.width==p.width&&g.height==p.height||K(this,_n,"f").fire("resolution:changed",[{width:p.width,height:p.height},{width:g.width,height:g.height}],{target:this,async:!1}),K(this,_n,"f").fire("played",null,{target:this,async:!1})});return function(){return f.apply(this,arguments)}}(),Ed=function(){K(this,Pe,"m",E_).call(this),mt(this,Ni,null,"f"),K(this,nt,"f")&&(K(this,nt,"f").srcObject=null,this.videoSrc&&(K(this,nt,"f").pause(),K(this,nt,"f").currentTime=0)),mt(this,Ir,!0,"f");try{this.resetSoftwareScale()}catch(f){}},vi=function(){var f=se(function*(u,g){const p=$=>{if(!K(this,wt,"f")||!this.isVideoPlaying||$.focusTaskId!=this._focusParameters.curFocusTaskId){K(this,wt,"f")&&this.isVideoPlaying||(this._focusParameters.isDoingFocus=0);const q=new Error(`Focus task ${$.focusTaskId} canceled.`);throw q.name="DeprecatedTaskError",q}1===this._focusParameters.isDoingFocus&&Date.now()-$.timeStart>this._focusParameters.focusCancelableTime&&(this._focusParameters.isDoingFocus=-1)};let m;g=ii(g,this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),yield K(this,wt,"f").applyConstraints({advanced:[{focusMode:"manual",focusDistance:g}]}),p(u),m=null==this._focusParameters.oldDistance?this._focusParameters.kTimeout*Math.max(Math.abs(1/this._focusParameters.fds.min-1/g),Math.abs(1/this._focusParameters.fds.max-1/g))+this._focusParameters.minTimeout:this._focusParameters.kTimeout*Math.abs(1/this._focusParameters.oldDistance-1/g)+this._focusParameters.minTimeout,this._focusParameters.oldDistance=g,yield new Promise($=>{setTimeout($,m)}),p(u);let v=u.focusL-u.focusW/2,y=u.focusT-u.focusH/2,b=u.focusW,O=u.focusH;const L=this.getResolution();if(v>=L.width||y>=L.height)throw new Error("Invalid area.");v+b>L.width&&(b=L.width-v),y+O>L.height&&(O=L.height-y),v=Math.round(v),y=Math.round(y),b=Math.round(b),O=Math.round(O);const N=4*L.width*L.height*this._focusParameters.defaultTempBufferContainerLenRatio,B=4*b*O;let U=this._focusParameters.tempBufferContainer;if(U){const $=U.length;N>$&&N>=B?U=new Uint8Array(N):B>$&&B>=N&&(U=new Uint8Array(B))}else U=this._focusParameters.tempBufferContainer=new Uint8Array(Math.max(N,B));if(!this.imageDataGetter.getImageData(K(this,nt,"f"),L.width,L.height,{sx:v,sy:y,sWidth:b,sHeight:O,dWidth:b,dHeight:O},{pixelFormat:_t.RGBA,bufferContainer:U}))return K(this,Pe,"m",l).call(this,u,g);const W=U;let Y=0;for(let $=0,q=B-8;$b&&bU)return yield K(this,Pe,"m",l).call(this,u,y,b,m,v,N,U)}else{let B=yield K(this,Pe,"m",vi).call(this,u,N);if(b>B)return yield K(this,Pe,"m",l).call(this,u,y,b,m,v,N,B);if(b==B)return yield K(this,Pe,"m",l).call(this,u,y,b,N,B);let U=yield K(this,Pe,"m",vi).call(this,u,L);if(U>b&&bb.width||L<0||L>b.height)throw new Error("Invalid 'centerPoint'.");let N=0;if(u.endsWith("px"))N=parseFloat(u);else{if(!u.endsWith("%"))throw new Error("Invalid 'width'.");N=parseFloat(u)/100*b.width}if(isNaN(N)||N<0)throw new Error("Invalid 'width'.");let B=0;if(g.endsWith("px"))B=parseFloat(g);else{if(!g.endsWith("%"))throw new Error("Invalid 'height'.");B=parseFloat(g)/100*b.height}if(isNaN(B)||B<0)throw new Error("Invalid 'height'.");if(1!==K(this,ns,"f")){const Y=K(this,ns,"f"),$=K(this,is,"f");N/=Y,B/=Y,O=(1-1/Y)*$.x+O/Y,L=(1-1/Y)*$.y+L/Y}if(!this._focusSupported)throw new Error("Manual focus unsupported.");if(!this._focusParameters.fds&&(this._focusParameters.fds=null===(y=this.getCameraCapabilities())||void 0===y?void 0:y.focusDistance,!this._focusParameters.fds))throw this._focusSupported=!1,new Error("Manual focus unsupported.");null==this._focusParameters.kTimeout&&(this._focusParameters.kTimeout=(this._focusParameters.maxTimeout-this._focusParameters.minTimeout)/(1/this._focusParameters.fds.min-1/this._focusParameters.fds.max)),this._focusParameters.isDoingFocus=1;const U={focusL:O,focusT:L,focusW:N,focusH:B,focusTaskId:++this._focusParameters.curFocusTaskId,timeStart:Date.now()},W=function(){var Y=se(function*($,q,X){try{(null==q||qv._focusParameters.fds.max)&&(X=v._focusParameters.fds.max),v._focusParameters.oldDistance=null;let Q=ii(Math.sqrt(X*(q||v._focusParameters.fds.step)),v._focusParameters.fds.min,v._focusParameters.fds.step,v._focusParameters.fds.max),pe=ii(Math.sqrt((q||v._focusParameters.fds.step)*Q),v._focusParameters.fds.min,v._focusParameters.fds.step,v._focusParameters.fds.max),ve=ii(Math.sqrt(Q*X),v._focusParameters.fds.min,v._focusParameters.fds.step,v._focusParameters.fds.max),Te=yield K(v,Pe,"m",vi).call(v,$,ve),Ae=yield K(v,Pe,"m",vi).call(v,$,pe),P=yield K(v,Pe,"m",vi).call(v,$,Q);if(Ae>P&&PTe&&Ae>Te){let Ee=yield K(v,Pe,"m",vi).call(v,$,X);const Be=yield K(v,Pe,"m",Va).call(v,$,Q,P,X,Ee,ve,Te);return v._focusParameters.isDoingFocus=0,Be}if(Ae==P&&PP){const Ee=yield K(v,Pe,"m",Va).call(v,$,Q,P,ve,Te);return v._focusParameters.isDoingFocus=0,Ee}return W($,q,X)}catch(Q){if("DeprecatedTaskError"!==Q.name)throw Q}});return function(q,X,Q){return Y.apply(this,arguments)}}();return W(U,p,m)});return function(u,g,p,m,v){return f.apply(this,arguments)}}(),D_=function(f){if("opened"!==this.state)throw new Error("Video is not playing.");if(!f||"string"!=typeof f.x||"string"!=typeof f.y)throw new Error("Invalid 'center'.");const l=this.getResolution();let u=0,g=0;if(f.x.endsWith("px"))u=parseFloat(f.x);else{if(!f.x.endsWith("%"))throw new Error("Invalid scale center.");u=parseFloat(f.x)/100*l.width}if(f.y.endsWith("px"))g=parseFloat(f.y);else{if(!f.y.endsWith("%"))throw new Error("Invalid scale center.");g=parseFloat(f.y)/100*l.height}if(isNaN(u)||isNaN(g))throw new Error("Invalid scale center.");mt(this,is,{x:u,y:g},"f")},ZI=function(f){if("opened"!==this.state)throw new Error("Video is not playing.");const l=this.getResolution();return f&&f.x==l.width/2&&f.y==l.height/2},We.browserInfo=jn,We.onWarning=null===(v_=null==window?void 0:window.console)||void 0===v_?void 0:v_.warn;class os{constructor(l){Pc.add(this),bd.set(this,void 0),Ua.set(this,0),wo.set(this,void 0),Dd.set(this,0),ja.set(this,!1),Le(this,bd,l,"f")}startCharging(){j(this,ja,"f")||(os._onLog&&os._onLog("start charging."),j(this,Pc,"m",QI).call(this),Le(this,ja,!0,"f"))}stopCharging(){j(this,wo,"f")&&clearTimeout(j(this,wo,"f")),j(this,ja,"f")&&(os._onLog&&os._onLog("stop charging."),Le(this,Ua,Date.now()-j(this,Dd,"f"),"f"),Le(this,ja,!1,"f"))}}bd=new WeakMap,Ua=new WeakMap,wo=new WeakMap,Dd=new WeakMap,ja=new WeakMap,Pc=new WeakSet,KI=function(){sn.cfd(1),os._onLog&&os._onLog("charge 1.")},QI=function f(){0==j(this,Ua,"f")&&j(this,Pc,"m",KI).call(this),Le(this,Dd,Date.now(),"f"),j(this,wo,"f")&&clearTimeout(j(this,wo,"f")),Le(this,wo,setTimeout(()=>{Le(this,Ua,0,"f"),j(this,Pc,"m",f).call(this)},j(this,bd,"f")-j(this,Ua,"f")),"f")};const tT=new Map([[Ue.IPF_GRAYSCALED,_t.GREY],[Ue.IPF_ABGR_8888,_t.RGBA],[Ue.IPF_ARGB_8888,_t.BGRA]]),nT=new Map([[_t.GREY,Ue.IPF_GRAYSCALED],[_t.RGBA,Ue.IPF_ABGR_8888],[_t.BGRA,Ue.IPF_ARGB_8888]]),R_="function"==typeof BigInt?{BF_NULL:BigInt(0),BF_ALL:BigInt(0x10000000000000000),BF_DEFAULT:BigInt(4265345023),BF_ONED:BigInt(3147775),BF_GS1_DATABAR:BigInt(260096),BF_CODE_39:BigInt(1),BF_CODE_128:BigInt(2),BF_CODE_93:BigInt(4),BF_CODABAR:BigInt(8),BF_ITF:BigInt(16),BF_EAN_13:BigInt(32),BF_EAN_8:BigInt(64),BF_UPC_A:BigInt(128),BF_UPC_E:BigInt(256),BF_INDUSTRIAL_25:BigInt(512),BF_CODE_39_EXTENDED:BigInt(1024),BF_GS1_DATABAR_OMNIDIRECTIONAL:BigInt(2048),BF_GS1_DATABAR_TRUNCATED:BigInt(4096),BF_GS1_DATABAR_STACKED:BigInt(8192),BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL:BigInt(16384),BF_GS1_DATABAR_EXPANDED:BigInt(32768),BF_GS1_DATABAR_EXPANDED_STACKED:BigInt(65536),BF_GS1_DATABAR_LIMITED:BigInt(131072),BF_PATCHCODE:BigInt(262144),BF_CODE_32:BigInt(16777216),BF_PDF417:BigInt(33554432),BF_QR_CODE:BigInt(67108864),BF_DATAMATRIX:BigInt(134217728),BF_AZTEC:BigInt(268435456),BF_MAXICODE:BigInt(536870912),BF_MICRO_QR:BigInt(1073741824),BF_MICRO_PDF417:BigInt(524288),BF_GS1_COMPOSITE:BigInt(2147483648),BF_MSI_CODE:BigInt(1048576),BF_CODE_11:BigInt(2097152),BF_TWO_DIGIT_ADD_ON:BigInt(4194304),BF_FIVE_DIGIT_ADD_ON:BigInt(8388608),BF_MATRIX_25:BigInt(68719476736),BF_POSTALCODE:BigInt(0x3f0000000000000),BF_NONSTANDARD_BARCODE:BigInt(4294967296),BF_USPSINTELLIGENTMAIL:BigInt(4503599627370496),BF_POSTNET:BigInt(9007199254740992),BF_PLANET:BigInt(0x40000000000000),BF_AUSTRALIANPOST:BigInt(0x80000000000000),BF_RM4SCC:BigInt(72057594037927940),BF_KIX:BigInt(0x200000000000000),BF_DOTCODE:BigInt(8589934592),BF_PHARMACODE_ONE_TRACK:BigInt(17179869184),BF_PHARMACODE_TWO_TRACK:BigInt(34359738368),BF_PHARMACODE:BigInt(51539607552)}:{BF_NULL:"0x00",BF_ALL:"0xFFFFFFFFFFFFFFFF",BF_DEFAULT:"0xFE3BFFFF",BF_ONED:"0x003007FF",BF_GS1_DATABAR:"0x0003F800",BF_CODE_39:"0x1",BF_CODE_128:"0x2",BF_CODE_93:"0x4",BF_CODABAR:"0x8",BF_ITF:"0x10",BF_EAN_13:"0x20",BF_EAN_8:"0x40",BF_UPC_A:"0x80",BF_UPC_E:"0x100",BF_INDUSTRIAL_25:"0x200",BF_CODE_39_EXTENDED:"0x400",BF_GS1_DATABAR_OMNIDIRECTIONAL:"0x800",BF_GS1_DATABAR_TRUNCATED:"0x1000",BF_GS1_DATABAR_STACKED:"0x2000",BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL:"0x4000",BF_GS1_DATABAR_EXPANDED:"0x8000",BF_GS1_DATABAR_EXPANDED_STACKED:"0x10000",BF_GS1_DATABAR_LIMITED:"0x20000",BF_PATCHCODE:"0x00040000",BF_CODE_32:"0x01000000",BF_PDF417:"0x02000000",BF_QR_CODE:"0x04000000",BF_DATAMATRIX:"0x08000000",BF_AZTEC:"0x10000000",BF_MAXICODE:"0x20000000",BF_MICRO_QR:"0x40000000",BF_MICRO_PDF417:"0x00080000",BF_GS1_COMPOSITE:"0x80000000",BF_MSI_CODE:"0x100000",BF_CODE_11:"0x200000",BF_TWO_DIGIT_ADD_ON:"0x400000",BF_FIVE_DIGIT_ADD_ON:"0x800000",BF_MATRIX_25:"0x1000000000",BF_POSTALCODE:"0x3F0000000000000",BF_NONSTANDARD_BARCODE:"0x100000000",BF_USPSINTELLIGENTMAIL:"0x10000000000000",BF_POSTNET:"0x20000000000000",BF_PLANET:"0x40000000000000",BF_AUSTRALIANPOST:"0x80000000000000",BF_RM4SCC:"0x100000000000000",BF_KIX:"0x200000000000000",BF_DOTCODE:"0x200000000",BF_PHARMACODE_ONE_TRACK:"0x400000000",BF_PHARMACODE_TWO_TRACK:"0x800000000",BF_PHARMACODE:"0xC00000000"};class it extends Fi{static set _onLog(l){Le(it,S_,l,"f",I_),We._onLog=l,os._onLog=l}static get _onLog(){return j(it,S_,"f",I_)}static detectEnvironment(){return se(function*(){return yield se(function*(){return{wasm:wU,worker:EU,getUserMedia:RI,camera:yield bU(),browser:Ln.browser,version:Ln.version,OS:Ln.OS}})()})()}static testCameraAccess(){return se(function*(){const l=yield We.testCameraAccess();return l.ok?{ok:!0,message:"Successfully accessed the camera."}:"InsecureContext"===l.errorName?{ok:!1,message:"Insecure context."}:"OverconstrainedError"===l.errorName||"NotFoundError"===l.errorName?{ok:!1,message:"No camera detected."}:"NotAllowedError"===l.errorName?{ok:!1,message:"No permission to access camera."}:"AbortError"===l.errorName?{ok:!1,message:"Some problem occurred which prevented the device from being used."}:"NotReadableError"===l.errorName?{ok:!1,message:"A hardware error occurred."}:"SecurityError"===l.errorName?{ok:!1,message:"User media support is disabled."}:{ok:!1,message:l.errorMessage}})()}static createInstance(l){return se(function*(){var u,g;if(l&&!(l instanceof on))throw new TypeError("Invalid view.");if(null===(u=pn.license)||void 0===u?void 0:u.LicenseManager){if(!(null===(g=pn.license)||void 0===g?void 0:g.LicenseManager.bCallInitLicense))throw new Error("License is not set.");yield sn.loadWasm(["license"]),yield pn.license.dynamsoft()}const p=new it(l);return it.onWarning&&(location&&"file:"===location.protocol?setTimeout(()=>{it.onWarning&&it.onWarning({id:1,message:"The page is opened over file:// and Dynamsoft Camera Enhancer may not work properly. Please open the page via https://."})},0):!1!==window.isSecureContext&&navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia||setTimeout(()=>{it.onWarning&&it.onWarning({id:2,message:"Dynamsoft Camera Enhancer may not work properly in a non-secure context. Please open the page via https://."})},0)),p})()}get video(){return j(this,Fe,"f").getVideoEl()}set videoSrc(l){if(!j(this,Fe,"f"))throw new Error("Camera manager is null.");j(this,ke,"f")&&(j(this,ke,"f")._hideDefaultSelection=!0),j(this,Fe,"f").videoSrc=l}get videoSrc(){var l;return null===(l=j(this,Fe,"f"))||void 0===l?void 0:l.videoSrc}set ifSaveLastUsedCamera(l){if(!j(this,Fe,"f"))throw new Error("Camera manager is null.");j(this,Fe,"f").ifSaveLastUsedCamera=l}get ifSaveLastUsedCamera(){var l;return null===(l=j(this,Fe,"f"))||void 0===l?void 0:l.ifSaveLastUsedCamera}set ifSkipCameraInspection(l){if(!j(this,Fe,"f"))throw new Error("Camera manager is null.");j(this,Fe,"f").ifSkipCameraInspection=l}get ifSkipCameraInspection(){var l;return null===(l=j(this,Fe,"f"))||void 0===l?void 0:l.ifSkipCameraInspection}set cameraOpenTimeout(l){if(!j(this,Fe,"f"))throw new Error("Camera manager is null.");j(this,Fe,"f").cameraOpenTimeout=l}get cameraOpenTimeout(){var l;return null===(l=j(this,Fe,"f"))||void 0===l?void 0:l.cameraOpenTimeout}set singleFrameMode(l){if(!["disabled","image","camera"].includes(l))throw new Error("Invalid value.");if(this.isOpen())throw new Error("It is not allowed to change `singleFrameMode` when the camera is open.");Le(this,Sd,l,"f")}get singleFrameMode(){return j(this,Sd,"f")}get _isFetchingStarted(){return j(this,ss,"f")}get disposed(){return j(this,T_,"f")}constructor(l){var u;if(super(),u=this,vt.add(this),Fe.set(this,void 0),ke.set(this,void 0),Nc.set(this,"closed"),rs.set(this,void 0),Eo.set(this,!1),Sd.set(this,void 0),this._onCameraSelChange=se(function*(){u.isOpen()&&j(u,ke,"f")&&!j(u,ke,"f").disposed&&(yield u.selectCamera(j(u,ke,"f")._selCam.value))}),this._onResolutionSelChange=se(function*(){if(!u.isOpen()||!j(u,ke,"f")||j(u,ke,"f").disposed)return;let g,p;if(j(u,ke,"f")._selRsl&&-1!=j(u,ke,"f")._selRsl.selectedIndex){let m=j(u,ke,"f")._selRsl.options[j(u,ke,"f")._selRsl.selectedIndex];g=parseInt(m.getAttribute("data-width")),p=parseInt(m.getAttribute("data-height"))}yield u.setResolution({width:g,height:p})}),this._onCloseBtnClick=se(function*(){u.isOpen()&&j(u,ke,"f")&&!j(u,ke,"f").disposed&&u.close()}),Id.set(this,(g,p,m,v)=>{const y=Date.now(),b={sx:v.x,sy:v.y,sWidth:v.width,sHeight:v.height,dWidth:v.width,dHeight:v.height},O=Math.max(b.dWidth,b.dHeight);if(this.canvasSizeLimit&&O>this.canvasSizeLimit){const B=this.canvasSizeLimit/O;b.dWidth>b.dHeight?(b.dWidth=this.canvasSizeLimit,b.dHeight=Math.round(b.dHeight*B)):(b.dWidth=Math.round(b.dWidth*B),b.dHeight=this.canvasSizeLimit)}const L=j(this,Fe,"f").imageDataGetter.getImageData(g,p,m,b,{pixelFormat:tT.get(this.getPixelFormat())});let N=null;if(L){const B=Date.now();let U;U=L.pixelFormat===_t.GREY?L.width:4*L.width;let W=!0;0===b.sx&&0===b.sy&&b.sWidth===p&&b.sHeight===m&&(W=!1),N={bytes:L.data,width:L.width,height:L.height,stride:U,format:nT.get(L.pixelFormat),tag:{imageId:this._imageId==Number.MAX_VALUE?this._imageId=0:++this._imageId,type:qh.ITT_FILE_IMAGE,isCropped:W,cropRegion:{left:v.x,top:v.y,right:v.x+v.width,bottom:v.y+v.height,isMeasuredInPercentage:!1},originalWidth:p,originalHeight:m,currentWidth:L.width,currentHeight:L.height,timeSpent:B-y,timeStamp:B},toCanvas:j(this,Td,"f"),isDCEFrame:!0}}return N}),this._onSingleFrameAcquired=g=>{let p;p=j(this,ke,"f")?j(this,ke,"f").getConvertedRegion():id.convert(j(this,bo,"f"),g.width,g.height),p||(p={x:0,y:0,width:g.width,height:g.height});const m=j(this,Id,"f").call(this,g,g.width,g.height,p);j(this,rs,"f").fire("singleFrameAcquired",[m],{async:!1,copy:!1})},Td.set(this,function(){if(!(this.bytes instanceof Uint8Array||this.bytes instanceof Uint8ClampedArray))throw new TypeError("Invalid bytes.");if("number"!=typeof this.width||this.width<=0)throw new Error("Invalid width.");if("number"!=typeof this.height||this.height<=0)throw new Error("Invalid height.");const g=document.createElement("canvas");let p;if(g.width=this.width,g.height=this.height,this.format===Ue.IPF_GRAYSCALED){p=new Uint8ClampedArray(this.width*this.height*4);for(let m=0;m{if(!this.video)return;const g=j(this,Fe,"f").getSoftwareScale();if(g<1)throw new RangeError("Invalid scale value.");j(this,ke,"f")&&!j(this,ke,"f").disposed?(this.video.style.transform=1===g?"":`scale(${g})`,j(this,ke,"f")._updateVideoContainer()):this.video.style.transform=1===g?"":`scale(${g})`},["iPhone","iPad","Android","HarmonyOS"].includes(Ln.OS)?j(this,Fe,"f").setResolution(1280,720):j(this,Fe,"f").setResolution(1920,1080),this.singleFrameMode=navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia?"disabled":"image",l&&this.setCameraView(l),this._on("before:camera:change",()=>{j(this,Tr,"f").stopCharging();const g=j(this,ke,"f");g&&!g.disposed&&(g._startLoading(),g.clearAllInnerDrawingItems())}),this._on("camera:changed",()=>{this.clearBuffer()}),this._on("before:resolution:change",()=>{const g=j(this,ke,"f");g&&!g.disposed&&(g._startLoading(),g.clearAllInnerDrawingItems())}),this._on("resolution:changed",()=>{this.clearBuffer(),l.eventHandler.fire("content:updated",null,{async:!1})}),this._on("paused",()=>{j(this,Tr,"f").stopCharging(),j(this,ke,"f")}),this._on("resumed",()=>{j(this,ke,"f")}),this._on("tapfocus",()=>{j(this,qt,"f").tapToFocus&&j(this,Tr,"f").startCharging()}),this._intermediateResultReceiver={},this._intermediateResultReceiver.onTaskResultsReceived=function(){var g=se(function*(p,m){var v,y,b,O;if(j(u,vt,"m",Lt).call(u)||!u.isOpen()||u.isPaused())return;const L=p.intermediateResultUnits;it._onLog&&(it._onLog("intermediateResultUnits:"),it._onLog(L));let N=!1,B=!1;for(let U of L){if(U.unitType===ba.IRUT_DECODED_BARCODES&&U.decodedBarcodes.length){N=!0;break}U.unitType===ba.IRUT_LOCALIZED_BARCODES&&U.localizedBarcodes.length&&(B=!0)}if(it._onLog&&(it._onLog("hasLocalizedBarcodes:"),it._onLog(B)),j(u,qt,"f").autoZoom||j(u,qt,"f").enhancedFocus)if(N)j(u,Ne,"f").autoZoomInFrameArray.length=0,j(u,Ne,"f").autoZoomOutFrameCount=0,j(u,Ne,"f").frameArrayInIdealZoom.length=0,j(u,Ne,"f").autoFocusFrameArray.length=0;else{const U=function(){var Y=se(function*($){yield u.setZoom($),j(u,qt,"f").autoZoom&&j(u,Tr,"f").startCharging()});return function(q){return Y.apply(this,arguments)}}(),W=function(){var Y=se(function*($){yield u.setFocus($),j(u,qt,"f").enhancedFocus&&j(u,Tr,"f").startCharging()});return function(q){return Y.apply(this,arguments)}}();if(B){const Y=L[0].originalImageTag,$=(null===(v=Y.cropRegion)||void 0===v?void 0:v.left)||0,q=(null===(y=Y.cropRegion)||void 0===y?void 0:y.top)||0,X=(null===(b=Y.cropRegion)||void 0===b?void 0:b.right)?Y.cropRegion.right-$:Y.originalWidth,Q=(null===(O=Y.cropRegion)||void 0===O?void 0:O.bottom)?Y.cropRegion.bottom-q:Y.originalHeight,pe=Y.currentWidth,ve=Y.currentHeight;let Te;{let Ae,P,Ee,Be,et;{const D=u.video.videoWidth*(1-j(u,Ne,"f").autoZoomDetectionArea)/2,T=u.video.videoWidth*(1+j(u,Ne,"f").autoZoomDetectionArea)/2,_=T,C=D,I=u.video.videoHeight*(1-j(u,Ne,"f").autoZoomDetectionArea)/2,M=I,x=u.video.videoHeight*(1+j(u,Ne,"f").autoZoomDetectionArea)/2;et=[{x:D,y:I},{x:T,y:M},{x:_,y:x},{x:C,y:x}]}it._onLog&&(it._onLog("detectionArea:"),it._onLog(et));const S=[];{const D=(T,_)=>{const C=(M,x)=>{if(!M&&!x)throw new Error("Invalid arguments.");return function(A,F,k){let V=!1;const H=A.length;if(H<=2)return!1;for(let G=0;G0!=o_(Z.y-k)>0&&o_(F-(k-z.y)*(z.x-Z.x)/(z.y-Z.y)-z.x)<0&&(V=!V)}return V}(x,M.x,M.y)},I=(M,x)=>!!(sd([M[0],M[1]],[M[2],M[3]],[x[0].x,x[0].y],[x[1].x,x[1].y])||sd([M[0],M[1]],[M[2],M[3]],[x[1].x,x[1].y],[x[2].x,x[2].y])||sd([M[0],M[1]],[M[2],M[3]],[x[2].x,x[2].y],[x[3].x,x[3].y])||sd([M[0],M[1]],[M[2],M[3]],[x[3].x,x[3].y],[x[0].x,x[0].y]));return!!(C({x:T[0].x,y:T[0].y},_)||C({x:T[1].x,y:T[1].y},_)||C({x:T[2].x,y:T[2].y},_)||C({x:T[3].x,y:T[3].y},_))||!!(C({x:_[0].x,y:_[0].y},T)||C({x:_[1].x,y:_[1].y},T)||C({x:_[2].x,y:_[2].y},T)||C({x:_[3].x,y:_[3].y},T))||!!(I([_[0].x,_[0].y,_[1].x,_[1].y],T)||I([_[1].x,_[1].y,_[2].x,_[2].y],T)||I([_[2].x,_[2].y,_[3].x,_[3].y],T)||I([_[3].x,_[3].y,_[0].x,_[0].y],T))};for(let T of L)if(T.unitType===ba.IRUT_LOCALIZED_BARCODES)for(let _ of T.localizedBarcodes){if(!_)continue;const C=_.location.points;C.forEach(I=>{on._transformCoordinates(I,$,q,X,Q,pe,ve)}),D(et,C)&&S.push(_)}if(it._debug&&j(u,ke,"f")){const T=u.__layer||(u.__layer=j(u,ke,"f")._createDrawingLayer(99));T.clearDrawingItems();const _=u.__styleId2||(u.__styleId2=we.createDrawingStyle({strokeStyle:"red"}));for(let C of L)if(C.unitType===ba.IRUT_LOCALIZED_BARCODES)for(let I of C.localizedBarcodes){if(!I)continue;const x=new h_({points:I.location.points},_);T.addDrawingItems([x])}}}if(it._onLog&&(it._onLog("intersectedResults:"),it._onLog(S)),!S.length)return;let w;if(S.length){let D=S.filter(T=>T.possibleFormats==R_.BF_QR_CODE||T.possibleFormats==R_.BF_DATAMATRIX);if(D.length||(D=S.filter(T=>T.possibleFormats==R_.BF_ONED),D.length||(D=S)),D.length){const T=C=>{const I=C.location.points,M=(I[0].x+I[1].x+I[2].x+I[3].x)/4,x=(I[0].y+I[1].y+I[2].y+I[3].y)/4;return(M-pe/2)*(M-pe/2)+(x-ve/2)*(x-ve/2)};w=D[0];let _=T(w);if(1!=D.length)for(let C=1;C1.1*w.confidence||D[C].confidence>.9*w.confidence&&I<_)&&(w=D[C],_=I)}}}if(it._onLog&&(it._onLog("highPriorityResult:"),it._onLog(w)),w){const D=w.location.points;Ae=Math.min(D[0].x,D[1].x,D[2].x,D[3].x),P=Math.max(D[0].x,D[1].x,D[2].x,D[3].x),Ee=Math.min(D[0].y,D[1].y,D[2].y,D[3].y),Be=Math.max(D[0].y,D[1].y,D[2].y,D[3].y),Te={points:[{x:Ae,y:Ee},{x:P,y:Ee},{x:P,y:Be},{x:Ae,y:Be}],result:w}}}if(it._onLog&&(it._onLog("boundingRect:"),it._onLog(Te)),!Te)return;if(it._debug&&j(u,ke,"f")&&(null==Te?void 0:Te.points)){const Ae=u.__layer||(u.__layer=j(u,ke,"f")._createDrawingLayer(99)),P=u.__styleId1||(u.__styleId1=we.createDrawingStyle({strokeStyle:"blue"})),Ee=new h_({points:Te.points},P);Ae.addDrawingItems([Ee])}if(j(u,Ne,"f").autoZoomOutFrameCount=0,j(u,qt,"f").autoZoom){const Ae=j(u,Ne,"f").autoZoomIdealArea[1];let P=(1-j(u,Ne,"f").autoZoomTargetBorder)/2;const Ee=Te.points[0].x/X,Be=(X-Te.points[2].x)/X,et=Te.points[0].y/Q,S=(Q-Te.points[2].y)/Q;if(Ee>Ae&&Be>Ae&&et>Ae&&S>Ae&&Te.result.moduleSize{}),j(u,Ne,"f").autoZoomInFrameArray.filter(w=>!0===w).length>=j(u,Ne,"f").autoZoomInFrameLimit[1]){j(u,Ne,"f").autoZoomInFrameArray.length=0;const w=[(.5-P)/(.5-Ee),(.5-P)/(.5-Be),(.5-P)/(.5-et),(.5-P)/(.5-S)].filter(I=>I>0),D=Math.min(...w,j(u,Ne,"f").autoZoomInIdealModuleSize/Te.result.moduleSize),T=u.getZoomSettings().factor;let _=Math.max(Math.pow(T*D,1/j(u,Ne,"f").autoZoomInMaxTimes),j(u,Ne,"f").autoZoomInMinStep);_=Math.min(_,D);let C=T*_;C=Math.max(j(u,Ne,"f").minValue,C),C=Math.min(j(u,Ne,"f").maxValue,C);try{yield U({factor:C})}catch(I){console.warn(I.message||I)}u.clearBuffer()}}else if(j(u,Ne,"f").autoZoomInFrameArray.length=0,j(u,Ne,"f").frameArrayInIdealZoom.push(!0),j(u,Ne,"f").frameArrayInIdealZoom.splice(0,j(u,Ne,"f").frameArrayInIdealZoom.length-j(u,Ne,"f").frameLimitInIdealZoom[0]),j(u,Ne,"f").frameArrayInIdealZoom.filter(w=>!0===w).length>=j(u,Ne,"f").frameLimitInIdealZoom[1]&&(j(u,Ne,"f").frameArrayInIdealZoom.length=0,j(u,qt,"f").enhancedFocus)){const w=Te.points;try{yield W({mode:"manual",area:{centerPoint:{x:(w[0].x+w[2].x)/2+"px",y:(w[0].y+w[2].y)/2+"px"},width:w[2].x-w[0].x+"px",height:w[2].y-w[0].y+"px"}})}catch(D){console.warn(D.message||D)}u.clearBuffer()}}if(!j(u,qt,"f").autoZoom&&j(u,qt,"f").enhancedFocus&&(j(u,Ne,"f").autoFocusFrameArray.push(!0),j(u,Ne,"f").autoFocusFrameArray.splice(0,j(u,Ne,"f").autoFocusFrameArray.length-j(u,Ne,"f").autoFocusFrameLimit[0]),j(u,Ne,"f").autoFocusFrameArray.filter(Ae=>!0===Ae).length>=j(u,Ne,"f").autoFocusFrameLimit[1])){j(u,Ne,"f").autoFocusFrameArray.length=0;try{const Ae=Te.points;yield W({mode:"manual",area:{centerPoint:{x:(Ae[0].x+Ae[2].x)/2+"px",y:(Ae[0].y+Ae[2].y)/2+"px"},width:Ae[2].x-Ae[0].x+"px",height:Ae[2].y-Ae[0].y+"px"}})}catch(Ae){console.warn(Ae.message||Ae)}u.clearBuffer()}}else{if(j(u,qt,"f").autoZoom){if(j(u,Ne,"f").autoZoomInFrameArray.push(!1),j(u,Ne,"f").autoZoomInFrameArray.splice(0,j(u,Ne,"f").autoZoomInFrameArray.length-j(u,Ne,"f").autoZoomInFrameLimit[0]),j(u,Ne,"f").autoZoomOutFrameCount++,j(u,Ne,"f").frameArrayInIdealZoom.push(!1),j(u,Ne,"f").frameArrayInIdealZoom.splice(0,j(u,Ne,"f").frameArrayInIdealZoom.length-j(u,Ne,"f").frameLimitInIdealZoom[0]),j(u,Ne,"f").autoZoomOutFrameCount>=j(u,Ne,"f").autoZoomOutFrameLimit){j(u,Ne,"f").autoZoomOutFrameCount=0;const Y=u.getZoomSettings().factor;let $=Y-Math.max((Y-1)*j(u,Ne,"f").autoZoomOutStepRate,j(u,Ne,"f").autoZoomOutMinStep);$=Math.max(j(u,Ne,"f").minValue,$),$=Math.min(j(u,Ne,"f").maxValue,$);try{yield U({factor:$})}catch(q){console.warn(q.message||q)}u.clearBuffer()}j(u,qt,"f").enhancedFocus&&W({mode:"continuous"}).catch(()=>{})}!j(u,qt,"f").autoZoom&&j(u,qt,"f").enhancedFocus&&(j(u,Ne,"f").autoFocusFrameArray.length=0,W({mode:"continuous"}).catch(()=>{}))}}});return function(p,m){return g.apply(this,arguments)}}(),Le(this,Tr,new os(1e4),"f")}setCameraView(l){if(!(l instanceof on))throw new TypeError("Invalid view.");if(l.disposed)throw new Error("The camera view has been disposed.");if(this.isOpen())throw new Error("It is not allowed to change camera view when the camera is open.");this.releaseCameraView(),l._singleFrameMode=this.singleFrameMode,l._onSingleFrameAcquired=this._onSingleFrameAcquired,this.videoSrc&&(j(this,ke,"f")._hideDefaultSelection=!0),j(this,vt,"m",Lt).call(this)||j(this,Fe,"f").setVideoEl(l.getVideoElement()),Le(this,ke,l,"f"),this.addListenerToView()}getCameraView(){return j(this,ke,"f")}releaseCameraView(){j(this,ke,"f")&&(this.removeListenerFromView(),j(this,ke,"f").disposed||(j(this,ke,"f")._singleFrameMode="disabled",j(this,ke,"f")._onSingleFrameAcquired=null,j(this,ke,"f")._hideDefaultSelection=!1),j(this,Fe,"f").releaseVideoEl(),Le(this,ke,null,"f"))}addListenerToView(){if(!j(this,ke,"f"))return;if(j(this,ke,"f").disposed)throw new Error("'cameraView' has been disposed.");const l=j(this,ke,"f");j(this,vt,"m",Lt).call(this)||this.videoSrc||(l._innerComponent&&(j(this,Fe,"f").tapFocusEventBoundEl=l._innerComponent),l._selCam&&l._selCam.addEventListener("change",this._onCameraSelChange),l._selRsl&&l._selRsl.addEventListener("change",this._onResolutionSelChange)),l._btnClose&&l._btnClose.addEventListener("click",this._onCloseBtnClick)}removeListenerFromView(){if(!j(this,ke,"f")||j(this,ke,"f").disposed)return;const l=j(this,ke,"f");j(this,Fe,"f").tapFocusEventBoundEl=null,l._selCam&&l._selCam.removeEventListener("change",this._onCameraSelChange),l._selRsl&&l._selRsl.removeEventListener("change",this._onResolutionSelChange),l._btnClose&&l._btnClose.removeEventListener("click",this._onCloseBtnClick)}getCameraState(){return j(this,vt,"m",Lt).call(this)?j(this,Nc,"f"):new Map([["closed","closed"],["opening","opening"],["opened","open"]]).get(j(this,Fe,"f").state)}isOpen(){return"open"===this.getCameraState()}getVideoEl(){return this.video}open(){var l=this;return se(function*(){const u=j(l,ke,"f");if(null==u?void 0:u.disposed)throw new Error("'cameraView' has been disposed.");u&&(u._singleFrameMode=l.singleFrameMode,j(l,vt,"m",Lt).call(l)?u._clickIptSingleFrameMode():(j(l,Fe,"f").setVideoEl(u.getVideoElement()),u._startLoading()));let g={width:0,height:0,deviceId:""};if(!j(l,vt,"m",Lt).call(l)){try{yield j(l,Fe,"f").open()}catch(m){throw u&&u._stopLoading(),m}j(l,Eo,"f")&&l.turnOnTorch().catch(()=>{});const p=l.getResolution();g.width=p.width,g.height=p.height,g.deviceId=l.getSelectedCamera().deviceId}return Le(l,Nc,"open","f"),u&&(u._innerComponent.style.display="",j(l,vt,"m",Lt).call(l)||(u._stopLoading(),u._renderCamerasInfo(l.getSelectedCamera(),j(l,Fe,"f")._arrCameras),u._renderResolutionInfo({width:g.width,height:g.height}),u.eventHandler.fire("content:updated",null,{async:!1}),u.eventHandler.fire("videoEl:resized",null,{async:!1}))),j(l,rs,"f").fire("opened",null,{target:l,async:!1}),g})()}close(){const l=j(this,ke,"f");if(null==l?void 0:l.disposed)throw new Error("'cameraView' has been disposed.");this.stopFetching(),this.clearBuffer(),j(this,vt,"m",Lt).call(this)||j(this,Fe,"f").close(),Le(this,Nc,"closed","f"),j(this,Tr,"f").stopCharging(),l&&(l._innerComponent.style.display="none",j(this,vt,"m",Lt).call(this)&&l._innerComponent.removeElement("content"),l._stopLoading()),j(this,rs,"f").fire("closed",null,{target:this,async:!1})}pause(){if(j(this,vt,"m",Lt).call(this))throw new Error("'pause()' is invalid in 'singleFrameMode'.");j(this,Fe,"f").pause()}isPaused(){var l;return!j(this,vt,"m",Lt).call(this)&&!0===(null===(l=this.video)||void 0===l?void 0:l.paused)}resume(){var l=this;return se(function*(){if(j(l,vt,"m",Lt).call(l))throw new Error("'resume()' is invalid in 'singleFrameMode'.");yield j(l,Fe,"f").resume()})()}selectCamera(l){var u=this;return se(function*(){if(!l)throw new Error("Invalid value.");let g;g="string"==typeof l?l:l.deviceId,yield j(u,Fe,"f").setCamera(g),Le(u,Eo,!1,"f");const p=u.getResolution(),m=j(u,ke,"f");return m&&!m.disposed&&(m._stopLoading(),m._renderCamerasInfo(u.getSelectedCamera(),j(u,Fe,"f")._arrCameras),m._renderResolutionInfo({width:p.width,height:p.height})),{width:p.width,height:p.height,deviceId:u.getSelectedCamera().deviceId}})()}getSelectedCamera(){return j(this,Fe,"f").getCamera()}getAllCameras(){var l=this;return se(function*(){return j(l,Fe,"f").getCameras()})()}setResolution(l){var u=this;return se(function*(){yield j(u,Fe,"f").setResolution(l.width,l.height),j(u,Eo,"f")&&u.turnOnTorch().catch(()=>{});const g=u.getResolution(),p=j(u,ke,"f");return p&&!p.disposed&&(p._stopLoading(),p._renderResolutionInfo({width:g.width,height:g.height})),{width:g.width,height:g.height,deviceId:u.getSelectedCamera().deviceId}})()}getResolution(){return j(this,Fe,"f").getResolution()}getAvailableResolutions(){var l;return null===(l=j(this,Fe,"f"))||void 0===l?void 0:l.getResolutions()}_on(l,u){["opened","closed","singleframeacquired","frameaddedtobuffer"].includes(l.toLowerCase())?j(this,rs,"f").on(l,u):j(this,Fe,"f").on(l,u)}_off(l,u){["opened","closed","singleframeacquired","frameaddedtobuffer"].includes(l.toLowerCase())?j(this,rs,"f").off(l,u):j(this,Fe,"f").off(l,u)}on(l,u){const g=l.toLowerCase(),p=new Map([["cameraopen","opened"],["cameraclose","closed"],["camerachange","camera:changed"],["resolutionchange","resolution:changed"],["played","played"],["singleframeacquired","singleFrameAcquired"],["frameaddedtobuffer","frameAddedToBuffer"]]).get(g);if(!p)throw new Error("Invalid event.");this._on(p,u)}off(l,u){const g=l.toLowerCase(),p=new Map([["cameraopen","opened"],["cameraclose","closed"],["camerachange","camera:changed"],["resolutionchange","resolution:changed"],["played","played"],["singleframeacquired","singleFrameAcquired"],["frameaddedtobuffer","frameAddedToBuffer"]]).get(g);if(!p)throw new Error("Invalid event.");this._off(p,u)}getVideoSettings(){var l;return null===(l=j(this,Fe,"f"))||void 0===l?void 0:l.getMediaStreamConstraints()}updateVideoSettings(l){var u=this;return se(function*(){var g;yield null===(g=j(u,Fe,"f"))||void 0===g?void 0:g.setMediaStreamConstraints(l,!0)})()}getCapabilities(){var l;return null===(l=j(this,Fe,"f"))||void 0===l?void 0:l.getCameraCapabilities()}getCameraSettings(){return j(this,Fe,"f").getCameraSettings()}turnOnTorch(){var l=this;return se(function*(){var u;if(j(l,vt,"m",Lt).call(l))throw new Error("'turnOnTorch()' is invalid in 'singleFrameMode'.");yield null===(u=j(l,Fe,"f"))||void 0===u?void 0:u.turnOnTorch(),Le(l,Eo,!0,"f")})()}turnOffTorch(){var l=this;return se(function*(){var u;if(j(l,vt,"m",Lt).call(l))throw new Error("'turnOffTorch()' is invalid in 'singleFrameMode'.");yield null===(u=j(l,Fe,"f"))||void 0===u?void 0:u.turnOffTorch(),Le(l,Eo,!1,"f")})()}setColorTemperature(l){var u=this;return se(function*(){if(j(u,vt,"m",Lt).call(u))throw new Error("'setColorTemperature()' is invalid in 'singleFrameMode'.");yield j(u,Fe,"f").setColorTemperature(l,!0)})()}getColorTemperature(){return j(this,Fe,"f").getColorTemperature()}setExposureCompensation(l){var u=this;return se(function*(){var g;if(j(u,vt,"m",Lt).call(u))throw new Error("'setExposureCompensation()' is invalid in 'singleFrameMode'.");yield null===(g=j(u,Fe,"f"))||void 0===g?void 0:g.setExposureCompensation(l,!0)})()}getExposureCompensation(){var l;return null===(l=j(this,Fe,"f"))||void 0===l?void 0:l.getExposureCompensation()}_setZoom(l){var u=this;return se(function*(){var g;if(j(u,vt,"m",Lt).call(u))throw new Error("'setZoom()' is invalid in 'singleFrameMode'.");yield null===(g=j(u,Fe,"f"))||void 0===g?void 0:g.setZoom(l)})()}setZoom(l){var u=this;return se(function*(){yield u._setZoom(l)})()}getZoomSettings(){var l;return null===(l=j(this,Fe,"f"))||void 0===l?void 0:l.getZoom()}resetZoom(){var l=this;return se(function*(){var u;if(j(l,vt,"m",Lt).call(l))throw new Error("'resetZoom()' is invalid in 'singleFrameMode'.");yield null===(u=j(l,Fe,"f"))||void 0===u?void 0:u.resetZoom()})()}setFrameRate(l){var u=this;return se(function*(){var g;if(j(u,vt,"m",Lt).call(u))throw new Error("'setFrameRate()' is invalid in 'singleFrameMode'.");yield null===(g=j(u,Fe,"f"))||void 0===g?void 0:g.setFrameRate(l,!0)})()}getFrameRate(){var l;return null===(l=j(this,Fe,"f"))||void 0===l?void 0:l.getFrameRate()}setFocus(l){var u=this;return se(function*(){var g;if(j(u,vt,"m",Lt).call(u))throw new Error("'setFocus()' is invalid in 'singleFrameMode'.");yield null===(g=j(u,Fe,"f"))||void 0===g?void 0:g.setFocus(l,!0)})()}getFocusSettings(){var l;return null===(l=j(this,Fe,"f"))||void 0===l?void 0:l.getFocus()}setAutoZoomRange(l){j(this,Ne,"f").minValue=l.min,j(this,Ne,"f").maxValue=l.max}getAutoZoomRange(){return{min:j(this,Ne,"f").minValue,max:j(this,Ne,"f").maxValue}}enableEnhancedFeatures(l){var u=this;return se(function*(){var g,p;if(!(null===(p=null===(g=pn.license)||void 0===g?void 0:g.LicenseManager)||void 0===p?void 0:p.bPassValidation))throw new Error("License is not verified, or license is invalid.");if(0!==sn.bSupportDce4Module)throw new Error("Please set a license containing the DCE module.");l&Os.EF_ENHANCED_FOCUS&&(j(u,qt,"f").enhancedFocus=!0),l&Os.EF_AUTO_ZOOM&&(j(u,qt,"f").autoZoom=!0),l&Os.EF_TAP_TO_FOCUS&&(j(u,qt,"f").tapToFocus=!0,j(u,Fe,"f").enableTapToFocus())})()}disableEnhancedFeatures(l){l&Os.EF_ENHANCED_FOCUS&&(j(this,qt,"f").enhancedFocus=!1,this.setFocus({mode:"continuous"}).catch(()=>{})),l&Os.EF_AUTO_ZOOM&&(j(this,qt,"f").autoZoom=!1,this.resetZoom().catch(()=>{})),l&Os.EF_TAP_TO_FOCUS&&(j(this,qt,"f").tapToFocus=!1,j(this,Fe,"f").disableTapToFocus()),j(this,vt,"m",eT).call(this)&&j(this,vt,"m",JI).call(this)||j(this,Tr,"f").stopCharging()}_setScanRegion(l){if(null!=l&&!s_(l)&&!qr(l))throw TypeError("Invalid 'region'.");Le(this,bo,l?JSON.parse(JSON.stringify(l)):null,"f"),j(this,ke,"f")&&!j(this,ke,"f").disposed&&j(this,ke,"f").setScanRegion(l)}setScanRegion(l){this._setScanRegion(l),j(this,ke,"f")&&!j(this,ke,"f").disposed&&(null===l?j(this,ke,"f").setScanRegionMaskVisible(!1):j(this,ke,"f").setScanRegionMaskVisible(!0))}getScanRegion(){return JSON.parse(JSON.stringify(j(this,bo,"f")))}setErrorListener(l){if(!l)throw new TypeError("Invalid 'listener'");Le(this,kc,l,"f")}hasNextImageToFetch(){return!("open"!==this.getCameraState()||!j(this,Fe,"f").isVideoLoaded()||j(this,vt,"m",Lt).call(this))}startFetching(){if(j(this,vt,"m",Lt).call(this))throw Error("'startFetching()' is unavailable in 'singleFrameMode'.");j(this,ss,"f")||(Le(this,ss,!0,"f"),j(this,vt,"m",x_).call(this))}stopFetching(){j(this,ss,"f")&&(it._onLog&&it._onLog("DCE: stop fetching loop: "+Date.now()),j(this,yi,"f")&&clearTimeout(j(this,yi,"f")),Le(this,ss,!1,"f"))}fetchImage(){if(j(this,vt,"m",Lt).call(this))throw new Error("'fetchImage()' is unavailable in 'singleFrameMode'.");if(!this.video)throw new Error("The video element does not exist.");if(4!==this.video.readyState)throw new Error("The video is not loaded.");const l=this.getResolution();if(!(null==l?void 0:l.width)||!(null==l?void 0:l.height))throw new Error("The video is not loaded.");let u;if(u=id.convert(j(this,bo,"f"),l.width,l.height),u||(u={x:0,y:0,width:l.width,height:l.height}),u.x>l.width||u.y>l.height)throw new Error("Invalid scan region.");u.x+u.width>l.width&&(u.width=l.width-u.x),u.y+u.height>l.height&&(u.height=l.height-u.y);const g={sx:u.x,sy:u.y,sWidth:u.width,sHeight:u.height,dWidth:u.width,dHeight:u.height},p=Math.max(g.dWidth,g.dHeight);if(this.canvasSizeLimit&&p>this.canvasSizeLimit){const b=this.canvasSizeLimit/p;g.dWidth>g.dHeight?(g.dWidth=this.canvasSizeLimit,g.dHeight=Math.round(g.dHeight*b)):(g.dWidth=Math.round(g.dWidth*b),g.dHeight=this.canvasSizeLimit)}const m=j(this,Fe,"f").getFrameData({position:g,pixelFormat:tT.get(this.getPixelFormat())});if(!m)return null;let v;v=m.pixelFormat===_t.GREY?m.width:4*m.width;let y=!0;return 0===g.sx&&0===g.sy&&g.sWidth===l.width&&g.sHeight===l.height&&(y=!1),{bytes:m.data,width:m.width,height:m.height,stride:v,format:nT.get(m.pixelFormat),tag:{imageId:this._imageId==Number.MAX_VALUE?this._imageId=0:++this._imageId,type:qh.ITT_VIDEO_FRAME,isCropped:y,cropRegion:{left:u.x,top:u.y,right:u.x+u.width,bottom:u.y+u.height,isMeasuredInPercentage:!1},originalWidth:l.width,originalHeight:l.height,currentWidth:m.width,currentHeight:m.height,timeSpent:m.timeSpent,timeStamp:m.timeStamp},toCanvas:j(this,Td,"f"),isDCEFrame:!0}}setImageFetchInterval(l){this.fetchInterval=l,j(this,ss,"f")&&(j(this,yi,"f")&&clearTimeout(j(this,yi,"f")),Le(this,yi,setTimeout(()=>{this.disposed||j(this,vt,"m",x_).call(this)},l),"f"))}getImageFetchInterval(){return this.fetchInterval}setPixelFormat(l){Le(this,xd,l,"f")}getPixelFormat(){return j(this,xd,"f")}takePhoto(l){var u=this;if(!this.isOpen())throw new Error("Not open.");if(j(this,vt,"m",Lt).call(this))throw new Error("'takePhoto()' is unavailable in 'singleFrameMode'.");const g=document.createElement("input");g.setAttribute("type","file"),g.setAttribute("accept",".jpg,.jpeg,.icon,.gif,.svg,.webp,.png,.bmp"),g.setAttribute("capture",""),g.style.position="absolute",g.style.top="-9999px",g.style.backgroundColor="transparent",g.style.color="transparent",g.addEventListener("click",()=>{const p=this.isOpen();this.close(),window.addEventListener("focus",()=>{p&&this.open(),g.remove()},{once:!0})}),g.addEventListener("change",se(function*(){const p=g.files[0],m=yield(L=se(function*(N){let B=null,U=null;if("undefined"!=typeof createImageBitmap)try{if(B=yield createImageBitmap(N),B)return B}catch(Y){}var W;return B||(U=yield(W=N,new Promise((Y,$)=>{let q=URL.createObjectURL(W),X=new Image;X.src=q,X.onload=()=>{URL.revokeObjectURL(X.src),Y(X)},X.onerror=Q=>{$(new Error("Can't convert blob to image : "+(Q instanceof Event?Q.type:Q)))}}))),U}),function(N){return L.apply(this,arguments)})(p),v=m instanceof HTMLImageElement?m.naturalWidth:m.width,y=m instanceof HTMLImageElement?m.naturalHeight:m.height;var L;let b=id.convert(j(u,bo,"f"),v,y);b||(b={x:0,y:0,width:v,height:y});const O=j(u,Id,"f").call(u,m,v,y,b);l&&l(O)})),document.body.appendChild(g),g.click()}convertToPageCoordinates(l){const u=j(this,vt,"m",A_).call(this,l);return{x:u.pageX,y:u.pageY}}convertToClientCoordinates(l){const u=j(this,vt,"m",A_).call(this,l);return{x:u.clientX,y:u.clientY}}dispose(){this.close(),j(this,Fe,"f").dispose(),this.releaseCameraView(),this.__proto__=null;for(let l in this)delete this[l];Object.defineProperty(this,"isCameraEnhancer",{value:!0}),Object.defineProperty(this,"disposed",{value:!0})}}function qn(f,l,u,g){if("a"===u&&!g)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof l?f!==l||!g:!l.has(f))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===u?g:"a"===u?g.call(f):g?g.value:l.get(f)}function rr(f,l,u,g,p){if("m"===g)throw new TypeError("Private method is not writable");if("a"===g&&!p)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof l?f!==l||!p:!l.has(f))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===g?p.call(f,u):p?p.value=u:l.set(f,u),u}S_=it,Fe=new WeakMap,ke=new WeakMap,Nc=new WeakMap,rs=new WeakMap,Eo=new WeakMap,Sd=new WeakMap,Id=new WeakMap,Td=new WeakMap,kc=new WeakMap,bo=new WeakMap,xd=new WeakMap,ss=new WeakMap,yi=new WeakMap,qt=new WeakMap,Ne=new WeakMap,Tr=new WeakMap,T_=new WeakMap,vt=new WeakSet,Lt=function(){return"disabled"!==this.singleFrameMode},JI=function(){return!this.videoSrc&&"opened"===j(this,Fe,"f").state},eT=function(){for(let f in j(this,qt,"f"))if(1==j(this,qt,"f")[f])return!0;return!1},x_=function f(){if(this.disposed)return;if("open"!==this.getCameraState()||!j(this,ss,"f"))return j(this,yi,"f")&&clearTimeout(j(this,yi,"f")),void Le(this,yi,setTimeout(()=>{this.disposed||j(this,vt,"m",f).call(this)},this.fetchInterval),"f");const l=()=>{var u;let g;it._onLog&&it._onLog("DCE: start fetching a frame into buffer: "+Date.now());try{g=this.fetchImage()}catch(p){const m=p.message||p;if("The video is not loaded."===m)return;if(null===(u=j(this,kc,"f"))||void 0===u?void 0:u.onErrorReceived)return void setTimeout(()=>{var v;null===(v=j(this,kc,"f"))||void 0===v||v.onErrorReceived(Ym.EC_IMAGE_READ_FAILED,m)},0);console.warn(p)}g?(this.addImageToBuffer(g),it._onLog&&it._onLog("DCE: finish fetching a frame into buffer: "+Date.now()),j(this,rs,"f").fire("frameAddedToBuffer",null,{async:!1})):it._onLog&&it._onLog("DCE: get a invalid frame, abandon it: "+Date.now())};if(this.getImageCount()>=this.getMaxImageCount())switch(this.getBufferOverflowProtectionMode()){case ho.BOPM_BLOCK:break;case ho.BOPM_UPDATE:l()}else l();j(this,yi,"f")&&clearTimeout(j(this,yi,"f")),Le(this,yi,setTimeout(()=>{this.disposed||j(this,vt,"m",f).call(this)},this.fetchInterval),"f")},A_=function(f){if(!j(this,ke,"f"))throw new Error("Camera view is not set.");if(j(this,ke,"f").disposed)throw new Error("'cameraView' has been disposed.");if(!this.isOpen())throw new Error("Not open.");if(!j(this,vt,"m",Lt).call(this)&&!j(this,Fe,"f").isVideoLoaded())throw new Error("Video is not loaded.");if(j(this,vt,"m",Lt).call(this)&&!j(this,ke,"f")._cvsSingleFrameMode)throw new Error("No image is selected.");const l=j(this,ke,"f")._innerComponent.getBoundingClientRect(),u=l.left,g=l.top,p=u+window.scrollX,m=g+window.scrollY,{width:v,height:y}=j(this,ke,"f")._innerComponent.getBoundingClientRect();if(v<=0||y<=0)throw new Error("Unable to get content dimensions. Camera view may not be rendered on the page.");let b,O,L;if(j(this,vt,"m",Lt).call(this)){const X=j(this,ke,"f")._innerComponent.getElement("content");b=X.width,O=X.height,L="contain"}else{const X=this.getVideoEl();b=X.videoWidth,O=X.videoHeight,L=j(this,ke,"f").getVideoFit()}const N=v/y,B=b/O;let U,W,Y,$,q=1;if("contain"===L)Nb+O*m[L],0);g.push(y)}}return g}static identity(){return[1,0,0,0,1,0,0,0,1]}static translate(l,u,g){return Ci.multiply(l,[1,0,0,0,1,0,u,g,1])}static rotate(l,u){var g=Math.cos(u),p=Math.sin(u);return Ci.multiply(l,[g,-p,0,p,g,0,0,0,1])}static scale(l,u,g){return Ci.multiply(l,[u,0,0,0,g,0,0,0,1])}}var zt,as,ls,Ad,Ga,Bc,Vc,Ha,Rd,ki,iT,L_,Gc,Hc;!function(f){f.GREY="grey",f.GREY32="grey32",f.RGBA="rgba",f.RBGA="rbga",f.GRBA="grba",f.GBRA="gbra",f.BRGA="brga",f.BGRA="bgra"}(zt||(zt={}));class Ze{static get version(){return"1.1.0"}static checkWebGLSupport(){return null===document.createElement("canvas").getContext("webgl")?(rr(Ze,as,!1,"f",ls),!1):(rr(Ze,as,!0,"f",ls),!0)}get disposed(){return qn(this,Rd,"f")}constructor(){Ad.set(this,zt.RGBA),Ga.set(this,null),Bc.set(this,null),Vc.set(this,null),this.useWebGLByDefault=!0,this._reusedCvs=null,this._reusedWebGLCvs=null,Ha.set(this,null),Rd.set(this,!1)}drawImage(l,u,g,p,m,v){if(this.disposed)throw Error("The 'ImageDataGetter' instance has been disposed.");if(!g||!p)throw new Error("Invalid 'sourceWidth' or 'sourceHeight'.");if(null==qn(Ze,as,"f",ls)&&Ze.checkWebGLSupport(),(null==v?void 0:v.bUseWebGL)&&!qn(Ze,as,"f",ls))throw new Error("Your browser or machine may not support WebGL.");if(u instanceof HTMLVideoElement&&4!==u.readyState||u instanceof HTMLImageElement&&!u.complete)throw new Error("The source is not loaded.");let y;Ze._onLog&&(y=Date.now(),Ze._onLog("drawImage(), START: "+y));let b=0,O=0,L=g,N=p,B=0,U=0,W=g,Y=p;m&&(m.sx&&(b=Math.round(m.sx)),m.sy&&(O=Math.round(m.sy)),m.sWidth&&(L=Math.round(m.sWidth)),m.sHeight&&(N=Math.round(m.sHeight)),m.dx&&(B=Math.round(m.dx)),m.dy&&(U=Math.round(m.dy)),m.dWidth&&(W=Math.round(m.dWidth)),m.dHeight&&(Y=Math.round(m.dHeight)));let $,q=zt.RGBA;if((null==v?void 0:v.pixelFormat)&&(q=v.pixelFormat),(null==v?void 0:v.bufferContainer)&&($=v.bufferContainer,$.length<4*W*Y))throw new Error("Unexpected size of the 'bufferContainer'.");const X=l;if(!qn(Ze,as,"f",ls)||!(this.useWebGLByDefault&&null==(null==v?void 0:v.bUseWebGL)||(null==v?void 0:v.bUseWebGL))){Ze._onLog&&Ze._onLog("drawImage() in context2d."),X.ctx2d||(X.ctx2d=X.getContext("2d",{willReadFrequently:!0}));const Q=X.ctx2d;if(!Q)throw new Error("Unable to get 'CanvasRenderingContext2D' from canvas.");return(X.width{const C=_.createBuffer();_.bindBuffer(_.ARRAY_BUFFER,C),_.bufferData(_.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),_.STATIC_DRAW);const I=_.createBuffer();return _.bindBuffer(_.ARRAY_BUFFER,I),_.bufferData(_.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),_.STATIC_DRAW),{positions:C,texCoords:I}},Ee=_=>{const C=_.createTexture();return _.bindTexture(_.TEXTURE_2D,C),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_MAG_FILTER,_.LINEAR),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_MIN_FILTER,_.LINEAR),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_WRAP_S,_.CLAMP_TO_EDGE),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_WRAP_T,_.CLAMP_TO_EDGE),C},Be=(_,C)=>{const I=_.createProgram();if(C.forEach(M=>_.attachShader(I,M)),_.linkProgram(I),!_.getProgramParameter(I,_.LINK_STATUS)){const M=new Error(`An error occured linking the program: ${_.getProgramInfoLog(I)}.`);throw M.name="WebGLError",M}return _.useProgram(I),I},et=(_,C,I)=>{const M=_.createShader(C);if(_.shaderSource(M,I),_.compileShader(M),!_.getShaderParameter(M,_.COMPILE_STATUS)){const x=new Error(`An error occured compiling the shader: ${_.getShaderInfoLog(M)}.`);throw x.name="WebGLError",x}return M},S="\n attribute vec2 a_position;\n attribute vec2 a_texCoord;\n \n uniform mat3 u_matrix;\n uniform mat3 u_textureMatrix;\n \n varying vec2 v_texCoord;\n void main(void) {\n gl_Position = vec4((u_matrix * vec3(a_position, 1)).xy, 0, 1.0);\n v_texCoord = vec4((u_textureMatrix * vec3(a_texCoord, 1)).xy, 0, 1.0).xy;\n }\n ";let w="rgb";["rgba","rbga","grba","gbra","brga","bgra"].includes(q)&&(w=q.slice(0,3));const D=`\n precision mediump float;\n varying vec2 v_texCoord;\n uniform sampler2D u_image;\n uniform float uColorFactor;\n \n void main() {\n vec4 sample = texture2D(u_image, v_texCoord);\n float grey = 0.21 * sample.r + 0.71 * sample.g + 0.07 * sample.b;\n gl_FragColor = vec4(sample.${w} * (1.0 - uColorFactor) + (grey * uColorFactor), sample.a);\n }\n `,T=Be(Q,[et(Q,Q.VERTEX_SHADER,S),et(Q,Q.FRAGMENT_SHADER,D)]);rr(this,Bc,{program:T,attribLocations:{vertexPosition:Q.getAttribLocation(T,"a_position"),texPosition:Q.getAttribLocation(T,"a_texCoord")},uniformLocations:{uSampler:Q.getUniformLocation(T,"u_image"),uColorFactor:Q.getUniformLocation(T,"uColorFactor"),uMatrix:Q.getUniformLocation(T,"u_matrix"),uTextureMatrix:Q.getUniformLocation(T,"u_textureMatrix")}},"f"),rr(this,Vc,P(Q),"f"),rr(this,Ga,Ee(Q),"f"),rr(this,Ad,q,"f")}const pe=(P,Ee,Be)=>{P.bindBuffer(P.ARRAY_BUFFER,Ee),P.enableVertexAttribArray(Be),P.vertexAttribPointer(Be,2,P.FLOAT,!1,0,0)},Te=(P,Ee,Be,et)=>{P.clearColor(0,0,0,1),P.clearDepth(1),P.enable(P.DEPTH_TEST),P.depthFunc(P.LEQUAL),P.clear(P.COLOR_BUFFER_BIT|P.DEPTH_BUFFER_BIT),pe(P,Be.positions,Ee.attribLocations.vertexPosition),pe(P,Be.texCoords,Ee.attribLocations.texPosition),P.activeTexture(P.TEXTURE0),P.bindTexture(P.TEXTURE_2D,et),P.uniform1i(Ee.uniformLocations.uSampler,0),P.uniform1f(Ee.uniformLocations.uColorFactor,[zt.GREY,zt.GREY32].includes(q)?1:0);let S,w,D=Ci.translate(Ci.identity(),-1,-1);D=Ci.scale(D,2,2),D=Ci.scale(D,1/P.canvas.width,1/P.canvas.height),S=Ci.translate(D,B,U),S=Ci.scale(S,W,Y),P.uniformMatrix3fv(Ee.uniformLocations.uMatrix,!1,S),w=Ci.translate(Ci.identity(),b/g,O/p),w=Ci.scale(w,L/g,N/p),P.uniformMatrix3fv(Ee.uniformLocations.uTextureMatrix,!1,w),P.drawArrays(P.TRIANGLES,0,6)};((P,Ee,Be)=>{const et=P.RGBA,S=P.RGBA,w=P.UNSIGNED_BYTE;P.bindTexture(P.TEXTURE_2D,Ee),P.texImage2D(P.TEXTURE_2D,0,et,S,w,Be)})(Q,qn(this,Ga,"f"),u),Te(Q,qn(this,Bc,"f"),qn(this,Vc,"f"),qn(this,Ga,"f"));const Ae=$||new Uint8Array(4*W*Y);if(Q.readPixels(B,U,W,Y,Q.RGBA,Q.UNSIGNED_BYTE,Ae),255!==Ae[3]){Ze._onLog&&Ze._onLog("Incorrect WebGL drawing .");const P=new Error("WebGL error: incorrect drawing.");throw P.name="WebGLError",P}return Ze._onLog&&Ze._onLog("drawImage() in WebGL end. Costs: "+(Date.now()-y)),{context:Q,pixelFormat:q===zt.GREY?zt.GREY32:q,bUseWebGL:!0}}catch(Q){if(this.forceLoseContext(),null==(null==v?void 0:v.bUseWebGL))return Ze._onLog&&Ze._onLog("'drawImage()' in WebGL failed, try again in context2d."),this.useWebGLByDefault=!1,this.drawImage(l,u,g,p,m,Object.assign({},v,{bUseWebGL:!1}));throw Q.name="WebGLError",Q}}readCvsData(l,u,g){if(!(l instanceof CanvasRenderingContext2D||l instanceof WebGLRenderingContext))throw new Error("Invalid 'context'.");let p,m=0,v=0,y=l.canvas.width,b=l.canvas.height;if(u&&(u.x&&(m=u.x),u.y&&(v=u.y),u.width&&(y=u.width),u.height&&(b=u.height)),(null==g?void 0:g.length)<4*y*b)throw new Error("Unexpected size of the 'bufferContainer'.");if(l instanceof WebGLRenderingContext){const O=l;g?(O.readPixels(m,v,y,b,O.RGBA,O.UNSIGNED_BYTE,g),p=new Uint8Array(g.buffer,0,4*y*b)):(p=new Uint8Array(4*y*b),O.readPixels(m,v,y,b,O.RGBA,O.UNSIGNED_BYTE,p))}else if(l instanceof CanvasRenderingContext2D){let O;O=l.getImageData(m,v,y,b),p=new Uint8Array(O.data.buffer),null==g||g.set(p)}return p}transformPixelFormat(l,u,g,p){let m,v;if(Ze._onLog&&(m=Date.now(),Ze._onLog("transformPixelFormat(), START: "+m)),u===g)return Ze._onLog&&Ze._onLog("transformPixelFormat() end. Costs: "+(Date.now()-m)),p?new Uint8Array(l):l;const y=[zt.RGBA,zt.RBGA,zt.GRBA,zt.GBRA,zt.BRGA,zt.BGRA];if(y.includes(u))if(g===zt.GREY){v=new Uint8Array(l.length/4);for(let b=0;bu||p.sy>g||p.sx+p.sWidth>u||p.sy+p.sHeight>g)throw new Error("Invalid position.");if(l instanceof HTMLVideoElement&&4!==l.readyState||l instanceof HTMLImageElement&&!l.complete)throw new Error("The source is not loaded.");let v;Ze._onLog&&(v=Date.now(),Ze._onLog("getImageData(), START: "+v));const y=Math.round(p.sx),b=Math.round(p.sy),O=Math.round(p.sWidth),L=Math.round(p.sHeight),N=Math.round(p.dWidth),B=Math.round(p.dHeight);let U=zt.RGBA;(null==m?void 0:m.pixelFormat)&&(U=m.pixelFormat);let W,Y,$,q=null;if((null==m?void 0:m.bufferContainer)&&(q=m.bufferContainer),qn(Ze,as,"f",ls)&&(this.useWebGLByDefault&&null==(null==m?void 0:m.bUseWebGL)||(null==m?void 0:m.bUseWebGL))){Ze._onLog&&Ze._onLog("getImageData() in WebGL."),this._reusedWebGLCvs||(this._reusedWebGLCvs=document.createElement("canvas")),W=this._reusedWebGLCvs;try{if(q)if(U===zt.GREY){if($=new Uint8Array(4*N*B),Y=this.drawImage(W,l,u,g,{sx:y,sy:b,sWidth:O,sHeight:L,dWidth:N,dHeight:B},{pixelFormat:U,bUseWebGL:!0,bufferContainer:$}),$=this.transformPixelFormat($,Y.pixelFormat,U),q){if(q.length<$.length)throw new Error("Unexpected size of the 'bufferContainer'.");q.set($)}}else Y=this.drawImage(W,l,u,g,{sx:y,sy:b,sWidth:O,sHeight:L,dWidth:N,dHeight:B},{pixelFormat:U,bUseWebGL:!0,bufferContainer:q}),$=new Uint8Array(q.buffer,0,4*N*B),$=this.transformPixelFormat($,Y.pixelFormat,U);else U===zt.GREY?((!qn(this,Ha,"f")||qn(this,Ha,"f").length<4*N*B)&&rr(this,Ha,new Uint8Array(4*N*B),"f"),$=new Uint8Array(qn(this,Ha,"f").buffer,0,4*N*B)):$=new Uint8Array(4*N*B),Y=this.drawImage(W,l,u,g,{sx:y,sy:b,sWidth:O,sHeight:L,dWidth:N,dHeight:B},{pixelFormat:U,bUseWebGL:!0,bufferContainer:$}),$=this.transformPixelFormat($,Y.pixelFormat,U)}catch(X){if("WebGLError"===X.name&&(this.forceLoseContext(),null==(null==m?void 0:m.bUseWebGL)))return Ze._onLog&&Ze._onLog("getImageData() in WebGL failed, try again in context2d."),this.useWebGLByDefault=!1,this.getImageData(l,u,g,{sx:y,sy:b,sWidth:O,sHeight:L,dWidth:N,dHeight:B},Object.assign({},m,{bUseWebGL:!1}));throw X}}else if(Ze._onLog&&Ze._onLog("getImageData() in context2d."),this._reusedCvs||(this._reusedCvs=document.createElement("canvas")),W=this._reusedCvs,Y=this.drawImage(W,l,u,g,{sx:y,sy:b,sWidth:O,sHeight:L,dWidth:N,dHeight:B},{pixelFormat:zt.RGBA,bUseWebGL:!1}),$=this.readCvsData(Y.context,{width:N,height:B},null),$=this.transformPixelFormat($,Y.pixelFormat,U),q){if(q.length<$.length)throw new Error("Unexpected size of the 'bufferContainer'.");q.set($)}return Ze._onLog&&Ze._onLog("getImageData() end. Costs: "+(Date.now()-v)),{data:$,pixelFormat:U,width:N,height:B,bUseWebGL:Y.bUseWebGL}}convertDataToCvs(l,u,g,p){if(!(l instanceof Uint8Array||l instanceof Uint8ClampedArray))throw new TypeError("Invalid 'data'.");if("number"!=typeof u||u<=0)throw new Error("Invalid 'width'.");if("number"!=typeof g||g<=0)throw new Error("Invalid 'height'.");const m=document.createElement("canvas");let v;if(m.width=u,m.height=g,p===zt.GREY){v=new Uint8ClampedArray(4*u*g);for(let b=0;b{l.removeEventListener("loadedmetadata",g),l.play(),u=setTimeout(()=>{j(this,ki,"f",Hc).delete(l)},2e3*l.duration)};l.addEventListener("loadedmetadata",g),l.addEventListener("ended",()=>{null!=u&&(clearTimeout(u),u=null),l.pause(),l.currentTime=0,j(this,ki,"f",Hc).delete(l),j(this,ki,"f",Gc).add(l)})}else j(this,ki,"f",L_)||(Le(this,ki,!0,"f",L_),console.warn("The requested audio tracks exceed 64 and will not be played."));l&&j(this,ki,"f",Hc).add(l)}static vibrate(){if(!navigator||!navigator.vibrate)throw new Error("Not supported.");navigator.vibrate(za.vibrateDuration)}}ki=za,iT={value:"data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjI5LjEwMAAAAAAAAAAAAAAA/+M4wAAAAAAAAAAAAEluZm8AAAAPAAAABQAAAkAAgICAgICAgICAgICAgICAgICAgKCgoKCgoKCgoKCgoKCgoKCgoKCgwMDAwMDAwMDAwMDAwMDAwMDAwMDg4ODg4ODg4ODg4ODg4ODg4ODg4P//////////////////////////AAAAAExhdmM1OC41NAAAAAAAAAAAAAAAACQEUQAAAAAAAAJAk0uXRQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/+MYxAANQAbGeUEQAAHZYZ3fASqD4P5TKBgocg+Bw/8+CAYBA4XB9/4EBAEP4nB9+UOf/6gfUCAIKyjgQ/Kf//wfswAAAwQA/+MYxAYOqrbdkZGQAMA7DJLCsQxNOij///////////+tv///3RWiZGBEhsf/FO/+LoCSFs1dFVS/g8f/4Mhv0nhqAieHleLy/+MYxAYOOrbMAY2gABf/////////////////usPJ66R0wI4boY9/8jQYg//g2SPx1M0N3Z0kVJLIs///Uw4aMyvHJJYmPBYG/+MYxAgPMALBucAQAoGgaBoFQVBUFQWDv6gZBUFQVBUGgaBr5YSgqCoKhIGg7+IQVBUFQVBoGga//SsFSoKnf/iVTEFNRTMu/+MYxAYAAANIAAAAADEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"},L_={value:!1},Gc={value:new Set},Hc={value:new Set},za.beepSoundSource=j(za,ki,"f",iT),za.vibrateDuration=300;const sT="undefined"==typeof self,F_=(()=>{if(!sT&&document.currentScript){let f=document.currentScript.src,l=f.indexOf("?");if(-1!=l)f=f.substring(0,l);else{let u=f.indexOf("#");-1!=u&&(f=f.substring(0,u))}return f.substring(0,f.lastIndexOf("/")+1)}return"./"})(),oT=f=>{if(null==f&&(f="./"),!sT){let l=document.createElement("a");l.href=f,f=l.href}return f.endsWith("/")||(f+="/"),f};null==je.dbr&&(je.dbr=F_),$r.dbr={js:!1,wasm:!0,deps:["license","dip"]},pn.dbr={};"string"!=typeof je.std&&zr(je.std.version,"1.2.0")<0&&(je.std={version:"1.2.0",path:oT(F_+"../../dynamsoft-capture-vision-std@1.2.0/dist/")});const N_="2.2.10";var aT,lT,cT,uT;(!je.dip||"string"!=typeof je.dip&&zr(je.dip.version,N_)<0)&&(je.dip={version:N_,path:oT(F_+`../../dynamsoft-image-processing@${N_}/dist/`)}),"function"==typeof BigInt&&(BigInt(0),BigInt(0x10000000000000000),BigInt(4265345023),BigInt(3147775),BigInt(260096),BigInt(1),BigInt(2),BigInt(4),BigInt(8),BigInt(16),BigInt(32),BigInt(64),BigInt(128),BigInt(256),BigInt(512),BigInt(1024),BigInt(2048),BigInt(4096),BigInt(8192),BigInt(16384),BigInt(32768),BigInt(65536),BigInt(131072),BigInt(262144),BigInt(16777216),BigInt(33554432),BigInt(67108864),BigInt(134217728),BigInt(268435456),BigInt(536870912),BigInt(1073741824),BigInt(524288),BigInt(2147483648),BigInt(1048576),BigInt(2097152),BigInt(4194304),BigInt(8388608),BigInt(68719476736),BigInt(0x3f0000000000000),BigInt(4294967296),BigInt(4503599627370496),BigInt(9007199254740992),BigInt(0x40000000000000),BigInt(0x80000000000000),BigInt(72057594037927940),BigInt(0x200000000000000),BigInt(8589934592),BigInt(17179869184),BigInt(34359738368),BigInt(51539607552)),function(f){f[f.EBRT_STANDARD_RESULT=0]="EBRT_STANDARD_RESULT",f[f.EBRT_CANDIDATE_RESULT=1]="EBRT_CANDIDATE_RESULT",f[f.EBRT_PARTIAL_RESULT=2]="EBRT_PARTIAL_RESULT"}(aT||(aT={})),function(f){f[f.QRECL_ERROR_CORRECTION_H=0]="QRECL_ERROR_CORRECTION_H",f[f.QRECL_ERROR_CORRECTION_L=1]="QRECL_ERROR_CORRECTION_L",f[f.QRECL_ERROR_CORRECTION_M=2]="QRECL_ERROR_CORRECTION_M",f[f.QRECL_ERROR_CORRECTION_Q=3]="QRECL_ERROR_CORRECTION_Q"}(lT||(lT={})),function(f){f[f.LM_AUTO=1]="LM_AUTO",f[f.LM_CONNECTED_BLOCKS=2]="LM_CONNECTED_BLOCKS",f[f.LM_STATISTICS=4]="LM_STATISTICS",f[f.LM_LINES=8]="LM_LINES",f[f.LM_SCAN_DIRECTLY=16]="LM_SCAN_DIRECTLY",f[f.LM_STATISTICS_MARKS=32]="LM_STATISTICS_MARKS",f[f.LM_STATISTICS_POSTAL_CODE=64]="LM_STATISTICS_POSTAL_CODE",f[f.LM_CENTRE=128]="LM_CENTRE",f[f.LM_ONED_FAST_SCAN=256]="LM_ONED_FAST_SCAN",f[f.LM_REV=-2147483648]="LM_REV",f[f.LM_SKIP=0]="LM_SKIP"}(cT||(cT={})),function(f){f[f.DM_DIRECT_BINARIZATION=1]="DM_DIRECT_BINARIZATION",f[f.DM_THRESHOLD_BINARIZATION=2]="DM_THRESHOLD_BINARIZATION",f[f.DM_GRAY_EQUALIZATION=4]="DM_GRAY_EQUALIZATION",f[f.DM_SMOOTHING=8]="DM_SMOOTHING",f[f.DM_MORPHING=16]="DM_MORPHING",f[f.DM_DEEP_ANALYSIS=32]="DM_DEEP_ANALYSIS",f[f.DM_SHARPENING=64]="DM_SHARPENING",f[f.DM_BASED_ON_LOC_BIN=128]="DM_BASED_ON_LOC_BIN",f[f.DM_SHARPENING_SMOOTHING=256]="DM_SHARPENING_SMOOTHING",f[f.DM_REV=-2147483648]="DM_REV",f[f.DM_SKIP=0]="DM_SKIP"}(uT||(uT={}));const dT="undefined"==typeof self,k_=(()=>{if(!dT&&document.currentScript){let f=document.currentScript.src,l=f.indexOf("?");if(-1!=l)f=f.substring(0,l);else{let u=f.indexOf("#");-1!=u&&(f=f.substring(0,u))}return f.substring(0,f.lastIndexOf("/")+1)}return"./"})(),fT=f=>{if(null==f&&(f="./"),!dT){let l=document.createElement("a");l.href=f,f=l.href}return f.endsWith("/")||(f+="/"),f};null==je.utility&&(je.utility=k_),$r.utility={js:!0,wasm:!0};const B_="1.2.10";"string"!=typeof je.std&&zr(je.std.version,B_)<0&&(je.std={version:B_,path:fT(k_+`../../dynamsoft-capture-vision-std@${B_}/dist/`)});const V_="2.2.30";(!je.dip||"string"!=typeof je.dip&&zr(je.dip.version,V_)<0)&&(je.dip={version:V_,path:fT(k_+`../../dynamsoft-image-processing@${V_}/dist/`)});let Us="./";if(document.currentScript){let f=document.currentScript.src,l=f.indexOf("?");if(-1!=l)f=f.substring(0,l);else{let u=f.indexOf("#");-1!=u&&(f=f.substring(0,u))}Us=f.substring(0,f.lastIndexOf("/")+1)}const Do=f=>{null==f&&(f="./");let l=document.createElement("a");return l.href=f,(f=l.href).endsWith("/")||(f+="/"),f};sn.engineResourcePaths={std:Do(Us+"../../dynamsoft-capture-vision-std@1.2.10/dist/"),dip:Do(Us+"../../dynamsoft-image-processing@2.2.30/dist/"),core:Do(Us+"../../dynamsoft-core@3.2.30/dist/"),license:Do(Us+"../../dynamsoft-license@3.2.21/dist/"),cvr:Do(Us+"../../dynamsoft-capture-vision-router@2.2.30/dist/"),dce:Do(Us+"../../dynamsoft-camera-enhancer@4.0.3/dist/"),dbr:Do(Us+"../../dynamsoft-barcode-reader@10.2.10/dist/")};const gT="undefined"==typeof self,G_=(()=>{if(!gT&&document.currentScript){let f=document.currentScript.src,l=f.indexOf("?");if(-1!=l)f=f.substring(0,l);else{let u=f.indexOf("#");-1!=u&&(f=f.substring(0,u))}return f.substring(0,f.lastIndexOf("/")+1)}return"./"})(),pT=f=>{if(null==f&&(f="./"),!gT){let l=document.createElement("a");l.href=f,f=l.href}return f.endsWith("/")||(f+="/"),f},H_=f=>{const l=document.createElement("canvas");return l.width=f.width,l.height=f.height,l.getContext("2d",{willReadFrequently:!0}).putImageData(f,0,0),l},mT=function(){var f=se(function*(l,u){const g=H_(u);return new Promise((p,m)=>{g.toBlob(v=>p(v),l)})});return function(u,g){return f.apply(this,arguments)}}();null==je.ddn&&(je.ddn=G_),$r.ddn={js:!0,wasm:!0,deps:["license","dip"]},pn.ddn={handleNormalizedImageResultItem:function(f){let l=f,u=(g=>{let p,m=g.bytes;if(!(m&&m instanceof Uint8Array))throw Error("Parameter type error");if(Number(g.format)===Ue.IPF_BGR_888){const v=m.length/3;p=new Uint8ClampedArray(4*v);for(let y=0;y=y)break;p[$]=p[$+1]=p[$+2]=(128&N)/128*255,p[$+3]=255,N<<=1}}}else if(Number(g.format)===Ue.IPF_ABGR_8888){const v=m.length/4;p=new Uint8ClampedArray(m.length);for(let y=0;yH_(u),l.toImage=g=>((p,m)=>{const v=H_(m);let y=new Image,b=v.toDataURL(p);return y.src=b,y})(g,u),l.toBlob=g=>mT(g,u),l.saveToFile=function(){var g=se(function*(p,m){if(!p)return null;if("string"!=typeof p)throw new TypeError("FileName must be of type string.");return(v=se(function*(y,b,O){return yield new Promise(function(){var L=se(function*(N,B){try{const U=b.split(".");let W=U[U.length-1];const Y=yield mT(`image/${W}`,y);U.length<=1&&(W="png");const $=new File([Y],b,{type:`image/${W}`});if(O){const q=URL.createObjectURL($),X=document.createElement("a");X.href=q,X.download=b,X.click()}return N($)}catch(U){return B()}});return function(N,B){return L.apply(this,arguments)}}())}),function(y,b,O){return v.apply(this,arguments)})(u,p,m);var v});return function(p,m){return g.apply(this,arguments)}}()}};"string"!=typeof je.std&&zr(je.std.version,"1.2.0")<0&&(je.std={version:"1.2.0",path:pT(G_+"../../dynamsoft-capture-vision-std@1.2.0/dist/")});const z_="2.2.10";var xr;(!je.dip||"string"!=typeof je.dip&&zr(je.dip.version,z_)<0)&&(je.dip={version:z_,path:pT(G_+`../../dynamsoft-image-processing@${z_}/dist/`)}),function(f){f[f.ICM_COLOUR=0]="ICM_COLOUR",f[f.ICM_GRAYSCALE=1]="ICM_GRAYSCALE",f[f.ICM_BINARY=2]="ICM_BINARY"}(xr||(xr={}));let BU=(()=>{class f{constructor(){this.showDiv=!1}getShowDiv(){return this.showDiv}setShowDiv(u){this.showDiv=u}toggleShowDiv(){this.showDiv=!this.showDiv}}return f.\u0275fac=function(u){return new(u||f)},f.\u0275prov=yt({token:f,factory:f.\u0275fac,providedIn:"root"}),f})();const VU=function(){return["/barcode-reader"]};function UU(f,l){if(1&f&&(tt(0,"a",6),Kt(1),$e()),2&f){const u=Qs().$implicit;wn("title",u.name+" details")("routerLink",da(3,VU)),Rn(1),ws("> ",u.name," ")}}const jU=function(){return["/barcode-scanner"]};function GU(f,l){if(1&f&&(tt(0,"a",6),Kt(1),$e()),2&f){const u=Qs().$implicit;wn("title",u.name+" details")("routerLink",da(3,jU)),Rn(1),ws("> ",u.name," ")}}const HU=function(){return["/file-detection"]};function WU(f,l){if(1&f&&(tt(0,"a",6),Kt(1),$e()),2&f){const u=Qs().$implicit;wn("title",u.name+" details")("routerLink",da(3,HU)),Rn(1),ws("> ",u.name," ")}}const zU=function(){return["/camera-detection"]};function YU(f,l){if(1&f&&(tt(0,"a",6),Kt(1),$e()),2&f){const u=Qs().$implicit;wn("title",u.name+" details")("routerLink",da(3,zU)),Rn(1),ws("> ",u.name," ")}}function $U(f,l){if(1&f&&(tt(0,"p"),Kt(1),$e()),2&f){const u=Qs().$implicit;Rn(1),ws("Description: ",u.description,"")}}function XU(f,l){if(1&f&&(tt(0,"div")(1,"h3")(2,"div"),Cs(3,UU,2,4,"ng-template",5),$e(),tt(4,"div"),Cs(5,GU,2,4,"ng-template",5),$e(),tt(6,"div"),Cs(7,WU,2,4,"ng-template",5),$e(),tt(8,"div"),Cs(9,YU,2,4,"ng-template",5),$e()(),Cs(10,$U,2,1,"p",3),$e()),2&f){const u=l.$implicit;Rn(3),wn("ngIf","reader"===u.id),Rn(2),wn("ngIf","scanner"===u.id),Rn(2),wn("ngIf","file-detection"===u.id),Rn(2),wn("ngIf","camera-detection"===u.id),Rn(1),wn("ngIf",u.description)}}function qU(f,l){if(1&f&&(tt(0,"div")(1,"h2"),Kt(2,"Examples"),$e(),Cs(3,XU,11,5,"div",4),$e()),2&f){const u=Qs();Rn(3),wn("ngForOf",u.products)}}let ZU=(()=>{class f{constructor(u){this.sharedService=u,this.products=rU,this.inputText="",this.processedText="",this.placeholderText="DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ=="}activate(){var u=this;return se(function*(){u.processedText=u.inputText.toUpperCase(),sn.engineResourcePaths={std:"assets/dynamsoft-capture-vision-std/",dip:"assets/dynamsoft-image-processing/",core:"assets/dynamsoft-core/",license:"assets/dynamsoft-license/",cvr:"assets/dynamsoft-capture-vision-router/",dbr:"assets/dynamsoft-barcode-reader/",dce:"assets/dynamsoft-camera-enhancer/",ddn:"assets/dynamsoft-document-normalizer/"};try{let g=""===u.inputText?u.placeholderText:u.inputText;yield Bt.initLicense(g,!0),yield sn.loadWasm(["DBR","DDN"]),u.toggleDivVisibility()}catch(g){alert(g)}})()}toggleDivVisibility(){this.sharedService.toggleShowDiv()}get showDiv(){return this.sharedService.getShowDiv()}}return f.\u0275fac=function(u){return new(u||f)(ye(BU))},f.\u0275cmp=ar({type:f,selectors:[["app-product-list"]],decls:9,vars:3,consts:[["href","https://www.dynamsoft.com/customer/license/trialLicense","target","_blank"],["type","text",3,"ngModel","placeholder","ngModelChange"],[3,"click"],[4,"ngIf"],[4,"ngFor","ngForOf"],[3,"ngIf"],[3,"title","routerLink"]],template:function(u,g){1&u&&(tt(0,"div")(1,"div"),Kt(2," Get a License key from "),tt(3,"a",0),Kt(4,"here"),$e()(),tt(5,"input",1),kt("ngModelChange",function(m){return g.inputText=m}),$e(),tt(6,"button",2),kt("click",function(){return g.activate()}),Kt(7,"Activate SDK"),$e()(),Cs(8,qU,4,1,"div",3)),2&u&&(Rn(5),wn("ngModel",g.inputText)("placeholder",g.placeholderText),Rn(3),wn("ngIf",g.showDiv))},directives:[_h,lD,dm,mb,gb,uc],styles:[""]}),f})();class Pd{initOverlay(l){this.overlay=l,this.context=this.overlay.getContext("2d")}updateOverlay(l,u){this.overlay&&(this.overlay.width=l,this.overlay.height=u,this.clearOverlay())}clearOverlay(){this.context&&this.overlay&&(this.context.clearRect(0,0,this.overlay.width,this.overlay.height),this.context.strokeStyle="#ff0000",this.context.lineWidth=5)}drawOverlay(l,u){if(this.context){let g=l.points;this.context.beginPath(),this.context.moveTo(g[0].x,g[0].y),this.context.lineTo(g[1].x,g[1].y),this.context.lineTo(g[2].x,g[2].y),this.context.lineTo(g[3].x,g[3].y),this.context.lineTo(g[0].x,g[0].y),this.context.stroke(),this.context.font="18px Verdana",this.context.fillStyle="#ff0000";let p=[g[0].x,g[1].x,g[2].x,g[3].x],m=[g[0].y,g[1].y,g[2].y,g[3].y];p.sort(function(b,O){return b-O}),m.sort(function(b,O){return O-b}),this.context.fillText(u,p[0],m[0]+50)}}}let KU=(()=>{class f{constructor(){this.isLoaded=!1,this.overlayManager=new Pd}ngOnInit(){var u=this;this.overlayManager.initOverlay(document.getElementById("overlay")),se(function*(){u.cvr=yield St.createInstance(),u.isLoaded=!0})()}onChange(u){let p=u.currentTarget.files;if(p){let m=p.item(0);if(m){let v=new FileReader;v.onload=y=>{let b=document.getElementById("image");if(b){b.src=y.target.result;const O=new Image;O.onload=L=>{this.overlayManager.updateOverlay(O.width,O.height),this.cvr&&this.cvr.capture(m,"ReadBarcodes_Balance").then(N=>{console.log(N);let B=[],U=document.getElementById("result");try{let Y,$=N.items;if($.length>0){for(var W=0;W<$.length;++W){if($[W].type!==Yt.CRIT_BARCODE)continue;let q=$[W];B.push(q.text),Y=q.location,console.log(Y),this.overlayManager.drawOverlay(Y,q.text)}U&&(U.innerHTML=B.join(", "))}else U&&(U.innerHTML=B.join(", "))}catch(Y){alert(Y)}})},O.src=y.target.result}},v.readAsDataURL(m)}}}}return f.\u0275fac=function(u){return new(u||f)},f.\u0275cmp=ar({type:f,selectors:[["app-barcode-reader"]],decls:6,vars:0,consts:[["type","file","id","file","accept","image/*",3,"change"],["id","result"],["id","imageview"],["id","image"],["id","overlay"]],template:function(u,g){1&u&&(tt(0,"input",0),kt("change",function(m){return g.onChange(m)}),$e(),tt(1,"div"),Jn(2,"a",1),$e(),tt(3,"div",2),Jn(4,"img",3)(5,"canvas",4),$e())},styles:["#imageview[_ngcontent-%COMP%]{position:absolute;width:20vw}#image[_ngcontent-%COMP%]{position:relative;width:100%;height:100%}#overlay[_ngcontent-%COMP%]{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:contain}"]}),f})(),QU=(()=>{class f{constructor(){this.isLoaded=!1,this.cameraInfo={},this.isDestroyed=!1,this.overlayManager=new Pd}ngOnInit(){var u=this;this.videoSelect=document.querySelector("select#videoSource"),this.overlayManager.initOverlay(document.getElementById("overlay")),se(function*(){yield u.initBarcodeScanner()})()}ngOnDestroy(){var u,g;this.isDestroyed=!0;try{null===(u=this.cvr)||void 0===u||u.dispose(),null===(g=this.cameraEnhancer)||void 0===g||g.dispose()}catch(p){}}updateResolution(){if(this.cameraEnhancer&&this.overlayManager){let u=this.cameraEnhancer.getResolution();this.overlayManager.updateOverlay(u.width,u.height)}}initBarcodeScanner(){var u=this;return se(function*(){var g,p,m,v;const y=yield on.createInstance();u.cameraEnhancer=yield it.createInstance(y),u.isLoaded=!0;let b=document.getElementById("videoContainer");if(b){b.append(y.getUIElement()),null===(p=null===(g=y.getUIElement().shadowRoot)||void 0===g?void 0:g.querySelector(".dce-sel-camera"))||void 0===p||p.setAttribute("style","display: none"),null===(v=null===(m=y.getUIElement().shadowRoot)||void 0===m?void 0:m.querySelector(".dce-sel-resolution"))||void 0===v||v.setAttribute("style","display: none");let O=yield u.cameraEnhancer.getAllCameras();if(u.listCameras(O),u.cvr=yield St.createInstance(),u.isDestroyed||(u.cvr.setInput(u.cameraEnhancer),u.cvr.addResultReceiver({onCapturedResultReceived:L=>{u.overlayManager.clearOverlay();let N=[],B=document.getElementById("result");try{let W,Y=L.items;if(Y.length>0){for(var U=0;U{!L.barcodeResultItems.length||console.log(L)}}),u.cameraEnhancer.on("played",()=>{u.updateResolution()}),yield u.openCamera(),u.isDestroyed)||(yield u.cvr.startCapturing("ReadSingleBarcode"),u.isDestroyed))throw Error("VideoCapture Component Destroyed")}})()}openCamera(){var u=this;return se(function*(){if(u.overlayManager.clearOverlay(),u.videoSelect){let g=u.videoSelect.value;u.cameraEnhancer&&(yield u.cameraEnhancer.selectCamera(g),yield u.cameraEnhancer.open())}})()}listCameras(u){for(var g=0;g{class f{constructor(){this.isLoaded=!1,this.points=[],this.overlayManager=new Pd}ngOnDestroy(){var u;try{null===(u=this.cvr)||void 0===u||u.dispose()}catch(g){}}ngOnInit(){var u=this;this.overlayManager.initOverlay(document.getElementById("overlay")),se(function*(){u.cvr=yield St.createInstance(),u.isLoaded=!0})()}onRadioChange(u){var g=this;if(!this.cvr)return;let p=u.target,m=xr.ICM_COLOUR;"binary"===p.value?m=xr.ICM_BINARY:"grayscale"===p.value?m=xr.ICM_GRAYSCALE:"color"===p.value&&(m=xr.ICM_COLOUR);let v=this.cvr;se(function*(){let y=yield v.getSimplifiedSettings("NormalizeDocument_Default");y.documentSettings.colourMode=m,yield g.cvr.updateSettings("NormalizeDocument_Default",y),g.normalize(g.currentFile,g.points)})()}normalize(u,g){var p=this;return se(function*(){if(p.cvr){let m=yield p.cvr.getSimplifiedSettings("NormalizeDocument_Default");m.roi.points=g,m.roiMeasuredInPercentage=!1,yield p.cvr.updateSettings("NormalizeDocument_Default",m),p.cvr.capture(u,"NormalizeDocument_Default").then(v=>{if(0===v.items.length)return;let y=v.items[0],b=document.getElementById("normalizedImage");b.width=y.imageData.width,b.height=y.imageData.height;const O=b.getContext("2d");null==O||O.drawImage(y.toCanvas(),0,0)})}})()}onChange(u){var g=this;let m=u.currentTarget.files;if(m){let v=m.item(0);if(v){this.currentFile=v;let y=new FileReader;y.onload=b=>{let O=document.getElementById("image");if(O){O.src=b.target.result;const L=new Image;L.onload=function(){var N=se(function*(B){if(g.overlayManager.updateOverlay(L.width,L.height),g.cvr){let U=yield g.cvr.capture(v,"DetectDocumentBoundaries_Default");if(U.items.length>0){let W=U.items[0];g.points=W.location.points,g.overlayManager.drawOverlay(W.location,""),g.normalize(v,g.points)}}});return function(B){return N.apply(this,arguments)}}(),L.src=b.target.result}},y.readAsDataURL(v)}}}}return f.\u0275fac=function(u){return new(u||f)},f.\u0275cmp=ar({type:f,selectors:[["app-file-detection"]],decls:20,vars:2,consts:[["id","loading-status",2,"font-size","x-large",3,"hidden"],[1,"row"],["for","binary"],["type","radio","name","templates","value","binary",3,"change"],["for","grayscale"],["type","radio","name","templates","value","grayscale",3,"change"],["for","color"],["type","radio","name","templates","value","color",3,"checked","change"],["type","file","title","file","id","file","accept","image/*",3,"change"],[1,"container"],["id","imageview"],["id","image","alt",""],["id","overlay"],["id","resultview"],["id","normalizedImage"]],template:function(u,g){1&u&&(tt(0,"span",0),Kt(1,"Loading Library..."),$e(),Jn(2,"br"),tt(3,"div",1)(4,"label",2)(5,"input",3),kt("change",function(m){return g.onRadioChange(m)}),$e(),Kt(6,"Black & White "),$e(),tt(7,"label",4)(8,"input",5),kt("change",function(m){return g.onRadioChange(m)}),$e(),Kt(9," Grayscale "),$e(),tt(10,"label",6)(11,"input",7),kt("change",function(m){return g.onRadioChange(m)}),$e(),Kt(12," Color "),$e()(),tt(13,"input",8),kt("change",function(m){return g.onChange(m)}),$e(),tt(14,"div",9)(15,"div",10),Jn(16,"img",11)(17,"canvas",12),$e(),tt(18,"div",13),Jn(19,"canvas",14),$e()()),2&u&&(wn("hidden",g.isLoaded),Rn(11),wn("checked",!0))},styles:["#imageview[_ngcontent-%COMP%]{position:relative;width:20vw}#image[_ngcontent-%COMP%]{position:relative;width:100%;height:100%}#overlay[_ngcontent-%COMP%]{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:contain}.container[_ngcontent-%COMP%]{align-items:center;border:3px solid orange}"]}),f})();const $_="VideoCapture Component Destroyed",ej=[{path:"",component:ZU},{path:"barcode-reader",component:KU},{path:"barcode-scanner",component:QU},{path:"file-detection",component:JU},{path:"camera-detection",component:(()=>{class f{constructor(){this.isLoaded=!1,this.cameraInfo={},this.isNormalized=!0,this.captured=[],this.isDestroyed=!1,this.points=[],this.isDetecting=!1,this.overlayManager=new Pd}ngOnDestroy(){var u,g;this.isDestroyed=!0;try{null===(u=this.cvr)||void 0===u||u.dispose(),null===(g=this.cameraEnhancer)||void 0===g||g.dispose()}catch(p){}}ngOnInit(){var u=this;this.videoSelect=document.querySelector("select#videoSource"),this.overlayManager.initOverlay(document.getElementById("overlay")),se(function*(){var g,p,m,v;u.cameraView=yield on.createInstance(),u.cameraEnhancer=yield it.createInstance(u.cameraView),u.isLoaded=!0;let y=document.getElementById("videoContainer");if(y){y.append(u.cameraView.getUIElement()),null===(p=null===(g=u.cameraView.getUIElement().shadowRoot)||void 0===g?void 0:g.querySelector(".dce-sel-camera"))||void 0===p||p.setAttribute("style","display: none"),null===(v=null===(m=u.cameraView.getUIElement().shadowRoot)||void 0===m?void 0:m.querySelector(".dce-sel-resolution"))||void 0===v||v.setAttribute("style","display: none");let b=yield u.cameraEnhancer.getAllCameras();if(u.listCameras(b),u.cvr=yield St.createInstance(),u.isDestroyed)throw Error($_);u.cvr.setInput(u.cameraEnhancer);let O=yield u.cvr.getSimplifiedSettings("DetectDocumentBoundaries_Default");if(O.capturedResultItemTypes|=Yt.CRIT_ORIGINAL_IMAGE,yield u.cvr.updateSettings("DetectDocumentBoundaries_Default",O),u.cvr.addResultReceiver({onCapturedResultReceived:L=>{u.overlayManager.clearOverlay();try{let U=L.items;if(U.length>0)for(var B=0;B{u.updateResolution()}),yield u.openCamera(),u.isDestroyed||u.isDestroyed)throw Error($_)}})()}openCamera(){var u=this;return se(function*(){if(u.overlayManager.clearOverlay(),u.videoSelect){let g=u.videoSelect.value;u.cameraEnhancer&&(yield u.cameraEnhancer.selectCamera(u.cameraInfo[g]),yield u.cameraEnhancer.open())}})()}listCameras(u){for(var g=0;g{if(0===v.items.length)return;let y=v.items[0],b=document.getElementById("normalizedImage");b.width=y.imageData.width,b.height=y.imageData.height;const O=b.getContext("2d");null==O||O.drawImage(y.toCanvas(),0,0)})}})()}captureDocument(){this.isNormalized=!1}toggleDetection(){var u,g,p;this.isDetecting?(this.isDetecting=!1,null===(u=this.cvr)||void 0===u||u.stopCapturing(),null===(g=this.cameraView)||void 0===g||g.clearAllInnerDrawingItems(),this.overlayManager.clearOverlay(),document.getElementById("detectButton").textContent="Start Detection"):(this.isDetecting=!0,document.getElementById("detectButton").textContent="Stop Detection",null===(p=this.cvr)||void 0===p||p.startCapturing("DetectDocumentBoundaries_Default"))}updateResolution(){if(this.cameraEnhancer&&this.overlayManager){let u=this.cameraEnhancer.getResolution();this.overlayManager.updateOverlay(u.width,u.height)}}}return f.\u0275fac=function(u){return new(u||f)},f.\u0275cmp=ar({type:f,selectors:[["app-camera-detection"]],decls:28,vars:2,consts:[["id","document-scanner"],["id","loading-status",2,"font-size","x-large",3,"hidden"],[1,"row"],["for","binary"],["type","radio","name","templates","value","binary",3,"change"],["for","grayscale"],["type","radio","name","templates","value","grayscale",3,"change"],["for","color"],["type","radio","name","templates","value","color",3,"checked","change"],["for","videoSource"],["id","videoSource",3,"change"],["id","detectButton",3,"click"],["id","captureButton",3,"click"],["id","videoview"],["id","videoContainer",1,"dce-video-container"],["id","overlay"],[1,"container"],["id","resultview"],["id","normalizedImage"]],template:function(u,g){1&u&&(tt(0,"div",0)(1,"span",1),Kt(2,"Loading Library..."),$e(),Jn(3,"br"),tt(4,"div",2)(5,"label",3)(6,"input",4),kt("change",function(m){return g.onRadioChange(m)}),$e(),Kt(7,"Black & White "),$e(),tt(8,"label",5)(9,"input",6),kt("change",function(m){return g.onRadioChange(m)}),$e(),Kt(10," Grayscale "),$e(),tt(11,"label",7)(12,"input",8),kt("change",function(m){return g.onRadioChange(m)}),$e(),Kt(13," Color "),$e()(),tt(14,"div")(15,"label",9),Kt(16,"Video Source: "),tt(17,"select",10),kt("change",function(){return g.openCamera()}),$e()(),tt(18,"button",11),kt("click",function(){return g.toggleDetection()}),Kt(19,"Start Detection"),$e(),tt(20,"button",12),kt("click",function(){return g.captureDocument()}),Kt(21,"Capture Document"),$e()(),tt(22,"div",13),Jn(23,"div",14)(24,"canvas",15),$e(),tt(25,"div",16)(26,"div",17),Jn(27,"canvas",18),$e()()()),2&u&&(Rn(1),wn("hidden",g.isLoaded),Rn(11),wn("checked",!0))},styles:["#videoview[_ngcontent-%COMP%]{position:absolute;width:40vw;height:40vh}#videoContainer[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;z-index:1}#overlay[_ngcontent-%COMP%]{position:absolute;top:0;left:0;width:100%;height:100%;z-index:2;object-fit:contain}#normalizedImage[_ngcontent-%COMP%]{width:20vw;top:60%;position:absolute;z-index:2}"]}),f})()}];let tj=(()=>{class f{}return f.\u0275fac=function(u){return new(u||f)},f.\u0275mod=lr({type:f}),f.\u0275inj=Ui({imports:[[$S.forRoot(ej)],$S]}),f})();const nj=function(){return["/"]};let ij=(()=>{class f{constructor(){}ngOnInit(){}}return f.\u0275fac=function(u){return new(u||f)},f.\u0275cmp=ar({type:f,selectors:[["app-top-bar"]],decls:3,vars:2,consts:[[3,"routerLink"]],template:function(u,g){1&u&&(tt(0,"a",0)(1,"h1"),Kt(2,"Dynamsoft Capture Vision SDK"),$e()()),2&u&&wn("routerLink",da(1,nj))},directives:[uc],styles:[""]}),f})(),rj=(()=>{class f{constructor(){this.title="angular-barcode-qr-code-scanner"}}return f.\u0275fac=function(u){return new(u||f)},f.\u0275cmp=ar({type:f,selectors:[["app-root"]],decls:3,vars:0,consts:[[1,"container"]],template:function(u,g){1&u&&(Jn(0,"app-top-bar"),tt(1,"div",0),Jn(2,"router-outlet"),$e())},directives:[ij,Lm],styles:[""]}),f})(),sj=(()=>{class f{}return f.\u0275fac=function(u){return new(u||f)},f.\u0275mod=lr({type:f,bootstrap:[rj]}),f.\u0275inj=Ui({providers:[],imports:[[Tk,tj,W2]]}),f})();(function cP(){WE=!1})(),Sk().bootstrapModule(sj).catch(f=>console.error(f))}},Vt=>{Vt(Vt.s=727)}]); \ No newline at end of file