PageSourceSearch

https://openreviewer-reviewer-arena.hf.space/assets/Index-YhvySncB.js

js openreviewer-reviewer-arena.hf.space collected 2026-10-03 10:22:06 UTC 539,276 bytes, 1,173 lines download raw bytes

1import{W as Cf,S as If}from"./ImageUploader-BgZNxhRR.js";import{B as mu}from"./Button-CUfznalD.js";import{w as Ot,I as cs,e as gu,S as bu}from"./Index-DT6VPx-K.js";import"./Image-BDs3hydk.js";/* empty css                                              */import{p as to}from"./index-DQnOSUE6.js";import{g as vu}from"./_commonjsHelpers-BosuxZz1.js";import"./url-BybKzMWq.js";import{C as Rf}from"./Check-Ck0iADAu.js";import{U as Mf}from"./Undo-CpmTQw3B.js";import{U as Pf}from"./ModifyUpload.svelte_svelte_type_style_lang-XgQKUhC8.js";import{I as fh}from"./Image-Bsh8Umrh.js";import{I as kf}from"./Upload-Cp8Go_XF.js";import{W as Bf}from"./SelectSource-DGT5JIov.js";import{B as Df}from"./BlockLabel-BwPib9nm.js";import"./Blocks-Dx73k_4L.js";import"./Empty-eMcf0w5h.js";import"./ShareButton-BGgKOk1e.js";import"./DownloadLink-Dgc8RBAI.js";import"./file-url-C2d3k_cF.js";import"./DropdownArrow-DBFeRcfr.js";import"./svelte/svelte.js";import"./__vite-browser-external-DFe-p4yY.js";const{SvelteComponent:Ff,append:Ph,attr:xi,detach:Lf,init:Nf,insert:Of,noop:eo,safe_not_equal:Uf,svg_element:io}=window.__gradio__svelte__internal;function Gf(s){let t,e,i;return{c(){t=io("svg"),e=io("path"),i=io("path"),xi(e,"d","M28.828 3.172a4.094 4.094 0 0 0-5.656 0L4.05 22.292A6.954 6.954 0 0 0 2 27.242V30h2.756a6.952 6.952 0 0 0 4.95-2.05L28.828 8.829a3.999 3.999 0 0 0 0-5.657zM10.91 18.26l2.829 2.829l-2.122 2.121l-2.828-2.828zm-2.619 8.276A4.966 4.966 0 0 1 4.756 28H4v-.759a4.967 4.967 0 0 1 1.464-3.535l1.91-1.91l2.829 2.828zM27.415 7.414l-12.261 12.26l-2.829-2.828l12.262-12.26a2.047 2.047 0 0 1 2.828 0a2 2 0 0 1 0 2.828z"),xi(e,"fill","currentColor"),xi(i,"d","M6.5 15a3.5 3.5 0 0 1-2.475-5.974l3.5-3.5a1.502 1.502 0 0 0 0-2.121a1.537 1.537 0 0 0-2.121 0L3.415 5.394L2 3.98l1.99-1.988a3.585 3.585 0 0 1 4.95 0a3.504 3.504 0 0 1 0 4.949L5.439 10.44a1.502 1.502 0 0 0 0 2.121a1.537 1.537 0 0 0 2.122 0l4.024-4.024L13 9.95l-4.025 4.024A3.475 3.475 0 0 1 6.5 15z"),xi(i,"fill","currentColor"),xi(t,"width","100%"),xi(t,"height","100%"),xi(t,"viewBox","0 0 32 32")},m(r,n){Of(r,t,n),Ph(t,e),Ph(t,i)},p:eo,i:eo,o:eo,d(r){r&&Lf(t)}}}let Hf=class extends Ff{constructor(t){super(),Nf(this,t,null,Gf,Uf,{})}};const{SvelteComponent:zf,append:$f,attr:$i,detach:Xf,init:Vf,insert:Wf,noop:so,safe_not_equal:jf,svg_element:kh}=window.__gradio__svelte__internal;function Yf(s){let t,e;return{c(){t=kh("svg"),e=kh("path"),$i(e,"fill","currentColor"),$i(e,"d","M2.753 2.933a.75.75 0 0 1 .814-.68l3.043.272c2.157.205 4.224.452 5.922.732c1.66.273 3.073.594 3.844.983c.197.1.412.233.578.415c.176.192.352.506.28.9c-.067.356-.304.59-.487.729a3.001 3.001 0 0 1-.695.369c-1.02.404-2.952.79-5.984 1.169c-1.442.18-2.489.357-3.214.522c.205.045.43.089.674.132c.992.174 2.241.323 3.568.437a31.21 31.21 0 0 1 3.016.398c.46.087.893.186 1.261.296c.352.105.707.236.971.412c.13.086.304.225.42.437a.988.988 0 0 1 .063.141A1.75 1.75 0 0 0 14.5 12.25v.158c-.758.154-1.743.302-2.986.444c-2.124.243-3.409.55-4.117.859c-.296.128-.442.236-.508.3c.026.037.073.094.156.17c.15.138.369.29.65.45c.56.316 1.282.61 1.979.838l2.637.814a.75.75 0 1 1-.443 1.433l-2.655-.819c-.754-.247-1.58-.578-2.257-.96a5.082 5.082 0 0 1-.924-.65c-.255-.233-.513-.544-.62-.935c-.12-.441-.016-.88.274-1.244c.261-.328.656-.574 1.113-.773c.92-.4 2.387-.727 4.545-.974c1.366-.156 2.354-.313 3.041-.462a16.007 16.007 0 0 0-.552-.114a29.716 29.716 0 0 0-2.865-.378c-1.352-.116-2.649-.27-3.7-.454c-.524-.092-1-.194-1.395-.307c-.376-.106-.75-.241-1.021-.426a1.186 1.186 0 0 1-.43-.49a.934.934 0 0 1 .059-.873c.13-.213.32-.352.472-.442a3.23 3.23 0 0 1 .559-.251c.807-.287 2.222-.562 4.37-.83c2.695-.338 4.377-.666 5.295-.962c-.638-.21-1.623-.427-2.89-.635c-1.65-.273-3.679-.515-5.816-.718l-3.038-.272a.75.75 0 0 1-.68-.814M17 12.25a.75.75 0 0 0-1.5 0v4.19l-.72-.72a.75.75 0 1 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0l2-2a.75.75 0 1 0-1.06-1.06l-.72.72z"),$i(t,"xmlns","http://www.w3.org/2000/svg"),$i(t,"width","100%"),$i(t,"height","100%"),$i(t,"viewBox","0 0 24 24")},m(i,r){Wf(i,t,r),$f(t,e)},p:so,i:so,o:so,d(i){i&&Xf(t)}}}class qf extends zf{constructor(t){super(),Vf(this,t,null,Yf,jf,{})}}const{SvelteComponent:Zf,append:Kf,attr:Xi,detach:Jf,init:Qf,insert:t_,noop:ro,safe_not_equal:e_,svg_element:Bh}=window.__gradio__svelte__internal;function i_(s){let t,e;return{c(){t=Bh("svg"),e=Bh("path"),Xi(e,"fill","currentColor"),Xi(e,"d","M17 23v-4H7q-.825 0-1.413-.588T5 17V7H1V5h4V1h2v16h16v2h-4v4h-2Zm0-8V7H9V5h8q.825 0 1.413.588T19 7v8h-2Z"),Xi(t,"xmlns","http://www.w3.org/2000/svg"),Xi(t,"width","100%"),Xi(t,"height","100%"),Xi(t,"viewBox","0 0 24 24")},m(i,r){t_(i,t,r),Kf(t,e)},p:ro,i:ro,o:ro,d(i){i&&Jf(t)}}}let s_=class extends Zf{constructor(t){super(),Qf(this,t,null,i_,e_,{})}};const{SvelteComponent:r_,append:no,attr:ne,detach:n_,init:o_,insert:a_,noop:oo,safe_not_equal:h_,svg_element:ir}=window.__gradio__svelte__internal;function l_(s){let t,e,i,r;return{c(){t=ir("svg"),e=ir("g"),i=ir("path"),r=ir("path"),ne(i,"fill","currentColor"),ne(i,"d","m5.505 11.41l.53.53l-.53-.53ZM3 14.952h-.75H3ZM9.048 21v.75V21ZM11.41 5.505l-.53-.53l.53.53Zm1.831 12.34a.75.75 0 0 0 1.06-1.061l-1.06 1.06ZM7.216 9.697a.75.75 0 1 0-1.06 1.061l1.06-1.06Zm10.749 2.362l-5.905 5.905l1.06 1.06l5.905-5.904l-1.06-1.06Zm-11.93-.12l5.905-5.905l-1.06-1.06l-5.905 5.904l1.06 1.06Zm0 6.025c-.85-.85-1.433-1.436-1.812-1.933c-.367-.481-.473-.79-.473-1.08h-1.5c0 .749.312 1.375.78 1.99c.455.596 1.125 1.263 1.945 2.083l1.06-1.06Zm-1.06-7.086c-.82.82-1.49 1.488-1.945 2.084c-.468.614-.78 1.24-.78 1.99h1.5c0-.29.106-.6.473-1.08c.38-.498.962-1.083 1.812-1.933l-1.06-1.06Zm7.085 7.086c-.85.85-1.435 1.433-1.933 1.813c-.48.366-.79.472-1.08.472v1.5c.75 0 1.376-.312 1.99-.78c.596-.455 1.264-1.
1125 2.084-1.945l-1.06-1.06Zm-7.085 1.06c.82.82 1.487 1.49 2.084 1.945c.614.468 1.24.78 1.989.78v-1.5c-.29 0-.599-.106-1.08-.473c-.497-.38-1.083-.962-1.933-1.812l-1.06 1.06Zm12.99-12.99c.85.85 1.433 1.436 1.813 1.933c.366.481.472.79.472 1.08h1.5c0-.749-.312-1.375-.78-1.99c-.455-.596-1.125-1.263-1.945-2.083l-1.06 1.06Zm1.06 7.086c.82-.82 1.49-1.488 1.945-2.084c.468-.614.78-1.24.78-1.99h-1.5c0 .29-.106.6-.473 1.08c-.38.498-.962 1.083-1.812 1.933l1.06 1.06Zm0-8.146c-.82-.82-1.487-1.49-2.084-1.945c-.614-.468-1.24-.78-1.989-.78v1.5c.29 0 .599.106 1.08.473c.497.38 1.083.962 1.933 1.812l1.06-1.06Zm-7.085 1.06c.85-.85 1.435-1.433 1.933-1.812c.48-.367.79-.473 1.08-.473v-1.5c-.75 0-1.376.312-1.99.78c-.596.455-1.264 1.125-2.084 1.945l1.06 1.06Zm2.362 10.749L7.216 9.698l-1.06 1.061l7.085 7.085l1.06-1.06Z"),ne(r,"stroke","currentColor"),ne(r,"stroke-linecap","round"),ne(r,"stroke-width","1.5"),ne(r,"d","M9 21h12"),ne(e,"fill","none"),ne(t,"xmlns","http://www.w3.org/2000/svg"),ne(t,"width","100%"),ne(t,"height","100%"),ne(t,"viewBox","0 0 24 24")},m(n,o){a_(n,t,o),no(t,e),no(e,i),no(e,r)},p:oo,i:oo,o:oo,d(n){n&&n_(t)}}}class c_ extends r_{constructor(t){super(),o_(this,t,null,l_,h_,{})}}const{SvelteComponent:u_,append:d_,attr:Vi,detach:f_,init:__,insert:p_,noop:ao,safe_not_equal:m_,svg_element:Dh}=window.__gradio__svelte__internal;function g_(s){let t,e;return{c(){t=Dh("svg"),e=Dh("path"),Vi(e,"fill","currentColor"),Vi(e,"d","M21.03 2.97a3.578 3.578 0 0 0-5.06 0L14 4.94l-.013-.013a1.75 1.75 0 0 0-2.475 0l-.585.586a1.75 1.75 0 0 0 0 2.475l.012.012l-6.78 6.78a2.25 2.25 0 0 0-.659 1.592v.687l-1.28 2.347c-.836 1.533.841 3.21 2.374 2.375l2.347-1.28h.688a2.25 2.25 0 0 0 1.59-.66L16 13.061l.012.012a1.75 1.75 0 0 0 2.475 0l.586-.585a1.75 1.75 0 0 0 0-2.475L19.061 10l1.97-1.97a3.578 3.578 0 0 0 0-5.06ZM12 9.061l2.94 2.94l-6.78 6.78a.75.75 0 0 1-.531.22H6.75a.75.75 0 0 0-.359.09l-2.515 1.373a.234.234 0 0 1-.159.032a.264.264 0 0 1-.138-.075a.264.264 0 0 1-.075-.138a.234.234 0 0 1 .033-.158l1.372-2.515A.75.75 0 0 0 5 17.25v-.878a.75.75 0 0 1 .22-.53L12 9.06Z"),Vi(t,"xmlns","http://www.w3.org/2000/svg"),Vi(t,"width","100%"),Vi(t,"height","100%"),Vi(t,"viewBox","0 0 24 24")},m(i,r){p_(i,t,r),d_(t,e)},p:ao,i:ao,o:ao,d(i){i&&f_(t)}}}class b_ extends u_{constructor(t){super(),__(this,t,null,g_,m_,{})}}const{SvelteComponent:v_,append:Fh,attr:qt,detach:y_,init:x_,insert:w_,noop:ho,safe_not_equal:T_,svg_element:lo}=window.__gradio__svelte__internal;function E_(s){let t,e,i;return{c(){t=lo("svg"),e=lo("path"),i=lo("path"),qt(e,"d","M1.35327 10.9495L6.77663 15.158C7.12221 15.4229 7.50051 15.5553 7.91154 15.5553C8.32258 15.5553 8.70126 15.4229 9.0476 15.158L14.471 10.9495"),qt(e,"stroke","currentColor"),qt(e,"stroke-width","1.5"),qt(e,"stroke-linecap","round"),qt(i,"d","M7.23461 11.4324C7.23406 11.432 7.2335 11.4316 7.23295 11.4312L1.81496 7.2268C1.81471 7.22661 1.81446 7.22641 1.8142 7.22621C1.52269 6.99826 1.39429 6.73321 1.39429 6.37014C1.39429 6.00782 1.52236 5.74301 1.81325 5.51507C1.8136 5.5148 1.81394 5.51453 1.81428 5.51426L7.2331 1.30812C7.45645 1.13785 7.67632 1.06653 7.91159 1.06653C8.14692 1.06653 8.36622 1.13787 8.58861 1.30787C8.58915 1.30828 8.58969 1.30869 8.59023 1.30911L14.0082 5.51462C14.0085 5.51485 14.0088 5.51507 14.0091 5.51529C14.3008 5.74345 14.4289 6.00823 14.4289 6.37014C14.4289 6.73356 14.3006 6.99862 14.01 7.22634C14.0096 7.22662 14.0093 7.22689 14.0089 7.22717L8.59007 11.4322C8.36672 11.6024 8.14686 11.6738 7.91159 11.6738C7.67628 11.6738 7.45699 11.6024 7.23461 11.4324Z"),qt(i,"stroke","currentColor"),qt(i,"stroke-width","1.5"),qt(t,"width","100%"),qt(t,"height","100%"),qt(t,"viewBox","0 0 17 17"),qt(t,"fill","none"),qt(t,"xmlns","http://www.w3.org/2000/svg")},m(r,n){w_(r,t,n),Fh(t,e),Fh(t,i)},p:ho,i:ho,o:ho,d(r){r&&y_(t)}}}class A_ extends v_{constructor(t){super(),x_(this,t,null,E_,T_,{})}}const{SvelteComponent:S_,append:Cs,attr:Dt,detach:C_,init:I_,insert:R_,noop:co,safe_not_equal:M_,svg_element:Wi}=window.__gradio__svelte__internal;function P_(s){let t,e,i,r,n,o;return{c(){t=Wi("svg"),e=Wi("g"),i=Wi("path"),r=Wi("circle"),n=Wi("circle"),o=Wi("path"),Dt(i,"d","M2 12.026c0 5.146 3.867 9.387 8.847 9.96c.735.085 1.447-.228 1.97-.753a1.
168 1.68 0 0 0 0-2.372c-.523-.525-.95-1.307-.555-1.934c1.576-2.508 9.738 3.251 9.738-4.9C22 6.488 17.523 2 12 2S2 6.489 2 12.026Z"),Dt(r,"cx","17.5"),Dt(r,"cy","11.5"),Dt(r,"r",".75"),Dt(n,"cx","6.5"),Dt(n,"cy","11.5"),Dt(n,"r",".75"),Dt(o,"d","M10.335 7a.75.75 0 1 1-1.5 0a.75.75 0 0 1 1.5 0Zm4.915 0a.75.75 0 1 1-1.5 0a.75.75 0 0 1 1.5 0Z"),Dt(e,"fill","none"),Dt(e,"stroke","currentColor"),Dt(e,"stroke-width","1.5"),Dt(t,"xmlns","http://www.w3.org/2000/svg"),Dt(t,"width","100%"),Dt(t,"height","100%"),Dt(t,"viewBox","0 0 24 24")},m(a,h){R_(a,t,h),Cs(t,e),Cs(e,i),Cs(e,r),Cs(e,n),Cs(e,o)},p:co,i:co,o:co,d(a){a&&C_(t)}}}class k_ extends S_{constructor(t){super(),I_(this,t,null,P_,M_,{})}}const{SvelteComponent:B_,append:Lh,attr:Zt,detach:D_,init:F_,insert:L_,noop:uo,safe_not_equal:N_,set_style:O_,svg_element:fo}=window.__gradio__svelte__internal;function U_(s){let t,e,i;return{c(){t=fo("svg"),e=fo("polyline"),i=fo("path"),Zt(e,"points","1 4 1 10 7 10"),Zt(i,"d","M3.51 15a9 9 0 1 0 2.13-9.36L1 10"),Zt(t,"xmlns","http://www.w3.org/2000/svg"),Zt(t,"width","100%"),Zt(t,"height","100%"),Zt(t,"viewBox","0 0 24 24"),Zt(t,"fill","none"),Zt(t,"stroke","currentColor"),Zt(t,"stroke-width","2"),Zt(t,"stroke-linecap","round"),Zt(t,"stroke-linejoin","round"),Zt(t,"class","feather feather-rotate-ccw"),O_(t,"transform","rotateY(180deg)")},m(r,n){L_(r,t,n),Lh(t,e),Lh(t,i)},p:uo,i:uo,o:uo,d(r){r&&D_(t)}}}class G_ extends B_{constructor(t){super(),F_(this,t,null,U_,N_,{})}}const{SvelteComponent:H_,append:qe,attr:gt,detach:z_,init:$_,insert:X_,noop:_o,safe_not_equal:V_,svg_element:Ze,text:W_}=window.__gradio__svelte__internal;function j_(s){let t,e,i,r,n,o,a,h,l;return{c(){t=Ze("svg"),e=Ze("defs"),i=Ze("style"),r=W_(`.cls-1 {
2				fill: none;
3			}`),n=Ze("rect"),o=Ze("rect"),a=Ze("path"),h=Ze("rect"),l=Ze("rect"),gt(n,"x","12"),gt(n,"y","12"),gt(n,"width","2"),gt(n,"height","12"),gt(o,"x","18"),gt(o,"y","12"),gt(o,"width","2"),gt(o,"height","12"),gt(a,"d","M4,6V8H6V28a2,2,0,0,0,2,2H24a2,2,0,0,0,2-2V8h2V6ZM8,28V8H24V28Z"),gt(h,"x","12"),gt(h,"y","2"),gt(h,"width","8"),gt(h,"height","2"),gt(l,"id","_Transparent_Rectangle_"),gt(l,"data-name","<Transparent Rectangle>"),gt(l,"class","cls-1"),gt(l,"width","32"),gt(l,"height","32"),gt(t,"id","icon"),gt(t,"xmlns","http://www.w3.org/2000/svg"),gt(t,"viewBox","0 0 32 32"),gt(t,"fill","currentColor")},m(c,u){X_(c,t,u),qe(t,e),qe(e,i),qe(i,r),qe(t,n),qe(t,o),qe(t,a),qe(t,h),qe(t,l)},p:_o,i:_o,o:_o,d(c){c&&z_(t)}}}class Y_ extends H_{constructor(t){super(),$_(this,t,null,j_,V_,{})}}const{SvelteComponent:q_,attr:Z_,create_slot:K_,detach:J_,element:Q_,flush:tp,get_all_dirty_from_scope:ep,get_slot_changes:ip,init:sp,insert:rp,safe_not_equal:np,toggle_class:Nh,transition_in:op,transition_out:ap,update_slot_base:hp}=window.__gradio__svelte__internal;function lp(s){let t,e;const i=s[2].default,r=K_(i,s,s[1],null);return{c(){t=Q_("div"),r&&r.c(),Z_(t,"class","svelte-1ua59x3"),Nh(t,"show_border",s[0])},m(n,o){rp(n,t,o),r&&r.m(t,null),e=!0},p(n,[o]){r&&r.p&&(!e||o&2)&&hp(r,i,n,n[1],e?ip(i,n[1],o,null):ep(n[1]),null),(!e||o&1)&&Nh(t,"show_border",n[0])},i(n){e||(op(r,n),e=!0)},o(n){ap(r,n),e=!1},d(n){n&&J_(t),r&&r.d(n)}}}function cp(s,t,e){let{$$slots:i={},$$scope:r}=t,{show_border:n=!1}=t;return s.$$set=o=>{"show_border"in o&&e(0,n=o.show_border),"$$scope"in o&&e(1,r=o.$$scope)},[n,r,i]}class up extends q_{constructor(t){super(),sp(this,t,cp,lp,np,{show_border:0})}get show_border(){return this.$$.ctx[0]}set show_border(t){this.$$set({show_border:t}),tp()}}const{SvelteComponent:dp,add_iframe_resize_listener:fp,add_render_callback:_p,attr:pp,binding_callbacks:mp,check_outros:gp,component_subscribe:po,create_component:yu,create_slot:bp,destroy_component:xu,detach:rn,element:vp,empty:wu,ensure_array_like:Oh,flush:yp,get_all_dirty_from_scope:xp,get_slot_changes:wp,group_outros:Tp,init:Ep,insert:nn,mount_component:Tu,outro_and_destroy_block:Ap,safe_not_equal:Sp,set_store_value:Uh,space:Cp,transition_in:on,transition_out:an,update_keyed_each:Ip,update_slot_base:Rp}=window.__gradio__svelte__internal,{getContext:Mp,setContext:Pp}=window.__gradio__svelte__internal;function Gh(s,t,e){const i=s.slice();return i[21]=t[e],i}function Hh(s,t){let e,i,r;function n(...o){return t[12](t[21],...o)}return i=new cs({props:{highlight:t[3]===t[21],Icon:t[7][t[21]].icon,size:"medium",padded:!1,label:t[7][t[21]].label+" button",transparent:!0,offset:t[21]==="draw"?-2:t[21]==="erase"?-6:0}}),i.$on("click",n),{key:s,first:null,c(){e=wu(),yu(i.$$.fragment),this.first=e},m(o,a){nn(o,e,a),Tu(i,o,a),r=!0},p(o,a){t=o;const h={};a&10&&(h.highlight=t[3]===t[21]),a&2&&(h.Icon=t[7][t[21]].icon),a&2&&(h.label=t[7][t[21]].label+" button"),a&2&&(h.offset=t[21]==="draw"?-2:t[21]==="erase"?-6:0),i.$set(h)},i(o){r||(on(i.$$.fragment,o),r=!0)},o(o){an(i.$$.fragment,o),r=!1},d(o){o&&rn(e),xu(i,o)}}}function kp(s){let t=[],e=new Map,i,r,n=Oh(s[1]);const o=a=>a[21];for(let a=0;a<n.length;a+=1){let h=Gh(s,n,a),l=o(h);e.set(l,t[a]=Hh(l,h))}return{c(){for(let a=0;a<t.length;a+=1)t[a].c();i=wu()},m(a,h){for(let l=0;l<t.length;l+=1)t[l]&&t[l].m(a,h);nn(a,i,h),r=!0},p(a,h){h&394&&(n=Oh(a[1]),Tp(),t=Ip(t,h,o,1,a,n,e,i.parentNode,Ap,Hh,i,Gh),gp())},i(a){if(!r){for(let h=0;h<n.length;h+=1)on(t[h]);r=!0}},o(a){for(let h=0;h<t.length;h+=1)an(t[h]);r=!1},d(a){a&&rn(i);for(let h=0;h<t.length;h+=1)t[h].d(a)}}}function Bp(s){let t,e,i,r,n;const o=s[11].default,a=bp(o,s,s[15],null);return i=new up({props:{show_border:!1,$$slots:{default:[kp]},$$scope:{ctx:s}}}),{c(){a&&a.c(),t=Cp(),e=vp("div"),yu(i.$$.fragment),pp(e,"class","toolbar-wrap svelte-k9d7m2"),_p(()=>s[13].call(e))},m(h,l){a&&a.m(h,l),nn(h,t,l),nn(h,e,l),Tu(i,e,null),r=fp(e,s[13].bind(e)),s[14](e),n=!0},p(h,[l]){a&&a.p&&(!n||l&32768)&&Rp(a,o,h,h[15],n?wp(o,h[15],l,null):xp(h[15]),null);const c={};l&32778&&(c.$$scope={dirty:l,ctx:h}),i.$set(c)},i(h){n||(on(a,h),on(i.$$.fragment,h),n=!0)},o(h){an(a,h),an(i.$$.fragment,h),n=!1},d(h){h&&(rn(t),rn(e)),a&&a.d(h),xu(i),r(),s[14](null)}}}const kn=Symbol("tool");function Dp(s,t,e){let i,r,n,{$$slots:o={},$$scope:a}=t;const{active_tool:h,toolbar_box:l,editor_box:c}=Mp(As);po(s,h,T=>e(3,i=T)),po(s,l,T=>e(17,r=T)),po(s,c,T=>e(10,n=T));let{i18n:u}=t,d=[];const f={},p={current_color:Ot("#000000"),register_tool:(T,I)=>(e(1,d=[...d,T]),I?.cb&&(f[T]=I.cb),()=>{e(1,d=d.filter(M=>M!==T))}),active_tool:{subscribe:h.subscribe,set:h.set}};Pp(kn,p);const m={crop:{order:1,label:u("Transform"),icon:s_},draw:{order:2,label:u("Draw"),icon:Hf},erase:{order:2,label:u("Erase"),icon:c_}
3,bg:{order:0,label:u("Background"),icon:fh}};let g,v;function b(){v&&Uh(l,r=v.getBoundingClientRect(),r)}function y(T,I){T.stopPropagation(),Uh(h,i=I,i),f[I]&&f[I]()}const E=(T,I)=>y(I,T);function w(){g=this.clientWidth,e(0,g)}function x(T){mp[T?"unshift":"push"](()=>{v=T,e(2,v)})}return s.$$set=T=>{"i18n"in T&&e(9,u=T.i18n),"$$scope"in T&&e(15,a=T.$$scope)},s.$$.update=()=>{s.$$.dirty&1025&&b()},[g,d,v,i,h,l,c,m,y,u,n,o,E,w,x,a]}class Fp extends dp{constructor(t){super(),Ep(this,t,Dp,Bp,Sp,{i18n:9})}get i18n(){return this.$$.ctx[9]}set i18n(t){this.$$set({i18n:t}),yp()}}function hn(s){"@babel/helpers - typeof";return hn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hn(s)}var Lp=/^\s+/,Np=/\s+$/;function $(s,t){if(s=s||"",t=t||{},s instanceof $)return s;if(!(this instanceof $))return new $(s,t);var e=Op(s);this._originalInput=s,this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||e.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=e.ok}$.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},getLuminance:function(){var t=this.toRgb(),e,i,r,n,o,a;return e=t.r/255,i=t.g/255,r=t.b/255,e<=.03928?n=e/12.92:n=Math.pow((e+.055)/1.055,2.4),i<=.03928?o=i/12.92:o=Math.pow((i+.055)/1.055,2.4),r<=.03928?a=r/12.92:a=Math.pow((r+.055)/1.055,2.4),.2126*n+.7152*o+.0722*a},setAlpha:function(t){return this._a=Eu(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=$h(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=$h(this._r,this._g,this._b),e=Math.round(t.h*360),i=Math.round(t.s*100),r=Math.round(t.v*100);return this._a==1?"hsv("+e+", "+i+"%, "+r+"%)":"hsva("+e+", "+i+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=zh(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=zh(this._r,this._g,this._b),e=Math.round(t.h*360),i=Math.round(t.s*100),r=Math.round(t.l*100);return this._a==1?"hsl("+e+", "+i+"%, "+r+"%)":"hsla("+e+", "+i+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return Xh(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return zp(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(ut(this._r,255)*100)+"%",g:Math.round(ut(this._g,255)*100)+"%",b:Math.round(ut(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(ut(this._r,255)*100)+"%, "+Math.round(ut(this._g,255)*100)+"%, "+Math.round(ut(this._b,255)*100)+"%)":"rgba("+Math.round(ut(this._r,255)*100)+"%, "+Math.round(ut(this._g,255)*100)+"%, "+Math.round(ut(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:tm[Xh(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var e="#"+Vh(this._r,this._g,this._b,this._a),i=e,r=this._gradientType?"GradientType = 1, ":"";if(t){var n=$(t);i="#"+Vh(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+e+",endColorstr="+i+")"},toString:function(t){var e=!!t;t=t||this._format;var i=!1,r=this._a<1&&this._a>=0,n=!e&&r&&(t==="hex"||t==="hex6"||t==="hex3"||t==="hex4"||t==="hex8"||t==="name");return n?t==="name"&&this._a===0?this.toName():this.toRgbString():(t==="rgb"&&(i=this.toRgbString()),t==="prgb"&&(i=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(i=this.toHexString()),t==="hex3"&&(i=this.toHexString(!0)),t==="hex4"&&(i=this.toHex8String(!0)),t==="hex8"&&(i=this.toHex8String()),t==="name"&&(i=this.toName()),t==="hsl"&&(i=this.toHslString()),t==="hsv"&&(i=this.toHsvString()),i||this.toHexString())},clone:function(){return $(this.toString())},_applyModification:function(t,e){var i=t.apply(null,[this].concat([].slice.call(e)));return this._r=i._r,this._g=i._g,this._b=i._b,this.setAlpha(i._a),this},lighten:function(){return this._applyModification(Wp,arguments)},brighten:function(){return this._applyModification(jp,arguments)},darken:function(){return this._applyModification(Yp,arguments)},desaturate:function(){return this._applyModification($p,arguments)},saturate:function(){return this._applyModification(Xp,arguments)},greyscale:function(){return this._applyModification(Vp,arguments)},spin:function(){return this._applyModification(qp,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(Jp,arguments)},complement:function(){return this._applyCombination(Zp,arguments)},monochromatic:function(){return this._applyCombination(Qp,arguments)},splitcomplement:function(){return this._applyCombination(Kp,arguments)},triad:function(){return this._applyCombination(Wh,[3])},tetrad:function(){return this._applyCombination(Wh,[4])}};$.fromRatio=function(s,t){if(hn(s)=="object"){var e={};for(var i in s)s.hasOwnProperty(i)&&(i==="a"?e[i]=s[i]:e[i]=Fs(s[i]));s=e}return $(s,t)};function Op(s){var t={r:0,g:0,b:0},e=1,i=null,r=null,n=null,o=!1,a=!1;return typeof s=="string"&&(s=rm(s)),hn(s)=="object"&&(Be(s.r)&&Be(s.g)&&Be(s.b)?(t=Up(s.r,s.g,s.b),o=!0,a=String(s.r).substr(-1)==="%"?"prgb":"rgb"):Be(s.h)&&Be(s.s)&&Be(s.v)?(i=Fs(s.s),r
vendor: 4,340 bytes, line 3
3=Fs(s.v),t=Hp(s.h,i,r),o=!0,a="hsv"):Be(s.h)&&Be(s.s)&&Be(s.l)&&(i=Fs(s.s),n=Fs(s.l),t=Gp(s.h,i,n),o=!0,a="hsl"),s.hasOwnProperty("a")&&(e=s.a)),e=Eu(e),{ok:o,format:s.format||a,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:e}}function Up(s,t,e){return{r:ut(s,255)*255,g:ut(t,255)*255,b:ut(e,255)*255}}function zh(s,t,e){s=ut(s,255),t=ut(t,255),e=ut(e,255);var i=Math.max(s,t,e),r=Math.min(s,t,e),n,o,a=(i+r)/2;if(i==r)n=o=0;else{var h=i-r;switch(o=a>.5?h/(2-i-r):h/(i+r),i){case s:n=(t-e)/h+(t<e?6:0);break;case t:n=(e-s)/h+2;break;case e:n=(s-t)/h+4;break}n/=6}return{h:n,s:o,l:a}}function Gp(s,t,e){var i,r,n;s=ut(s,360),t=ut(t,100),e=ut(e,100);function o(l,c,u){return u<0&&(u+=1),u>1&&(u-=1),u<1/6?l+(c-l)*6*u:u<1/2?c:u<2/3?l+(c-l)*(2/3-u)*6:l}if(t===0)i=r=n=e;else{var a=e<.5?e*(1+t):e+t-e*t,h=2*e-a;i=o(h,a,s+1/3),r=o(h,a,s),n=o(h,a,s-1/3)}return{r:i*255,g:r*255,b:n*255}}function $h(s,t,e){s=ut(s,255),t=ut(t,255),e=ut(e,255);var i=Math.max(s,t,e),r=Math.min(s,t,e),n,o,a=i,h=i-r;if(o=i===0?0:h/i,i==r)n=0;else{switch(i){case s:n=(t-e)/h+(t<e?6:0);break;case t:n=(e-s)/h+2;break;case e:n=(s-t)/h+4;break}n/=6}return{h:n,s:o,v:a}}function Hp(s,t,e){s=ut(s,360)*6,t=ut(t,100),e=ut(e,100);var i=Math.floor(s),r=s-i,n=e*(1-t),o=e*(1-r*t),a=e*(1-(1-r)*t),h=i%6,l=[e,o,n,n,a,e][h],c=[a,e,e,o,n,n][h],u=[n,n,a,e,e,o][h];return{r:l*255,g:c*255,b:u*255}}function Xh(s,t,e,i){var r=[_e(Math.round(s).toString(16)),_e(Math.round(t).toString(16)),_e(Math.round(e).toString(16))];return i&&r[0].charAt(0)==r[0].charAt(1)&&r[1].charAt(0)==r[1].charAt(1)&&r[2].charAt(0)==r[2].charAt(1)?r[0].charAt(0)+r[1].charAt(0)+r[2].charAt(0):r.join("")}function zp(s,t,e,i,r){var n=[_e(Math.round(s).toString(16)),_e(Math.round(t).toString(16)),_e(Math.round(e).toString(16)),_e(Au(i))];return r&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)&&n[3].charAt(0)==n[3].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0)+n[3].charAt(0):n.join("")}function Vh(s,t,e,i){var r=[_e(Au(i)),_e(Math.round(s).toString(16)),_e(Math.round(t).toString(16)),_e(Math.round(e).toString(16))];return r.join("")}$.equals=function(s,t){return!s||!t?!1:$(s).toRgbString()==$(t).toRgbString()};$.random=function(){return $.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function $p(s,t){t=t===0?0:t||10;var e=$(s).toHsl();return e.s-=t/100,e.s=Bn(e.s),$(e)}function Xp(s,t){t=t===0?0:t||10;var e=$(s).toHsl();return e.s+=t/100,e.s=Bn(e.s),$(e)}function Vp(s){return $(s).desaturate(100)}function Wp(s,t){t=t===0?0:t||10;var e=$(s).toHsl();return e.l+=t/100,e.l=Bn(e.l),$(e)}function jp(s,t){t=t===0?0:t||10;var e=$(s).toRgb();return e.r=Math.max(0,Math.min(255,e.r-Math.round(255*-(t/100)))),e.g=Math.max(0,Math.min(255,e.g-Math.round(255*-(t/100)))),e.b=Math.max(0,Math.min(255,e.b-Math.round(255*-(t/100)))),$(e)}function Yp(s,t){t=t===0?0:t||10;var e=$(s).toHsl();return e.l-=t/100,e.l=Bn(e.l),$(e)}function qp(s,t){var e=$(s).toHsl(),i=(e.h+t)%360;return e.h=i<0?360+i:i,$(e)}function Zp(s){var t=$(s).toHsl();return t.h=(t.h+180)%360,$(t)}function Wh(s,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var e=$(s).toHsl(),i=[$(s)],r=360/t,n=1;n<t;n++)i.push($({h:(e.h+n*r)%360,s:e.s,l:e.l}));return i}function Kp(s){var t=$(s).toHsl(),e=t.h;return[$(s),$({h:(e+72)%360,s:t.s,l:t.l}),$({h:(e+216)%360,s:t.s,l:t.l})]}function Jp(s,t,e){t=t||6,e=e||30;var i=$(s).toHsl(),r=360/e,n=[$(s)];for(i.h=(i.h-(r*t>>1)+720)%360;--t;)i.h=(i.h+r)%360,n.push($(i));return n}function Qp(s,t){t=t||6;for(var e=$(s).toHsv(),i=e.h,r=e.s,n=e.v,o=[],a=1/t;t--;)o.push($({h:i,s:r,v:n})),n=(n+a)%1;return o}$.mix=function(s,t,e){e=e===0?0:e||50;var i=$(s).toRgb(),r=$(t).toRgb(),n=e/100,o={r:(r.r-i.r)*n+i.r,g:(r.g-i.g)*n+i.g,b:(r.b-i.b)*n+i.b,a:(r.a-i.a)*n+i.a};return $(o)};$.readability=function(s,t){var e=$(s),i=$(t);return(Math.max(e.getLuminance(),i.getLuminance())+.05)/(Math.min(e.getLuminance(),i.getLuminance())+.05)};$.isReadable=function(s,t,e){var i=$.readability(s,t),r,n;switch(n=!1,r=nm(e),r.level+r.size){case"AAsmall":case"AAAlarge":n=i>=4.5;break;case"AAlarge":n=i>=3;break;case"AAAsmall":n=i>=7;break}return n};$.mostReadable=function(s,t,e){var i=null,r=0,n,o,a,h;e=e||{},o=e.includeFallbackColors,a=e.level,h=e.size;
3for(var l=0;l<t.length;l++)n=$.readability(s,t[l]),n>r&&(r=n,i=$(t[l]));return $.isReadable(s,i,{level:a,size:h})||!o?i:(e.includeFallbackColors=!1,$.mostReadable(s,["#fff","#000"],e))};var pa=$.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee9
30",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},tm=$.hexNames=em(pa);function em(s){var t={};for(var e in s)s.hasOwnProperty(e)&&(t[s[e]]=e);return t}function Eu(s){return s=parseFloat(s),(isNaN(s)||s<0||s>1)&&(s=1),s}function ut(s,t){im(s)&&(s="100%");var e=sm(s);return s=Math.min(t,Math.max(0,parseFloat(s))),e&&(s=parseInt(s*t,10)/100),Math.abs(s-t)<1e-6?1:s%t/parseFloat(t)}function Bn(s){return Math.min(1,Math.max(0,s))}function $t(s){return parseInt(s,16)}function im(s){return typeof s=="string"&&s.indexOf(".")!=-1&&parseFloat(s)===1}function sm(s){return typeof s=="string"&&s.indexOf("%")!=-1}function _e(s){return s.length==1?"0"+s:""+s}function Fs(s){return s<=1&&(s=s*100+"%"),s}function Au(s){return Math.round(parseFloat(s)*255).toString(16)}function jh(s){return $t(s)/255}var le=function(){var s="[-\\+]?\\d+%?",t="[-\\+]?\\d*\\.\\d+%?",e="(?:"+t+")|(?:"+s+")",i="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",r="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?";return{CSS_UNIT:new RegExp(e),rgb:new RegExp("rgb"+i),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+i),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+i),hsva:new RegExp("hsva"
3+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Be(s){return!!le.CSS_UNIT.exec(s)}function rm(s){s=s.replace(Lp,"").replace(Np,"").toLowerCase();var t=!1;if(pa[s])s=pa[s],t=!0;else if(s=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var e;return(e=le.rgb.exec(s))?{r:e[1],g:e[2],b:e[3]}:(e=le.rgba.exec(s))?{r:e[1],g:e[2],b:e[3],a:e[4]}:(e=le.hsl.exec(s))?{h:e[1],s:e[2],l:e[3]}:(e=le.hsla.exec(s))?{h:e[1],s:e[2],l:e[3],a:e[4]}:(e=le.hsv.exec(s))?{h:e[1],s:e[2],v:e[3]}:(e=le.hsva.exec(s))?{h:e[1],s:e[2],v:e[3],a:e[4]}:(e=le.hex8.exec(s))?{r:$t(e[1]),g:$t(e[2]),b:$t(e[3]),a:jh(e[4]),format:t?"name":"hex8"}:(e=le.hex6.exec(s))?{r:$t(e[1]),g:$t(e[2]),b:$t(e[3]),format:t?"name":"hex"}:(e=le.hex4.exec(s))?{r:$t(e[1]+""+e[1]),g:$t(e[2]+""+e[2]),b:$t(e[3]+""+e[3]),a:jh(e[4]+""+e[4]),format:t?"name":"hex8"}:(e=le.hex3.exec(s))?{r:$t(e[1]+""+e[1]),g:$t(e[2]+""+e[2]),b:$t(e[3]+""+e[3]),format:t?"name":"hex"}:!1}function nm(s){var t,e;return s=s||{level:"AA",size:"small"},t=(s.level||"AA").toUpperCase(),e=(s.size||"small").toLowerCase(),t!=="AA"&&t!=="AAA"&&(t="AA"),e!=="small"&&e!=="large"&&(e="small"),{level:t,size:e}}var zi=(s=>(s[s.WEBGL_LEGACY=0]="WEBGL_LEGACY",s[s.WEBGL=1]="WEBGL",s[s.WEBGL2=2]="WEBGL2",s))(zi||{}),Su=(s=>(s[s.UNKNOWN=0]="UNKNOWN",s[s.WEBGL=1]="WEBGL",s[s.CANVAS=2]="CANVAS",s))(Su||{}),ma=(s=>(s[s.COLOR=16384]="COLOR",s[s.DEPTH=256]="DEPTH",s[s.STENCIL=1024]="STENCIL",s))(ma||{}),Z=(s=>(s[s.NORMAL=0]="NORMAL",s[s.ADD=1]="ADD",s[s.MULTIPLY=2]="MULTIPLY",s[s.SCREEN=3]="SCREEN",s[s.OVERLAY=4]="OVERLAY",s[s.DARKEN=5]="DARKEN",s[s.LIGHTEN=6]="LIGHTEN",s[s.COLOR_DODGE=7]="COLOR_DODGE",s[s.COLOR_BURN=8]="COLOR_BURN",s[s.HARD_LIGHT=9]="HARD_LIGHT",s[s.SOFT_LIGHT=10]="SOFT_LIGHT",s[s.DIFFERENCE=11]="DIFFERENCE",s[s.EXCLUSION=12]="EXCLUSION",s[s.HUE=13]="HUE",s[s.SATURATION=14]="SATURATION",s[s.COLOR=15]="COLOR",s[s.LUMINOSITY=16]="LUMINOSITY",s[s.NORMAL_NPM=17]="NORMAL_NPM",s[s.ADD_NPM=18]="ADD_NPM",s[s.SCREEN_NPM=19]="SCREEN_NPM",s[s.NONE=20]="NONE",s[s.SRC_OVER=0]="SRC_OVER",s[s.SRC_IN=21]="SRC_IN",s[s.SRC_OUT=22]="SRC_OUT",s[s.SRC_ATOP=23]="SRC_ATOP",s[s.DST_OVER=24]="DST_OVER",s[s.DST_IN=25]="DST_IN",s[s.DST_OUT=26]="DST_OUT",s[s.DST_ATOP=27]="DST_ATOP",s[s.ERASE=26]="ERASE",s[s.SUBTRACT=28]="SUBTRACT",s[s.XOR=29]="XOR",s))(Z||{}),Ie=(s=>(s[s.POINTS=0]="POINTS",s[s.LINES=1]="LINES",s[s.LINE_LOOP=2]="LINE_LOOP",s[s.LINE_STRIP=3]="LINE_STRIP",s[s.TRIANGLES=4]="TRIANGLES",s[s.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",s[s.TRIANGLE_FAN=6]="TRIANGLE_FAN",s))(Ie||{}),B=(s=>(s[s.RGBA=6408]="RGBA",s[s.RGB=6407]="RGB",s[s.RG=33319]="RG",s[s.RED=6403]="RED",s[s.RGBA_INTEGER=36249]="RGBA_INTEGER",s[s.RGB_INTEGER=36248]="RGB_INTEGER",s[s.RG_INTEGER=33320]="RG_INTEGER",s[s.RED_INTEGER=36244]="RED_INTEGER",s[s.ALPHA=6406]="ALPHA",s[s.LUMINANCE=6409]="LUMINANCE",s[s.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",s[s.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",s[s.DEPTH_STENCIL=34041]="DEPTH_STENCIL",s))(B||{}),us=(s=>(s[s.TEXTURE_2D=3553]="TEXTURE_2D",s[s.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",s[s.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",s[s.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",s[s.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",s[s.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",s[s.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",s))(us||{}),Y=(s=>
3(s[s.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",s[s.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",s[s.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",s[s.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",s[s.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",s[s.UNSIGNED_INT=5125]="UNSIGNED_INT",s[s.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",s[s.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",s[s.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",s[s.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",s[s.BYTE=5120]="BYTE",s[s.SHORT=5122]="SHORT",s[s.INT=5124]="INT",s[s.FLOAT=5126]="FLOAT",s[s.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",s[s.HALF_FLOAT=36193]="HALF_FLOAT",s))(Y||{}),G=(s=>(s[s.FLOAT=0]="FLOAT",s[s.INT=1]="INT",s[s.UINT=2]="UINT",s))(G||{}),He=(s=>(s[s.NEAREST=0]="NEAREST",s[s.LINEAR=1]="LINEAR",s))(He||{}),li=(s=>(s[s.CLAMP=33071]="CLAMP",s[s.REPEAT=10497]="REPEAT",s[s.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",s))(li||{}),Pe=(s=>(s[s.OFF=0]="OFF",s[s.POW2=1]="POW2",s[s.ON=2]="ON",s[s.ON_MANUAL=3]="ON_MANUAL",s))(Pe||{}),Ht=(s=>(s[s.NPM=0]="NPM",s[s.UNPACK=1]="UNPACK",s[s.PMA=2]="PMA",s[s.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",s[s.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",s[s.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",s))(Ht||{}),Ae=(s=>(s[s.NO=0]="NO",s[s.YES=1]="YES",s[s.AUTO=2]="AUTO",s[s.BLEND=0]="BLEND",s[s.CLEAR=1]="CLEAR",s[s.BLIT=2]="BLIT",s))(Ae||{}),_h=(s=>(s[s.AUTO=0]="AUTO",s[s.MANUAL=1]="MANUAL",s))(_h||{}),ie=(s=>(s.LOW="lowp",s.MEDIUM="mediump",s.HIGH="highp",s))(ie||{}),xt=(s=>
vendor: 6,233 bytes, line 3
3(s[s.NONE=0]="NONE",s[s.SCISSOR=1]="SCISSOR",s[s.STENCIL=2]="STENCIL",s[s.SPRITE=3]="SPRITE",s[s.COLOR=4]="COLOR",s))(xt||{}),vt=(s=>(s[s.NONE=0]="NONE",s[s.LOW=2]="LOW",s[s.MEDIUM=4]="MEDIUM",s[s.HIGH=8]="HIGH",s))(vt||{}),Re=(s=>(s[s.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",s[s.ARRAY_BUFFER=34962]="ARRAY_BUFFER",s[s.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",s))(Re||{});const om={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")},H={ADAPTER:om,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var mo=/iPhone/i,Yh=/iPod/i,qh=/iPad/i,Zh=/\biOS-universal(?:.+)Mac\b/i,go=/\bAndroid(?:.+)Mobile\b/i,Kh=/Android/i,ji=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,sr=/Silk/i,De=/Windows Phone/i,Jh=/\bWindows(?:.+)ARM\b/i,Qh=/BlackBerry/i,tl=/BB10/i,el=/Opera Mini/i,il=/\b(CriOS|Chrome)(?:.+)Mobile/i,sl=/Mobile(?:.+)Firefox\b/i,rl=function(s){return typeof s<"u"&&s.platform==="MacIntel"&&typeof s.maxTouchPoints=="number"&&s.maxTouchPoints>1&&typeof MSStream>"u"};function am(s){return function(t){return t.test(s)}}function nl(s){var t={userAgent:"",platform:"",maxTouchPoints:0};!s&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof s=="string"?t.userAgent=s:s&&s.userAgent&&(t={userAgent:s.userAgent,platform:s.platform,maxTouchPoints:s.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var r=am(e),n={apple:{phone:r(mo)&&!r(De),ipod:r(Yh),tablet:!r(mo)&&(r(qh)||rl(t))&&!r(De),universal:r(Zh),device:(r(mo)||r(Yh)||r(qh)||r(Zh)||rl(t))&&!r(De)},amazon:{phone:r(ji),tablet:!r(ji)&&r(sr),device:r(ji)||r(sr)},android:{phone:!r(De)&&r(ji)||!r(De)&&r(go),tablet:!r(De)&&!r(ji)&&!r(go)&&(r(sr)||r(Kh)),device:!r(De)&&(r(ji)||r(sr)||r(go)||r(Kh))||r(/\bokhttp\b/i)},windows:{phone:r(De),tablet:r(Jh),device:r(De)||r(Jh)},other:{blackberry:r(Qh),blackberry10:r(tl),opera:r(el),firefox:r(sl),chrome:r(il),device:r(Qh)||r(tl)||r(el)||r(sl)||r(il)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const hm=nl.default??nl,ze=hm(globalThis.navigator);H.RETINA_PREFIX=/@([0-9\.]+)x/;H.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Cu={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function r(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function n(h,l,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new r(c,u||h,d),_=e?e+l:l;return h._events[_]?h._events[_].fn?h._events[_]=[h._events[_],f]:h._events[_].push(f):(h._events[_]=f,h._eventsCount++),h}function o(h,l){--h._eventsCount===0?h._events=new i:delete h._events[l]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],c,u;if(this._eventsCount===0)return l;for(u in c=this._events)t.call(c,u)&&l.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=e?e+l:l,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,_=new Array(f);d<f;d++)_[d]=u[d].fn;return _},a.prototype.listenerCount=function(l){var c=e?e+l:l,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(l,c,u,d,f,_){var p=e?e+l:l;if(!this._events[p])return!1;var m=this._events[p],g=arguments.length,v,b;if(m.fn){switch(m.once&&this.removeListener(l,m.fn,void 0,!0),g){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,c),!0;case 3:return m.fn.call(m.context,c,u),!0;case 4:return m.fn.call(m.context,c,u,d),!0;case 5:return m.fn.call(m.context,c,u,d,f),!0;case 6:return m.fn.call(m.context,c,u,d,f,_),!0}for(b=1,v=new Array(g-1);b<g;b++)v[b-1]=arguments[b];m.fn.apply(m.context,v)}else{var y=m.length,E;for(b=0;b<y;b++)switch(m[b].once&&this.removeListener(l,m[b].fn,void 0,!0),g){case 1:m[b].fn.call(m[b].context);break;case 2:m[b].fn.call(m[b].context,c);break;case 3:m[b].fn.call(m[b].context,c,u);break;case 4:m[b].fn.call(m[b].context,c,u,d);break;default:if(!v)for(E=1,v=new Array(g-1);E<g;E++)v[E-1]=arguments[E];m[b].fn.apply(m[b].context,v)}}return!0},a.prototype.on=function(l,c,u){return n(this,l,c,u,!1)},a.prototype.once=function(l,c,u){return n(this,l,c,u,!0)},a.prototype.removeListener=function(l,c,u,d){var f=e?e+l:l;if(!this._events[f])return this;if(!c)return o(this,f),this;var _=this._events[f];if(_.fn)_.fn===c&&(!d||_.once)&&(!u||_.context===u)&&o(this,f);else{for(var p=0,m=[],g=_.length;p<g;p++)(_[p].fn!==c||d&&!_[p].once||u&&_[p].context!==u)&&m.push(_[p]);m.length?this._events[f]=m.length===1?m[0]:m:o(this,f)}return this},a.prototype.removeAllListeners=function(l){var c;return l?(c=e?e+l:l,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,s.exports=a})(Cu);var lm=Cu.exports;const Qs=vu(lm);var ph={exports:{}};ph.exports=Dn;ph.exports.default=Dn;function Dn(s,t,e){e=e||2;var i=t&&t.length,r=i?t[0]*e:s.length,n=Iu(s,0,r,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,h,l,c,u,d,f;if(i&&(n=_m(s,t,n,e)),s.length>80*e){a=l=s[0],h=c=s[1];for(var _=e;_<r;_+=e)u=s[_],d=s[_+1],u<a&&(a=u),d<h&&(h=d),u>l&&(l=u),d>c&&(c=d);f=Math.max(l-a,c-h),f=f!==0?32767/f:0}return Ys(n,o,e,a,h,f,0),o}function Iu(s,t,e,i,r){var n,o;if(r===va(s,t,e,i)>0)for(n=t;n<e;n+=i)o=ol(n,s[n],s[n+1],o);else for(n=e-i;n>=t;n-=i)o=ol(n,s[n],s[n+1],o);return o&&Fn(o,o.next)&&(Zs(o),o=o.next),o}function Oi(s,t){if(!s)return s;t||(t=s);var e=s,i;do if(i=!1,!e.steiner&&(Fn(e,e.next)||ft(e.prev,e,e.next)===0)){if(Zs(e),e=t=e.prev,e===e.next)break;
vendor: 4,996 bytes, line 3
3i=!0}else e=e.next;while(i||e!==t);return t}function Ys(s,t,e,i,r,n,o){if(s){!o&&n&&vm(s,i,r,n);for(var a=s,h,l;s.prev!==s.next;){if(h=s.prev,l=s.next,n?um(s,i,r,n):cm(s)){t.push(h.i/e|0),t.push(s.i/e|0),t.push(l.i/e|0),Zs(s),s=l.next,a=l.next;continue}if(s=l,s===a){o?o===1?(s=dm(Oi(s),t,e),Ys(s,t,e,i,r,n,2)):o===2&&fm(s,t,e,i,r,n):Ys(Oi(s),t,e,i,r,n,1);break}}}}function cm(s){var t=s.prev,e=s,i=s.next;if(ft(t,e,i)>=0)return!1;for(var r=t.x,n=e.x,o=i.x,a=t.y,h=e.y,l=i.y,c=r<n?r<o?r:o:n<o?n:o,u=a<h?a<l?a:l:h<l?h:l,d=r>n?r>o?r:o:n>o?n:o,f=a>h?a>l?a:l:h>l?h:l,_=i.next;_!==t;){if(_.x>=c&&_.x<=d&&_.y>=u&&_.y<=f&&hs(r,a,n,h,o,l,_.x,_.y)&&ft(_.prev,_,_.next)>=0)return!1;_=_.next}return!0}function um(s,t,e,i){var r=s.prev,n=s,o=s.next;if(ft(r,n,o)>=0)return!1;for(var a=r.x,h=n.x,l=o.x,c=r.y,u=n.y,d=o.y,f=a<h?a<l?a:l:h<l?h:l,_=c<u?c<d?c:d:u<d?u:d,p=a>h?a>l?a:l:h>l?h:l,m=c>u?c>d?c:d:u>d?u:d,g=ga(f,_,t,e,i),v=ga(p,m,t,e,i),b=s.prevZ,y=s.nextZ;b&&b.z>=g&&y&&y.z<=v;){if(b.x>=f&&b.x<=p&&b.y>=_&&b.y<=m&&b!==r&&b!==o&&hs(a,c,h,u,l,d,b.x,b.y)&&ft(b.prev,b,b.next)>=0||(b=b.prevZ,y.x>=f&&y.x<=p&&y.y>=_&&y.y<=m&&y!==r&&y!==o&&hs(a,c,h,u,l,d,y.x,y.y)&&ft(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;b&&b.z>=g;){if(b.x>=f&&b.x<=p&&b.y>=_&&b.y<=m&&b!==r&&b!==o&&hs(a,c,h,u,l,d,b.x,b.y)&&ft(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;y&&y.z<=v;){if(y.x>=f&&y.x<=p&&y.y>=_&&y.y<=m&&y!==r&&y!==o&&hs(a,c,h,u,l,d,y.x,y.y)&&ft(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function dm(s,t,e){var i=s;do{var r=i.prev,n=i.next.next;!Fn(r,n)&&Ru(r,i,i.next,n)&&qs(r,n)&&qs(n,r)&&(t.push(r.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),Zs(i),Zs(i.next),i=s=n),i=i.next}while(i!==s);return Oi(i)}function fm(s,t,e,i,r,n){var o=s;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&wm(o,a)){var h=Mu(o,a);o=Oi(o,o.next),h=Oi(h,h.next),Ys(o,t,e,i,r,n,0),Ys(h,t,e,i,r,n,0);return}a=a.next}o=o.next}while(o!==s)}function _m(s,t,e,i){var r=[],n,o,a,h,l;for(n=0,o=t.length;n<o;n++)a=t[n]*i,h=n<o-1?t[n+1]*i:s.length,l=Iu(s,a,h,i,!1),l===l.next&&(l.steiner=!0),r.push(xm(l));for(r.sort(pm),n=0;n<r.length;n++)e=mm(r[n],e);return e}function pm(s,t){return s.x-t.x}function mm(s,t){var e=gm(s,t);if(!e)return t;var i=Mu(e,s);return Oi(i,i.next),Oi(e,e.next)}function gm(s,t){var e=t,i=s.x,r=s.y,n=-1/0,o;do{if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){var a=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&a>n&&(n=a,o=e.x<e.next.x?e:e.next,a===i))return o}e=e.next}while(e!==t);if(!o)return null;var h=o,l=o.x,c=o.y,u=1/0,d;e=o;do i>=e.x&&e.x>=l&&i!==e.x&&hs(r<c?i:n,r,l,c,r<c?n:i,r,e.x,e.y)&&(d=Math.abs(r-e.y)/(i-e.x),qs(e,s)&&(d<u||d===u&&(e.x>o.x||e.x===o.x&&bm(o,e)))&&(o=e,u=d)),e=e.next;while(e!==h);return o}function bm(s,t){return ft(s.prev,s,t.prev)<0&&ft(t.next,s,s.next)<0}function vm(s,t,e,i){var r=s;do r.z===0&&(r.z=ga(r.x,r.y,t,e,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==s);r.prevZ.nextZ=null,r.prevZ=null,ym(r)}function ym(s){var t,e,i,r,n,o,a,h,l=1;do{for(e=s,s=null,n=null,o=0;e;){for(o++,i=e,a=0,t=0;t<l&&(a++,i=i.nextZ,!!i);t++);for(h=l;a>0||h>0&&i;)a!==0&&(h===0||!i||e.z<=i.z)?(r=e,e=e.nextZ,a--):(r=i,i=i.nextZ,h--),n?n.nextZ=r:s=r,r.prevZ=n,n=r;e=i}n.nextZ=null,l*=2}while(o>1);return s}function ga(s,t,e,i,r){return s=(s-e)*r|0,t=(t-i)*r|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function xm(s){var t=s,e=s;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==s);return e}function hs(s,t,e,i,r,n,o,a){return(r-o)*(t-a)>=(s-o)*(n-a)&&(s-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(r-o)*(i-a)}function wm(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!Tm(s,t)&&(qs(s,t)&&qs(t,s)&&Em(s,t)&&(ft(s.prev,s,t.prev)||ft(s,t.prev,t))||Fn(s,t)&&ft(s.prev,s,s.next)>0&&ft(t.prev,t,t.next)>0)}function ft(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function Fn(s,t){return s.x===t.x&&s.y===t.y}function Ru(s,t,e,i){var r=nr(ft(s,t,e)),n=nr(ft(s,t,i)),o=nr(ft(e,i,s)),a=nr(ft(e,i,t));return!!(r!==n&&o!==a||r===0&&rr(s,e,t)||n===0&&rr(s,i,t)||o===0&&rr(e,s,i)||a===0&&rr(e,t,i))}function rr(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function nr(s){return s>0?1:s<0?-1:0}function Tm(s,t){var e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&Ru(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function qs(s,t){return ft(s.prev,s,s.next)<0?ft(s,t,s.next)>=0&&ft(s,s.prev,t)>=0:ft(s,t,s.prev)<0||ft(s,s.next,t)<0}function Em(s,t){var e=s,i=!1,r=(s.x+t.x)/2,n=(s.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&r<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==s);return i}function Mu(s,t){var e=new ba(s.i,s.x,s.y),i=new ba(t.i,t.x,t.y),r=s.next,n=t.prev;return s.next=t,t.prev=s,e.next=r,r.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function ol(s,t,e,i){var r=new ba(s,t,e);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}
vendor: 5,379 bytes, lines 3-8
3function Zs(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function ba(s,t,e){this.i=s,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Dn.deviation=function(s,t,e,i){var r=t&&t.length,n=r?t[0]*e:s.length,o=Math.abs(va(s,0,n,e));if(r)for(var a=0,h=t.length;a<h;a++){var l=t[a]*e,c=a<h-1?t[a+1]*e:s.length;o-=Math.abs(va(s,l,c,e))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,f=i[a+1]*e,_=i[a+2]*e;u+=Math.abs((s[d]-s[_])*(s[f+1]-s[d+1])-(s[d]-s[f])*(s[_+1]-s[d+1]))}return o===0&&u===0?0:Math.abs((u-o)/o)};function va(s,t,e,i){for(var r=0,n=t,o=e-i;n<e;n+=i)r+=(s[o]-s[n])*(s[n+1]+s[o+1]),o=n;return r}Dn.flatten=function(s){for(var t=s[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,r=0;r<s.length;r++){for(var n=0;n<s[r].length;n++)for(var o=0;o<t;o++)e.vertices.push(s[r][n][o]);r>0&&(i+=s[r-1].length,e.holes.push(i))}return e};var Am=ph.exports;const Sm=vu(Am),al={};function et(s,t,e=3){if(al[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
4Deprecated since v${s}`):(i=i.split(`
5`).splice(e).join(`
6`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
7Deprecated since v${s}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
8Deprecated since v${s}`),console.warn(i))),al[t]=!0}function oe(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function Is(s){return s.split("?")[0].split("#")[0]}function Cm(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Im(s,t,e){return s.replace(new RegExp(Cm(t),"g"),e)}function Rm(s,t){let e="",i=0,r=-1,n=0,o=-1;for(let a=0;a<=s.length;++a){if(a<s.length)o=s.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(r===a-1||n===1))if(r!==a-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),r=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,r=a,n=0;continue}}}else e.length>0?e+=`/${s.slice(r+1,a)}`:e=s.slice(r+1,a),i=a-r-1;r=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const wt={toPosix(s){return Im(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){oe(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(oe(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=Is(this.toPosix(t??H.ADAPTER.getBaseUrl())),r=Is(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?wt.join(r,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(oe(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=Rm(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return oe(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e<s.length;++e){const i=s[e];if(oe(i),i.length>0)if(t===void 0)t=i;else{const r=s[e-1]??"";this.extname(r)?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(oe(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,r=!0;const n=this.getProtocol(s),o=s;s=s.slice(n.length);for(let a=s.length-1;a>=1;--a)if(t=s.charCodeAt(a),t===47){if(!r){i=a;break}}else r=!1;return i===-1?e?"/":this.isUrl(o)?n+s:n:e&&i===1?"//":n+s.slice(0,i)},rootname(s){oe(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){oe(s),t&&oe(t),s=Is(this.toPosix(s));let e=0,i=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let o=t.length-1,a=-1;for(n=s.length-1;n>=0;--n){const h=s.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else a===-1&&(r=!1,a=n+1),o>=0&&(h===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=s.length),s.slice(e,i)}for(n=s.length-1;n>=0;--n)if(s.charCodeAt(n)===47){if(!r){e=n+1;break}}else i===-1&&(r=!1,i=n+1);return i===-1?"":s.slice(e,i)},extname(s){oe(s),s=Is(this.toPosix(s));let t=-1,e=0,i=-1,r=!0,n=0;for(let o=s.length-1;o>=0;--o){const a=s.charCodeAt(o);if(a===47){if(!r){e=o+1;break}continue}i===-1&&(r=!1,i=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":s.slice(t,i)},parse(s){oe(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=Is(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let r;t.root=this.rootname(s),i||this.hasProtocol(s)?r=1:r=0;let n=-1,o=0,a=-1,h=!0,l=s.length-1,c=0;for(;l>=r;
8--l){if(e=s.charCodeAt(l),e===47){if(!h){o=l+1;break}continue}a===-1&&(h=!1,a=l+1),e===46?n===-1?n=l:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||a===-1||c===0||c===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&i?t.base=t.name=s.slice(1,a):t.base=t.name=s.slice(o,a)):(o===0&&i?(t.name=s.slice(1,n),t.base=s.slice(1,a)):(t.name=s.slice(o,n),t.base=s.slice(o,a)),t.ext=s.slice(n,a)),t.dir=this.dirname(s),t},sep:"/",delimiter:":"};let bo;async function Mm(){return bo??(bo=(async()=>{const s=document.createElement("canvas").getContext("webgl");if(!s)return Ht.UNPACK;const t=await new Promise(n=>{const o=document.createElement("video");o.onloadeddata=()=>n(o),o.onerror=()=>n(null),o.autoplay=!1,o.crossOrigin="anonymous",o.preload="auto",o.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",o.load()});if(!t)return Ht.UNPACK;const e=s.createTexture();s.bindTexture(s.TEXTURE_2D,e);const i=s.createFramebuffer();s.bindFramebuffer(s.FRAMEBUFFER,i),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,e,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.NONE),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,t);const r=new Uint8Array(4);return s.readPixels(0,0,1,1,s.RGBA,s.UNSIGNED_BYTE,r),s.deleteFramebuffer(i),s.deleteTexture(e),s.getExtension("WEBGL_lose_context")?.loseContext(),r[0]<=r[3]?Ht.PMA:Ht.UNPACK})()),bo}let vo;function Pm(){return typeof vo>"u"&&(vo=function(){const s={stencil:!0,failIfMajorPerformanceCaveat:H.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!H.ADAPTER.getWebGLRenderingContext())return!1;const t=H.ADAPTER.createCanvas();let e=t.getContext("webgl",s)||t.getContext("experimental-webgl",s);const i=!!e?.getContextAttributes()?.stencil;if(e){const r=e.getExtension("WEBGL_lose_context");r&&r.loseContext()}return e=null,i}catch{return!1}}()),vo}var km={grad:.9,turn:360,rad:360/(2*Math.PI)},Fe=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},Et=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},se=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},Pu=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},hl=function(s){return{r:se(s.r,0,255),g:se(s.g,0,255),b:se(s.b,0,255),a:se(s.a)}},yo=function(s){return{r:Et(s.r),g:Et(s.g),b:Et(s.b),a:Et(s.a,3)}},Bm=/^#([0-9a-f]{3,8})$/i,or=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},ku=function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:r}},Bu=function(s){var t=s.h,e=s.s,i=s.v,r=s.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),h=i*(1-(1-t+n)*e),l=n%6;return{r:255*[i,a,o,o,h,i][l],g:255*[h,i,i,a,o,o][l],b:255*[o,o,h,i,i,a][l],a:r}},ll=function(s){return{h:Pu(s.h),s:se(s.s,0,100),l:se(s.l,0,100),a:se(s.a)}},cl=function(s){return{h:Et(s.h),s:Et(s.s),l:Et(s.l),a:Et(s.a,3)}},ul=function(s){return Bu((e=(t=s).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},$s=function(s){return{h:(t=ku(s)).h,s:(r=(200-(e=t.s))*(i=t.v)/100)>0&&r<200?e*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,i,r},Dm=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Fm=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Lm=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\
vendor: 4,115 bytes, line 8
8s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Nm=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ya={string:[[function(s){var t=Bm.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?Et(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?Et(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=Lm.exec(s)||Nm.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:hl({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(s){var t=Dm.exec(s)||Fm.exec(s);if(!t)return null;var e,i,r=ll({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(km[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return ul(r)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=r===void 0?1:r;return Fe(t)&&Fe(e)&&Fe(i)?hl({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,r=s.a,n=r===void 0?1:r;if(!Fe(t)||!Fe(e)||!Fe(i))return null;var o=ll({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return ul(o)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,r=s.a,n=r===void 0?1:r;if(!Fe(t)||!Fe(e)||!Fe(i))return null;var o=function(a){return{h:Pu(a.h),s:se(a.s,0,100),v:se(a.v,0,100),a:se(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Bu(o)},"hsv"]]},dl=function(s,t){for(var e=0;e<t.length;e++){var i=t[e][0](s);if(i)return[i,t[e][1]]}return[null,void 0]},Om=function(s){return typeof s=="string"?dl(s.trim(),ya.string):typeof s=="object"&&s!==null?dl(s,ya.object):[null,void 0]},xo=function(s,t){var e=$s(s);return{h:e.h,s:se(e.s+100*t,0,100),l:e.l,a:e.a}},wo=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},fl=function(s,t){var e=$s(s);return{h:e.h,s:e.s,l:se(e.l+100*t,0,100),a:e.a}},xa=function(){function s(t){this.parsed=Om(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return Et(wo(this.rgba),2)},s.prototype.isDark=function(){return wo(this.rgba)<.5},s.prototype.isLight=function(){return wo(this.rgba)>=.5},s.prototype.toHex=function(){return t=yo(this.rgba),e=t.r,i=t.g,r=t.b,o=(n=t.a)<1?or(Et(255*n)):"","#"+or(e)+or(i)+or(r)+o;var t,e,i,r,n,o},s.prototype.toRgb=function(){return yo(this.rgba)},s.prototype.toRgbString=function(){return t=yo(this.rgba),e=t.r,i=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+r+", "+n+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,n},s.prototype.toHsl=function(){return cl($s(this.rgba))},s.prototype.toHslString=function(){return t=cl($s(this.rgba)),e=t.h,i=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+n+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,n},s.prototype.toHsv=function(){return t=ku(this.rgba),{h:Et(t.h),s:Et(t.s),v:Et(t.v),a:Et(t.a,3)};var t},s.prototype.invert=function(){return xe({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),xe(xo(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),xe(xo(this.rgba,-t))},s.prototype.grayscale=function(){return xe(xo(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),xe(fl(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),xe(fl(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?xe({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Et(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=$s(this.rgba);return typeof t=="number"?xe({h:t,s:e.s,l:e.l,a:e.a}):Et(e.h)},s.prototype.isEqual=function(t){return this.toHex()===xe(t).toHex()},s}(),xe=function(s){return s instanceof xa?s:new xa(s)},_l=[],Um=function(s){s.forEach(function(t){_l.indexOf(t)<0&&(t(xa,ya),_l.push(t))})};
vendor: 4,443 bytes, line 8
8function Gm(s,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var r in e)i[e[r]]=r;var n={};s.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,h,l=i[this.toHex()];if(l)return l;if(o?.closest){var c=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in e)n[f]=new s(e[f]).toRgb();for(var _ in e){var p=(a=c,h=n[_],Math.pow(a.r-h.r,2)+Math.pow(a.g-h.g,2)+Math.pow(a.b-h.b,2));p<u&&(u=p,d=_)}return d}},t.string.push([function(o){var a=o.toLowerCase(),h=a==="transparent"?"#0000":e[a];return h?new s(h).toRgb():null},"name"])}Um([Gm]);const es=class Dr{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof Dr)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;
vendor: 4,345 bytes, line 8
8if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((r,n)=>r===e[n]);if(t!==null&&e!==null){const r=Object.keys(t),n=Object.keys(e);return r.length!==n.length?!1:r.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(r*255),t}toRgbArray(t){t=t??[];const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,r,n]=Dr.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=r,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(r<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,i,r]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(r*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,r,n]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=n,t}normalize(t){let e,i,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,r=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,r,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,r,n=255]=t,e/=255,i/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=Dr.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=xe(t);o.isValid()&&({r:e,g:i,b:r,a:n}=o.rgba,e/=255,i/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=r,this._components[3]=n,this.refreshInt();else throw new Error(`Unable to convert color ${t}`)}refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),i)}),t)}};es.shared=new es,es.temp=new es,es.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let nt=es;function Hm(s){return et("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),nt.shared.setValue(s).toHex()}function zm(s){return et("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),nt.shared.setValue(s).toNumber()}function $m(){const s=[],t=[];for(let i=0;i<32;i++)s[i]=i,t[i]=i;s[Z.NORMAL_NPM]=Z.NORMAL,s[Z.ADD_NPM]=Z.ADD,s[Z.SCREEN_NPM]=Z.SCREEN,t[Z.NORMAL]=Z.NORMAL_NPM,t[Z.ADD]=Z.ADD_NPM,t[Z.SCREEN]=Z.SCREEN_NPM;const e=[];return e.push(t),e.push(s),e}const Du=$m();function Fu(s,t){return Du[t?1:0][s]}function Xm(s,t=null){const e=s*6;if(t=t||new Uint16Array(e),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,r=0;i<e;i+=6,r+=4)t[i+0]=r+0,t[i+1]=r+1,t[i+2]=r+2,t[i+3]=r+0,t[i+4]=r+2,t[i+5]=r+3;return t}function Lu(s){if(s.BYTES_PER_ELEMENT===4)return s instanceof Float32Array?"Float32Array":s instanceof Uint32Array?"Uint32Array":"Int32Array";if(s.BYTES_PER_ELEMENT===2){if(s instanceof Uint16Array)return"Uint16Array"}else if(s.BYTES_PER_ELEMENT===1&&s instanceof Uint8Array)return"Uint8Array";return null}function ln(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}
8function pl(s){return!(s&s-1)&&!!s}function ml(s){let t=(s>65535?1:0)<<4;s>>>=t;let e=(s>255?1:0)<<3;return s>>>=e,t|=e,e=(s>15?1:0)<<2,s>>>=e,t|=e,e=(s>3?1:0)<<1,s>>>=e,t|=e,t|s>>1}function ds(s,t,e){const i=s.length;let r;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(r=t;r<n;++r)s[r]=s[r+e];s.length=n}function ni(s){return s===0?0:s<0?-1:1}let Vm=0;function Ui(){return++Vm}const wa=class{constructor(s,t,e,i){this.left=s,this.top=t,this.right=e,this.bottom=i}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};wa.EMPTY=new wa(0,0,0,0);let gl=wa;const bl={},we=Object.create(null),Ke=Object.create(null);class Wm{constructor(t,e,i){this._canvas=H.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||H.RESOLUTION,this.resize(t,e)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(e*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function vl(s,t,e){for(let i=0,r=4*e*t;i<t;++i,r+=4)if(s[r+3]!==0)return!1;return!0}function yl(s,t,e,i,r){const n=4*t;for(let o=i,a=i*n+4*e;o<=r;++o,a+=n)if(s[a+3]!==0)return!1;return!0}function jm(s){const{width:t,height:e}=s,i=s.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const r=i.getImageData(0,0,t,e).data;let n=0,o=0,a=t-1,h=e-1;for(;o<e&&vl(r,t,o);)++o;if(o===e)return gl.EMPTY;for(;vl(r,t,h);)--h;for(;yl(r,t,n,o,h);)++n;for(;yl(r,t,a,o,h);)--a;return++a,++h,new gl(n,o,a,h)}function Ym(s){const t=jm(s),{width:e,height:i}=t;let r=null;if(!t.isEmpty()){const n=s.getContext("2d");if(n===null)throw new TypeError("Failed to get canvas 2D context");r=n.getImageData(t.left,t.top,e,i)}return{width:e,height:i,data:r}}function qm(s,t=globalThis.location){if(s.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(s,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function je(s,t=1){const e=H.RETINA_PREFIX?.exec(s);return e?parseFloat(e[1]):t}var N=(s=>(s.Renderer="renderer",s.Application="application",s.RendererSystem="renderer-webgl-system",s.RendererPlugin="renderer-webgl-plugin",s.CanvasRendererSystem="renderer-canvas-system",s.CanvasRendererPlugin="renderer-canvas-plugin",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s))(N||{});const Ta=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},xl=(s,t)=>Ta(s).priority??t,W={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(Ta).forEach(t=>{t.type.forEach(e=>this._removeHandlers[e]?.(t))}),this},add(...s){return s.map(Ta).forEach(t=>{t.type.forEach(e=>{const i=this._addHandlers,r=this._queue;i[e]?i[e](t):(r[e]=r[e]||[],r[e].push(t))})}),this},handle(s,t,e){const i=this._addHandlers,r=this._removeHandlers;if(i[s]||r[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,r[s]=e;const n=this._queue;return n[s]&&(n[s].forEach(o=>t(o)),delete n[s]),this},handleByMap(s,t){return this.handle(s,e=>{t[e.name]=e.ref},e=>{delete t[e.name]})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((r,n)=>xl(n,e)-xl(r,e)))},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1)})}};class Ea{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const Zm=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
9`);function Km(s){let t="";for(let e=0;e<s;++e)e>0&&(t+=`
10else `),e<s-1&&(t+=`if(test == ${e}.0){}`);return t}function Jm(s,t){if(s===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);for(;;){const i=Zm.replace(/%forloop%/gi,Km(s));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))s=s/2|0;else break}return s}const To=0,Eo=1,Ao=2,So=3,Co=4,Io=5;class ke{constructor(){this.data=0,this.blendMode=Z.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<To)}set blend(t){!!(this.data&1<<To)!==t&&(this.data^=1<<To)}get offsets(){return!!(this.data&1<<Eo)}set offsets(t){!!(this.data&1<<Eo)!==t&&(this.data^=1<<Eo)}
vendor: 26,039 bytes, lines 10-24
10get culling(){return!!(this.data&1<<Ao)}set culling(t){!!(this.data&1<<Ao)!==t&&(this.data^=1<<Ao)}get depthTest(){return!!(this.data&1<<So)}set depthTest(t){!!(this.data&1<<So)!==t&&(this.data^=1<<So)}get depthMask(){return!!(this.data&1<<Io)}set depthMask(t){!!(this.data&1<<Io)!==t&&(this.data^=1<<Io)}get clockwiseFrontFace(){return!!(this.data&1<<Co)}set clockwiseFrontFace(t){!!(this.data&1<<Co)!==t&&(this.data^=1<<Co)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==Z.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new ke;return t.depthTest=!1,t.blend=!0,t}}ke.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const Aa=[];function Nu(s,t){if(!s)return null;let e="";if(typeof s=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(s);i&&(e=i[1].toLowerCase())}for(let i=Aa.length-1;i>=0;--i){const r=Aa[i];if(r.test&&r.test(s,e))return new r(s,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class pe{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,r,n,o,a,h){if(arguments.length>8)throw new Error("max arguments reached");const{name:l,items:c}=this;this._aliasCount++;for(let u=0,d=c.length;u<d;u++)c[u][l](t,e,i,r,n,o,a,h);return c===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(pe.prototype,{dispatch:{value:pe.prototype.emit},run:{value:pe.prototype.emit}});class Ks{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new pe("setRealSize"),this.onUpdate=new pe("update"),this.onError=new pe("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,e,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,e){return!1}}class Ln extends Ks{constructor(t,e){const{width:i,height:r}=e||{};if(!i||!r)throw new Error("BufferResource width or height invalid");super(i,r),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const r=t.gl;r.pixelStorei(r.UNPACK_ALIGNMENT,this.unpackAlignment),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Ht.UNPACK);const n=e.realWidth,o=e.realHeight;return i.width===n&&i.height===o?r.texSubImage2D(e.target,0,0,0,n,o,e.format,i.type,this.data):(i.width=n,i.height=o,r.texImage2D(e.target,0,i.internalFormat,n,o,0,e.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const Qm={scaleMode:He.NEAREST,alphaMode:Ht.NPM},Sa=class is extends Qs{constructor(t=null,e=null){super(),e=Object.assign({},is.defaultOptions,e);const{alphaMode:i,mipmap:r,anisotropicLevel:n,scaleMode:o,width:a,height:h,wrapMode:l,format:c,type:u,target:d,resolution:f,resourceOptions:_}=e;t&&!(t instanceof Ks)&&(t=Nu(t,_),t.internal=!0),this.resolution=f||H.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((h||0)*this.resolution)/this.resolution,this._mipmap=r,this.anisotropicLevel=n,this._wrapMode=l,this._scaleMode=o,this.format=c,this.type=u,this.target=d,this.alphaMode=i,this.uid=Ui(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=a>0&&h>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(t)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,e){let i;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,i=!0),e!==void 0&&e!==this.mipmap&&(this.mipmap=e,i=!0),i&&this.dirtyStyleId++,this}setSize(t,e,i){return i=i||this.resolution,this.setRealSize(t*i,e*i,i)}setRealSize(t,e,i){return this.resolution=i||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=pl(this.realWidth)&&pl(this.realHeight)}setResolution(t){const e=this.resolution;return e===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete Ke[this.cacheId],delete we[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),is.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,e,i=H.STRICT_TEXTURE_CACHE){const r=typeof t=="string";let n=null;if(r)n=t;else{if(!t._pixiId){const a=e?.pixiIdPrefix||"pixiid";t._pixiId=`${a}_${Ui()}`}n=t._pixiId}let o=Ke[n];if(r&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new is(t,e),o.cacheId=n,is.addToCache(o,n)),o}static fromBuffer(t,e,i,r){t=t||new Float32Array(e*i*4);const n=new Ln(t,{width:e,height:i,...r?.resourceOptions});let o,a;return t instanceof Float32Array?(o=B.RGBA,a=Y.FLOAT):t instanceof Int32Array?(o=B.RGBA_INTEGER,a=Y.INT):t instanceof Uint32Array?(o=B.RGBA_INTEGER,a=Y.UNSIGNED_INT):t instanceof Int16Array?(o=B.RGBA_INTEGER,a=Y.SHORT):t instanceof Uint16Array?(o=B.RGBA_INTEGER,a=Y.UNSIGNED_SHORT):t instanceof Int8Array?(o=B.RGBA,a=Y.BYTE):(o=B.RGBA,a=Y.UNSIGNED_BYTE),n.internal=!0,new is(n,Object.assign({},Qm,{type:a,format:o},r))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),Ke[e]&&Ke[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),Ke[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=Ke[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete Ke[t],e}}else if(t?.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete Ke[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};Sa.defaultOptions={mipmap:Pe.POW2,anisotropicLevel:0,scaleMode:He.LINEAR,wrapMode:li.CLAMP,alphaMode:Ht.UNPACK,target:us.TEXTURE_2D,format:B.RGBA,type:Y.UNSIGNED_BYTE},Sa._globalBatch=0;let Q=Sa;class Ca{constructor(){this.texArray=null,this.blend=0,this.type=Ie.TRIANGLES,this.start=0,this.size=0,this.data=null}}let tg=0;class bt{constructor(t,e=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=e,this.id=tg++,this.disposeRunner=new pe("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?Re.ELEMENT_ARRAY_BUFFER:Re.ARRAY_BUFFER}get index(){return this.type===Re.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new bt(t)}}class cn{constructor(t,e=0,i=!1,r=Y.FLOAT,n,o,a,h=1){this.buffer=t,this.size=e,this.normalized=i,this.type=r,this.stride=n,this.start=o,this.instance=a,this.divisor=h}destroy(){this.buffer=null}static from(t,e,i,r,n){return new cn(t,e,i,r,n)}}const eg={Float32Array,Uint32Array,Int32Array,Uint8Array};function ig(s,t){let e=0,i=0;const r={};for(let h=0;h<s.length;h++)i+=t[h],e+=s[h].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let h=0;h<s.length;h++){const l=t[h],c=s[h],u=Lu(c);r[u]||(r[u]=new eg[u](n)),o=r[u];for(let d=0;d<c.length;d++){const f=(d/l|0)*i+a,_=d%l;o[f+_]=c[d]}a+=l}return new Float32Array(n)}const wl={5126:4,5123:2,5121:1};let sg=0;const rg={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class ui{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=sg++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new pe("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,r=!1,n,o,a,h=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof bt||(e instanceof Array&&(e=new Float32Array(e)),e=new bt(e));const l=t.split("|");if(l.length>1){for(let u=0;u<l.length;u++)this.addAttribute(l[u],e,i,r,n);return this}let c=this.buffers.indexOf(e);return c===-1&&(this.buffers.push(e),c=this.buffers.length-1),this.attributes[t]=new cn(c,i,r,n,o,a,h),this.instanced=this.instanced||h,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof bt||(t instanceof Array&&(t=new Uint16Array(t)),t=new bt(t)),t.type=Re.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],i=new bt;let r;for(r in this.attributes){const n=this.attributes[r],o=this.buffers[n.buffer];t.push(o.data),e.push(n.size*wl[n.type]/4),n.buffer=0}for(i.data=ig(t,e),r=0;r<this.buffers.length;r++)this.buffers[r]!==this.indexBuffer&&this.buffers[r].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new ui;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new bt(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new cn(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=Re.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new ui,i=[],r=[],n=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let h=0;h<o.buffers.length;h++)r[h]=r[h]||0,r[h]+=o.buffers[h].data.length,n[h]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new rg[Lu(o.buffers[a].data)](r[a]),e.buffers[a]=new bt(i[a]);for(let a=0;a<t.length;a++){o=t[a];for(let h=0;h<o.buffers.length;h++)i[h].set(o.buffers[h].data,n[h]),n[h]+=o.buffers[h].data.length}if(e.attributes=o.attributes,o.indexBuffer){e.indexBuffer=e.buffers[o.buffers.indexOf(o.indexBuffer)],e.indexBuffer.type=Re.ELEMENT_ARRAY_BUFFER;let a=0,h=0,l=0,c=0;for(let u=0;u<o.buffers.length;u++)if(o.buffers[u]!==o.indexBuffer){c=u;break}for(const u in o.attributes){const d=o.attributes[u];(d.buffer|0)===c&&(h+=d.size*wl[d.type]/4)}for(let u=0;u<t.length;u++){const d=t[u].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+l]+=a;a+=t[u].buffers[c].data.length/h,l+=d.length}}return e}}class Ou extends ui{constructor(t=!1){super(),this._buffer=new bt(null,t,!1),this._indexBuffer=new bt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,Y.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,Y.FLOAT).addAttribute("aColor",this._buffer,4,!0,Y.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,Y.FLOAT).addIndex(this._indexBuffer)}}const un=Math.PI*2,ng=180/Math.PI,og=Math.PI/180;var Rt=(s=>(s[s.POLY=0]="POLY",s[s.RECT=1]="RECT",s[s.CIRC=2]="CIRC",s[s.ELIP=3]="ELIP",s[s.RREC=4]="RREC",s))(Rt||{});class st{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new st(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}}st.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const ar=[new st,new st,new st,new st];class J{constructor(t=0,e=0,i=0,r=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(r),this.type=Rt.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new J(0,0,0,0)}clone(){return new J(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const T=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=T)return!1;const I=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>I}const i=this.left,r=this.right,n=this.top,o=this.bottom;if(r<=i||o<=n)return!1;const a=ar[0].set(t.left,t.top),h=ar[1].set(t.left,t.bottom),l=ar[2].set(t.right,t.top),c=ar[3].set(t.right,t.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(a.x,h.x,l.x,c.x)<=i||Math.min(a.x,h.x,l.x,c.x)>=r||Math.max(a.y,h.y,l.y,c.y)<=n||Math.min(a.y,h.y,l.y,c.y)>=o))return!1;const d=u*(h.y-a.y),f=u*(a.x-h.x),_=d*i+f*n,p=d*r+f*n,m=d*i+f*o,g=d*r+f*o;if(Math.max(_,p,m,g)<=d*a.x+f*a.y||Math.min(_,p,m,g)>=d*c.x+f*c.y)return!1;const v=u*(a.y-l.y),b=u*(l.x-a.x),y=v*i+b*n,E=v*r+b*n,w=v*i+b*o,x=v*r+b*o;return!(Math.max(y,E,w,x)<=v*a.x+b*a.y||Math.min(y,E,w,x)>=v*c.x+b*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,r=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=r,this.height=n-r,this}}J.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Nn{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Rt.CIRC}clone(){return new Nn(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=i}getBounds(){return new J(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}Nn.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class On{constructor(t=0,e=0,i=0,r=0){this.x=t,this.y=e,this.width=i,this.height=r,this.type=Rt.ELIP}clone(){return new On(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,r=(e-this.y)/this.height;return i*=i,r*=r,i+r<=1}getBounds(){return new J(this.x-this.width,this.y-this.height,this.width,this.height)}}On.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Li{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let r=0,n=e.length;r<n;r++)i.push(e[r].x,e[r].y);e=i}this.points=e,this.type=Rt.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Li(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const r=this.points.length/2;for(let n=0,o=r-1;n<r;o=n++){const a=this.points[n*2],h=this.points[n*2+1],l=this.points[o*2],c=this.points[o*2+1];h>e!=c>e&&t<(l-a)*((e-h)/(c-h))+a&&(i=!i)}return i}}Li.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((s,t)=>`${s}, ${t}`,"")}]`};class Un{constructor(t=0,e=0,i=0,r=0,n=20){this.x=t,this.y=e,this.width=i,this.height=r,this.radius=n,this.type=Rt.RREC}clone(){return new Un(this.x,this.y,this.width,this.height,this.radius)}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(r*r+n*n<=o||(r=t-(this.x+this.width-i),r*r+n*n<=o)||(n=e-(this.y+this.height-i),r*r+n*n<=o)||(r=t-(this.x+i),r*r+n*n<=o))return!0}return!1}}Un.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class ct{constructor(t=1,e=0,i=0,r=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,r,n,o){return this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new st;const i=t.x,r=t.y;return e.x=this.a*i+this.c*r+this.tx,e.y=this.b*i+this.d*r+this.ty,e}applyInverse(t,e){e=e||new st;const i=1/(this.a*this.d+this.c*-this.b),r=t.x,n=t.y;return e.x=this.d*i*r+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*n+-this.b*i*r+(-this.ty*this.a+this.tx*this.b)*i,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),r=this.a,n=this.c,o=this.tx;return this.a=r*e-this.b*i,this.b=r*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,r=this.c,n=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*r,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}setTransform(t,e,i,r,n,o,a,h,l){return this.a=Math.cos(a+l)*n,this.b=Math.sin(a+l)*n,this.c=-Math.sin(a-h)*o,this.d=Math.cos(a-h)*o,this.tx=t-(i*this.a+r*this.c),this.ty=e-(i*this.b+r*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,r=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=r*t.a+this.d*t.c,this.d=r*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,r=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-r,n),h=Math.atan2(i,e),l=Math.abs(a+h);return l<1e-5||Math.abs(un-l)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=h),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(r*r+n*n),t.position.x=this.tx+(o.x*e+o.y*r),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,o=t*r-e*i;return this.a=r/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-r*n)/o,this.ty=-(t*this.ty-e*n)/o,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new ct;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}static get IDENTITY(){return new ct}static get TEMP_MATRIX(){return new ct}}ct.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const Ci=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Ii=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Ri=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Mi=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Ia=[],Uu=[],hr=Math.sign;function ag(){for(let s=0;s<16;s++){const t=[];Ia.push(t);for(let e=0;e<16;e++){const i=hr(Ci[s]*Ci[e]+Ri[s]*Ii[e]),r=hr(Ii[s]*Ci[e]+Mi[s]*Ii[e]),n=hr(Ci[s]*Ri[e]+Ri[s]*Mi[e]),o=hr(Ii[s]*Ri[e]+Mi[s]*Mi[e]);for(let a=0;a<16;a++)if(Ci[a]===i&&Ii[a]===r&&Ri[a]===n&&Mi[a]===o){t.push(a);break}}}for(let s=0;s<16;s++){const t=new ct;t.set(Ci[s],Ii[s],Ri[s],Mi[s],0,0),Uu.push(t)}}ag();const dt={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:s=>Ci[s],uY:s=>Ii[s],vX:s=>Ri[s],vY:s=>Mi[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>Ia[s][t],sub:(s,t)=>Ia[s][dt.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?dt.S:dt.N:Math.abs(t)*2<=Math.abs(s)?s>0?dt.E:dt.W:t>0?s>0?dt.SE:dt.SW:s>0?dt.NE:dt.NW,matrixAppendRotationInv:(s,t,e=0,i=0)=>{const r=Uu[dt.inv(t)];r.tx=e,r.ty=i,s.append(r)}};class $e{constructor(t,e,i=0,r=0){this._x=i,this._y=r,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new $e(t,e,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}$e.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Ra=class{constructor(){this.worldTransform=new ct,this.localTransform=new ct,this.position=new $e(this.onChange,this,0,0),this.scale=new $e(this.onChange,this,1,1),this.pivot=new $e(this.onChange,this,0,0),this.skew=new $e(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const s=this.localTransform;this._localID!==this._currentLocalID&&(s.a=this._cx*this.scale.x,s.b=this._sx*this.scale.x,s.c=this._cy*this.scale.y,s.d=this._sy*this.scale.y,s.tx=this.position.x-(this.pivot.x*s.a+this.pivot.y*s.c),s.ty=this.position.y-(this.pivot.x*s.b+this.pivot.y*s.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(s){const t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==s._worldID){const e=s.worldTransform,i=this.worldTransform;i.a=t.a*e.a+t.b*e.c,i.b=t.a*e.b+t.b*e.d,i.c=t.c*e.a+t.d*e.c,i.d=t.c*e.b+t.d*e.d,i.tx=t.tx*e.a+t.ty*e.c+e.tx,i.ty=t.tx*e.b+t.ty*e.d+e.ty,this._parentID=s._worldID,this._worldID++}}setFromMatrix(s){s.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(s){this._rotation!==s&&(this._rotation=s,this.updateSkew())}};Ra.IDENTITY=new Ra;let mh=Ra;mh.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};var hg=`varying vec2 vTextureCoord;
11
12uniform sampler2D uSampler;
13
14void main(void){
15   gl_FragColor *= texture2D(uSampler, vTextureCoord);
16}`,lg=`attribute vec2 aVertexPosition;
17attribute vec2 aTextureCoord;
18
19uniform mat3 projectionMatrix;
20
21varying vec2 vTextureCoord;
22
23void main(void){
24   gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0
24)).xy, 0.0, 1.0);
25   vTextureCoord = aTextureCoord;
26}
27`;function Tl(s,t,e){const i=s.createShader(t);return s.shaderSource(i,e),s.compileShader(i),i}function Ro(s){const t=new Array(s);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Gu(s,t){switch(s){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return Ro(2*t);case"bvec3":return Ro(3*t);case"bvec4":return Ro(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const fs=[{test:s=>s.type==="float"&&s.size===1&&!s.isArray,code:s=>`
28            if(uv["${s}"] !== ud["${s}"].value)
29            {
30                ud["${s}"].value = uv["${s}"]
31                gl.uniform1f(ud["${s}"].location, uv["${s}"])
32            }
33            `},{test:(s,t)=>(s.type==="sampler2D"||s.type==="samplerCube"||s.type==="sampler2DArray")&&s.size===1&&!s.isArray&&(t==null||t.castToBaseTexture!==void 0),code:s=>`t = syncData.textureCount++;
34
35            renderer.texture.bind(uv["${s}"], t);
36
37            if(ud["${s}"].value !== t)
38            {
39                ud["${s}"].value = t;
40                gl.uniform1i(ud["${s}"].location, t);
41; // eslint-disable-line max-len
42            }`},{test:(s,t)=>s.type==="mat3"&&s.size===1&&!s.isArray&&t.a!==void 0,code:s=>`
43            gl.uniformMatrix3fv(ud["${s}"].location, false, uv["${s}"].toArray(true));
44            `,codeUbo:s=>`
45                var ${s}_matrix = uv.${s}.toArray(true);
46
47                data[offset] = ${s}_matrix[0];
48                data[offset+1] = ${s}_matrix[1];
49                data[offset+2] = ${s}_matrix[2];
50        
51                data[offset + 4] = ${s}_matrix[3];
52                data[offset + 5] = ${s}_matrix[4];
53                data[offset + 6] = ${s}_matrix[5];
54        
55                data[offset + 8] = ${s}_matrix[6];
56                data[offset + 9] = ${s}_matrix[7];
57                data[offset + 10] = ${s}_matrix[8];
58            `},{test:(s,t)=>s.type==="vec2"&&s.size===1&&!s.isArray&&t.x!==void 0,code:s=>`
59                cv = ud["${s}"].value;
60                v = uv["${s}"];
61
62                if(cv[0] !== v.x || cv[1] !== v.y)
63                {
64                    cv[0] = v.x;
65                    cv[1] = v.y;
66                    gl.uniform2f(ud["${s}"].location, v.x, v.y);
67                }`,codeUbo:s=>`
68                v = uv.${s};
69
70                data[offset] = v.x;
71                data[offset+1] = v.y;
72            `},{test:s=>s.type==="vec2"&&s.size===1&&!s.isArray,code:s=>`
73                cv = ud["${s}"].value;
74                v = uv["${s}"];
75
76                if(cv[0] !== v[0] || cv[1] !== v[1])
77                {
78                    cv[0] = v[0];
79                    cv[1] = v[1];
80                    gl.uniform2f(ud["${s}"].location, v[0], v[1]);
81                }
82            `},{test:(s,t)=>s.type==="vec4"&&s.size===1&&!s.isArray&&t.width!==void 0,code:s=>`
83                cv = ud["${s}"].value;
84                v = uv["${s}"];
85
86                if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height)
87                {
88                    cv[0] = v.x;
89                    cv[1] = v.y;
90                    cv[2] = v.width;
91                    cv[3] = v.height;
92                    gl.uniform4f(ud["${s}"].location, v.x, v.y, v.width, v.height)
93                }`,codeUbo:s=>`
94                    v = uv.${s};
95
96                    data[offset] = v.x;
97                    data[offset+1] = v.y;
98                    data[offset+2] = v.width;
99                    data[offset+3] = v.height;
100                `},{test:(s,t)=>s.type==="vec4"&&s.size===1&&!s.isArray&&t.red!==void 0,code:s=>`
101                cv = ud["${s}"].value;
102                v = uv["${s}"];
103
104                if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha)
105                {
106                    cv[0] = v.red;
107                    cv[1] = v.green;
108                    cv[2] = v.blue;
109                    cv[3] = v.alpha;
110                    gl.uniform4f(ud["${s}"].location, v.red, v.green, v.blue, v.alpha)
111                }`,codeUbo:s=>`
112                    v = uv.${s};
113
114                    data[offset] = v.red;
115                    data[offset+1] = v.green;
116                    data[offset+2] = v.blue;
117                    data[offset+3] = v.alpha;
118                `},{test:(s,t)=>s.type==="vec3"&&s.size===1&&!s.isArray&&t.red!==void 0,code:s=>`
119                cv = ud["${s}"].value;
120                v = uv["${s}"];
121
122                if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a)
123                {
124                    cv[0] = v.red;
125                    cv[1] = v.green;
126                    cv[2] = v.blue;
127    
128                    gl.uniform3f(ud["${s}"].location, v.red, v.green, v.blue)
129                }`,codeUbo:s=>`
130                    v = uv.${s};
131
132                    data[offset] = v.red;
133                    data[offset+1] = v.green;
134                    data[offset+2] = v.blue;
135                `},{test:s=>s.type==="vec4"&&s.size===1&&!s.isArray,code:s=>`
136                cv = ud["${s}"].value;
137                v = uv["${s}"];
138
139                if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
140                {
141                    cv[0] = v[0];
142                    cv[1] = v[1];
143                    cv[2] = v[2];
144                    cv[3] = v[3];
145
146                    gl.uniform4f(ud["${s}"].location, v[0], v[1], v[2], v[3])
147                }`}],cg={float:`
148    if (cv !== v)
149    {
150        cu.value = v;
151        gl.uniform1f(location, v);
152    }`,vec2:`
153    if (cv[0] !== v[0] || cv[1] !== v[1])
154    {
155        cv[0] = v[0];
156        cv[1] = v[1];
157
158        gl.uniform2f(location, v[0], v[1])
159    }`,vec3:`
160    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
161    {
162        cv[0] = v[0];
163        cv[1] = v[1];
164        cv[2] = v[2];
165
166        gl.uniform3f(location, v[0], v[1], v[2])
167    }`,vec4:`
168    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
169    {
170        cv[0] = v[0];
171        cv[1] = v[1];
172        cv[2] = v[2];
173        cv[3] = v[3];
174
175        gl.uniform4f(location, v[0], v[1], v[2], v[3]);
176    }`,int:`
177    if (cv !== v)
178    {
179        cu.value = v;
180
181        gl.uniform1i(location, v);
182    }`,ivec2:`
183    if (cv[0] !== v[0] || cv[1] !== v[1])
184    {
185        cv[0] = v[0];
186        cv[1] = v[1];
187
188        gl.uniform2i(location, v[0], v[1]);
189    }`,ivec3:`
190    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
191    {
192        cv[0] = v[0];
193        cv[1] = v[1];
194        cv[2] = v[2];
195
196        gl.uniform3i(location, v[0], v[1], v[2]);
197    }`,ivec4:`
198    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
199    {
200        cv[0] = v[0];
201        cv[1] = v[1];
202        cv[2] = v[2];
203        cv[3] = v[3];
204
205        gl.uniform4i(location, v[0], v[1], v[2], v[3]);
206    }`,uint:`
207    if (cv !== v)
208    {
209        cu.value = v;
210
211        gl.uniform1ui(location, v);
212    }`,uvec2:`
213    if (cv[0] !== v[0] || cv[1] !== v[1])
214    {
215        cv[0] = v[0];
216        cv[1] = v[1];
217
218        gl.uniform2ui(location, v[0], v[1]);
219    }`,uvec3:`
220    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
221    {
222        cv[0] = v[0];
223        cv[1] = v[1];
224        cv[2] = v[2];
225
226        gl.uniform3ui(location, v[0], v[1], v[2]);
227    }`,uvec4:`
228    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
229    {
230        cv[0] = v[0];
231        cv[1] = v[1];
232        cv[2] = v[2];
233        cv[3] = v[3];
234
235        gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
236    }`,bool:`
237    if (cv !== v)
238    {
239        cu.value = v;
240        gl.uniform1i(location, v);
241    }`,bvec2:`
242    if (cv[0] != v[0] || cv[1] != v[1])
243    {
244        cv[0] = v[0];
245        cv[1] = v[1];
246
247        gl.uniform2i(location, v[0], v[1]);
248    }`,bvec3:`
249    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
250    {
251        cv[0] = v[0];
252        cv[1] = v[1];
253        cv[2] = v[2];
254
255        gl.uniform3i(location, v[0], v[1], v[2]);
256    }`,bvec4:`
257    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
258    {
259        cv[0] = v[0];
260        cv[1] = v[1];
261        cv[2] = v[2];
262        cv[3] = v[3];
263
264        gl.uniform4i(location, v[0], v[1], v[2], v[3]);
265    }`,mat2:"gl.uniformMatrix2fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",sampler2D:`
266    if (cv !== v)
267    {
268        cu.value = v;
269
270        gl.uniform1i(location, v);
271    }`,samplerCube:`
272    if (cv !== v)
273    {
274        cu.value = v;
275
276        gl.uniform1i(location, v);
277    }`,sampler2DArray:`
278    if (cv !== v)
279    {
280        cu.value = v;
281
282        gl.uniform1i(location, v);
283    }`},ug={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};function dg(s,t){const e=[`
284        var v = null;
285        var cv = null;
286        var cu = null;
287        var t = 0;
288        var gl = renderer.gl;
289    `];for(const i in s.uniforms){const r=t[i];if(!r){s.uniforms[i]?.group===!0&&(s.uniforms[i].ubo?e.push(`
290                        renderer.shader.syncUniformBufferGroup(uv.${i}, '${i}');
291                    `):e.push(`
292                        renderer.shader.syncUniformGroup(uv.${i}, syncData);
293                    `));continue}const n=s.uniforms[i];let o=!1;for(let a=0;a<fs.length;a++)if(fs[a].test(r,n)){e.push(fs[a].code(i,n)),o=!0;break}if(!o){const a=(r.size===1&&!r.isArray?cg:ug)[r.type].replace("location",`ud["${i}"].location`);e.push(`
294            cu = ud["${i}"];
295            cv = cu.value;
296            v = uv["${i}"];
297            ${a};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
298`))}const Hu={};let lr=Hu;function fg(){if(lr===Hu||lr?.isContextLost()){const s=H.ADAPTER.createCanvas();let t;H.PREFER_ENV>=zi.WEBGL2&&(t=s.getContext("webgl2",{})),t||(t=s.getContext("webgl",{})||s.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),lr=t}return lr}let cr;function _g(){if(!cr){cr=ie.MEDIUM;const s=fg();if(s&&s.getShaderPrecisionFormat){const t=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT);t&&(cr=t.precision?ie.HIGH:ie.MEDIUM)}}return cr}function El(s,t){const e=s.getShaderSource(t).split(`
299`).map((l,c)=>`${c}: ${l}`),i=s.getShaderInfoLog(t),r=i.split(`
300`),n={},o=r.map(l=>
vendor: 6,481 bytes, lines 300-337
300parseFloat(l.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(l=>l&&!n[l]?(n[l]=!0,!0):!1),a=[""];o.forEach(l=>{e[l-1]=`%c${e[l-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const h=e.join(`
301`);a[0]=h,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function pg(s,t,e,i){s.getProgramParameter(t,s.LINK_STATUS)||(s.getShaderParameter(e,s.COMPILE_STATUS)||El(s,e),s.getShaderParameter(i,s.COMPILE_STATUS)||El(s,i),console.error("PixiJS Error: Could not initialize shader."),s.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",s.getProgramInfoLog(t)))}const mg={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function zu(s){return mg[s]}let ur=null;const Al={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function $u(s,t){if(!ur){const e=Object.keys(Al);ur={};for(let i=0;i<e.length;++i){const r=e[i];ur[s[r]]=Al[r]}}return ur[t]}function Sl(s,t,e){if(s.substring(0,9)!=="precision"){let i=t;return t===ie.HIGH&&e!==ie.HIGH&&(i=ie.MEDIUM),`precision ${i} float;
302${s}`}else if(e!==ie.HIGH&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}let Rs;function gg(){if(typeof Rs=="boolean")return Rs;try{Rs=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Rs=!1}return Rs}let bg=0;const dr={},Ma=class ss{constructor(t,e,i="pixi-shader",r={}){this.extra={},this.id=bg++,this.vertexSrc=t||ss.defaultVertexSrc,this.fragmentSrc=e||ss.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=r,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),dr[i]?(dr[i]++,i+=`-${dr[i]}`):dr[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
303${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i}
304${this.fragmentSrc}`,this.vertexSrc=Sl(this.vertexSrc,ss.defaultVertexPrecision,ie.HIGH),this.fragmentSrc=Sl(this.fragmentSrc,ss.defaultFragmentPrecision,_g())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return lg}static get defaultFragmentSrc(){return hg}static from(t,e,i){const r=t+e;let n=bl[r];return n||(bl[r]=n=new ss(t,e,i)),n}};Ma.defaultVertexPrecision=ie.HIGH,Ma.defaultFragmentPrecision=ze.apple.device?ie.HIGH:ie.MEDIUM;let Xe=Ma,vg=0;class me{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=vg++,this.static=!!e,this.ubo=!!i,t instanceof bt?(this.buffer=t,this.buffer.type=Re.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new bt(new Float32Array(1)),this.buffer.type=Re.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,i){if(!this.ubo)this.uniforms[t]=new me(e,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,e,i){return new me(t,e,i)}static uboFrom(t,e){return new me(t,e??!0,!0)}}class Me{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof me?this.uniformGroup=e:this.uniformGroup=new me(e):this.uniformGroup=new me({}),this.disposeRunner=new pe("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const r=e.uniforms[i];if(r.group===!0&&this.checkUniformExists(t,r))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,e,i){const r=Xe.from(t,e);return new Me(r,i)}}class yg{constructor(t,e){if(this.vertexSrc=t,this.fragTemplate=e,this.programCache={},this.defaultGroupCache={},!e.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!e.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=n;this.defaultGroupCache[t]=me.from({uSamplers:i},!0);let r=this.fragTemplate;r=r.replace(/%count%/gi,`${t}`),r=r.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new Xe(this.vertexSrc,r)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new ct,default:this.defaultGroupCache[t]};return new Me(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=`
305`,e+=`
306`;for(let i=0;i<t;i++)i>0&&(e+=`
307else `),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+=`
308{`,e+=`
309	color = texture2D(uSamplers[${i}], vTextureCoord);`,e+=`
310}`;return e+=`
311`,e+=`
312`,e}}class Pa{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}function xg(){return!ze.apple.device}function wg(s){let t=!0;const e=H.ADAPTER.getNavigator();if(ze.tablet||ze.phone){if(ze.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(ze.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?s:4}class Gn{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var Tg=`varying vec2 vTextureCoord;
313varying vec4 vColor;
314varying float vTextureId;
315uniform sampler2D uSamplers[%count%];
316
317void main(void){
318    vec4 color;
319    %forloop%
320    gl_FragColor = color * vColor;
321}
322`,Eg=`precision highp float;
323attribute vec2 aVertexPosition;
324attribute vec2 aTextureCoord;
325attribute vec4 aColor;
326attribute float aTextureId;
327
328uniform mat3 projectionMatrix;
329uniform mat3 translationMatrix;
330uniform vec4 tint;
331
332varying vec2 vTextureCoord;
333varying vec4 vColor;
334varying float vTextureId;
335
336void main(void){
337    gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
337)).xy, 0.0, 1.0);
338
339    vTextureCoord = aTextureCoord;
340    vTextureId = aTextureId;
341    vColor = aColor * tint;
342}
343`;const Ls=class ce extends Gn{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Ou,this.vertexSize=6,this.state=ke.for2d(),this.size=ce.defaultBatchSize*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),t.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??wg(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??xg(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return et("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return Eg}static get defaultFragmentTemplate(){return Tg}setShaderGenerator({vertex:t=ce.defaultVertexSrc,fragment:e=ce.defaultFragmentTemplate}={}){this.shaderGenerator=new yg(t,e)}contextChange(){const t=this.renderer.gl;H.PREFER_ENV===zi.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),ce.defaultMaxTextures),this.maxTextures=Jm(this.maxTextures,t)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let e=0;e<this._packedGeometryPoolSize;e++)this._packedGeometries[e]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:t,_textureArrayPool:e}=ce,i=this.size/4,r=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new Ca);for(;e.length<r;)e.push(new Pa);for(let n=0;n<this.maxTextures;n++)this._tempBoundTextures[n]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:e}=this,i=ce._textureArrayPool,r=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++Q._globalBatch,h=0,l=i[0],c=0;r.copyBoundTextures(n,e);for(let u=0;u<this._bufferSize;++u){const d=t[u];t[u]=null,d._batchEnabled!==a&&(l.count>=e&&(r.boundArray(l,n,a,e),this.buildDrawCalls(l,c,u),c=u,l=i[++h],++a),d._batchEnabled=a,d.touched=o,l.elements[l.count++]=d)}l.count>0&&(r.boundArray(l,n,a,e),this.buildDrawCalls(l,c,this._bufferSize),++h,++a);for(let u=0;u<n.length;u++)n[u]=null;Q._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:r,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,h=ce._drawCallPool;let l=this._dcIndex,c=this._aIndex,u=this._iIndex,d=h[l];d.start=this._iIndex,d.texArray=t;for(let f=e;f<i;++f){const _=r[f],p=_._texture.baseTexture,m=Du[p.alphaMode?1:0][_.blendMode];r[f]=null,e<f&&d.blend!==m&&(d.size=u-d.start,e=f,d=h[++l],d.texArray=t,d.start=u),this.packInterleavedGeometry(_,n,o,c,u),c+=_.vertexData.length/2*a,u+=_.indices.length,d.blend=m}e<i&&(d.size=u-d.start,++l),this._dcIndex=l,this._aIndex=c,this._iIndex=u}bindAndClearTexArray(t){const e=this.renderer.texture;for(let i=0;i<t.count;i++)e.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:e,_indexBuffer:i}=this;ce.canUploadSameBuffer?(t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,t[this._flushId]=new this.geometryClass),t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:e,state:i}=this.renderer,r=ce._drawCallPool;let n=null;for(let o=0;o<t;o++){const{texArray:a,type:h,size:l,start:c,blend:u}=r[o];n!==a&&(n=a,this.bindAndClearTexArray(a)),this.state.blendMode=u,i.set(this.state),e.drawElements(h,l,e.UNSIGNED_SHORT,c*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),ce.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]&&this._packedGeometries[t].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(t){const e=ln(Math.ceil(t/8)),i=ml(e),r=e*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._aBuffers[r];return n||(this._aBuffers[r]=n=new Ea(r*this.vertexSize*4)),n}getIndexBuffer(t){const e=ln(Math.ceil(t/12)),i=ml(e),r=e*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._iBuffers[i];return n||(this._iBuffers[i]=n=new Uint16Array(r)),n}packInterleavedGeometry(t,e,i,r,n){const{uint32View:o,float32View:a}=e,h=r/this.vertexSize,l=t.uvs,c=t.indices,u=t.vertexData,d=t._texture.baseTexture._batchLocation,f=Math.min(t.worldAlpha,1),_=nt.shared.setValue(t._tintRGB).toPremultiplied(f,t._texture.baseTexture.alphaMode>0);for(let p=0;p<u.length;p+=2)a[r++]=u[p],a[r++]=u[p+1],a[r++]=l[p],a[r++]=l[p+1],o[r++]=_,a[r++]=d;for(let p=0;p<c.length;p++)i[n++]=h+c[p]}};Ls.defaultBatchSize=4096,Ls.extension={name:"batch",type:N.RendererPlugin},Ls._drawCallPool=[],Ls._textureArrayPool=[];let Pi=Ls;W.add(Pi);var Ag=`varying vec2 vTextureCoord;
344
345uniform sampler2D uSampler;
346
347void main(void){
348   gl_FragColor = texture2D(uSampler, vTextureCoord);
349}
350`,Sg=`attribute vec2 aVertexPosition;
351
352uniform mat3 projectionMatrix;
353
354varying vec2 vTextureCoord;
355
356uniform vec4 inputSize;
357uniform vec4 outputFrame;
358
359vec4 filterVertexPosition( void )
360{
361    vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
362
363    return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
364}
365
366vec2 filterTextureCoord( void )
367{
368    return aVertexPosition * (outputFrame.zw * inputSize.zw);
369}
370
371void main(void)
372{
373    gl_Position = filterVertexPosition();
374    vTextureCoord = filterTextureCoord();
375}
376`;const ka=class Ns extends Me{constructor(t,e,i){const r=Xe.from(t||Ns.defaultVertexSrc,e||Ns.defaultFragmentSrc);super(r,i),this.padding=0,this.resolution=Ns.defaultResolution,this.multisample=Ns.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new ke}apply(t,e,i,r,n){t.applyFilter(this,e,i,r)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return Sg}static get defaultFragmentSrc(){return Ag}};ka.defaultResolution=1,ka.defaultMultisample=vt.NONE;let Pt=ka;class dn{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new nt(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:r}=t,n=i??e;n!==void 0&&(this.color=n),this.alpha=r}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}dn.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},dn.extension={type:[N.RendererSystem,N.CanvasRendererSystem],name:"background"};W.add(dn);class Xu{constructor(t){this.renderer=t,this.emptyRenderer=new Gn(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:i}=this.renderer.texture;for(let r=e-1;r>=0;--r)t[r]=i[r]||null,t[r]&&(t[r]._batchLocation=r)}boundArray(t,e,i,r){const{elements:n,ids:o,count:a}=t;let h=0;for(let l=0;l<a;l++){const c=n[l],u=c._batchLocation;if(u>=0&&u<r&&e[u]===c){o[l]=u;continue}for(;h<r;){const d=e[h];if(d&&d._batchEnabled===i&&d._batchLocation===h){h++;continue}o[l]=h,c._batchLocation=h,e[h]=c;break}}}destroy(){this.renderer=null}}Xu.extension={type:N.RendererSystem,name:"batch"};W.add(Xu);let Cl=0;class fn{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=Cl++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:i,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=Cl++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;e.addEventListener!==void 0&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let i;if(H.PREFER_ENV>=zi.WEBGL2&&(i=t.getContext("webgl2",e)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const r=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=r,r||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}fn.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},fn.extension={type:N.RendererSystem,name:"context"};W.add(fn);class Ba{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new pe("disposeFramebuffer"),this.multisample=vt.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new Q(null,{scaleMode:He.NEAREST,resolution:1,mipmap:Pe.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new Q(null,{scaleMode:He.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Pe.OFF,format:B.DEPTH_COMPONENT,type:Y.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,e){if(t=Math.round(t),e=Math.round(e),!t||!e)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const r=this.colorTextures[i],n=r.resolution;r.setSize(t/n,e/n)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,e/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Vu extends Q{constructor(t={}){if(typeof t=="number"){const e=arguments[0],i=arguments[1],r=arguments[2],n=arguments[3];t={width:e,height:i,scaleMode:r,resolution:n}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=vt.NONE),super(null,t),this.mipmap=Pe.OFF,this.valid=!0,this._clear=new nt([0,0,0,0]),this.framebuffer=new Ba(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e){this.framebuffer.resize(t*this.resolution,e*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.he
vendor: 18,295 bytes, line 376
376ight)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class di extends Ks{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.width,r=e.naturalHeight||e.videoHeight||e.height;super(i,r),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=qm(e):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,e,i,r){const n=t.gl,o=e.realWidth,a=e.realHeight;if(r=r||this.source,typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement){if(!r.complete||r.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement&&r.readyState<=1)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Ht.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&i.width===o&&i.height===a?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,i.type,r):(i.width=o,i.height=a,n.texImage2D(e.target,0,i.internalFormat,e.format,i.type,r)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(e,i),super.update()}dispose(){this.source=null}}class Wu extends di{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;di.crossOrigin(i,t,e.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(e.createBitmap??H.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.bitmap=null,this._load=null,e.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((e,i)=>{const r=this.source;this.url=r.src;const n=()=>{this.destroyed||(r.onload=null,r.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};r.complete&&r.src?n():(r.onload=n,r.onerror=o=>{i(o),this.onError.emit(o)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(r=>r.blob()).then(r=>e(r,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Ht.UNPACK?"premultiply":"none"})).then(r=>this.destroyed?Promise.reject():(this.bitmap=r,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,i){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let r=!0;const n=e._glTextures;for(const o in n){const a=n[o];if(a!==i&&a.dirtyId!==e.dirtyId){r=!1;break}}r&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class gh{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const r=e.width,n=e.height;if(i){const o=t.width/2/r,a=t.height/2/n,h=t.x/r+o,l=t.y/n+a;i=dt.add(i,dt.NW),this.x0=h+o*dt.uX(i),this.y0=l+a*dt.uY(i),i=dt.add(i,2),this.x1=h+o*dt.uX(i),this.y1=l+a*dt.uY(i),i=dt.add(i,2),this.x2=h+o*dt.uX(i),this.y2=l+a*dt.uY(i),i=dt.add(i,2),this.x3=h+o*dt.uX(i),this.y3=l+a*dt.uY(i)}else this.x0=t.x/r,this.y0=t.y/n,this.x1=(t.x+t.width)/r,this.y1=t.y/n,this.x2=(t.x+t.width)/r,this.y2=(t.y+t.height)/n,this.x3=t.x/r,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}gh.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const Il=new gh;function fr(s){s.destroy=function(){},s.on=function(){},s.once=function(){},s.emit=function(){}}class V extends Qs{constructor(t,e,i,r,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new J(0,0,1,1)),t instanceof V&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=r,this.valid=!1,this.destroyed=!1,this._uvs=Il,this.uvMatrix=null,this.orig=i||e,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=o?new st(o.x,o.y):new st(0,0),this.defaultBorders=a,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:e}=this.baseTexture;e?.url&&we[e.url]&&V.removeFromCache(e.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,V.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),i=new V(this.baseTexture,!this.noFrame&&t,e,this.trim?.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===Il&&(this._uvs=new gh),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=H.STRICT_TEXTURE_CACHE){const r=typeof t=="string";let n=null;if(r)n=t;else if(t instanceof Q){if(!t.cacheId){const a=e?.pixiIdPrefix||"pixiid";t.cacheId=`${a}-${Ui()}`,Q.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=e?.pixiIdPrefix||"pixiid";t._pixiId=`${a}_${Ui()}`}n=t._pixiId}let o=we[n];if(r&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof Q)?(e.resolution||(e.resolution=je(t)),o=new V(new Q(t,e)),o.baseTexture.cacheId=n,Q.addToCache(o.baseTexture,n),V.addToCache(o,n)):!o&&t instanceof Q&&(o=new V(t),V.addToCache(o,n)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e?.resourceOptions),r=V.from(t,Object.assign({resourceOptions:i},e),!1),n=r.baseTexture.resource;return r.baseTexture.valid?Promise.resolve(r):n.load().then(()=>Promise.resolve(r))}static fromBuffer(t,e,i,r){return new V(Q.fromBuffer(t,e,i,r))}static fromLoader(t,e,i,r){const n=new Q(t,Object.assign({scaleMode:Q.defaultOptions.scaleMode,resolution:je(e)},r)),{resource:o}=n;o instanceof Wu&&(o.url=e);const a=new V(n);return i||(i=e),Q.addToCache(a.baseTexture,i),V.addToCache(a,i),i!==e&&(Q.addToCache(a.baseTexture,e),V.addToCache(a,e)),a.baseTexture.valid?Promise.resolve(a):new Promise(h=>{a.baseTexture.once("loaded",()=>h(a))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),we[e]&&we[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),we[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=we[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete we[t],e}}else if(t?.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)we[t.textureCacheIds[e]]===t&&delete we[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:i,width:r,height:n}=t,o=e+r>this.baseTexture.width,a=i+n>this.baseTexture.height;if(o||a){const h=o&&a?"and":"or",l=`X: ${e} + ${r} = ${e+r} > ${this.baseTexture.width}`,c=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${l} ${h} ${c}`)}this.valid=r&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return V._EMPTY||(V._EMPTY=new V(new Q),fr(V._EMPTY),fr(V._EMPTY.baseTexture)),V._EMPTY}static get WHITE(){if(!V._WHITE){const t=H.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),V._WHITE=new V(Q.from(t)),fr(V._WHITE),fr(V._WHITE.baseTexture)}return V._WHITE}}class Bt extends V{constructor(t,e){super(t,e),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e,i=!0){const r=this.baseTexture.resolution,n=Math.round(t*r)/r,o=Math.round(e*r)/r;this.valid=n>0&&o>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=o,i&&this.baseTexture.resize(n,o),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new Bt(new Vu(t))}}class ju{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=vt.NONE){const r=new Vu(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new Bt(r)}getOptimalTexture(t,e,i=1,r=vt.NONE){let n;t=Math.max(Math.ceil(t*i-1e-6),1),e=Math.max(Math.ceil(e*i-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=ln(t),e=ln(e),n=((t&65535)<<16|e&65535)>>>0,r>1&&(n+=r*4294967296)):n=r>1?-r:-1,this.texturePool[n]||(this.texturePool[n]=[]);let o=this.texturePool[n].pop();return o||(o=this.createTexture(t,e,r)),o.filterPoolKey=n,o.setResolution(i),o}getFilterTexture(t,e,i){const r=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||vt.NONE);return r.filterFrame=t.filterFrame,r}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const e in this.texturePool){const i=this.texturePool[e];if(i)for(let r=0;r<i.length;r++)i[r].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const i=this.texturePool[e];if(i)for(let r=0;r<i.length;r++)i[r].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}ju.SCREEN_KEY=-1;class Cg extends ui{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class Yu extends ui{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new bt(this.vertices),this.uvBuffer=new bt(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,r=0;return this.uvs[0]=i,this.uvs[1]=r,this.uvs[2]=i+e.width/t.width,this.uvs[3]=r,this.uvs[4]=i+e.width/t.width,this.uvs[5]=r+e.height/t.height,this.uvs[6]=i,this.uvs[7]=r+e.height/t.height,i=e.x,r=e.y,this.vertices[0]=i,this.vertices[1]=r,this.vertices[2]=i+e.width,this.vertices[3]=r,this.vertices[4]=i+e.width,this.vertices[5]=r+e.height,this.vertices[6]=i,this.vertices[7]=r+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class Ig{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=vt.NONE,this.sourceFrame=new J,this.destinationFrame=new J,this.bindingSourceFrame=new J,this.bindingDestinationFrame=new J,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const _r=[new st,new st,new st,new st],Mo=new ct;class qu{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new ju,this.statePool=[],this.quad=new Cg,this.quadUv=new Yu,this.tempRect=new J,this.activeState={},this.globalUniforms=new me({outputFrame:new J,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const i=this.renderer,r=this.defaultFilterStack,n=this.statePool.pop()||new Ig,o=i.renderTexture;let a,h;if(o.current){const m=o.current;a=m.resolution,h=m.multisample}else a=i.resolution,h=i.multisample;let l=e[0].resolution||a,c=e[0].multisample??h,u=e[0].padding,d=e[0].autoFit,f=e[0].legacy??!0;for(let m=1;m<e.length;m++){const g=e[m];l=Math.min(l,g.resolution||a),c=Math.min(c,g.multisample??h),u=this.useMaxPadding?Math.max(u,g.padding):u+g.padding,d=d&&g.autoFit,f=f||(g.legacy??!0)}r.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),r.push(n),n.resolution=l,n.multisample=c,n.legacy=f,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(u);const _=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(Mo.copyFrom(i.projection.transform).invert(),_),d?(n.sourceFrame.fit(_),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(_)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,o.current?o.current.resolution:i.resolution,o.sourceFrame,o.destinationFrame,i.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,l,c),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const p=this.tempRect;p.x=0,p.y=0,p.width=n.sourceFrame.width,p.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(o.sourceFrame),n.bindingDestinationFrame.copyFrom(o.destinationFrame),n.transform=i.projection.transform,i.projection.transform=null,o.bind(n.renderTexture,n.sourceFrame,p),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const r=this.globalUniforms.uniforms;r.outputFrame=e.sourceFrame,r.resolution=e.resolution;const n=r.inputSize,o=r.inputPixel,a=r.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],o[0]=Math.round(n[0]*e.resolution),o[1]=Math.round(n[1]*e.resolution),o[2]=1/o[0],o[3]=1/o[1],a[0]=.5*o[2],a[1]=.5*o[3],a[2]=e.sourceFrame.width*n[2]-.5*o[2],a[3]=e.sourceFrame.height*n[3]-.5*o[3],e.legacy){const l=r.filterArea;l[0]=e.destinationFrame.width,l[1]=e.destinationFrame.height,l[2]=e.sourceFrame.x,l[3]=e.sourceFrame.y,r.filterClamp=r.inputClamp}this.globalUniforms.update();const h=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,e.renderTexture,h.renderTexture,Ae.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let l=e.renderTexture,c=this.getOptimalFilterTexture(l.width,l.height,e.resolution);c.filterFrame=l.filterFrame;let u=0;for(u=0;u<i.length-1;++u){u===1&&e.multisample>1&&(c=this.getOptimalFilterTexture(l.width,l.height,e.resolution),c.filterFrame=l.filterFrame),i[u].apply(this,l,c,Ae.CLEAR,e);const d=l;l=c,c=d}i[u].apply(this,l,h.renderTexture,Ae.BLEND,e),u>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(l),this.returnFilterTexture(c)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=Ae.CLEAR){const{renderTexture:i,state:r}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t?.filterFrame){const o=this.tempRect;o.x=0,o.y=0,o.width=t.filterFrame.width,o.height=t.filterFrame.height,i.bind(t,t.filterFrame,o)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=r.stateId&1||this.forceClear;(e===Ae.CLEAR||e===Ae.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,r){const n=this.renderer;n.state.set(t.state),this.bindAndClear(i,r),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(Ie.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(Ie.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:r}=this.activeState,{orig:n}=e._texture,o=t.set(r.width,0,0,r.height,i.x,i.y),a=e.worldTransform.copyTo(ct.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/n.width,1/n.height),o.translate(e.anchor.x,e.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,i=1,r=vt.NONE){return this.texturePool.getOptimalTexture(t,e,i,r)}getFilterTexture(t,e,i){if(typeof t=="number"){const n=t;t=e,e=n}t=t||this.activeState.renderTexture;const r=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,i||vt.NONE);return r.filterFrame=t.filterFrame,r}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}
vendor: 15,430 bytes, lines 376-393
376resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=_r[0],r=_r[1],n=_r[2],o=_r[3];i.set(e.left,e.top),r.set(e.left,e.bottom),n.set(e.right,e.top),o.set(e.right,e.bottom),t.apply(i,i),t.apply(r,r),t.apply(n,n),t.apply(o,o);const a=Math.min(i.x,r.x,n.x,o.x),h=Math.min(i.y,r.y,n.y,o.y),l=Math.max(i.x,r.x,n.x,o.x),c=Math.max(i.y,r.y,n.y,o.y);e.x=a,e.y=h,e.width=l-a,e.height=c-h}roundFrame(t,e,i,r,n){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(n){const{a:o,b:a,c:h,d:l}=n;if((Math.abs(a)>1e-4||Math.abs(h)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(l)>1e-4))return}n=n?Mo.copyFrom(n):Mo.identity(),n.translate(-i.x,-i.y).scale(r.width/i.width,r.height/i.height).translate(r.x,r.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}qu.extension={type:N.RendererSystem,name:"filter"};W.add(qu);class Rg{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=vt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const Mg=new J;class Zu{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Ba(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new J,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;H.PREFER_ENV===zi.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=r=>e.drawBuffersWEBGL(r):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,i=0){const{gl:r}=this;if(t){const n=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,r.bindFramebuffer(r.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=i),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let o=0;o<t.colorTextures.length;o++){const a=t.colorTextures[o];this.renderer.texture.unbind(a.parentTextureArray||a)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const o=e.width>>i,a=e.height>>i,h=o/e.width;this.setViewport(e.x*h,e.y*h,o,a)}else{const o=t.width>>i,a=t.height>>i;this.setViewport(0,0,o,a)}}else this.current&&(this.current=null,r.bindFramebuffer(r.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,i,r){const n=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),r=Math.round(r),(n.width!==i||n.height!==r||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=i,n.height=r,this.gl.viewport(t,e,i,r))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,e,i,r,n=ma.COLOR|ma.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,r),o.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new Rg(e.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:e}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){e.bindRenderbuffer(e.RENDERBUFFER,i.stencil);let o;this.renderer.context.webGLVersion===1?o=e.DEPTH_STENCIL:t.depth&&t.stencil?o=e.DEPTH24_STENCIL8:t.depth?o=e.DEPTH_COMPONENT24:o=e.STENCIL_INDEX8,i.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,o,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,o,t.width,t.height)}const r=t.colorTextures;let n=r.length;e.drawBuffers||(n=Math.min(n,1));for(let o=0;o<n;o++){const a=r[o],h=a.parentTextureArray||a;this.renderer.texture.bind(h,0),o===0&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,h._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:i}=this,r=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let o=n.length;i.drawBuffers||(o=Math.min(o,1)),r.multisample>1&&this.canMultisampleFramebuffer(t)?r.msaaBuffer=r.msaaBuffer||i.createRenderbuffer():r.msaaBuffer&&(i.deleteRenderbuffer(r.msaaBuffer),r.msaaBuffer=null,r.blitFramebuffer&&(r.blitFramebuffer.dispose(),r.blitFramebuffer=null));const a=[];for(let h=0;h<o;h++){const l=n[h],c=l.parentTextureArray||l;this.renderer.texture.bind(c,0),h===0&&r.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,r.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,c._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,r.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+h,l.target,c._glTextures[this.CONTEXT_UID].texture,e),a.push(i.COLOR_ATTACHMENT0+h))}if(a.length>1&&i.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const h=t.depthTexture;this.renderer.texture.bind(h,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,h._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){r.stencil=r.stencil||i.createRenderbuffer();let h,l;this.renderer.context.webGLVersion===1?(h=i.DEPTH_STENCIL_ATTACHMENT,l=i.DEPTH_STENCIL):t.depth&&t.stencil?(h=i.DEPTH_STENCIL_ATTACHMENT,l=i.DEPTH24_STENCIL8):t.depth?(h=i.DEPTH_ATTACHMENT,l=i.DEPTH_COMPONENT24):(h=i.STENCIL_ATTACHMENT,l=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,r.stencil),r.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,l,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,l,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,h,i.RENDERBUFFER,r.stencil)}else r.stencil&&(i.deleteRenderbuffer(r.stencil),r.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=vt.NONE;if(t<=1||e===null)return i;for(let r=0;r<e.length;r++)if(e[r]<=t){i=e[r];break}return i===1&&(i=vt.NONE),i}blit(t,e,i){const{current:r,renderer:n,gl:o,CONTEXT_UID:a}=this;if(n.context.webGLVersion!==2||!r)return;const h=r.glFramebuffers[a];if(!h)return;if(!t){if(!h.msaaBuffer)return;const c=r.colorTextures[0];if(!c)return;h.blitFramebuffer||(h.blitFramebuffer=new Ba(r.width,r.height),h.blitFramebuffer.addColorTexture(0,c)),t=h.blitFramebuffer,t.colorTextures[0]!==c&&(t.colorTextures[0]=c,t.dirtyId++,t.dirtyFormat++),(t.width!==r.width||t.height!==r.height)&&(t.width=r.width,t.height=r.height,t.dirtyId++,t.dirtySize++)}e||(e=Mg,e.width=r.width,e.height=r.height),i||(i=e);const l=e.width===i.width&&e.height===i.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,h.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,o.COLOR_BUFFER_BIT,l?o.NEAREST:o.LINEAR),o.bindFramebuffer(o.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const i=t.glFramebuffers[this.CONTEXT_UID],r=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(r.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&r.deleteRenderbuffer(i.msaaBuffer),i.stencil&&r.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<e.length;i++)this.disposeFramebuffer(e[i],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,r=t.height,n=this.gl,o=e.stencil=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,o);let a,h;this.renderer.context.webGLVersion===1?(a=n.DEPTH_STENCIL_ATTACHMENT,h=n.DEPTH_STENCIL):t.depth?(a=n.DEPTH_STENCIL_ATTACHMENT,h=n.DEPTH24_STENCIL8):(a=n.STENCIL_ATTACHMENT,h=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,h,i,r):n.renderbufferStorage(n.RENDERBUFFER,h,i,r),n.framebufferRenderbuffer(n.FRAMEBUFFER,a,n.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new J}destroy(){this.renderer=null}}Zu.extension={type:N.RendererSystem,name:"framebuffer"};W.add(Zu);const Po={5126:4,5123:2,5121:1};class Ku{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,e.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;H.PREFER_ENV===zi.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=r=>i.bindVertexArrayOES(r),t.deleteVertexArray=r=>i.deleteVertexArrayOES(r)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(r,n)=>i.vertexAttribDivisorANGLE(r,n),t.drawElementsInstanced=(r,n,o,a,h)=>i.drawElementsInstancedANGLE(r,n,o,a,h),t.drawArraysInstanced=(r,n,o,a)=>i.drawArraysInstancedANGLE(r,n,o,a)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:i}=this;let r=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;r||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=r={},n=!0);const o=r[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==o&&(this._activeVao=o,this.hasVao?i.bindVertexArray(o):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const r=t.buffers[i];e.update(r)}}checkCompatibility(t,e){const i=t.attributes,r=e.attributeData;for(const n in r)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,r=e.attributeData,n=["g",t.id];for(const o in i)r[o]&&n.push(o,r[o].location);return n.join("-")}initGeometryVao(t,e,i=!0){const r=this.gl,n=this.CONTEXT_UID,o=this.renderer.buffer,a=e.program;a.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,a);const h=this.getSignature(t,a),l=t.glVertexArrayObjects[this.CONTEXT_UID];let c=l[h];if(c)return l[a.id]=c,c;const u=t.buffers,d=t.attributes,f={},_={};for(const p in u)f[p]=0,_[p]=0;for(const p in d)!d[p].size&&a.attributeData[p]?d[p].size=a.attributeData[p].size:d[p].size||console.warn(`PIXI Geometry attribute '${p}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[p].buffer]+=d[p].size*Po[d[p].type];for(const p in d){const m=d[p],g=m.size;m.stride===void 0&&(f[m.buffer]===g*Po[m.type]?m.stride=0:m.stride=f[m.buffer]),m.start===void 0&&(m.start=_[m.buffer],_[m.buffer]+=g*Po[m.type])}c=r.createVertexArray(),r.bindVertexArray(c);for(let p=0;p<u.length;p++){const m=u[p];o.bind(m),i&&m._glBuffers[n].refCount++}return this.activateVao(t,a),l[a.id]=c,l[h]=c,r.bindVertexArray(null),o.unbind(Re.ARRAY_BUFFER),c}disposeGeometry(t,e){if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],r=this.gl,n=t.buffers,o=this.renderer?.buffer;if(t.disposeRunner.remove(this),!!i){if(o)for(let a=0;a<n.length;a++){const h=n[a]._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&o.dispose(n[a],e))}if(!e){for(const a in i)if(a[0]==="g"){const h=i[a];this._activeVao===h&&this.unbind(),r.deleteVertexArray(h)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let i=0;i<e.length;i++)this.disposeGeometry(this.managedGeometries[e[i]],t)}activateVao(t,e){const i=this.gl,r=this.CONTEXT_UID,n=this.renderer.buffer,o=t.buffers,a=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let h=null;for(const l in a){const c=a[l],u=o[c.buffer],d=u._glBuffers[r];if(e.attributeData[l]){h!==d&&(n.bind(u),h=d);const f=e.attributeData[l].location;if(i.enableVertexAttribArray(f),i.vertexAttribPointer(f,c.size,c.type||i.FLOAT,c.normalized,c.stride,c.start),c.instance)if(this.hasInstance)i.vertexAttribDivisor(f,c.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,r){const{gl:n}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,h=a===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?n.drawElementsInstanced(t,e||o.indexBuffer.data.length,h,(i||0)*a,r||1):n.drawElements(t,e||o.indexBuffer.data.length,h,(i||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?n.drawArraysInstanced(t,i,e||o.getSize(),r||1):n.drawArrays(t,i,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}Ku.extension={type:N.RendererSystem,name:"geometry"};W.add(Ku);const Rl=new ct;class Ju{constructor(t,e){this._texture=t,this.mapCoord=new ct,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let r=0;r<t.length;r+=2){const n=t[r],o=t[r+1];e[r]=n*i.a+o*i.c+i.tx,e[r+1]=n*i.b+o*i.d+i.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const i=e._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const r=e.orig,n=e.trim;n&&(Rl.set(r.width/n.width,0,0,r.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Rl));const o=e.baseTexture,a=this.uClampFrame,h=this.clampMargin/o.resolution,l=this.clampOffset;return a[0]=(e._frame.x+h+l)/o.width,a[1]=(e._frame.y+h+l)/o.height,a[2]=(e._frame.x+e._frame.width-h+l)/o.width,a[3]=(e._frame.y+e._frame.height-h+l)/o.height,this.uClampOffset[0]=l/o.realWidth,this.uClampOffset[1]=l/o.realHeight,this.isSimple=e._frame.width===o.width&&e._frame.height===o.height&&e.rotate===0,!0}}var Pg=`varying vec2 vMaskCoord;
377varying vec2 vTextureCoord;
378
379uniform sampler2D uSampler;
380uniform sampler2D mask;
381uniform float alpha;
382uniform float npmAlpha;
383uniform vec4 maskClamp;
384
385void main(void)
386{
387    float clip = step(3.5,
388        step(maskClamp.x, vMaskCoord.x) +
389        step(maskClamp.y, vMaskCoord.y) +
390        step(vMaskCoord.x, maskClamp.z) +
391        step(vMaskCoord.y, maskClamp.w));
392
393    vec4 original = texture2D(uSampler, vTextureCoord);
394    vec4 masky = texture2D(mask, vMaskCoord);
395    float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
396
397    original *= (alphaMul * masky.r * alpha * clip);
398
399    gl_FragColor = original;
400}
401`,kg=`attribute vec2 aVertexPosition;
402attribute vec2 aTextureCoord;
403
404uniform mat3 projectionMatrix;
405uniform mat3 otherMatrix;
406
407varying vec2 vMaskCoord;
408varying vec2 vTextureCoord;
409
410void main(void)
411{
412    gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
413
414    vTextureCoord = aTextureCoord;
415    vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0)  ).xy;
416}
417`;class Bg extends Pt{constructor(t,e,i){let r=null;typeof t!="string"&&e===void 0&&i===void 0&&(r=t,t=void 0,e=void 0,i=void 0),super(t||kg,e||Pg,i),this.maskSprite=r,this.maskMatrix=new ct}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,r){const n=this._maskSprite,o=n._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new Ju(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,n).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=n.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,t.applyFilter(this,e,i,r))}}class Dg{constructor(t=null){this.type=xt.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Pt.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=xt.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class Qu{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let i=e;if(!i.isMaskData){const n=this.maskDataPool.pop()||new Dg;n.pooled=!0,n.maskObject=e,i=n}const r=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(r),i._colorMask=r?r._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==xt.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case xt.SCISSOR:this.renderer.scissor.push(i);break;case xt.STENCIL:this.renderer.stencil.push(i);break;case xt.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case xt.COLOR:this.pushColorMask(i);break}i.type===xt.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case xt.SCISSOR:this.renderer.scissor.pop(e);break;case xt.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case xt.SPRITE:this.popSpriteMask(e);break;case xt.COLOR:this.popColorMask(e);break}if(e.reset(),e.pooled&&this.maskDataPool.push(e),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===xt.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=xt.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=xt.SCISSOR:t.type=xt.STENCIL:t.type=xt.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let r=t._filters;r||(r=this.alphaMaskPool[this.alphaMaskIndex],r||(r=this.alphaMaskPool[this.alphaMaskIndex]=[new Bg])),r[0].resolution=t.resolution,r[0].multisample=t.multisample,r[0].maskSprite=e;const n=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,r),i.filterArea=n,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,i=t._colorMask=e&t.colorMask;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const e=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}Qu.extension={type:N.RendererSystem,name:"mask"};W.add(Qu);class td{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,i=this.getStackLength();this.maskStack=t;const r=this.getStackLength();r!==i&&(r===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const Ml=new ct,Pl=[],ed=class Fr extends td{constructor(t){super(t),this.glConst=H.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}
vendor: 30,525 bytes, lines 417-487
417calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:i}=t,{renderer:r}=this,n=r.renderTexture,o=i.getBounds(!0,Pl.pop()??new J);this.roundFrameToPixels(o,n.current?n.current.resolution:r.resolution,n.sourceFrame,n.destinationFrame,r.projection.transform),e&&o.fit(e),t._scissorRectLocal=o}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:i,c:r,d:n}=t;return(Math.abs(i)>1e-4||Math.abs(r)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(n)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||Fr.isMatrixRotated(e.worldTransform)||Fr.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,e,i,r,n){Fr.isMatrixRotated(n)||(n=n?Ml.copyFrom(n):Ml.identity(),n.translate(-i.x,-i.y).scale(r.width/i.width,r.height/i.height).translate(r.x,r.y),this.renderer.filter.transformAABB(n,t),t.fit(r),t.x=Math.round(t.x*e),t.y=Math.round(t.y*e),t.width=Math.round(t.width*e),t.height=Math.round(t.height*e))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:e}=this.renderer;t._scissorRect||e.enable(e.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:e}=this.renderer;t&&Pl.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():e.disable(e.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let e;this.renderer.renderTexture.current?e=t.y:e=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};ed.extension={type:N.RendererSystem,name:"scissor"};let Fg=ed;W.add(Fg);class id extends td{constructor(t){super(t),this.glConst=H.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const e=t.maskObject,{gl:i}=this.renderer,r=t._stencilCounter;r===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,r,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,i.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}pop(t){const e=this.renderer.gl;if(this.getStackLength()===0)e.disable(e.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,r=i?i._colorMask:15;r!==0&&(i._colorMask=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,r!==0&&(i._colorMask=r,e.colorMask((r&1)!==0,(r&2)!==0,(r&4)!==0,(r&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}id.extension={type:N.RendererSystem,name:"stencil"};W.add(id);class sd{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return et("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return et("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return et("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),t.events}}})}init(){const t=this.rendererPlugins;for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}sd.extension={type:[N.RendererSystem,N.CanvasRendererSystem],name:"_plugin"};W.add(sd);class rd{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new ct,this.transform=null}update(t,e,i,r){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,r),this.transform&&this.projectionMatrix.append(this.transform);const n=this.renderer;n.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,n.globalUniforms.update(),n.shader.shader&&n.shader.syncUniformGroup(n.shader.shader.uniforms.globals)}calculateProjection(t,e,i,r){const n=this.projectionMatrix,o=r?-1:1;n.identity(),n.a=1/e.width*2,n.d=o*(1/e.height*2),n.tx=-1-e.x*n.a,n.ty=-o-e.y*n.d}setTransform(t){}destroy(){this.renderer=null}}rd.extension={type:N.RendererSystem,name:"projection"};W.add(rd);const Lg=new mh,kl=new J;class nd{constructor(t){this.renderer=t,this._tempMatrix=new ct}generateTexture(t,e){const{region:i,...r}=e||{},n=i?.copyTo(kl)||t.getLocalBounds(kl,!0),o=r.resolution||this.renderer.resolution;n.width=Math.max(n.width,1/o),n.height=Math.max(n.height,1/o),r.width=n.width,r.height=n.height,r.resolution=o,r.multisample??(r.multisample=this.renderer.multisample);const a=Bt.create(r);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const h=t.transform;return t.transform=Lg,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=h,a}destroy(){}}nd.extension={type:[N.RendererSystem,N.CanvasRendererSystem],name:"textureGenerator"};W.add(nd);const wi=new J,Ms=new J;class od{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new J,this.destinationFrame=new J,this.viewportFrame=new J}contextChange(){const t=this.renderer?.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,i){const r=this.renderer;this.current=t;let n,o,a;t?(n=t.baseTexture,a=n.resolution,e||(wi.width=t.frame.width,wi.height=t.frame.height,e=wi),i||(Ms.x=t.frame.x,Ms.y=t.frame.y,Ms.width=e.width,Ms.height=e.height,i=Ms),o=n.framebuffer):(a=r.resolution,e||(wi.width=r._view.screen.width,wi.height=r._view.screen.height,e=wi),i||(i=wi,i.width=e.width,i.height=e.height));const h=this.viewportFrame;h.x=i.x*a,h.y=i.y*a,h.width=i.width*a,h.height=i.height*a,t||(h.y=r.view.height-(h.y+h.height)),h.ceil(),this.renderer.framebuffer.bind(o,h),this.renderer.projection.update(i,e,a,!o),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(i)}clear(t,e){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,r=nt.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&r.premultiply(r.alpha);const n=this.destinationFrame,o=this.current?this.current.baseTexture:this.renderer._view.screen,a=n.width!==o.width||n.height!==o.height;if(a){let{x:h,y:l,width:c,height:u}=this.viewportFrame;h=Math.round(h),l=Math.round(l),c=Math.round(c),u=Math.round(u),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(h,l,c,u)}this.renderer.framebuffer.clear(r.red,r.green,r.blue,r.alpha,e),a&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}od.extension={type:N.RendererSystem,name:"renderTexture"};W.add(od);class Ng{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function Og(s,t){const e={},i=t.getProgramParameter(s,t.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const n=t.getActiveAttrib(s,r);if(n.name.startsWith("gl_"))continue;const o=$u(t,n.type),a={type:o,name:n.name,size:zu(o),location:t.getAttribLocation(s,n.name)};e[n.name]=a}return e}function Ug(s,t){const e={},i=t.getProgramParameter(s,t.ACTIVE_UNIFORMS);for(let r=0;r<i;r++){const n=t.getActiveUniform(s,r),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),h=$u(t,n.type);e[o]={name:o,index:r,type:h,size:n.size,isArray:a,value:Gu(h,n.size)}}return e}function Gg(s,t){const e=Tl(s,s.VERTEX_SHADER,t.vertexSrc),i=Tl(s,s.FRAGMENT_SHADER,t.fragmentSrc),r=s.createProgram();s.attachShader(r,e),s.attachShader(r,i);const n=t.extra?.transformFeedbackVaryings;if(n&&(typeof s.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):s.transformFeedbackVaryings(r,n.names,n.bufferMode==="separate"?s.SEPARATE_ATTRIBS:s.INTERLEAVED_ATTRIBS)),s.linkProgram(r),s.getProgramParameter(r,s.LINK_STATUS)||pg(s,r,e,i),t.attributeData=Og(r,s),t.uniformData=Ug(r,s),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const a=Object.keys(t.attributeData);a.sort((h,l)=>h>l?1:-1);for(let h=0;h<a.length;h++)t.attributeData[a[h]].location=h,s.bindAttribLocation(r,h,a[h]);s.linkProgram(r)}s.deleteShader(e),s.deleteShader(i);const o={};for(const a in t.uniformData){const h=t.uniformData[a];o[a]={location:s.getUniformLocation(r,a),value:Gu(h.type,h.size)}}return new Ng(r,o)}function Hg(s,t,e,i,r){e.buffer.update(r)}const zg={float:`
418        data[offset] = v;
419    `,vec2:`
420        data[offset] = v[0];
421        data[offset+1] = v[1];
422    `,vec3:`
423        data[offset] = v[0];
424        data[offset+1] = v[1];
425        data[offset+2] = v[2];
426
427    `,vec4:`
428        data[offset] = v[0];
429        data[offset+1] = v[1];
430        data[offset+2] = v[2];
431        data[offset+3] = v[3];
432    `,mat2:`
433        data[offset] = v[0];
434        data[offset+1] = v[1];
435
436        data[offset+4] = v[2];
437        data[offset+5] = v[3];
438    `,mat3:`
439        data[offset] = v[0];
440        data[offset+1] = v[1];
441        data[offset+2] = v[2];
442
443        data[offset + 4] = v[3];
444        data[offset + 5] = v[4];
445        data[offset + 6] = v[5];
446
447        data[offset + 8] = v[6];
448        data[offset + 9] = v[7];
449        data[offset + 10] = v[8];
450    `,mat4:`
451        for(var i = 0; i < 16; i++)
452        {
453            data[offset + i] = v[i];
454        }
455    `},ad={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:16*2,mat3:16*3,mat4:16*4};function $g(s){const t=s.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,i=0,r=0;for(let n=0;n<t.length;n++){const o=t[n];if(e=ad[o.data.type],o.data.size>1&&(e=Math.max(e,16)*o.data.size),o.dataLen=e,i%e!==0&&i<16){const a=i%e%16;i+=a,r+=a}i+e>16?(r=Math.ceil(r/16)*16,o.offset=r,r+=e,i=e):(o.offset=r,i+=e,r+=e)}return r=Math.ceil(r/16)*16,{uboElements:t,size:r}}function Xg(s,t){const e=[];for(const i in s)t[i]&&e.push(t[i]);return e.sort((i,r)=>i.index-r.index),e}function Vg(s,t){if(!s.autoManage)return{size:0,syncFunc:Hg};const e=Xg(s.uniforms,t),{uboElements:i,size:r}=$g(e),n=[`
456    var v = null;
457    var v2 = null;
458    var cv = null;
459    var t = 0;
460    var gl = renderer.gl
461    var index = 0;
462    var data = buffer.data;
463    `];for(let o=0;o<i.length;o++){const a=i[o],h=s.uniforms[a.data.name],l=a.data.name;let c=!1;for(let u=0;u<fs.length;u++){const d=fs[u];if(d.codeUbo&&d.test(a.data,h)){n.push(`offset = ${a.offset/4};`,fs[u].codeUbo(a.data.name,h)),c=!0;break}}if(!c)if(a.data.size>1){const u=zu(a.data.type),d=Math.max(ad[a.data.type]/16,1),f=u/d,_=(4-f%4)%4;n.push(`
464                cv = ud.${l}.value;
465                v = uv.${l};
466                offset = ${a.offset/4};
467
468                t = 0;
469
470                for(var i=0; i < ${a.data.size*d}; i++)
471                {
472                    for(var j = 0; j < ${f}; j++)
473                    {
474                        data[offset++] = v[t++];
475                    }
476                    offset += ${_};
477                }
478
479                `)}else{const u=zg[a.data.type];n.push(`
480                cv = ud.${l}.value;
481                v = uv.${l};
482                offset = ${a.offset/4};
483                ${u};
484                `)}}return n.push(`
485       renderer.buffer.update(buffer);
486    `),{size:r,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(`
487`))}}let Wg=0;const pr={textureCount:0,uboCount:0};class hd{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=Wg++}systemCheck(){if(!gg())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,r=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(r.program)),e||(pr.textureCount=0,pr.uboCount=0,this.syncUniformGroup(t.uniformGroup,pr)),r}setUniforms(t){const e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=dg(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;const r=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),r(i.uniformData,t.uniforms,this.renderer,pr,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:r}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,r.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const o=this.getSignature(t,this.shader.program.uniformData,"ubo");let a=this._uboCache[o];if(a||(a=this._uboCache[o]=Vg(t,this.shader.program.uniformData)),t.autoManage){const h=new Float32Array(a.size/4);t.buffer.update(h)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){const r=t.uniforms,n=[`${i}-`];for(const o in r)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,i=t.program,r=Gg(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=r,r}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}hd.extension={type:N.RendererSystem,name:"shader"};W.add(hd);class _n{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.3.2 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}_n.defaultOptions={hello:!1},_n.extension={type:[N.RendererSystem,N.CanvasRendererSystem],name:"startup"};W.add(_n);function jg(s,t=[]){return t[Z.NORMAL]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.ADD]=[s.ONE,s.ONE],t[Z.MULTIPLY]=[s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.SCREEN]=[s.ONE,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.OVERLAY]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.DARKEN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.LIGHTEN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.COLOR_DODGE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.COLOR_BURN]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.HARD_LIGHT]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.SOFT_LIGHT]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.DIFFERENCE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.EXCLUSION]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.HUE]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.SATURATION]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.COLOR]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.LUMINOSITY]=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.NONE]=[0,0],t[Z.NORMAL_NPM]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.ADD_NPM]=[s.SRC_ALPHA,s.ONE,s.ONE,s.ONE],t[Z.SCREEN_NPM]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t[Z.SRC_IN]=[s.DST_ALPHA,s.ZERO],t[Z.SRC_OUT]=[s.ONE_MINUS_DST_ALPHA,s.ZERO],t[Z.SRC_ATOP]=[s.DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],t[Z.DST_OVER]=[s.ONE_MINUS_DST_ALPHA,s.ONE],t[Z.DST_IN]=[s.ZERO,s.SRC_ALPHA],t[Z.DST_OUT]=[s.ZERO,s.ONE_MINUS_SRC_ALPHA],t[Z.DST_ATOP]=[s.ONE_MINUS_DST_ALPHA,s.SRC_ALPHA],t[Z.XOR]=[s.ONE_MINUS_DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],t[Z.SUBTRACT]=[s.ONE,s.ONE,s.ONE,s.ONE,s.FUNC_REVERSE_SUBTRACT,s.FUNC_ADD],t}const Yg=0,qg=1,Zg=2,Kg=3,Jg=4,Qg=5,ld=class Da{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=Z.NONE,this._blendEq=!1,this.map=[],this.map[Yg]=this.setBlend,this.map[qg]=this.setOffset,this.map[Zg]=this.setCullFace,this.map[Kg]=this.setDepthTest,this.map[Jg]=this.setFrontFace,this.map[Qg]=this.setDepthMask,this.checks=[],this.defaultState=new ke,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=jg(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(Da.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Da.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const e=this.blendModes[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,e){const i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};ld.extension={type:N.RendererSystem,name:"state"};let t0=ld;W.add(t0);class e0 extends Qs{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(r=>t.systems[r]),i=[...e,...Object.keys(t.systems).filter(r=>!e.includes(r))];for(const r of i)this.addSystem(t.systems[r],r)}addRunners(...t){t.forEach(e=>{this.runners[e]=new pe(e)})}addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const r in this.runners)this.runners[r].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach(r=>{const n=i.find(o=>this._systemsHash[o]===r);r[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const Os=class Lr{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Lr.defaultMaxIdle,this.checkCountMax=Lr.defaultCheckCountMax,this.mode=Lr.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==_h.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let i=!1;for(let r=0;r<e.length;r++){const n=e[r];n.resource&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[r]=null,i=!0)}if(i){let r=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[r++]=e[n]);e.length=r}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let r=t.children.length-1;r>=0;r--)this.unload(t.children[r])}destroy(){this.renderer=null}};Os.defaultMode=_h.AUTO,Os.defaultMaxIdle=60*60,Os.defaultCheckCountMax=60*10,Os.extension={type:N.RendererSystem,name:"textureGC"};let ki=Os;W.add(ki);class ko{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=Y.UNSIGNED_BYTE,this.internalFormat=B.RGBA,this.samplerType=0}}function i0(s){let t;return"WebGL2RenderingContext"in globalThis&&s instanceof globalThis.WebGL2RenderingContext?t={[s.RGB]:G.FLOAT,[s.RGBA]:G.FLOAT,[s.ALPHA]:G.FLOAT,[s.LUMINANCE]:G.FLOAT,[s.LUMINANCE_ALPHA]:G.FLOAT,[s.R8]:G.FLOAT,[s.R8_SNORM]:G.FLOAT,[s.RG8]:G.FLOAT,[s.RG8_SNORM]:G.FLOAT,[s.RGB8]:G.FLOAT,[s.RGB8_SNORM]:G.FLOAT,[s.RGB565]:G.FLOAT,[s.RGBA4]:G.FLOAT,[s.RGB5_A1]:G.FLOAT,[s.RGBA8]:G.FLOAT,[s.RGBA8_SNORM]:G.FLOAT,[s.RGB10_A2]:G.FLOAT,[s.RGB10_A2UI]:G.FLOAT,[s.SRGB8]:G.FLOAT,[s.SRGB8_ALPHA8]:G.FLOAT,[s.R16F]:G.FLOAT,[s.RG16F]:G.FLOAT,[s.RGB16F]:G.FLOAT,[s.RGBA16F]:G.FLOAT,[s.R32F]:G.FLOAT,[s.RG32F]:G.FLOAT,[s.RGB32F]:G.FLOAT,[s.RGBA32F]:G.FLOAT,[s.R11F_G11F_B10F]:G.FLOAT,[s.RGB9_E5]:G.FLOAT,[s.R8I]:G.INT,[s.R8UI]:G.UINT,[s.R16I]:G.INT,[s.R16UI]:G.UINT,[s.R32I]:G.INT,[s.R32UI]:G.UINT,[s.RG8I]:G.INT,[s.RG8UI]:G.UINT,[s.RG16I]:G.INT,[s.RG16UI]:G.UINT,[s.RG32I]:G.INT,[s.RG32UI]:G.UINT,[s.RGB8I]:G.INT,[s.RGB8UI]:G.UINT,[s.RGB16I]:G.INT,[s.RGB16UI]:G.UINT,[s.RGB32I]:G.INT,[s.RGB32UI]:G.UINT,[s.RGBA8I]:G.INT,[s.RGBA8UI]:G.UINT,[s.RGBA16I]:G.INT,[s.RGBA16UI]:G.UINT,[s.RGBA32I]:G.INT,[s.RGBA32UI]:G.UINT,[s.DEPTH_COMPONENT16]:G.FLOAT,[s.DEPTH_COMPONENT24]:G.FLOAT,[s.DEPTH_COMPONENT32F]:G.FLOAT,[s.DEPTH_STENCIL]:G.FLOAT,[s.DEPTH24_STENCIL8]:G.FLOAT,[s.DEPTH32F_STENCIL8]:G.FLOAT}:t={[s.RGB]:G.FLOAT,[s.RGBA]:G.FLOAT,[s.ALPHA]:G.FLOAT,[s.LUMINANCE]:G.FLOAT,[s.LUMINANCE_ALPHA]:G.FLOAT,[s.DEPTH_STENCIL]:G.FLOAT},t}function s0(s){let t;return"WebGL2RenderingContext"in globalThis&&s instanceof globalThis.WebGL2RenderingContext?t={[Y.UNSIGNED_BYTE]:{[B.RGBA]:s.RGBA8,[B.RGB]:s.RGB8,[B.RG]:s.RG8,[B.RED]:s.R8,[B.RGBA_INTEGER]:s.RGBA8UI,[B.RGB_INTEGER]:s.RGB8UI,[B.RG_INTEGER]:s.RG8UI,[B.RED_INTEGER]:s.R8UI,[B.ALPHA]:s.ALPHA,[B.LUMINANCE]:s.LUMINANCE,[B.LUMINANCE_ALPHA]:s.LUMINANCE_ALPHA},[Y.BYTE]:{[B.RGBA]:s.RGBA8_SNORM,[B.RGB]:s.RGB8_SNORM,[B.RG]:s.RG8_SNORM,[B.RED]:s.R8_SNORM,[B.RGBA_INTEGER]:s.RGBA8I,[B.RGB_INTEGER]:s.RGB8I,[B.RG_INTEGER]:s.RG8I,[B.RED_INTEGER]:s.R8I},[Y.UNSIGNED_SHORT]:{[B.RGBA_INTEGER]:s.RGBA16UI,[B.RGB_INTEGER]:s.RGB16UI,[B.RG_INTEGER]:s.RG16UI,[B.RED_INTEGER]:s.R16UI,[B.DEPTH_COMPONENT]:s.DEPTH_COMPONENT16},[Y.SHORT]:{[B.RGBA_INTEGER]:s.RGBA16I,[B.RGB_INTEGER]:s.RGB16I,[B.RG_INTEGER]:s.RG16I,[B.RED_INTEGER]:s.R16I},[Y.UNSIGNED_INT]:{[B.RGBA_INTEGER]:s.RGBA32UI,[B.RGB_INTEGER]:s.RGB32UI,[B.RG_INTEGER]:s.RG32UI,[B.RED_INTEGER]:s.R32UI,[B.DEPTH_COMPONENT]:s.DEPTH_COMPONENT24},[Y.INT]:{[B.RGBA_INTEGER]:s.RGBA32I,[B.RGB_INTEGER]:s.RGB32I,[B.RG_INTEGER]:s.RG32I,[B.RED_INTEGER]:s.R32I},[Y.FLOAT]:{[B.RGBA]:s.RGBA32F,[B.RGB]:s.RGB32F,[B.RG]:s.RG32F,[B.RED]:s.R32F,[B.DEPTH_COMPONENT]:s.DEPTH_COMPONENT32F},[Y.HALF_FLOAT]:{[B.RGBA]:s.RGBA16F,[B.RGB]:s.RGB16F,[B.RG]:s.RG16F,[B.RED]:s.R16F},[Y.UNSIGNED_SHORT_5_6_5]:{[B.RGB]:s.RGB565},[Y.UNSIGNED_SHORT_4_4_4_4]:{[B.RGBA]:s.RGBA4},[Y.UNSIGNED_SHORT_5_5_5_1]:{[B.RGBA]:s.RGB5_A1},[Y.UNSIGNED_INT_2_10_10_10_REV]:{[B.RGBA]:s.RGB10_A2,[B.RGBA_INTEGER]:s.RGB10_A2UI},[Y.UNSIGNED_INT_10F_11F_11F_REV]:{[B.RGB]:s.R11F_G11F_B10F},[Y.UNSIGNED_INT_5_9_9_9_REV]:{[B.RGB]:s.RGB9_E5},[Y.UNSIGNED_INT_24_8]:{[B.DEPTH_STENCIL]:s.DEPTH24_STENCIL8},[Y.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[B.DEPTH_STENCIL]:s.DEPTH32F_STENCIL8}}:t={[Y.UNSIGNED_BYTE]:{[B.RGBA]:s.RGBA,[B.RGB]:s.RGB,[B.ALPHA]:s.ALPHA,[B.LUMINANCE]:s.LUMINANCE,[B.LUMINANCE_ALPHA]:s.LUMINANCE_ALPHA},[Y.UNSIGNED_SHORT_5_6_5]:{[B.RGB]:s.RGB},[Y.UNSIGNED_SHORT_4_4_4_4]:{[B.RGBA]:s.RGBA},[Y.UNSIGNED_SHORT_5_5_5_1]:{[B.RGBA]:s.RGBA}},t}class cd{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new Q,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=s0(t),this.samplerTypes=i0(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let r=0;r<e;r++)this.boundTextures[r]=null;this.emptyTextures={};const i=new ko(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new ko(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let r=0;r<6;r++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let r=0;r<this.boundTextures.length;r++)this.bind(null,r)}bind(t,e=0){const{gl:i}=this;if(t=t?.castToBaseTexture(),t?.valid&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const r=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,r.texture)),r.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):r.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let r=0;r<i.length;r++)i[r]===this.unknownTexture&&this.bind(null,r)}for(let r=0;r<i.length;r++)i[r]===t&&(this.currentLocation!==r&&(e.activeTexture(e.TEXTURE0+r),this.currentLocation=r),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[r]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:r}=this;if(i)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[r].samplerType!==G.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new ko(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){e.internalFormat=this.internalFormats[t.type]?.[t.format]??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??G.FLOAT,this.webGLVersion===2&&t.type===Y.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const i=this.renderer;if(this.initTextureType(t,e),t.resource?.upload(i,t,e))e.samplerType!==G.FLOAT&&(this.hasIntegerTextures=!0);else{const r=t.realWidth,n=t.realHeight,o=i.gl;(e.width!==r||e.height!==n||e.dirtyId<0)&&(e.width=r,e.height=n,o.texImage2D(t.target,0,e.internalFormat,r,n,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const r=this.managedTextures.indexOf(t);r!==-1&&ds(this.managedTextures,r,1)}}updateTextureStyle(t){const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===Pe.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=li.CLAMP:e.wrapMode=t.wrapMode,t.resource?.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const i=this.gl;if(e.mipmap&&t.mipmap!==Pe.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===He.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const r=this.renderer.context.extensions.anisotropicFiltering;if(r&&t.anisotropicLevel>0&&t.scaleMode===He.LINEAR){const n=Math.min(t.anisotropicLevel,i.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,r.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===He.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===He.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}cd.extension={type:N.RendererSystem,name:"texture"};W.add(cd);class ud{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,r=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,r)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:i,renderer:r}=this;e&&r.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:r}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[r]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];a&&(i.buffer.update(a),a._glBuffers[r].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[r].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],r=this.gl;
487t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];if(!a)continue;const h=a._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&n.dispose(a,e))}i&&(e||r.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}ud.extension={type:N.RendererSystem,name:"transformFeedback"};W.add(ud);class pn{constructor(t){this.renderer=t}init(t){this.screen=new J(0,0,t.width,t.height),this.element=t.view||H.ADAPTER.createCanvas(),this.resolution=t.resolution||H.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const i=this.element.width/this.resolution,r=this.element.height/this.resolution;this.screen.width=i,this.screen.height=r,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${r}px`),this.renderer.emit("resize",i,r),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){t&&this.element.parentNode?.removeChild(this.element),this.renderer=null,this.element=null,this.screen=null}}pn.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},pn.extension={type:[N.RendererSystem,N.CanvasRendererSystem],name:"_view"};W.add(pn);H.PREFER_ENV=zi.WEBGL2;H.STRICT_TEXTURE_CACHE=!1;H.RENDER_OPTIONS={...fn.defaultOptions,...dn.defaultOptions,...pn.defaultOptions,..._n.defaultOptions};Object.defineProperties(H,{WRAP_MODE:{get(){return Q.defaultOptions.wrapMode},set(s){et("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),Q.defaultOptions.wrapMode=s}},SCALE_MODE:{get(){return Q.defaultOptions.scaleMode},set(s){et("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),Q.defaultOptions.scaleMode=s}},MIPMAP_TEXTURES:{get(){return Q.defaultOptions.mipmap},set(s){et("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),Q.defaultOptions.mipmap=s}},ANISOTROPIC_LEVEL:{get(){return Q.defaultOptions.anisotropicLevel},set(s){et("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),Q.defaultOptions.anisotropicLevel=s}},FILTER_RESOLUTION:{get(){return et("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Pt.defaultResolution},set(s){Pt.defaultResolution=s}},FILTER_MULTISAMPLE:{get(){return et("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Pt.defaultMultisample},set(s){Pt.defaultMultisample=s}},SPRITE_MAX_TEXTURES:{get(){return Pi.defaultMaxTextures},set(s){et("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Pi.defaultMaxTextures=s}},SPRITE_BATCH_SIZE:{get(){return Pi.defaultBatchSize},set(s){et("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Pi.defaultBatchSize=s}},CAN_UPLOAD_SAME_BUFFER:{get(){return Pi.canUploadSameBuffer},set(s){et("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Pi.canUploadSameBuffer=s}},GC_MODE:{get(){return ki.defaultMode},set(s){et("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),ki.defaultMode=s}},GC_MAX_IDLE:{get(){return ki.defaultMaxIdle},set(s){et("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),ki.defaultMaxIdle=s}},GC_MAX_CHECK_COUNT:{get(){return ki.defaultCheckCountMax},set(s){et("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),ki.defaultCheckCountMax=s}},PRECISION_VERTEX:{get(){return Xe.defaultVertexPrecision},set(s){et("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Xe.defaultVertexPrecision=s}},PRECISION_FRAGMENT:{get(){return Xe.defaultFragmentPrecision},set(s){et("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Xe.defaultFragmentPrecision=s}}});var Gi=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(Gi||{});class Bo{constructor(t,e=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=r}match(t,e=null){return this.fn===t&&this.context===e}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.
vendor: 4,087 bytes, lines 487-496
487next,t.next=this}destroy(t=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const dd=class Xt{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Bo(null,null,1/0),this.deltaMS=1/Xt.targetFPMS,this.elapsedMS=1/Xt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=Gi.NORMAL){return this._addListener(new Bo(t,e,i))}addOnce(t,e,i=Gi.NORMAL){return this._addListener(new Bo(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Xt.targetFPMS;const i=this._head;let r=i.next;for(;r;)r=r.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,Xt.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!Xt._shared){const t=Xt._shared=new Xt;t.autoStart=!0,t._protected=!0}return Xt._shared}static get system(){if(!Xt._system){const t=Xt._system=new Xt;t.autoStart=!0,t._protected=!0}return Xt._system}};dd.targetFPMS=.06;let Yt=dd;Object.defineProperties(H,{TARGET_FPMS:{get(){return Yt.targetFPMS},set(s){et("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),Yt.targetFPMS=s}}});class fd{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Gi.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Yt.shared:new Yt,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}fd.extension=N.Application;W.add(fd);const _d=[];W.handleByList(N.Renderer,_d);function r0(s){for(const t of _d)if(t.test(s))return new t(s);throw new Error("Unable to auto-detect a suitable renderer.")}var n0=`attribute vec2 aVertexPosition;
488attribute vec2 aTextureCoord;
489
490uniform mat3 projectionMatrix;
491
492varying vec2 vTextureCoord;
493
494void main(void)
495{
496    gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0
496)).xy, 0.0, 1.0);
497    vTextureCoord = aTextureCoord;
498}`,o0=`attribute vec2 aVertexPosition;
499
500uniform mat3 projectionMatrix;
501
502varying vec2 vTextureCoord;
503
504uniform vec4 inputSize;
505uniform vec4 outputFrame;
506
507vec4 filterVertexPosition( void )
508{
509    vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
510
511    return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
512}
513
514vec2 filterTextureCoord( void )
515{
516    return aVertexPosition * (outputFrame.zw * inputSize.zw);
517}
518
519void main(void)
520{
521    gl_Position = filterVertexPosition();
522    vTextureCoord = filterTextureCoord();
523}
524`;const a0=n0,pd=o0;class md{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{const i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=vt.HIGH?this.multisample=vt.HIGH:e>=vt.MEDIUM?this.multisample=vt.MEDIUM:e>=vt.LOW?this.multisample=vt.LOW:this.multisample=vt.NONE}destroy(){}}md.extension={type:N.RendererSystem,name:"_multisample"};W.add(md);class h0{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class gd{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,r=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,r.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:r}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[r]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,i){const{gl:r,CONTEXT_UID:n}=this;i=i||0;const o=t._glBuffers[n]||this.createGLBuffer(t);r.bindBufferRange(r.UNIFORM_BUFFER,e||0,o.buffer,i*256,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,r=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==r.updateID)if(r.updateID=t._updateID,e.bindBuffer(t.type,r.buffer),r.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;r.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this),i&&(e||r.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new h0(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}gd.extension={type:N.RendererSystem,name:"buffer"};W.add(gd);class bd{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let r,n,o,a;if(e&&(r=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!r,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=o,!i.context.isLost){if(r||(this.lastObjectRendered=t),!a){const h=t.enableTempParent();t.updateTransform(),t.disableTempParent(h)}i.renderTexture.bind(r),i.batch.currentRenderer.start(),(n??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),r&&(e.blit&&i.framebuffer.blit(),r.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}bd.extension={type:N.RendererSystem,name:"objectRenderer"};W.add(bd);const Nr=class Fa extends e0{constructor(t){super(),this.type=Su.WEBGL,t=Object.assign({},H.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new me({projectionMatrix:new ct},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Fa.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};
vendor: 4,569 bytes, line 524
524this.setup(e),"useContextAlpha"in t&&(et("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=Fa.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t?.forceCanvas?!1:Pm()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return et("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return et("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return et("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return et("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){et("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return et("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){et("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return et("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};Nr.extension={type:N.Renderer,priority:1},Nr.__plugins={},Nr.__systems={};let bh=Nr;W.handleByMap(N.RendererPlugin,bh.__plugins);W.handleByMap(N.RendererSystem,bh.__systems);W.add(bh);class vd extends Ks{constructor(t,e){const{width:i,height:r}=e||{};super(i,r),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const o=new Q;this.items.push(o),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof Ks?this.addResourceAt(t[i],i):this.addResourceAt(Nu(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{const{realWidth:e,realHeight:i}=this.items[0];return this.resize(e,i),this.update(),Promise.resolve(this)}),this._load}}class l0 extends vd{constructor(t,e){const{width:i,height:r}=e||{};let n,o;Array.isArray(t)?(n=t,o=t.length):o=t,super(o,{width:i,height:r}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);
vendor: 21,250 bytes, line 524
524else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=us.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:r,itemDirtyIds:n,items:o}=this,{gl:a}=t;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,r,0,e.format,i.type,null);for(let h=0;h<r;h++){const l=o[h];n[h]<l.dirtyId&&(n[h]=l.dirtyId,l.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,h,l.resource.width,l.resource.height,1,e.format,i.type,l.resource.source))}return!0}}class c0 extends di{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const yd=class Us extends vd{constructor(t,e){const{width:i,height:r,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==Us.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:r});for(let a=0;a<Us.SIDES;a++)this.items[a].target=us.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=o!==!1,t&&this.initFromArray(t,e),n!==!1&&this.load()}bind(t){super.bind(t),t.target=us.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=us.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,i){const r=this.itemDirtyIds;for(let n=0;n<Us.SIDES;n++){const o=this.items[n];(r[n]<o.dirtyId||i.dirtyId<e.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(t,o,i),r[n]=o.dirtyId):r[n]<-1&&(t.gl.texImage2D(o.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),r[n]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===Us.SIDES}};yd.SIDES=6;let u0=yd;class ls extends di{constructor(t,e){e=e||{};let i,r,n;typeof t=="string"?(i=ls.EMPTY,r=t,n=!0):(i=t,r=null,n=!1),super(i),this.url=r,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??n,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{const i=await H.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const r=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(r,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Ht.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return ls._EMPTY=ls._EMPTY??H.ADAPTER.createCanvas(0,0),ls._EMPTY}}const La=class Or extends di{constructor(t,e){e=e||{},super(H.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},Or.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const t=new Image;di.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let r=e*this.scale,n=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(r=this._overrideWidth||this._overrideHeight/i*e,n=this._overrideHeight||this._overrideWidth/e*i),r=Math.round(r),n=Math.round(n);const o=this.source;o.width=r,o.height=n,o._pixiId=`canvas_${Ui()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,r,n),this._resolve(),this._resolve=null}}static getSize(t){const e=Or.SVG_SIZE.exec(t),i={};return e&&(i[e[1]]=Math.round(parseFloat(e[3])),i[e[5]]=Math.round(parseFloat(e[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&Or.SVG_XML.test(t)}};La.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,La.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Na=La;const Oa=class Ua extends di{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const r=t[0].src||t[0];di.crossOrigin(i,r,e.crossorigin);for(let n=0;n<t.length;++n){const o=document.createElement("source");let{src:a,mime:h}=t[n];if(a=a||t[n],a.startsWith("data:"))h=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const l=a.split("?").shift().toLowerCase(),c=l.slice(l.lastIndexOf(".")+1);h=h||Ua.MIME_TYPES[c]||`video/${c}`}o.src=a,h&&(o.type=h),i.appendChild(o)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const e=Yt.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const t=this.source;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(Yt.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(Yt.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Yt.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||Ua.TYPES.includes(e)}};Oa.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Oa.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let xd=Oa;Aa.push(ls,Wu,c0,xd,Na,Ln,u0,l0);class mn{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?J.EMPTY:(t=t||new J(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:i,b:r,c:n,d:o,tx:a,ty:h}=t,l=i*e.x+n*e.y+a,c=r*e.x+o*e.y+h;this.minX=Math.min(this.minX,l),this.maxX=Math.max(this.maxX,l),this.minY=Math.min(this.minY,c),this.maxY=Math.max(this.maxY,c)}addQuad(t){let e=this.minX,i=this.minY,r=this.maxX,n=this.maxY,o=t[0],a=t[1];e=o<e?o:e,i=a<i?a:i,r=o>r?o:r,n=a>n?a:n,o=t[2],a=t[3],e=o<e?o:e,i=a<i?a:i,r=o>r?o:r,n=a>n?a:n,o=t[4],a=t[5],e=o<e?o:e,i=a<i?a:i,r=o>r?o:r,n=a>n?a:n,o=t[6],a=t[7],e=o<e?o:e,i=a<i?a:i,r=o>r?o:r,n=a>n?a:n,this.minX=e,this.minY=i,this.maxX=r,this.maxY=n}addFrame(t,e,i,r,n){this.addFrameMatrix(t.worldTransform,e,i,r,n)}addFrameMatrix(t,e,i,r,n){const o=t.a,a=t.b,h=t.c,l=t.d,c=t.tx,u=t.ty;let d=this.minX,f=this.minY,_=this.maxX,p=this.maxY,m=o*e+h*i+c,g=a*e+l*i+u;d=m<d?m:d,f=g<f?g:f,_=m>_?m:_,p=g>p?g:p,m=o*r+h*i+c,g=a*r+l*i+u,d=m<d?m:d,f=g<f?g:f,_=m>_?m:_,p=g>p?g:p,m=o*e+h*n+c,g=a*e+l*n+u,d=m<d?m:d,f=g<f?g:f,_=m>_?m:_,p=g>p?g:p,m=o*r+h*n+c,g=a*r+l*n+u,d=m<d?m:d,f=g<f?g:f,_=m>_?m:_,p=g>p?g:p,this.minX=d,this.minY=f,this.maxX=_,this.maxY=p}addVertexData(t,e,i){let r=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let h=e;h<i;h+=2){const l=t[h],c=t[h+1];r=l<r?l:r,n=c<n?c:n,o=l>o?l:o,a=c>a?c:a}this.minX=r,this.minY=n,this.maxX=o,this.maxY=a}addVertices(t,e,i,r){this.addVerticesMatrix(t.worldTransform,e,i,r)}addVerticesMatrix(t,e,i,r,n=0,o=n){const a=t.a,h=t.b,l=t.c,c=t.d,u=t.tx,d=t.ty;let f=this.minX,_=this.minY,p=this.maxX,m=this.maxY;for(let g=i;g<r;g+=2){const v=e[g],b=e[g+1],y=a*v+l*b+u,E=c*b+h*v+d;f=Math.min(f,y-n),p=Math.max(p,y+n),_=Math.min(_,E-o),m=Math.max(m,E+o)}this.minX=f,this.minY=_,this.maxX=p,this.maxY=m}addBounds(t){const e=this.minX,i=this.minY,r=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>r?t.maxX:r,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,r=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,o=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=n&&r<=o){const a=this.minX,h=this.minY,l=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=r<h?r:h,this.maxX=n>l?n:l,this.maxY=o>c?o:c}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const i=t.minX>e.x?t.minX:e.x,r=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,o=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(i<=n&&r<=o){const a=this.minX,h=this.minY,l=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=r<h?r:h,this.maxX=n>l?n:l,this.maxY=o>c?o:c}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,r,n,o){t-=n,e-=o,i+=n,r+=o,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>r?this.maxY:r}}class _t extends Qs{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new mh,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new mn,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const e=Object.keys(t);for(let i=0;i<e.length;++i){const r=e[i];Object.defineProperty(_t.prototype,r,Object.getOwnPropertyDescriptor(t,r))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new J),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new J),t=this._localBoundsRect),this._localBounds||(this._localBounds=new mn);const e=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=i?.worldAlpha??1,this.transform=this._tempDisplayObjectParent.transform;const r=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=r,this._bounds.updateID+=this._boundsID-n,o}toGlobal(t,e,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,i,r){return e&&(t=e.toGlobal(t,i,r)),r||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){this.parent?.removeChild(this)}setTransform(t=0,e=0,i=1,r=1,n=0,o=0,a=0,h=0,l=0){return this.position.x=t,this.position.y=e,this.scale.x=i||1,this.scale.y=r||1,this.rotation=n,this.skew.x=o,this.skew.y=a,this.pivot.x=h,this.pivot.y=l,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new d0),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*ng}set angle(t){this.transform.rotation=t*og}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex=t,this.parent&&(this.parent.sortDirty=!0)}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount--,e._maskRefCount===0&&(e.renderable=!0,e.isMask=!1))}if(this._mask=t,this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount===0&&(e.renderable=!1,e.isMask=!0),e._maskRefCount++)}}}}class d0 extends _t{constructor(){super(...arguments),this.sortDirty=null}}_t.prototype.displayObjectUpdateTransform=_t.prototype.updateTransform;const f0=new ct;function _0(s,t){return s.zIndex===t.zIndex?s._lastSortedIndex-t._lastSortedIndex:s.zIndex-t.zIndex}const wd=class Ga extends _t{constructor(){super(),this.children=[],this.sortableChildren=Ga.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),r=this.getChildIndex(e);this.children[i]=e,this.children[r]=t,this.onChildrenChange(i<r?i:r)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);ds(this.children,i,1),this.children.splice(e,0,t),this.onChildrenChange(e)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.removeChild(t[e]);else{const e=t[0],i=this.children.indexOf(e);if(i===-1)return null;e.parent=null,e.transform._parentID=-1,ds(this.children,i,1),this._boundsID++,this.onChildrenChange(i),e.emit("removed",this),this.emit("childRemoved",e,this,i)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,ds(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const i=t,r=e,n=r-i;let o;if(n>0&&n<=r){o=this.children.splice(i,n);for(let a=0;a<o.length;++a)o[a].parent=null,o[a].transform&&(o[a].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let a=0;a<o.length;
vendor: 16,087 bytes, lines 524-534
524++a)o[a].emit("removed",this),this.emit("childRemoved",o[a],this,a);return o}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,i=this.children.length;e<i;++e){const r=this.children[e];r._lastSortedIndex=e,!t&&r.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(_0),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t<e;++t){const i=this.children[t];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(!(!e.visible||!e.renderable))if(e.calculateBounds(),e._mask){const i=e._mask.isMaskData?e._mask.maskObject:e._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(e._bounds,i._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const i=super.getLocalBounds(t);if(!e)for(let r=0,n=this.children.length;r<n;++r){const o=this.children[r];o.visible&&o.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let i,r;this.cullArea?(i=this.cullArea,r=this.worldTransform):this._render!==Ga.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(r?(r=f0.copyFrom(r),r.prepend(n)):r=n),i&&e.intersects(i,r))this._render(t);else if(this.cullArea)return;for(let o=0,a=this.children.length;o<a;++o){const h=this.children[o],l=h.cullable;h.cullable=l||!this.cullArea,h.render(t),h.cullable=l}}render(t){if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||this.filters?.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let e=0,i=this.children.length;e<i;++e)this.children[e].render(t)}}renderAdvanced(t){const e=this.filters,i=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let n=0;n<e.length;n++)e[n].enabled&&this._enabledFilters.push(e[n])}const r=e&&this._enabledFilters?.length||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==xt.NONE));if(r&&t.batch.flush(),e&&this._enabledFilters?.length&&t.filter.push(this,this._enabledFilters),i&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let n=0,o=this.children.length;n<o;++n)this.children[n].render(t)}r&&t.batch.flush(),i&&t.mask.pop(this),e&&this._enabledFilters?.length&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t?.children,i=this.removeChildren(0,this.children.length);if(e)for(let r=0;r<i.length;++r)i[r].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}};wd.defaultSortableChildren=!1;let kt=wd;kt.prototype.containerUpdateTransform=kt.prototype.updateTransform;Object.defineProperties(H,{SORTABLE_CHILDREN:{get(){return kt.defaultSortableChildren},set(s){et("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),kt.defaultSortableChildren=s}}});const Ps=new st,p0=new Uint16Array([0,1,2,0,2,3]);class Ft extends kt{constructor(t){super(),this._anchor=new $e(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new nt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=Z.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||V.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=p0,this.pluginName="batch",this.isSprite=!0,this._roundPixels=H.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=ni(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=ni(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,i=e.a,r=e.b,n=e.c,o=e.d,a=e.tx,h=e.ty,l=this.vertexData,c=t.trim,u=t.orig,d=this._anchor;let f=0,_=0,p=0,m=0;if(c?(_=c.x-d._x*u.width,f=_+c.width,m=c.y-d._y*u.height,p=m+c.height):(_=-d._x*u.width,f=_+u.width,m=-d._y*u.height,p=m+u.height),l[0]=i*_+n*m+a,l[1]=o*m+r*_+h,l[2]=i*f+n*m+a,l[3]=o*m+r*f+h,l[4]=i*f+n*p+a,l[5]=o*p+r*f+h,l[6]=i*_+n*p+a,l[7]=o*p+r*_+h,this._roundPixels){const g=H.RESOLUTION;for(let v=0;v<l.length;++v)l[v]=Math.round(l[v]*g)/g}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,i=t.orig,r=this._anchor,n=this.transform.worldTransform,o=n.a,a=n.b,h=n.c,l=n.d,c=n.tx,u=n.ty,d=-r._x*i.width,f=d+i.width,_=-r._y*i.height,p=_+i.height;if(e[0]=o*d+h*_+c,e[1]=l*_+a*d+u,e[2]=o*f+h*_+c,e[3]=l*_+a*f+u,e[4]=o*f+h*p+c,e[5]=l*p+a*f+u,e[6]=o*d+h*p+c,e[7]=l*p+a*d+u,this._roundPixels){const m=H.RESOLUTION;for(let g=0;g<e.length;++g)e[g]=Math.round(e[g]*m)/m}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new mn),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new J),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,Ps);const e=this._texture.orig.width,i=this._texture.orig.height,r=-e*this.anchor.x;let n=0;return Ps.x>=r&&Ps.x<r+e&&(n=-i*this.anchor.y,Ps.y>=n&&Ps.y<n+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t?.texture){const e=typeof t=="boolean"?t:t?.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const i=t instanceof V?t:V.from(t,e);return new Ft(i)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=ni(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const e=ni(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||V.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Td=new ct;_t.prototype._cacheAsBitmap=!1;_t.prototype._cacheData=null;_t.prototype._cacheAsBitmapResolution=null;_t.prototype._cacheAsBitmapMultisample=null;class m0{constructor(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}Object.defineProperties(_t.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(s){s!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=s,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(s){s!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=s,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(s){if(this._cacheAsBitmap===s)return;this._cacheAsBitmap=s;let t;s?(this._cacheData||(this._cacheData=new m0),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}});_t.prototype._renderCached=function(s){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(s),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(s))};_t.prototype._initCachedDisplayObject=function(s){if(this._cacheData?.sprite)return;const t=this.alpha;this.alpha=1,s.batch.flush();const e=this.getLocalBounds(new J,!0);if(this.filters?.length){const d=this.filters[0].padding;e.pad(d)}const i=this.cacheAsBitmapResolution||s.resolution;e.ceil(i),e.width=Math.max(e.width,1/i),e.height=Math.max(e.height,1/i);const r=s.renderTexture.current,n=s.renderTexture.sourceFrame.clone(),o=s.renderTexture.destinationFrame.clone(),a=s.projection.transform,h=Bt.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??s.multisample}),l=`cacheAsBitmap_${Ui()}`;this._cacheData.textureCacheId=l,Q.addToCache(h.baseTexture,l),V.addToCache(h,l);const c=this.transform.localTransform.copyTo(Td).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,s.render(this,{renderTexture:h,clear:!0,transform:c,skipUpdateTransform:!1}),s.framebuffer.blit(),s.projection.transform=a,s.renderTexture.bind(r,n,o),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const u=new Ft(h);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(e.x/e.width),u.anchor.y=-(e.y/e.height),u.alpha=t,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=u.containsPoint.bind(u)};_t.prototype._renderCachedCanvas=function(s){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(s),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(s))};_t.prototype._initCachedDisplayObjectCanvas=function(s){if(this._cacheData?.sprite)return;const t=this.getLocalBounds(new J,!0),e=this.alpha;this.alpha=1;const i=s.canvasContext.activeContext,r=s._projTransform,n=this.cacheAsBitmapResolution||s.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const o=Bt.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${Ui()}`;this._cacheData.textureCacheId=a,Q.addToCache(o.baseTexture,a),V.addToCache(o,a);const h=Td;this.transform.localTransform.copyTo(h),h.invert(),h.tx-=t.x,h.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,s.render(this,{renderTexture:o,clear:!0,transform:h,skipUpdateTransform:!1}),s.canvasContext.activeContext=i,s._projTransform=r,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=e;const l=new Ft(o);l.transform.worldTransform=this.transform.worldTransform,l.anchor.x=-(t.x/t.width),l.anchor.y=-(t.y/t.height),l.alpha=e,l._bounds=this._bounds,this._cacheData.sprite=l,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=s._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=l.containsPoint.bind(l)};_t.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID};_t.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)};_t.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,Q.removeFromCache(this._cacheData.textureCacheId),V.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null};_t.prototype._cacheAsBitmapDestroy=function(s){this.cacheAsBitmap=!1,this.destroy(s)};_t.prototype.name=null;kt.prototype.getChildByName=function(s,t){for(let e=0,i=this.children.length;e<i;e++)if(this.children[e].name===s)return this.children[e];if(t)for(let e=0,i=this.children.length;e<i;e++){const r=this.children[e];if(!r.getChildByName)continue;const n=r.getChildByName(s,!0);if(n)return n}return null};_t.prototype.getGlobalPosition=function(s=new st,t=!1){return this.parent?this.parent.toGlobal(this.position,s,t):(s.x=this.position.x,s.y=this.position.y),s};var g0=`varying vec2 vTextureCoord;
525
526uniform sampler2D uSampler;
527uniform float uAlpha;
528
529void main(void)
530{
531   gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
532}
533`;class b0 extends Pt{constructor(t=1){super(a0,g0,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const v0={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},y0=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{","    gl_FragColor = vec4(0.0);","    %blur%","}"].join(`
534`);function x0(s){const t=v0[s],e=t.length;let i=y0,r="";
vendor: 13,290 bytes, lines 534-712
534const n="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<s;a++){let h=n.replace("%index%",a.toString());o=a,a>=e&&(o=s-a-1),h=h.replace("%value%",t[o].toString()),r+=h,r+=`
535`}return i=i.replace("%blur%",r),i=i.replace("%size%",s.toString()),i}const w0=`
536    attribute vec2 aVertexPosition;
537
538    uniform mat3 projectionMatrix;
539
540    uniform float strength;
541
542    varying vec2 vBlurTexCoords[%size%];
543
544    uniform vec4 inputSize;
545    uniform vec4 outputFrame;
546
547    vec4 filterVertexPosition( void )
548    {
549        vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
550
551        return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
552    }
553
554    vec2 filterTextureCoord( void )
555    {
556        return aVertexPosition * (outputFrame.zw * inputSize.zw);
557    }
558
559    void main(void)
560    {
561        gl_Position = filterVertexPosition();
562
563        vec2 textureCoord = filterTextureCoord();
564        %blur%
565    }`;function T0(s,t){const e=Math.ceil(s/2);let i=w0,r="",n;t?n="vBlurTexCoords[%index%] =  textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] =  textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o<s;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),r+=a,r+=`
566`}return i=i.replace("%blur%",r),i=i.replace("%size%",s.toString()),i}class Ha extends Pt{constructor(t,e=8,i=4,r=Pt.defaultResolution,n=5){const o=T0(n,t),a=x0(n);super(o,a),this.horizontal=t,this.resolution=r,this._quality=0,this.quality=i,this.blur=e}apply(t,e,i,r){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/e.width):this.uniforms.strength=1/i.height*(i.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,e,i,r);else{const n=t.getFilterTexture(),o=t.renderer;let a=e,h=n;this.state.blend=!1,t.applyFilter(this,a,h,Ae.CLEAR);for(let l=1;l<this.passes-1;l++){t.bindAndClear(a,Ae.BLIT),this.uniforms.uSampler=h;const c=h;h=a,a=c,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,h,i,r),t.returnFilterTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class E0 extends Pt{constructor(t=8,e=4,i=Pt.defaultResolution,r=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new Ha(!0,t,e,i,r),this.blurYFilter=new Ha(!1,t,e,i,r),this.resolution=i,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,i,r){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=t.getFilterTexture();this.blurXFilter.apply(t,e,a,Ae.CLEAR),this.blurYFilter.apply(t,a,i,r),t.returnFilterTexture(a)}else o?this.blurYFilter.apply(t,e,i,r):this.blurXFilter.apply(t,e,i,r)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var A0=`varying vec2 vTextureCoord;
567uniform sampler2D uSampler;
568uniform float m[20];
569uniform float uAlpha;
570
571void main(void)
572{
573    vec4 c = texture2D(uSampler, vTextureCoord);
574
575    if (uAlpha == 0.0) {
576        gl_FragColor = c;
577        return;
578    }
579
580    // Un-premultiply alpha before applying the color matrix. See issue #3539.
581    if (c.a > 0.0) {
582      c.rgb /= c.a;
583    }
584
585    vec4 result;
586
587    result.r = (m[0] * c.r);
588        result.r += (m[1] * c.g);
589        result.r += (m[2] * c.b);
590        result.r += (m[3] * c.a);
591        result.r += m[4];
592
593    result.g = (m[5] * c.r);
594        result.g += (m[6] * c.g);
595        result.g += (m[7] * c.b);
596        result.g += (m[8] * c.a);
597        result.g += m[9];
598
599    result.b = (m[10] * c.r);
600       result.b += (m[11] * c.g);
601       result.b += (m[12] * c.b);
602       result.b += (m[13] * c.a);
603       result.b += m[14];
604
605    result.a = (m[15] * c.r);
606       result.a += (m[16] * c.g);
607       result.a += (m[17] * c.b);
608       result.a += (m[18] * c.a);
609       result.a += m[19];
610
611    vec3 rgb = mix(c.rgb, result.rgb, uAlpha);
612
613    // Premultiply alpha again.
614    rgb *= result.a;
615
616    gl_FragColor = vec4(rgb, result.a);
617}
618`;class za extends Pt{constructor(){const t={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};super(pd,A0,t),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,r,n]=nt.shared.setValue(t).toArray(),o=[i,0,0,0,0,0,r,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),r=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),h=i+(1-i)*o,l=o*(1-i)-a*r,c=o*(1-i)+a*r,u=o*(1-i)+a*r,d=i+o*(1-i),f=o*(1-i)-a*r,_=o*(1-i)-a*r,p=o*(1-i)+a*r,m=i+o*(1-i),g=[h,l,c,0,0,u,d,f,0,0,_,p,m,0,0,0,0,0,1,0];this._loadMatrix(g,e)}contrast(t,e){const i=(t||0)+1,r=-.5*(i-1),n=[i,0,0,0,r,0,i,0,0,r,0,0,i,0,r,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,r=(i-1)*-.5,n=[i,r,r,0,0,r,i,r,0,0,r,r,i,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,i,r,n){t=t||.2,e=e||.15,i=i||16770432,r=r||3375104;const o=nt.shared,[a,h,l]=o.setValue(i).toArray(),[c,u,d]=o.setValue(r).toArray(),f=[.3,.59,.11,0,0,a,h,l,t,0,c,u,d,e,0,a-c,h-u,l-d,0,0];this._loadMatrix(f,n)}night(t,e){t=t||.1;const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}za.prototype.grayscale=za.prototype.greyscale;var S0=`varying vec2 vFilterCoord;
619varying vec2 vTextureCoord;
620
621uniform vec2 scale;
622uniform mat2 rotation;
623uniform sampler2D uSampler;
624uniform sampler2D mapSampler;
625
626uniform highp vec4 inputSize;
627uniform vec4 inputClamp;
628
629void main(void)
630{
631  vec4 map =  texture2D(mapSampler, vFilterCoord);
632
633  map -= 0.5;
634  map.xy = scale * inputSize.zw * (rotation * map.xy);
635
636  gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));
637}
638`,C0=`attribute vec2 aVertexPosition;
639
640uniform mat3 projectionMatrix;
641uniform mat3 filterMatrix;
642
643varying vec2 vTextureCoord;
644varying vec2 vFilterCoord;
645
646uniform vec4 inputSize;
647uniform vec4 outputFrame;
648
649vec4 filterVertexPosition( void )
650{
651    vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
652
653    return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
654}
655
656vec2 filterTextureCoord( void )
657{
658    return aVertexPosition * (outputFrame.zw * inputSize.zw);
659}
660
661void main(void)
662{
663	gl_Position = filterVertexPosition();
664	vTextureCoord = filterTextureCoord();
665	vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0)  ).xy;
666}
667`;class I0 extends Pt{constructor(t,e){const i=new ct;t.renderable=!1,super(C0,S0,{mapSampler:t._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=i,e==null&&(e=20),this.scale=new st(e,e)}apply(t,e,i,r){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const n=this.maskSprite.worldTransform,o=Math.sqrt(n.a*n.a+n.b*n.b),a=Math.sqrt(n.c*n.c+n.d*n.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=n.a/o,this.uniforms.rotation[1]=n.b/o,this.uniforms.rotation[2]=n.c/a,this.uniforms.rotation[3]=n.d/a),t.applyFilter(this,e,i,r)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var R0=`varying vec2 v_rgbNW;
668varying vec2 v_rgbNE;
669varying vec2 v_rgbSW;
670varying vec2 v_rgbSE;
671varying vec2 v_rgbM;
672
673varying vec2 vFragCoord;
674uniform sampler2D uSampler;
675uniform highp vec4 inputSize;
676
677
678/**
679 Basic FXAA implementation based on the code on geeks3d.com with the
680 modification that the texture2DLod stuff was removed since it's
681 unsupported by WebGL.
682
683 --
684
685 From:
686 https://github.com/mitsuhiko/webgl-meincraft
687
688 Copyright (c) 2011 by Armin Ronacher.
689
690 Some rights reserved.
691
692 Redistribution and use in source and binary forms, with or without
693 modification, are permitted provided that the following conditions are
694 met:
695
696 * Redistributions of source code must retain the above copyright
697 notice, this list of conditions and the following disclaimer.
698
699 * Redistributions in binary form must reproduce the above
700 copyright notice, this list of conditions and the following
701 disclaimer in the documentation and/or other materials provided
702 with the distribution.
703
704 * The names of the contributors may not be used to endorse or
705 promote products derived from this software without specific
706 prior written permission.
707
708 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
709 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
710 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
711 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
712 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
713 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
714 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
715 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
716 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
717 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
718 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
719 */
720
721#ifndef FXAA_REDUCE_MIN
722#define FXAA_REDUCE_MIN   (1.0/ 128.0)
723#endif
724#ifndef FXAA_REDUCE_MUL
725#define FXAA_REDUCE_MUL   (1.0 / 8.0)
726#endif
727#ifndef FXAA_SPAN_MAX
728#define FXAA_SPAN_MAX     8.0
729#endif
730
731//optimized version for mobile, where dependent
732//texture reads can be a bottleneck
733vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP,
734          vec2 v_rgbNW, vec2 v_rgbNE,
735          vec2 v_rgbSW, vec2 v_rgbSE,
736          vec2 v_rgbM) {
737    vec4 color;
738    vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;
739    vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;
740    vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;
741    vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;
742    vec4 texColor = texture2D(tex, v_rgbM);
743    vec3 rgbM  = texColor.xyz;
744    vec3 luma = vec3(0.299, 0.587, 0.114);
745    float lumaNW = dot(rgbNW, luma);
746    float lumaNE = dot(rgbNE, luma);
747    float lumaSW = dot(rgbSW, luma);
748    float lumaSE = dot(rgbSE, luma);
749    float lumaM  = dot(rgbM,  luma);
750    float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
751    float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
752
753    mediump vec2 dir;
754    dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
755    dir.y =  ((lumaNW + lumaSW) - (lumaNE + lumaSE));
756
757    float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *
758                          (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
759
760    float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
761    dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
762              max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
763                  dir * rcpDirMin)) * inverseVP;
764
765    vec3 rgbA = 0.5 * (
766                       texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +
767                       texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);
768    vec3 rgbB = rgbA * 0.5 + 0.25 * (
769                                     texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +
770                                     texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);
771
772    float lumaB = dot(rgbB, luma);
773    if ((lumaB < lumaMin) || (lumaB > lumaMax))
774        color = vec4(rgbA, texColor.a);
775    else
776        color = vec4(rgbB, texColor.a);
777    return color;
778}
779
780void main() {
781
782      vec4 color;
783
784      color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
785
786      gl_FragColor = color;
787}
788`,M0=`
789attribute vec2 aVertexPosition;
790
791uniform mat3 projectionMatrix;
792
793varying vec2 v_rgbNW;
794varying vec2 v_rgbNE;
795varying vec2 v_rgbSW;
796varying vec2 v_rgbSE;
797varying vec2 v_rgbM;
798
799varying vec2 vFragCoord;
800
801uniform vec4 inputSize;
802uniform vec4 outputFrame;
803
804vec4 filterVertexPosition( void )
805{
806    vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
807
808    return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
809}
810
811void texcoords(vec2 fragCoord, vec2 inverseVP,
812               out vec2 v_rgbNW, out vec2 v_rgbNE,
813               out vec2 v_rgbSW, out vec2 v_rgbSE,
814               out vec2 v_rgbM) {
815    v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;
816    v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;
817    v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;
818    v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;
819    v_rgbM = vec2(fragCoord * inverseVP);
820}
821
822void main(void) {
823
824   gl_Position = filterVertexPosition();
825
826   vFragCoord = aVertexPosition * outputFrame.zw;
827
828   texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
829}
830`;class P0 extends Pt{constructor(){super(M0,R0)}}var k0=`precision highp float;
831
832varying vec2 vTextureCoord;
833varying vec4 vColor;
834
835uniform float uNoise;
836uniform float uSeed;
837uniform sampler2D uSampler;
838
839float rand(vec2 co)
840{
841    return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
842}
843
844void main()
845{
846    vec4 color = texture2D(uSampler, vTextureCoord);
847    float randomValue = rand(gl_FragCoord.xy * uSeed);
848    float diff = (randomValue - 0.5) * uNoise;
849
850    // Un-premultiply alpha before applying the color matrix. See issue #3539.
851    if (color.a > 0.0) {
852        color.rgb /= color.a;
853    }
854
855    color.r += diff;
856    color.g += diff;
857    color.b += diff;
858
859    // Premultiply alpha again.
860    color.rgb *= color.a;
861
862    gl_FragColor = color;
863}
864`;class B0 extends Pt{constructor(t=.5,e=Math.random()){super(pd,k0,{uNoise:0,uSeed:0}),this.noise=t,this.seed=e}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}
vendor: 5,237 bytes, line 864
864const Bl={AlphaFilter:b0,BlurFilter:E0,BlurFilterPass:Ha,ColorMatrixFilter:za,DisplacementFilter:I0,FXAAFilter:P0,NoiseFilter:B0};Object.entries(Bl).forEach(([s,t])=>{Object.defineProperty(Bl,s,{get(){return et("7.1.0",`filters.${s} has moved to ${s}`),t}})});class D0{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||(Yt.system.add(this.tickerUpdate,this,Gi.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(Yt.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const ri=new D0;class tr{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=tr.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new st,this.page=new st,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,r,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class gn extends tr{constructor(){super(...arguments),this.client=new st,this.movement=new st,this.offset=new st,this.global=new st,this.screen=new st}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,r,n,o,a,h,l,c,u,d,f,_,p){throw new Error("Method not implemented.")}}class ue extends gn{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class _s extends gn{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}_s.DOM_DELTA_PIXEL=0,_s.DOM_DELTA_LINE=1,_s.DOM_DELTA_PAGE=2;const F0=2048,L0=new st,Do=new st;class N0{constructor(t){this.dispatch=new Qs,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,r)=>i.priority-r.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.prop
vendor: 10,784 bytes, line 864
864agate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,r=e.length;i<r;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){ri.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",r=this[i](this.rootTarget,this.rootTarget.eventMode,L0.set(t,e),this.hitTestFn,this.hitPruneFn);return r&&r[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let r=0,n=i.length-1;r<n;r++)if(t.currentTarget=i[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let r=i.length-2;r>=0;r--)if(t.currentTarget=i[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const r=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)r.forEach(o=>{t.currentTarget=i[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i<F0&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,r,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(ri.pauseUpdate=!1),t.interactiveChildren&&t.children){const c=t.children;for(let u=c.length-1;u>=0;u--){const d=c[u],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,r,n,o||n(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const _=t.isInteractive();(f.length>0||_)&&(_&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const h=this._isInteractive(e),l=t.isInteractive();return h&&l&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:h&&!n(t,i)&&r(t,i)?l?[t]:[]:null}hitTestRecursive(t,e,i,r,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(ri.pauseUpdate=!1),t.interactiveChildren&&t.children){const h=t.children;for(let l=h.length-1;l>=0;l--){const c=h[l],u=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,i,r,n);if(u){if(u.length>0&&!u[u.length-1].parent)continue;const d=t.isInteractive();return(u.length>0||d)&&u.push(t),u}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&r(t,i)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,Do),!t.hitArea.contains(Do.x,Do.y)))return!0;if(t._mask){const i=t._mask.isMaskData?t._mask.maskObject:t._mask;if(i&&!i.containsPoint?.(e))return!0}return!1}hitTestFn(t,e){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){e=e??t.type;const i=`on${e}`;t.currentTarget[i]?.(t);const r=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,r),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof ue)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const r=e.button===2;this.dispatchEvent(e,r?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){if(!(t instanceof ue)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=e.pointerType==="mouse"||e.pointerType==="pen",r=this.trackingData(t.pointerId),n=this.findMountedTarget(r.overTargets);if(r.overTargets?.length>0&&n!==e.target){const h=t.type==="mousemove"?"mouseout":"pointerout",l=this.createPointerEvent(t,h,n);if(this.dispatchEvent(l,"pointerout"),i&&this.dispatchEvent(l,"mouseout"),!e.composedPath().includes(n)){const c=this.createPointerEvent(t,"pointerleave",n);for(c.eventPhase=c.AT_TARGET;c.target&&!e.composedPath().includes(c.target);)c.currentTarget=c.target,this.notifyTarget(c),i&&this.notifyTarget(c,"mouseleave"),c.target=c.target.parent;this.freeEvent(c)}this.freeEvent(l)}if(n!==e.target){const h=t.type==="mousemove"?"mouseover":"pointerover",l=this.clonePointerEvent(e,h);this.dispatchEvent(l,"pointerover"),i&&this.dispatchEvent(l,"mouseover");let c=n?.parent;for(;c&&c!==this.rootTarget.parent&&c!==e.target;)c=c.parent;if(!c||c===this.rootTarget.parent){const u=this.clonePointerEvent(e,"pointerenter");for(u.eventPhase=u.AT_TARGET;u.target&&u.target!==n&&u.target!==this.rootTarget.parent;)u.currentTarget=u.target,this.notifyTarget(u),i&&this.notifyTarget(u,"mouseenter"),u.target=u.target.parent;this.freeEvent(u)}this.freeEvent(l)}const o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(e,"pointermove"),a&&o.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),a&&o.push("globaltouchmove")),i&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),a&&o.push("globalmousemove"),this.cursor=e.target?.cursor),o.length>0&&this.all(e,o),this._allInteractiveElements.length=0,this._hitElements.length=0,r.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){if(!(t instanceof ue)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),r=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),r&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=i.target?.cursor);const n=this.clonePointerEvent(i,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),r&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof ue)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",r=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",r);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",r);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),i&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof ue)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const a=i.button===2;this.dispatchEvent(i,a?"rightup":"mouseup")}const r=this.trackingData(t.pointerId),n=this.findMountedTarget(r.pressTargetsByButton[t.button]);let o=n;if(n&&!i.composedPath().includes(n)){let a=n;for(;a&&!i.composedPath().includes(a);){if(i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const h=i.button===2;this.notifyTarget(i,h?"rightupoutside":"mouseupoutside")}a=a.parent}delete r.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,r.clicksByButton[t.button]||(r.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const h=r.clicksByButton[t.button];if(h.target===a.target&&e-h.timeStamp<200?++h.clickCount:h.clickCount=1,h.target=a.target,h.timeStamp=e,a.detail=h.clickCount,a.pointerType==="mouse"){const l=a.button===2;this.dispatchEvent(a,l?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof ue)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),r=this.createPointerEvent(t);if(i){let n=i;for(;n;)r.currentTarget=n,this.notifyTarget(r,"pointerupoutside"),r.pointerType==="touch"?this.notifyTarget(r,"touchendoutside"):(r.pointerType==="mouse"||r.pointerType==="pen")&&this.notifyTarget(r,r.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(r)}mapWheel(t){if(!(t instanceof _s)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const r=this.allocateEvent(ue);return this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.nativeEvent=t.nativeEvent,r.originalEvent=t,r.target=i??this.hitTest(r.global.x,r.global.y)??this._hitElements[0],typeof e=="string"&&(r.type=e),r}createWheelEvent(t){const e=this.allocateEvent(_s);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(ue);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof ue&&e instanceof ue&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.t
vendor: 17,793 bytes, line 864
864iltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof gn&&e instanceof gn&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let r=0,n=i.length;r<n&&!t.propagationImmediatelyStopped;r++)i[r].once&&t.currentTarget.removeListener(e,i[r].fn,void 0,!0),i[r].fn.call(i[r].context,t)}}const O0=1,U0={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},$a=class Xa{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new N0(null),ri.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new ue(null),this.rootWheelEvent=new _s(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Xa.defaultEventFeatures},{set:(e,i,r)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=r),e[i]=r,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{view:e,resolution:i}=this.renderer;this.setTargetElement(e),this.resolution=i,Xa._defaultEventMode=t.eventMode??"auto",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,r=e.length;i<r;i++){const n=e[i],o=this.bootstrapEvent(this.rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,ri.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,r=e.length;i<r;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",r=this.normalizeToPointerData(t);for(let n=0,o=r.length;n<o;n++){const a=this.bootstrapEvent(this.rootPointerEvent,r[n]);a.type+=i,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let i=0,r=e.length;i<r;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,ri.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;ri.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;ri.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,e,i){const r=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-r.left)*(this.domElement.width/r.width)*n,t.y=(i-r.top)*(this.domElement.height/r.height)*n}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,r=t.changedTouches.length;i<r;i++){const n=t.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=O0),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}else e.push(t);return e}normalizeWheelEvent(t){const e=this.rootWheelEvent;return this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=U0[t.type]||t.type),t}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};$a.extension={name:"events",type:[N.RendererSystem,N.CanvasRendererSystem]},$a.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Va=$a;W.add(Va);function Dl(s){return s==="dynamic"||s==="static"}const G0={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??Dl(Va.defaultEventMode)},set interactive(s){et("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=s,this.eventMode=s?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Va.defaultEventMode},set eventMode(s){this._internalInteractive=Dl(s),this._internalEventMode=s},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(s,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,r=typeof t=="function"?void 0:t;s=i?`${s}capture`:s,t=typeof t=="function"?t:t.handleEvent,this.on(s,t,r)},removeEventListener(s,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,r=typeof t=="function"?void 0:t;s=i?`${s}capture`:s,t=typeof t=="function"?t:t.handleEvent,this.off(s,t,r)},dispatchEvent(s){if(!(s instanceof tr))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return s.defaultPrevented=!1,s.path=null,s.target=this,s.manager.dispatchEvent(s),!s.defaultPrevented}};_t.mixin(G0);const H0={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};_t.mixin(H0);const z0=9,mr=100,$0=0,X0=0,Fl=2,Ll=1,V0=-1e3,W0=-1e3,j0=2;class Ed{constructor(t){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(ze.tablet||ze.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${mr}px`,e.style.height=`${mr}px`,e.style.position="absolute",e.style.top=`${$0}px`,e.style.left=`${X0}px`,e.style.zIndex=Fl.toString(),this.div=e,this.renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}createTouchHook(){const t=document.createElement("button");t.style.width=`${Ll}px`,t.style.height=`${Ll}px`,t.style.position="absolute",t.style.top=`${V0}px`,t.style.left=`${W0}px`,t.style.zIndex=j0.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),this.renderer.view.parentNode?.appendChild(this.div))}deactivate(){!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),this.div.parentNode?.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this.updateAccessibleObjects(e[i])}update(){const t=performance.now();if(ze.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:e,y:i,width:r,height:n}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:h}=this.renderer,l=r/o*h,c=n/a*h;let u=this.div;u.style.left=`${e}px`,u.style.top=`${i}px`,u.style.width=`${o}px`,u.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const f=this.children[d];if(f.renderId!==this.renderId)f._accessibleActive=!1,ds(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{u=f._accessibleDiv;let _=f.hitArea;const p=f.worldTransform;f.hitArea?(u.style.left=`${(p.tx+_.x*p.a)*l}px`,u.style.top=`${(p.ty+_.y*p.d)*c}px`,u.style.width=`${_.width*p.a*l}px`,u.style.height=`${_.height*p.d*c}px`):(_=f.getBounds(),this.capHitArea(_),u.style.left=`${_.x*l}px`,u.style.top=`${_.y*c}px`,u.style.width=`${_.width*l}px`,u.style.height=`${_.height*c}px`,u.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(u.title=f.accessibleTitle),u.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&u.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==u.title||f.tabIndex!==u.tabIndex)&&(u.title=f.accessibleTitle,u.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(u))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=`${mr}px`,e.style.height=`${mr}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Fl.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.t
vendor: 1,684 bytes, line 864
864itle=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{displayObject:i}=t.target,r=this.renderer.events.rootBoundary,n=Object.assign(new tr(r),{target:i});r.rootTarget=this.renderer.lastObjectRendered,e.forEach(o=>r.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===z0&&this.activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this.deactivate()}destroy(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null}}Ed.extension={name:"accessibility",type:[N.RendererPlugin,N.CanvasRendererPlugin]};W.add(Ed);const Ad=class Wa{constructor(t){this.stage=new kt,t=Object.assign({forceCanvas:!1},t),this.renderer=r0(t),Wa._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render(this.stage)}get view(){return this.renderer?.view}get screen(){return this.renderer?.screen}destroy(t,e){const i=Wa._plugins.slice(0);
864i.reverse(),i.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Ad._plugins=[];let Sd=Ad;W.handleByList(N.Application,Sd._plugins);class Cd{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:r,clientHeight:n}=this._resizeTo;e=r,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Cd.extension=N.Application;W.add(Cd);const Nl={loader:N.LoadParser,resolver:N.ResolveParser,cache:N.CacheParser,detection:N.DetectionParser};W.handle(N.Asset,s=>{const t=s.ref;Object.entries(Nl).filter(([e])=>!!t[e]).forEach(([e,i])=>W.add(Object.assign(t[e],{extension:t[e].extension??i})))},s=>{const t=s.ref;Object.keys(Nl).filter(e=>!!t[e]).forEach(e=>W.remove(t[e]))});class Y0{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}function Es(s,t){if(Array.isArray(t)){for(const e of t)if(s.startsWith(`data:${e}`))return!0;return!1}return s.startsWith(`data:${t}`)}function vi(s,t){const e=s.split("?")[0],i=wt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const de=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s),ja=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s};function Id(s,t,e,i,r){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?Id(s.replace(i[e],a),t,e+1,i,r):r.push(s.replace(i[e],a))}}function q0(s){const t=/\{(.*?)\}/g,e=s.match(t),i=[];if(e){const r=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");r.push(o)}),Id(s,r,0,e,i)}else i.push(s);return i}const bn=s=>!Array.isArray(s);class Z0{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||console.warn(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=de(t);let r;for(let a=0;a<this.parsers.length;a++){const h=this.parsers[a];if(h.test(e)){r=h.getCacheableAssets(i,e);break}}r||(r={},i.forEach(a=>{r[a]=e}));const n=Object.keys(r),o={cacheKeys:n,keys:i};if(i.forEach(a=>{this._cacheMap.set(a,o)}),n.forEach(a=>{this._cache.has(a)&&this._cache.get(a)!==e&&console.warn("[Cache] already has key:",a),this._cache.set(a,r[a])}),e instanceof V){const a=e;i.forEach(h=>{a.baseTexture!==V.EMPTY.baseTexture&&Q.addToCache(a.baseTexture,h),V.addToCache(a,h)})}}remove(t){if(!this._cacheMap.has(t)){console.warn(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const Di=new Z0;class K0{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{let r=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let o=0;o<this.parsers.length;o++){const a=this.parsers[o];if(a.load&&a.test?.(t,e,this)){n=a;break}}if(!n)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}r=await n.load(t,e,this),i.parser=n;for(let o=0;o<this.parsers.length;o++){const a=this.parsers[o];a.parse&&a.parse&&await a.testParse?.(r,e,this)&&(r=await a.parse(r,e,this)||r,i.parser=a)}return r})(),i}
864async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const r={},n=bn(t),o=de(t,l=>({alias:[l],src:l})),a=o.length,h=o.map(async l=>{const c=wt.toAbsolute(l.src);if(!r[l.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,l)),r[l.src]=await this.promiseCache[c].promise,e&&e(++i/a)}catch(u){throw delete this.promiseCache[c],delete r[l.src],new Error(`[Loader.load] Failed to load ${c}.
865${u}`)}});return await Promise.all(h),n?r[o[0].src]:r}async unload(t){const e=de(t,i=>({alias:[i],src:i})).map(async i=>{const r=wt.toAbsolute(i.src),n=this.promiseCache[r];if(n){const o=await n.promise;delete this.promiseCache[r],n.parser?.unload?.(o,i,this)}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(t[e.name]&&console.warn(`[Assets] loadParser name conflict "${e.name}"`),{...t,[e.name]:e}),{})}}var ge=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(ge||{});const J0=".json",Q0="application/json",t1={extension:{type:N.LoadParser,priority:ge.Low},name:"loadJson",test(s){return Es(s,Q0)||vi(s,J0)},async load(s){return await(await H.ADAPTER.fetch(s)).json()}};W.add(t1);const e1=".txt",i1="text/plain",s1={name:"loadTxt",extension:{type:N.LoadParser,priority:ge.Low},test(s){return Es(s,i1)||vi(s,e1)},async load(s){return await(await H.ADAPTER.fetch(s)).text()}};W.add(s1);const r1=["normal","bold","100","200","300","400","500","600","700","800","900"],n1=[".ttf",".otf",".woff",".woff2"],o1=["font/ttf","font/otf","font/woff","font/woff2"],a1=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function h1(s){const t=wt.extname(s),e=wt.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=e.length>0;for(const n of e)if(!n.match(a1)){i=!1;break}let r=e.join(" ");return i||(r=`"${r.replace(/[\\"]/g,"\\$&")}"`),r}const l1=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function c1(s){return l1.test(s)?s:encodeURI(s)}const u1={extension:{type:N.LoadParser,priority:ge.Low},name:"loadWebFont",test(s){return Es(s,o1)||vi(s,n1)},async load(s,t){const e=H.ADAPTER.getFontFaceSet();if(e){const i=[],r=t.data?.family??h1(s),n=t.data?.weights?.filter(a=>r1.includes(a))??["normal"],o=t.data??{};for(let a=0;a<n.length;a++){const h=n[a],l=new FontFace(r,`url(${c1(s)})`,{...o,weight:h});await l.load(),e.add(l),i.push(l)}return i.length===1?i[0]:i}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(s){(Array.isArray(s)?s:[s]).forEach(t=>H.ADAPTER.getFontFaceSet().delete(t))}};W.add(u1);let Ol=0,Fo;const d1="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=",f1={id:"checkImageBitmap",code:`
866    async function checkImageBitmap()
867    {
868        try
869        {
870            if (typeof createImageBitmap !== 'function') return false;
871
872            const response = await fetch('${d1}');
873            const imageBlob =  await response.blob();
874            const imageBitmap = await createImageBitmap(imageBlob);
875
876            return imageBitmap.width === 1 && imageBitmap.height === 1;
877        }
878        catch (e)
879        {
880            return false;
881        }
882    }
883    checkImageBitmap().then((result) => { self.postMessage(result); });
884    `},_1={id:"loadImageBitmap",code:`
885    async function loadImageBitmap(url)
886    {
887        const response = await fetch(url);
888
889        if (!response.ok)
890        {
891            throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \`
892                + \`\${response.status} \${response.statusText}\`);
893        }
894
895        const imageBlob =  await response.blob();
896        const imageBitmap = await createImageBitmap(imageBlob);
897
898        return imageBitmap;
899    }
900    self.onmessage = async (event) =>
901    {
902        try
903        {
904            const imageBitmap = await loadImageBitmap(event.data.data[0]);
905
906            self.postMessage({
907                data: imageBitmap,
908                uuid: event.data.uuid,
909                id: event.data.id,
910            }, [imageBitmap]);
911        }
912        catch(e)
913        {
914            self.postMessage({
915                error: e,
916                uuid: event.data.uuid,
917                id: event.data.id,
918            });
919        }
920    };`};let Lo;class p1{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>
920{const e=URL.createObjectURL(new Blob([f1.code],{type:"application/javascript"})),i=new Worker(e);i.addEventListener("message",r=>{i.terminate(),URL.revokeObjectURL(e),t(r.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Fo===void 0&&(Fo=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<Fo&&(Lo||(Lo=URL.createObjectURL(new Blob([_1.code],{type:"application/javascript"}))),this._createdWorkers++,t=new Worker(Lo),t.addEventListener("message",e=>{this.complete(e.data),this.returnWorker(e.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((r,n)=>{this.queue.push({id:t,arguments:e,resolve:r,reject:n})});return this.next(),i}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),i=e.id;this.resolveHash[Ol]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Ol++,id:i})}}const Ul=new p1;function er(s,t,e){s.resource.internal=!0;const i=new V(s),r=()=>{delete t.promiseCache[e],Di.has(e)&&Di.remove(e)};return i.baseTexture.once("destroyed",()=>{e in t.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),r())}),i.once("destroyed",()=>{s.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),i}const m1=[".jpeg",".jpg",".png",".webp",".avif"],g1=["image/jpeg","image/png","image/webp","image/avif"];async function b1(s){const t=await H.ADAPTER.fetch(s);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const Hn={name:"loadTextures",extension:{type:N.LoadParser,priority:ge.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return Es(s,g1)||vi(s,m1)},async load(s,t,e){const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let r;i?this.config.preferWorkers&&await Ul.isImageBitmapSupported()?r=await Ul.loadImageBitmap(s):r=await b1(s):r=await new Promise((a,h)=>{const l=new Image;l.crossOrigin=this.config.crossOrigin,l.src=s,l.complete?a(l):(l.onload=()=>a(l),l.onerror=c=>h(c))});const n={...t.data};n.resolution??(n.resolution=je(s)),i&&n.resourceOptions?.ownsImageBitmap===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const o=new Q(r,n);return o.resource.src=s,er(o,e,s)},unload(s){s.destroy(!0)}};W.add(Hn);const v1=".svg",y1="image/svg+xml",x1={extension:{type:N.LoadParser,priority:ge.High},name:"loadSVG",test(s){return Es(s,y1)||vi(s,v1)},async testParse(s){return Na.test(s)},async parse(s,t,e){const i=new Na(s,t?.data?.resourceOptions);await i.load();const r=new Q(i,{resolution:je(s),...t?.data});return r.resource.src=t.src,er(r,e,t.src)},async load(s,t){return(await H.ADAPTER.fetch(s)).text()},unload:Hn.unload};W.add(x1);const w1=[".mp4",".m4v",".webm",".ogv"],T1=["video/mp4","video/webm","video/ogg"],E1={name:"loadVideo",extension:{type:N.LoadParser,priority:ge.High},config:{defaultAutoPlay:!0},test(s){return Es(s,T1)||vi(s,w1)},async load(s,t,e){let i;const r=await(await H.ADAPTER.fetch(s)).blob(),n=URL.createObjectURL(r);try{const o={autoPlay:this.config.defaultAutoPlay,...t?.data?.resourceOptions},a=new xd(n,o);await a.load();const h=new Q(a,{alphaMode:await Mm(),resolution:je(s),...t?.data});h.resource.src=s,i=er(h,e,s),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(o){throw URL.revokeObjectURL(n),o}return i},unload(s){s.destroy(!0)}};W.add(E1);class A1{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}
920prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,name:i,src:r,srcs:n}=t;return de(e||i||r||n,o=>typeof o=="string"?o:Array.isArray(o)?o.map(a=>a?.src??a?.srcs??a):o?.src||o?.srcs?o.src??o.srcs:o,!0)}addManifest(t){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];Array.isArray(e)?e.forEach(r=>{const n=r.src??r.srcs,o=r.alias??r.name;let a;if(typeof o=="string"){const h=this._createBundleAssetId(t,o);i.push(h),a=[o,h]}else{const h=o.map(l=>this._createBundleAssetId(t,l));i.push(...h),a=[...o,...h]}this.add({...r,alias:a,src:n})}):Object.keys(e).forEach(r=>{const n=[r,this._createBundleAssetId(t,r)];if(typeof e[r]=="string")this.add({alias:n,src:e[r]});else if(Array.isArray(e[r]))this.add({alias:n,src:e[r]});else{const o=e[r],a=o.src??o.srcs;this.add({...o,alias:n,src:Array.isArray(a)?a:[a]})}i.push(...n)}),this._bundles[t]=i}add(t,e,i,r,n){const o=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(et("7.2.0",`Assets.add now uses an object instead of individual parameters.
921Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),o.push({alias:t,src:e,data:i,format:r,loadParser:n})):Array.isArray(t)?o.push(...t):o.push(t);let a;a=h=>{this.hasKey(h)&&console.warn(`[Resolver] already has key: ${h} overwriting`)},de(o).forEach(h=>{const{src:l,srcs:c}=h;let{data:u,format:d,loadParser:f}=h;const _=de(l||c).map(g=>typeof g=="string"?q0(g):Array.isArray(g)?g:[g]),p=this.getAlias(h);Array.isArray(p)?p.forEach(a):a(p);const m=[];_.forEach(g=>{g.forEach(v=>{let b={};if(typeof v!="object"){b.src=v;for(let y=0;y<this._parsers.length;y++){const E=this._parsers[y];if(E.test(v)){b=E.parse(v);break}}}else u=v.data??u,d=v.format??d,f=v.loadParser??f,b={...b,...v};if(!p)throw new Error(`[Resolver] alias is undefined for this asset: ${b.src}`);b=this.buildResolvedAsset(b,{aliases:p,data:u,format:d,loadParser:f}),m.push(b)})}),p.forEach(g=>{this._assetMap[g]=m})})}resolveBundle(t){const e=bn(t);t=de(t);const i={};return t.forEach(r=>{const n=this._bundles[r];if(n){const o=this.resolve(n),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(r,h)]=l}i[r]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const r in e)i[r]=e[r].src;return i}return e.src}resolve(t){const e=bn(t);t=de(t);const i={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const o=n[0],a=this._getPreferredOrder(n);a?.priority.forEach(h=>{a.params[h].forEach(l=>{const c=n.filter(u=>u[h]?u[h]===l:!1);c.length&&(n=c)})}),this._resolverHash[r]=n[0]??o}else this._resolverHash[r]=this.buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],r=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}buildResolvedAsset(t,e){const{aliases:i,data:r,loadParser:n,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=wt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...r||{},...t.data},t.loadParser=n??t.loadParser,t.format=o??wt.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class S1{constructor(){this._detections=[],this._initialized=!1,this.resolver=new A1,this.loader=new K0,this.cache=Di,this._backgroundLoader=new Y0(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Asset.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let n=t.manifest;typeof n=="string"&&(n=await this.load(n)),this.resolver.addManifest(n)}const e=t.texturePreference?.resolution??1,i=typeof e=="number"?[e]:e,r=await this._detectFormats({preferredFormats:t.texturePreference?.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:r,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,i,r,n){this.resolver.add(t,e,i,r,n)}async load(t,e){this._initialized||await this.init();const i=bn(t),r=de(t).map(a=>{if(typeof a!="string"){const h=this.resolver.getAlias(a);return h.some(l=>!this.resolver.hasKey(l))&&this.add(a),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(r),o=await this._mapLoadToResolve(n,e);return i?o[r[0]]:o}
921addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const r=this.resolver.resolveBundle(t),n={},o=Object.keys(r);let a=0,h=0;const l=()=>{e?.(++a/h)},c=o.map(u=>{const d=r[u];return h+=Object.keys(d).length,this._mapLoadToResolve(d,l).then(f=>{n[u]=f})});return await Promise.all(c),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return Di.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=Di.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=Object.values(t),r=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const o={};return i.forEach((a,h)=>{const l=n[a.src],c=[a.src];a.alias&&c.push(...a.alias),o[r[h]]=l,Di.set(c,l)}),o}async unload(t){this._initialized||await this.init();const e=de(t).map(r=>typeof r!="string"?r.src:r),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=de(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{Di.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,r)=>e.indexOf(i)===r),e}get detections(){return this._detections}get preferWorkers(){return Hn.config.preferWorkers}set preferWorkers(t){et("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:t})}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const gr=new S1;W.handleByList(N.LoadParser,gr.loader.parsers).handleByList(N.ResolveParser,gr.resolver.parsers).handleByList(N.CacheParser,gr.cache.parsers).handleByList(N.DetectionParser,gr.detections);const C1={extension:N.CacheParser,test:s=>Array.isArray(s)&&s.every(t=>t instanceof V),getCacheableAssets:(s,t)=>{const e={};return s.forEach(i=>{t.forEach((r,n)=>{e[i+(n===0?"":n+1)]=r})}),e}};W.add(C1);async function Rd(s){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const I1={extension:{type:N.DetectionParser,priority:1},test:async()=>Rd("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")};W.add(I1);const R1={extension:{type:N.DetectionParser,priority:0},test:async()=>Rd("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")};W.add(R1);const Gl=["png","jpg","jpeg"],M1={extension:{type:N.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...Gl],remove:async s=>s.filter(t=>!Gl.includes(t))};W.add(M1);const P1="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function vh(s){return P1?!1:document.createElement("video").canPlayType(s)!==""}const k1={extension:{type:N.DetectionParser,priority:0},test:async()=>vh("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")};W.add(k1);const B1={extension:{type:N.DetectionParser,priority:0},test:async()=>vh("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")};W.add(B1);const D1={extension:{type:N.DetectionParser,priority:0},test:async()=>vh("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")};W.add(D1);const F1={extension:N.ResolveParser,test:Hn.test,parse:s=>({resolution:parseFloat(H.RETINA_PREFIX.exec(s)?.[1]??"1"),format:wt.extname(s).slice(1),src:s})};W.add(F1);var Vt=(s=>(s[s.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",s[s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",s[s.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",s[s.COMPRESSED_R11_
921EAC=37488]="COMPRESSED_R11_EAC",s[s.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",s[s.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",s[s.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",s[s.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",s[s.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",s[s.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",s[s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",s[s.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",s[s.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",s[s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",s[s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",s[s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",s[s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",s[s.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",s[s.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",s[s.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",s[s.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",s[s.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",s))(Vt||{});const vn={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35986:1,34798:1,37808:1};let Ge,rs;function Hl(){rs={s3tc:Ge.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Ge.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:Ge.getExtension("WEBGL_compressed_texture_etc"),etc1:Ge.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:Ge.getExtension("WEBGL_compressed_texture_pvrtc")||Ge.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:Ge.getExtension("WEBGL_compressed_texture_atc"),astc:Ge.getExtension("WEBGL_compressed_texture_astc")}}const L1={extension:{type:N.DetectionParser,priority:2},test:async()=>{const s=H.ADAPTER.createCanvas().getContext("webgl");return s?(Ge=s,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async s=>{rs||Hl();const t=[];for(const e in rs)rs[e]&&t.push(e);return[...t,...s]},remove:async s=>(rs||Hl(),s.filter(t=>!(t in rs)))};W.add(L1);class N1 extends Ln{constructor(t,e={width:1,height:1,autoLoad:!0}){let i,r;typeof t=="string"?(i=t,r=new Uint8Array):(i=null,r=t),super(r,e),this.origin=i,this.buffer=r?new Ea(r):null,this._load=null,this.loaded=!1,this.origin!==null&&e.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(t=>t.blob()).then(t=>t.arrayBuffer()).then(t=>(this.data=new Uint32Array(t),this.buffer=new Ea(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Ni extends N1{constructor(t,e){super(t,e),this.format=e.format,this.levels=e.levels||1,this._width=e.width,this._height=e.height,this._extension=Ni._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||Ni._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){const r=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;r.pixelStorei(r.UNPACK_ALIGNMENT,4);for(let n=0,o=this.levels;n<o;n++){const{levelID:a,levelWidth:h,levelHeight:l,levelBuffer:c}=this._levelBuffers[n];r.compressedTexImage2D(r.TEXTURE_2D,a,this.format,h,l,0,c)}return!0}onBlobLoaded(){this._levelBuffers=Ni._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t>=36196)return"etc1";if(t>=35986&&t<=34798)return"atc";throw new Error("Invalid (compressed) texture format given!")}static _createLevelBuffers(t,e,i,r,n,o,a){const h=new Array(i);let l=t.byteOffset,c=o,u=a,d=c+r-1&~(r-1),f=u+n-1&~(n-1),_=d*f*vn[e];for(let p=0;p<i;p++)h[p]={levelID:p,levelWidth:i>1?c:d,levelHeight:i>1?u:f,levelBuffer:new Uint8Array(t.buffer,l,_)},l+=_,c=c>>1||1,u=u>>1||1,d=c+r-1&~(r-1),f=u+n-1&~(n-1),_=d*f*vn[e];return h}}const No=4,br=124,O1=32,zl=20,U1=542327876,vr={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},G1={SIZE:0,FLAGS:1,FOURCC:2,RGB_BITCOUNT:3,R_BIT_MASK:4,G_BIT_MASK:5,B_BIT_MASK:6,A_BIT_MASK:7},yr={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},H1=1,z1=2,$1=4,X1=64,V1=512,W1=131072,j1=827611204,Y1=861165636,q1=894720068,Z1=808540228,K1=4,J1={[j1]:Vt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Y1]:Vt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[q1]:Vt.COMPRESSED_RGBA_S3TC_DXT5_EXT},Q1={70:Vt.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Vt.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Vt.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Vt.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Vt.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Vt.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Vt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Vt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Vt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT};function tb(s){const t=new Uint32Array(s);if(t[0]!==U1)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(s,0,br/Uint32Array.BYTES_PER_ELEMENT),i=e[vr.HEIGHT],r=e[vr.WIDTH],n=e[vr.MIPMAP_COUNT],o=new Uint32Array(s,vr.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,O1/Uint32Array.BYTES_PER_ELEMENT),a=o[H1];if(a&$1){const h=o[G1.FOURCC];if(h!==Z1){const v=J1[h],b=No+br,y=new Uint8Array(s,b);return[new Ni(y,{format:v,width:r,height:i,levels:n})]}const l=No+br,c=new Uint32Array(t.buffer,l,zl/Uint32Array.BYTES_PER_ELEMENT),u=c[yr.DXGI_FORMAT],d=c[yr.RESOURCE_DIMENSION],f=c[yr.MISC_FLAG],_=c[yr.ARRAY_SIZE],p=Q1[u];if(p===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${u}`);if(f===K1)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const m=new Array,g=No+br+zl;if(_===1)m.push(new Uint8Array(s,g));else{const v=vn[p];let b=0,y=r,E=i;for(let x=0;x<n;x++){const T=Math.max(1,y+3&-4),I=Math.max(1,E+3&-4),M=T*I*v;b+=M,y=y>
921>>1,E=E>>>1}let w=g;for(let x=0;x<_;x++)m.push(new Uint8Array(s,w,b)),w+=b}return m.map(v=>new Ni(v,{format:p,width:r,height:i,levels:n}))}throw a&X1?new Error("DDSParser does not support uncompressed texture data."):a&V1?new Error("DDSParser does not supported YUV uncompressed texture data."):a&W1?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&z1?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const $l=[171,75,84,88,32,49,49,187,13,10,26,10],eb=67305985,ae={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},Ya=64,Xl={[Y.UNSIGNED_BYTE]:1,[Y.UNSIGNED_SHORT]:2,[Y.INT]:4,[Y.UNSIGNED_INT]:4,[Y.FLOAT]:4,[Y.HALF_FLOAT]:8},ib={[B.RGBA]:4,[B.RGB]:3,[B.RG]:2,[B.RED]:1,[B.LUMINANCE]:1,[B.LUMINANCE_ALPHA]:2,[B.ALPHA]:1},sb={[Y.UNSIGNED_SHORT_4_4_4_4]:2,[Y.UNSIGNED_SHORT_5_5_5_1]:2,[Y.UNSIGNED_SHORT_5_6_5]:2};function rb(s,t,e=!1){const i=new DataView(t);if(!nb(s,i))return null;const r=i.getUint32(ae.ENDIANNESS,!0)===eb,n=i.getUint32(ae.GL_TYPE,r),o=i.getUint32(ae.GL_FORMAT,r),a=i.getUint32(ae.GL_INTERNAL_FORMAT,r),h=i.getUint32(ae.PIXEL_WIDTH,r),l=i.getUint32(ae.PIXEL_HEIGHT,r)||1,c=i.getUint32(ae.PIXEL_DEPTH,r)||1,u=i.getUint32(ae.NUMBER_OF_ARRAY_ELEMENTS,r)||1,d=i.getUint32(ae.NUMBER_OF_FACES,r),f=i.getUint32(ae.NUMBER_OF_MIPMAP_LEVELS,r),_=i.getUint32(ae.BYTES_OF_KEY_VALUE_DATA,r);if(l===0||c!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(u!==1)throw new Error("WebGL does not support array textures");const p=4,m=4,g=h+3&-4,v=l+3&-4,b=new Array(u);let y=h*l;n===0&&(y=g*v);let E;if(n!==0?Xl[n]?E=Xl[n]*ib[o]:E=sb[n]:E=vn[a],E===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const w=e?ab(i,_,r):null;let x=y*E,T=h,I=l,M=g,P=v,k=Ya+_;for(let A=0;A<f;A++){const S=i.getUint32(k,r);let X=k+4;for(let q=0;q<u;q++){let F=b[q];F||(F=b[q]=new Array(f)),F[A]={levelID:A,levelWidth:f>1||n!==0?T:M,levelHeight:f>1||n!==0?I:P,levelBuffer:new Uint8Array(t,X,x)},X+=x}k+=S+4,k=k%4!==0?k+4-k%4:k,T=T>>1||1,I=I>>1||1,M=T+p-1&~(p-1),P=I+m-1&~(m-1),x=M*P*E}return n!==0?{uncompressed:b.map(A=>{let S=A[0].levelBuffer,X=!1;return n===Y.FLOAT?S=new Float32Array(A[0].levelBuffer.buffer,A[0].levelBuffer.byteOffset,A[0].levelBuffer.byteLength/4):n===Y.UNSIGNED_INT?(X=!0,S=new Uint32Array(A[0].levelBuffer.buffer,A[0].levelBuffer.byteOffset,A[0].levelBuffer.byteLength/4)):n===Y.INT&&(X=!0,S=new Int32Array(A[0].levelBuffer.buffer,A[0].levelBuffer.byteOffset,A[0].levelBuffer.byteLength/4)),{resource:new Ln(S,{width:A[0].levelWidth,height:A[0].levelHeight}),type:n,format:X?ob(o):o}}),kvData:w}:{compressed:b.map(A=>new Ni(null,{format:a,width:h,height:l,levels:f,levelBuffers:A})),kvData:w}}function nb(s,t){for(let e=0;e<$l.length;e++)if(t.getUint8(e)!==$l[e])return console.error(`${s} is not a valid *.ktx file!`),!1;return!0}function ob(s){switch(s){case B.RGBA:return B.RGBA_INTEGER;case B.RGB:return B.RGB_INTEGER;case B.RG:return B.RG_INTEGER;case B.RED:return B.RED_INTEGER;default:return s}}function ab(s,t,e){const i=new Map;let r=0;for(;r<t;){const n=s.getUint32(Ya+r,e),o=Ya+r+4,a=3-(n+3)%4;if(n===0||n>t-r){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let h=0;for(;h<n&&s.getUint8(o+h)!==0;h++);if(h===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const l=new TextDecoder().decode(new Uint8Array(s.buffer,o,h)),c=new DataView(s.buffer,o+h+1,n-h-1);i.set(l,c),r+=4+n+a}return i}const hb={extension:{type:N.LoadParser,priority:ge.High},name:"loadDDS",test(s){return vi(s,".dds")},async load(s,t,e){const i=await(await H.ADAPTER.fetch(s)).arrayBuffer(),r=tb(i).map(n=>{const o=new Q(n,{mipmap:Pe.OFF,alphaMode:Ht.NO_PREMULTIPLIED_ALPHA,resolution:je(s),...t.data});return er(o,e,s)});return r.length===1?r[0]:r}
921,unload(s){Array.isArray(s)?s.forEach(t=>t.destroy(!0)):s.destroy(!0)}};W.add(hb);const lb={extension:{type:N.LoadParser,priority:ge.High},name:"loadKTX",test(s){return vi(s,".ktx")},async load(s,t,e){const i=await(await H.ADAPTER.fetch(s)).arrayBuffer(),{compressed:r,uncompressed:n,kvData:o}=rb(s,i),a=r??n,h={mipmap:Pe.OFF,alphaMode:Ht.NO_PREMULTIPLIED_ALPHA,resolution:je(s),...t.data},l=a.map(c=>{a===n&&Object.assign(h,{type:c.type,format:c.format});const u=c.resource??c,d=new Q(u,h);return d.ktxKeyValueData=o,er(d,e,s)});return l.length===1?l[0]:l},unload(s){Array.isArray(s)?s.forEach(t=>t.destroy(!0)):s.destroy(!0)}};W.add(lb);const cb={extension:N.ResolveParser,test:s=>{const t=wt.extname(s).slice(1);return["basis","ktx","dds"].includes(t)},parse:s=>{const t=wt.extname(s).slice(1);if(t==="ktx"){const e=[".s3tc.ktx",".s3tc_sRGB.ktx",".etc.ktx",".etc1.ktx",".pvrt.ktx",".atc.ktx",".astc.ktx"];if(e.some(i=>s.endsWith(i)))return{resolution:parseFloat(H.RETINA_PREFIX.exec(s)?.[1]??"1"),format:e.find(i=>s.endsWith(i)),src:s}}return{resolution:parseFloat(H.RETINA_PREFIX.exec(s)?.[1]??"1"),format:t,src:s}}};W.add(cb);const xr=new J,ub=4,Md=class Gs{constructor(t){this.renderer=t,this._rendererPremultipliedAlpha=!1}contextChange(){const t=this.renderer?.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(t,e,i,r){const n=new Image;return n.src=await this.base64(t,e,i,r),n}async base64(t,e,i,r){const n=this.canvas(t,r);if(n.toBlob!==void 0)return new Promise((o,a)=>{n.toBlob(h=>{if(!h){a(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>o(l.result),l.onerror=a,l.readAsDataURL(h)},e,i)});if(n.toDataURL!==void 0)return n.toDataURL(e,i);if(n.convertToBlob!==void 0){const o=await n.convertToBlob({type:e,quality:i});return new Promise((a,h)=>{const l=new FileReader;l.onload=()=>a(l.result),l.onerror=h,l.readAsDataURL(o)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const{pixels:i,width:r,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);o&&Gs._flipY(i,r,n),a&&Gs._unpremultiplyAlpha(i);const h=new Wm(r,n,1),l=new ImageData(new Uint8ClampedArray(i.buffer),r,n);return h.context.putImageData(l,0,0),h.canvas}pixels(t,e){const{pixels:i,width:r,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);return o&&Gs._flipY(i,r,n),a&&Gs._unpremultiplyAlpha(i),i}_rawPixels(t,e){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let r,n=!1,o=!1,a,h=!1;t&&(t instanceof Bt?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),h=!0,e&&(xr.width=e.width,xr.height=e.height,e=xr)));const l=i.gl;if(a){if(r=a.baseTexture.resolution,e=e??a.frame,n=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===B.RGBA,!h){i.renderTexture.bind(a);const f=a.framebuffer.glFramebuffers[i.CONTEXT_UID];f.blitFramebuffer&&i.framebuffer.bind(f.blitFramebuffer)}}else r=i.resolution,e||(e=xr,e.width=i.width/r,e.height=i.height/r),n=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const c=Math.max(Math.round(e.width*r),1),u=Math.max(Math.round(e.height*r),1),d=new Uint8Array(ub*c*u);return l.readPixels(Math.round(e.x*r),Math.round(e.y*r),c,u,l.RGBA,l.UNSIGNED_BYTE,d),h&&a?.destroy(!0),{pixels:d,width:c,height:u,flipY:n,premultipliedAlpha:o}}destroy(){this.renderer=null}static _flipY(t,e,i){const r=e<<2,n=i>>1,o=new Uint8Array(r);for(let a=0;a<n;a++){const h=a*r,l=(i-a-1)*r;o.set(t.subarray(h,h+r)),t.copyWithin(h,l,l+r),t.set(o,l)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const e=t.length;for(let i=0;i<e;i+=4){const r=t[i+3];if(r!==0){const n=255.001/r;t[i]=t[i]*n+.5,t[i+1]=t[i+1]*n+.5,t[i+2]=t[i+2]*n+.5}}}};Md.extension={name:"extract",type:N.RendererSystem};let db=Md;W.add(db);const yn={build(s){const t=s.points;let e,i,r,n,o,a;if(s.type===Rt.CIRC){const _=s.shape;e=_.x,i=_.y,o=a=_.radius,r=n=0}else if(s.type===Rt.ELIP){const _=s.shape;e=_.x,i=_.y,o=_.width,a=_.height,r=n=0}else{const _=s.shape,p=_.width/2,m=_.height/2;e=_.x+p,i=_.y+m,o=a=Math.max(0,Math.min(_.radius,Math.min(p,m))),r=p-o,n=m-a}if(!(o>=0&&a>=0&&r>=0&&n>=0)){t.length=0;return}const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(r?4:0)+(n?4:0);if(t.length=l,l===0)return;if(h===0){t.length=8,t[0]=t[6]=e+r,t[1]=t[3]=i+n,t[2]=t[4]=e-r,t[5]=t[7]=i-n;return}let c=0,u=h*4+(r?2:0)+2,d=u,f=l;{const _=r+o,p=n,m=e+_,g=e-_,v=i+p;if(t[c++]=m,t[c++]=v,t[--u]=v,t[--u]=g,n){const b=i-p;t[d++]=g,t[d++]=b,t[--f]=b,t[--f]=m}}for(let _=1;_<h;_++){const p=Math.PI/2*(_/h),m=r+Math.cos(p)*o,g=n+Math.sin(p)*a,v=e+m,b=e-m,y=i+g,E=i-g;t[c++]=v,t[c++]=y,t[--u]=y,t[--u]=b,t[d++]=b,t[d++]=E,t[--f]=E,t[--f]=v}{const _=r,p=n+a,m=e+_,g=e-_,v=i+p,b=i-p;t[c++]=m,t[c++]=v,t[--f]=b,t[--f]=m,r&&(t[c++]=g,t[c++]=v,t[--f]=b,t[--f]=g)}},triangulate(s,t){const e=s.points,i=t.points,r=t.indices;if(e.length===0)return;let n=i.length/2;const o=n;let a,h;
921if(s.type!==Rt.RREC){const c=s.shape;a=c.x,h=c.y}else{const c=s.shape;a=c.x+c.width/2,h=c.y+c.height/2}const l=s.matrix;i.push(s.matrix?l.a*a+l.c*h+l.tx:a,s.matrix?l.b*a+l.d*h+l.ty:h),n++,i.push(e[0],e[1]);for(let c=2;c<e.length;c+=2)i.push(e[c],e[c+1]),r.push(n++,o,n);r.push(o+1,o,n)}};function Vl(s,t=!1){const e=s.length;if(e<6)return;let i=0;for(let r=0,n=s[e-2],o=s[e-1];r<e;r+=2){const a=s[r],h=s[r+1];i+=(a-n)*(h+o),n=a,o=h}if(!t&&i>0||t&&i<=0){const r=e/2;for(let n=r+r%2;n<e;n+=2){const o=e-n-2,a=e-n-1,h=n,l=n+1;[s[o],s[h]]=[s[h],s[o]],[s[a],s[l]]=[s[l],s[a]]}}}const Pd={build(s){s.points=s.shape.points.slice()},triangulate(s,t){let e=s.points;const i=s.holes,r=t.points,n=t.indices;if(e.length>=6){Vl(e,!1);const o=[];for(let l=0;l<i.length;l++){const c=i[l];Vl(c.points,!0),o.push(e.length/2),e=e.concat(c.points)}const a=Sm(e,o,2);if(!a)return;const h=r.length/2;for(let l=0;l<a.length;l+=3)n.push(a[l]+h),n.push(a[l+1]+h),n.push(a[l+2]+h);for(let l=0;l<e.length;l++)r.push(e[l])}}},fb={build(s){const t=s.shape,e=t.x,i=t.y,r=t.width,n=t.height,o=s.points;o.length=0,r>=0&&n>=0&&o.push(e,i,e+r,i,e+r,i+n,e,i+n)},triangulate(s,t){const e=s.points,i=t.points;if(e.length===0)return;const r=i.length/2;i.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(r,r+1,r+2,r+1,r+2,r+3)}},_b={build(s){yn.build(s)},triangulate(s,t){yn.triangulate(s,t)}};var Qt=(s=>(s.MITER="miter",s.BEVEL="bevel",s.ROUND="round",s))(Qt||{}),oi=(s=>(s.BUTT="butt",s.ROUND="round",s.SQUARE="square",s))(oi||{});const bs={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(s,t=20){if(!this.adaptive||!s||isNaN(s))return t;let e=Math.ceil(s/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class Wl{static curveTo(t,e,i,r,n,o){const a=o[o.length-2],h=o[o.length-1]-e,l=a-t,c=r-e,u=i-t,d=Math.abs(h*u-l*c);if(d<1e-8||n===0)return(o[o.length-2]!==t||o[o.length-1]!==e)&&o.push(t,e),null;const f=h*h+l*l,_=c*c+u*u,p=h*c+l*u,m=n*Math.sqrt(f)/d,g=n*Math.sqrt(_)/d,v=m*p/f,b=g*p/_,y=m*u+g*l,E=m*c+g*h,w=l*(g+v),x=h*(g+v),T=u*(m+b),I=c*(m+b),M=Math.atan2(x-E,w-y),P=Math.atan2(I-E,T-y);return{cx:y+t,cy:E+e,radius:n,startAngle:M,endAngle:P,anticlockwise:l*c>u*h}}static arc(t,e,i,r,n,o,a,h,l){const c=a-o,u=bs._segmentsCount(Math.abs(c)*n,Math.ceil(Math.abs(c)/un)*40),d=c/(u*2),f=d*2,_=Math.cos(d),p=Math.sin(d),m=u-1,g=m%1/m;for(let v=0;v<=m;++v){const b=v+g*v,y=d+o+f*b,E=Math.cos(y),w=-Math.sin(y);l.push((_*E+p*w)*n+i,(_*-w+p*E)*n+r)}}}class pb{constructor(){this.reset()}begin(t,e,i){this.reset(),this.style=t,this.start=e,this.attribStart=i}end(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class yh{static curveLength(t,e,i,r,n,o,a,h){let l=0,c=0,u=0,d=0,f=0,_=0,p=0,m=0,g=0,v=0,b=0,y=t,E=e;for(let w=1;w<=10;++w)c=w/10,u=c*c,d=u*c,f=1-c,_=f*f,p=_*f,m=p*t+3*_*c*i+3*f*u*n+d*a,g=p*e+3*_*c*r+3*f*u*o+d*h,v=y-m,b=E-g,y=m,E=g,l+=Math.sqrt(v*v+b*b);return l}static curveTo(t,e,i,r,n,o,a){const h=a[a.length-2],l=a[a.length-1];a.length-=2;const c=bs._segmentsCount(yh.curveLength(h,l,t,e,i,r,n,o));let u=0,d=0,f=0,_=0,p=0;a.push(h,l);for(let m=1,g=0;m<=c;++m)g=m/c,u=1-g,d=u*u,f=d*u,_=g*g,p=_*g,a.push(f*h+3*d*g*t+3*u*_*i+p*n,f*l+3*d*g*e+3*u*_*r+p*o)}}function jl(s,t,e,i,r,n,o,a){const h=s-e*r,l=t-i*r,c=s+e*n,u=t+i*n;let d,f;o?(d=i,f=-e):(d=-i,f=e);const _=h+d,p=l+f,m=c+d,g=u+f;return a.push(_,p,m,g),2}function Ti(s,t,e,i,r,n,o,a){const h=e-s,l=i-t;let c=Math.atan2(h,l),u=Math.atan2(r-s,n-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,_=Math.abs(f),p=Math.sqrt(h*h+l*l),m=(15*_*Math.sqrt(p)/Math.PI>>0)+1,g=f/m;if(d+=g,a){o.push(s,t,e,i);for(let v=1,b=d;v<m;v++,b+=g)o.push(s,t,s+Math.sin(b)*p,t+Math.cos(b)*p);o.push(s,t,r,n)}else{o.push(e,i,s,t);for(let v=1,b=d;v<m;v++,b+=g)o.push(s+Math.sin(b)*p,t+Math.cos(b)*p,s,t);o.push(r,n,s,t)}return m*2}function mb(s,t){const e=s.shape;let i=s.points||e.points.slice();const r=t.closePointEps;if(i.length===0)return;const n=s.lineStyle,o=new st(i[0],i[1]),a=new st(i[i.length-2],i[i.length-1]),h=e.type!==Rt.POLY||e.closeStroke,l=Math.abs(o.x-a.x)<r&&Math.abs(o.y-a.y)<r;if(h){i=i.slice(),l&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const F=(o.x+a.x)*.5,tt=(a.y+o.y)*.5;i.unshift(F,tt),i.push(F,tt)}const c=t.points,u=i.length/2;let d=i.length;const f=c.length/2,_=n.width/2,p=_*_,m=n.miterLimit*n.miterLimit;let g=i[0],v=i[1],b=i[2],y=i[3],E=0,w=0,x=-(v-y),T=g-b,I=0,M=0,P=Math.sqrt(x*x+T*T);x/=P,T/=P,x*=_,T*=_;const k=n.alignment,A=(1-k)*2,S=k*2;h||(n.cap===oi.ROUND?d+=Ti(g-x*(A-S)*.5,v-T*(A-S)*.5,g-x*A,v-T*A,g+x*S,v+T*S,c,!0)+2:n.cap===oi.SQUARE&&(d+=jl(g,v,x,T,A,S,!0,c))),c.push(g-x*A,v-T*A,g+x*S,v+T*S);for(let F=1;F<u-1;
921++F){g=i[(F-1)*2],v=i[(F-1)*2+1],b=i[F*2],y=i[F*2+1],E=i[(F+1)*2],w=i[(F+1)*2+1],x=-(v-y),T=g-b,P=Math.sqrt(x*x+T*T),x/=P,T/=P,x*=_,T*=_,I=-(y-w),M=b-E,P=Math.sqrt(I*I+M*M),I/=P,M/=P,I*=_,M*=_;const tt=b-g,R=v-y,C=b-E,K=w-y,it=tt*C+R*K,O=R*C-K*tt,pt=O<0;if(Math.abs(O)<.001*Math.abs(it)){c.push(b-x*A,y-T*A,b+x*S,y+T*S),it>=0&&(n.join===Qt.ROUND?d+=Ti(b,y,b-x*A,y-T*A,b-I*A,y-M*A,c,!1)+4:d+=2,c.push(b-I*S,y-M*S,b+I*A,y+M*A));continue}const Tt=(-x+g)*(-T+y)-(-x+b)*(-T+v),U=(-I+E)*(-M+y)-(-I+b)*(-M+w),at=(tt*U-C*Tt)/O,At=(K*Tt-R*U)/O,mt=(at-b)*(at-b)+(At-y)*(At-y),rt=b+(at-b)*A,lt=y+(At-y)*A,St=b-(at-b)*S,L=y-(At-y)*S,Mt=Math.min(tt*tt+R*R,C*C+K*K),Lt=pt?A:S,Ye=Mt+Lt*Lt*p,Ss=mt<=Ye;let D=n.join;if(D===Qt.MITER&&mt/p>m&&(D=Qt.BEVEL),Ss)switch(D){case Qt.MITER:{c.push(rt,lt,St,L);break}case Qt.BEVEL:{pt?c.push(rt,lt,b+x*S,y+T*S,rt,lt,b+I*S,y+M*S):c.push(b-x*A,y-T*A,St,L,b-I*A,y-M*A,St,L),d+=2;break}case Qt.ROUND:{pt?(c.push(rt,lt,b+x*S,y+T*S),d+=Ti(b,y,b+x*S,y+T*S,b+I*S,y+M*S,c,!0)+4,c.push(rt,lt,b+I*S,y+M*S)):(c.push(b-x*A,y-T*A,St,L),d+=Ti(b,y,b-x*A,y-T*A,b-I*A,y-M*A,c,!1)+4,c.push(b-I*A,y-M*A,St,L));break}}else{switch(c.push(b-x*A,y-T*A,b+x*S,y+T*S),D){case Qt.MITER:{pt?c.push(St,L,St,L):c.push(rt,lt,rt,lt),d+=2;break}case Qt.ROUND:{pt?d+=Ti(b,y,b+x*S,y+T*S,b+I*S,y+M*S,c,!0)+2:d+=Ti(b,y,b-x*A,y-T*A,b-I*A,y-M*A,c,!1)+2;break}}c.push(b-I*A,y-M*A,b+I*S,y+M*S),d+=2}}g=i[(u-2)*2],v=i[(u-2)*2+1],b=i[(u-1)*2],y=i[(u-1)*2+1],x=-(v-y),T=g-b,P=Math.sqrt(x*x+T*T),x/=P,T/=P,x*=_,T*=_,c.push(b-x*A,y-T*A,b+x*S,y+T*S),h||(n.cap===oi.ROUND?d+=Ti(b-x*(A-S)*.5,y-T*(A-S)*.5,b-x*A,y-T*A,b+x*S,y+T*S,c,!1)+2:n.cap===oi.SQUARE&&(d+=jl(b,y,x,T,A,S,!1,c)));const X=t.indices,q=bs.epsilon*bs.epsilon;for(let F=f;F<d+f-2;++F)g=c[F*2],v=c[F*2+1],b=c[(F+1)*2],y=c[(F+1)*2+1],E=c[(F+2)*2],w=c[(F+2)*2+1],!(Math.abs(g*(y-w)+b*(w-v)+E*(v-y))<q)&&X.push(F,F+1,F+2)}function gb(s,t){let e=0;const i=s.shape,r=s.points||i.points,n=i.type!==Rt.POLY||i.closeStroke;if(r.length===0)return;const o=t.points,a=t.indices,h=r.length/2,l=o.length/2;let c=l;for(o.push(r[0],r[1]),e=1;e<h;e++)o.push(r[e*2],r[e*2+1]),a.push(c,c+1),c++;n&&a.push(c,l)}function Yl(s,t){s.lineStyle.native?gb(s,t):mb(s,t)}class xh{static curveLength(t,e,i,r,n,o){const a=t-2*i+n,h=e-2*r+o,l=2*i-2*t,c=2*r-2*e,u=4*(a*a+h*h),d=4*(a*l+h*c),f=l*l+c*c,_=2*Math.sqrt(u+d+f),p=Math.sqrt(u),m=2*u*p,g=2*Math.sqrt(f),v=d/p;return(m*_+p*d*(_-g)+(4*f*u-d*d)*Math.log((2*p+v+_)/(v+g)))/(4*m)}static curveTo(t,e,i,r,n){const o=n[n.length-2],a=n[n.length-1],h=bs._segmentsCount(xh.curveLength(o,a,t,e,i,r));let l=0,c=0;for(let u=1;u<=h;++u){const d=u/h;l=o+(t-o)*d,c=a+(e-a)*d,n.push(l+(t+(i-t)*d-l)*d,c+(e+(r-e)*d-c)*d)}}}const Oo={[Rt.POLY]:Pd,[Rt.CIRC]:yn,[Rt.ELIP]:yn,[Rt.RECT]:fb,[Rt.RREC]:_b},ql=[],wr=[];class xn{constructor(t,e=null,i=null,r=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=r,this.type=t.type}clone(){return new xn(this.shape,this.fillStyle,this.lineStyle,this.matrix)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const Yi=new st,kd=class Bd extends Ou{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new mn,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),wr.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),ql.push(e)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,i=null,r=null){const n=new xn(t,e,i,r);return this.graphicsData.push(n),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new xn(t,null,null,e),r=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=r.lineStyle,r.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const e=this.graphicsData;for(let i=0;i<e.length;++i){const r=e[i];if(r.fillStyle.visible&&r.shape&&(r.matrix?r.matrix.applyInverse(t,Yi):Yi.copyFrom(t),r.shape.contains(Yi.x,Yi.y))){let n=!1;if(r.holes){for(let o=0;o<r.holes.length;o++)if(r.holes[o].shape.contains(Yi.x,Yi.y)){n=!0;break}}if(!n)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let i=null,r=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],r=i.style);for(let h=this.shapeIndex;h<e.length;h++){this.shapeIndex++;const l=e[h],c=l.fillStyle,u=l.lineStyle;Oo[l.type].build(l),l.matrix&&this.transformPoints(l.points,l.matrix),(c.visible||u.visible)&&this.processHoles(l.holes);for(let d=0;d<2;d++){const f=d===0?c:u;if(!f.visible)continue;const _=f.texture.baseTexture,p=this.indices.length,m=this.points.length/2;_.wrapMode=li.REPEAT,d===0?this.processFill(l):this.processLine(l);const g=this.points.length/2-m;g!==0&&(i&&!this._compareStyles(r,f)&&(i.end(p,m),i=null),i||(i=ql.pop()||new pb,i.begin(f,p,m),this.batches.push(i),r=f),this.addUvs(this.points,t,f.texture,m,g,f.matrix))}}const n=this.indices.length,o=this.points.length/2;if(i&&i.end(n,o),this.batches.length===0){this.batchable=!0;return}const a=o>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&a===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=a?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const i=this.graphicsData[t],r=i.fillStyle,n=i.lineStyle;if(r&&!r.texture.baseTexture.valid||n&&!n.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,i=t.length;e<i;e++){const r=t[e];for(let n=0;n<r.size;n++){const o=r.start+n;this.indicesUint16[o]=this.indicesUint16[o]-r.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let e=0;e<t.length;e++)if(t[e].style.native)return!1;return this.points.length<Bd.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++Q._globalBatch;for(let u=0;u<this.drawCalls.length;u++)this.drawCalls[u].texArray.clear(),wr.push(this.drawCalls[u]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let r=wr.pop();r||(r=new Ca,r.texArray=new Pa),r.texArray.count=0,r.start=0,r.size=0,r.type=Ie.TRIANGLES;let n=0,o=null,a=0,h=!1,l=Ie.TRIANGLES,c=0;this.drawCalls.push(r);for(let u=0;u<this.batches.length;u++){const d=this.batches[u],f=8,_=d.style,p=_.texture.baseTexture;h!==!!_.native&&(h=!!_.native,l=h?Ie.LINES:Ie.TRIANGLES,o=null,n=f,t++),o!==p&&(o=p,p._batchEnabled!==t&&(n===f&&(t++,n=0,r.size>0&&(r=wr.pop(),r||(r=new Ca,r.texArray=new Pa),this.drawCalls.push(r)),r.start=c,r.size=0,r.texArray.count=0,r.type=l),p.touched=1,p._batchEnabled=t,p._batchLocation=n,p.wrapMode=li.REPEAT,r.texArray.elements[r.texArray.count++
921]=p,n++)),r.size+=d.size,c+=d.size,a=p._batchLocation,this.addColors(e,_.color,_.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}Q._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=this.colors,r=this.textureIds,n=new ArrayBuffer(t.length*3*4),o=new Float32Array(n),a=new Uint32Array(n);let h=0;for(let l=0;l<t.length/2;l++)o[h++]=t[l*2],o[h++]=t[l*2+1],o[h++]=e[l*2],o[h++]=e[l*2+1],a[h++]=i[l],o[h++]=r[l];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?Pd.triangulate(t,this):Oo[t.type].triangulate(t,this)}processLine(t){Yl(t,this);for(let e=0;e<t.holes.length;e++)Yl(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];Oo[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,e){for(let i=0;i<t.length/2;i++){const r=t[i*2],n=t[i*2+1];t[i*2]=e.a*r+e.c*n+e.tx,t[i*2+1]=e.b*r+e.d*n+e.ty}}addColors(t,e,i,r,n=0){const o=nt.shared.setValue(e).toLittleEndianNumber(),a=nt.shared.setValue(o).toPremultiplied(i);t.length=Math.max(t.length,n+r);for(let h=0;h<r;h++)t[n+h]=a}addTextureIds(t,e,i,r=0){t.length=Math.max(t.length,r+i);for(let n=0;n<i;n++)t[r+n]=e}addUvs(t,e,i,r,n,o=null){let a=0;const h=e.length,l=i.frame;for(;a<n;){let u=t[(r+a)*2],d=t[(r+a)*2+1];if(o){const f=o.a*u+o.c*d+o.tx;d=o.b*u+o.d*d+o.ty,u=f}a++,e.push(u/l.width,d/l.height)}const c=i.baseTexture;(l.width<c.width||l.height<c.height)&&this.adjustUvs(e,i,h,n)}adjustUvs(t,e,i,r){const n=e.baseTexture,o=1e-6,a=i+r*2,h=e.frame,l=h.width/n.width,c=h.height/n.height;let u=h.x/h.width,d=h.y/h.height,f=Math.floor(t[i]+o),_=Math.floor(t[i+1]+o);for(let p=i+2;p<a;p+=2)f=Math.min(f,Math.floor(t[p]+o)),_=Math.min(_,Math.floor(t[p+1]+o));u-=f,d-=_;for(let p=i;p<a;p+=2)t[p]=(t[p]+u)*l,t[p+1]=(t[p+1]+d)*c}};kd.BATCHABLE_SIZE=100;let bb=kd;class zn{constructor(){this.color=16777215,this.alpha=1,this.texture=V.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new zn;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=V.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class wh extends zn{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=oi.BUTT,this.join=Qt.MITER,this.miterLimit=10}clone(){const t=new wh;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=oi.BUTT,this.join=Qt.MITER,this.miterLimit=10}}const Uo={},qa=class Ur extends kt{constructor(t=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new zn,this._lineStyle=new wh,this._matrix=null,this._holeMode=!1,this.state=ke.for2d(),this._geometry=t||new bb,this._geometry.refCount++,this._transformID=-1,this._tintColor=new nt(16777215),this.blendMode=Z.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new Ur(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,r=.5,n=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:i,alignment:r,native:n}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:V.WHITE,color:t?.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:oi.BUTT,join:Qt.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();
921const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new Li,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Li,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,r=i[i.length-2],n=i[i.length-1];return(r!==t||n!==e)&&i.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,i,r){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),xh.curveTo(t,e,i,r,n),this}bezierCurveTo(t,e,i,r,n,o){return this._initCurve(),yh.curveTo(t,e,i,r,n,o,this.currentPath.points),this}arcTo(t,e,i,r,n){this._initCurve(t,e);const o=this.currentPath.points,a=Wl.curveTo(t,e,i,r,n,o);if(a){const{cx:h,cy:l,radius:c,startAngle:u,endAngle:d,anticlockwise:f}=a;this.arc(h,l,c,u,d,f)}return this}arc(t,e,i,r,n,o=!1){if(r===n)return this;if(!o&&n<=r?n+=un:o&&r<=n&&(r+=un),n-r===0)return this;const a=t+Math.cos(r)*i,h=e+Math.sin(r)*i,l=this._geometry.closePointEps;let c=this.currentPath?this.currentPath.points:null;if(c){const u=Math.abs(c[c.length-2]-a),d=Math.abs(c[c.length-1]-h);u<l&&d<l||c.push(a,h)}else this.moveTo(a,h),c=this.currentPath.points;return Wl.arc(a,h,t,e,i,r,n,o,c),this}beginFill(t=0,e){return this.beginTextureFill({texture:V.WHITE,color:t,alpha:e})}normalizeColor(t){const e=nt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:V.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,r){return this.drawShape(new J(t,e,i,r))}drawRoundedRect(t,e,i,r,n){return this.drawShape(new Un(t,e,i,r,n))}drawCircle(t,e,i){return this.drawShape(new Nn(t,e,i))}drawEllipse(t,e,i,r){return this.drawShape(new On(t,e,i,r))}drawPolygon(...t){let e,i=!0;const r=t[0];r.points?(i=r.closeStroke,e=r.points):Array.isArray(t[0])?e=t[0]:e=t;const n=new Li(e);return n.closeStroke=i,this.drawShape(n),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Rt.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const e=this._geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,e=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let r=0;r<i;r++){const n=t.batches[r],o=n.style.color,a=new Float32Array(this.vertexData.buffer,n.attribStart*4*2,n.attribSize*2),h=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),l=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),c={vertexData:a,blendMode:e,indices:l,uvs:h,_batchRGB:nt.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[r]=c}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,i=this.batches.length;e<i;e++){const r=this.batches[e];r.worldAlpha=this.worldAlpha*r.alpha,t.plugins[this.pluginName].render(r)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,r=this.worldAlpha,n=e.uniforms,o=i.drawCalls;n.translationMatrix=this.transform.worldTransform,nt.shared.setValue(this._tintColor).premultiply(r).toArray(n.tint),t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(let a=0,h=o.length;a<h;a++)this._renderDrawCallDirect(t,i.drawCalls[a])}_renderDrawCallDirect(t,e){const{texArray:i,type:r,size:n,start:o}=e,a=i.count;for(let h=0;h<a;h++)t.texture.bind(i.elements[h],h);t.geometry.draw(r,n,o)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!Uo[i]){const{maxTextures:r}=t.plugins[i],n=new Int32Array(r);for(let h=0;h<r;h++)n[h]=h;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new ct,default:me.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;Uo[i]=new Me(a,o)}e=Uo[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:r,maxY:n}=t.bounds;this._bounds.addFrame(this.transform,e,i,r,n)}containsPoint(t){return this.worldTransform.applyInverse(t,Ur._TEMP_POINT),this._geometry.containsPoint(Ur._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e._tintRGB=nt.shared.setValue(this._tintColor).multiply(e._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const e=this.transform.worldTransform,i=e.a,r=e.b,n=e.c,o=e.d,a=e.tx,h=e.ty,l=this._geometry.points,c=this.vertexData;let u=0;for(let d=0;d<l.length;d+=2){const f=l[d],_=l[d+1];c[u++]=i*f+n*_+a,c[u++]=o*_+r*f+h}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,
921super.destroy(t)}};qa.curves=bs,qa._TEMP_POINT=new st;let Hi=qa;class vb{constructor(t,e){this.uvBuffer=t,this.uvMatrix=e,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const e=this.uvBuffer.data;(!this.data||this.data.length!==e.length)&&(this.data=new Float32Array(e.length)),this.uvMatrix.multiplyUvs(e,this.data),this._updateID++}}const Go=new st,Zl=new Li,Dd=class Fd extends kt{constructor(t,e,i,r=Ie.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||ke.for2d(),this.drawMode=r,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=H.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const e=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===Ie.TRIANGLES&&e.length<Fd.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const e=this.shader;e.alpha=this.worldAlpha,e.update&&e.update(),t.batch.flush(),e.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(e),t.state.set(this.state),t.geometry.bind(this.geometry,e),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const e=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const r=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[r]),t.plugins[r].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,i=t._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==e.length&&(this.vertexData=new Float32Array(e.length));const r=this.transform.worldTransform,n=r.a,o=r.b,a=r.c,h=r.d,l=r.tx,c=r.ty,u=this.vertexData;for(let d=0;d<u.length/2;d++){const f=e[d*2],_=e[d*2+1];u[d*2]=n*f+a*_+l,u[d*2+1]=o*f+h*_+c}if(this._roundPixels){const d=H.RESOLUTION;for(let f=0;f<u.length;++f)u[f]=Math.round(u[f]*d)/d}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new vb(t,e.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,Go);const e=this.geometry.getBuffer("aVertexPosition").data,i=Zl.points,r=this.geometry.getIndex().data,n=r.length,o=this.drawMode===4?3:1;for(let a=0;a+2<n;a+=o){const h=r[a]*2,l=r[a+1]*2,c=r[a+2]*2;if(i[0]=e[h],i[1]=e[h+1],i[2]=e[l],i[3]=e[l+1],i[4]=e[c],i[5]=e[c+1],Zl.contains(Go.x,Go.y))return!0}return!1}destroy(t){super.destroy(t),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};Dd.BATCHABLE_SIZE=100;let Kl=Dd;class yb extends ui{constructor(t,e,i){super();const r=new bt(t),n=new bt(e,!0),o=new bt(i,!0,!0);this.addAttribute("aVertexPosition",r,2,!1,Y.FLOAT).addAttribute("aTextureCoord",n,2,!1,Y.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var xb=`varying vec2 vTextureCoord;
922uniform vec4 uColor;
923
924uniform sampler2D uSampler;
925
926void main(void)
927{
928    gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
929}
930`,wb=`attribute vec2 aVertexPosition;
931attribute vec2 aTextureCoord;
932
933uniform mat3 projectionMatrix;
934uniform mat3 translationMatrix;
935uniform mat3 uTextureMatrix;
936
937varying vec2 vTextureCoord;
938
939void main(void)
940{
941    gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
941)).xy, 0.0, 1.0);
942
943    vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
944}
945`;class Jl extends Me{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:ct.IDENTITY,uColor:new Float32Array([1,1,1,1])};e=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},e),e.uniforms&&Object.assign(i,e.uniforms),super(e.program||Xe.from(wb,xb),i),this._colorDirty=!1,this.uvMatrix=new Ju(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new nt(e.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=e.alpha}get texture(){return this.uniforms.uSampler}set texture(t){this.uniforms.uSampler!==t&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!t.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=t,this.uvMatrix.texture=t)}set alpha(t){t!==this._alpha&&(this._alpha=t,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(t){t!==this.tint&&(this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0)}get tint(){return this._tintColor.value}get tintValue(){return this._tintColor.toNumber()}update(){if(this._colorDirty){this._colorDirty=!1;const t=this.texture.baseTexture.alphaMode;nt.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class Ql{constructor(t,e,i){this.geometry=new ui,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let r=0;r<t.length;++r){let n=t[r];n={attributeName:n.attributeName,size:n.size,uploadFunction:n.uploadFunction,type:n.type||Y.FLOAT,offset:n.offset},e[r]?this.dynamicProperties.push(n):this.staticProperties.push(n)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const t=this.geometry;let e=0;this.indexBuffer=new bt(Xm(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];a.offset=e,e+=a.size,this.dynamicStride+=a.size}const i=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(i),this.dynamicDataUint32=new Uint32Array(i),this.dynamicBuffer=new bt(this.dynamicData,!1,!1);let r=0;this.staticStride=0;for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];a.offset=r,r+=a.size,this.staticStride+=a.size}const n=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(n),this.staticDataUint32=new Uint32Array(n),this.staticBuffer=new bt(this.staticData,!0,!1);for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];t.addAttribute(a.attributeName,this.dynamicBuffer,0,a.type===Y.UNSIGNED_BYTE,a.type,this.dynamicStride*4,a.offset*4)}for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];t.addAttribute(a.attributeName,this.staticBuffer,0,a.type===Y.UNSIGNED_BYTE,a.type,this.staticStride*4,a.offset*4)}}uploadDynamic(t,e,i){for(let r=0;r<this.dynamicProperties.length;r++){const n=this.dynamicProperties[r];n.uploadFunction(t,e,i,n.type===Y.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,n.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,i){for(let r=0;r<this.staticProperties.length;r++){const n=this.staticProperties[r];n.uploadFunction(t,e,i,n.type===Y.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,n.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var Tb=`varying vec2 vTextureCoord;
946varying vec4 vColor;
947
948uniform sampler2D uSampler;
949
950void main(void){
951    vec4 color = texture2D(uSampler, vTextureCoord) * vColor;
952    gl_FragColor = color;
953}`,Eb=`attribute vec2 aVertexPosition;
954attribute vec2 aTextureCoord;
955attribute vec4 aColor;
956
957attribute vec2 aPositionCoord;
958attribute float aRotation;
959
960uniform mat3 translationMatrix;
961uniform vec4 uColor;
962
963varying vec2 vTextureCoord;
964varying vec4 vColor;
965
966void main(void){
967    float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);
968    float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);
969
970    vec2 v = vec2(x, y);
971    v = v + aPositionCoord;
972
973    gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
974
975    vTextureCoord = aTextureCoord;
976    vColor = aColor * uColor;
977}
978`;class Ld extends Gn{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new ct,this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:Y.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=Me.from(Eb,Tb,{}),this.state=ke.for2d()}render(t){const e=t.children,i=t._maxSize,r=t._batchSize,n=this.renderer;let o=e.length;if(o===0)return;o>i&&!t.autoResize&&(o=i);let a=t._buffers;a||(a=t._buffers=this.generateBuffers(t));const h=e[0]._texture.baseTexture,l=h.alphaMode>0;this.state.blendMode=Fu(t.blendMode,l),n.state.set(this.state);const c=n.gl,u=t.worldTransform.copyTo(this.tempMatrix);
vendor: 7,196 bytes, lines 978-979
978u.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=u.toArray(!0),this.shader.uniforms.uColor=nt.shared.setValue(t.tintRgb).premultiply(t.worldAlpha,l).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=h,this.renderer.shader.bind(this.shader);let d=!1;for(let f=0,_=0;f<o;f+=r,_+=1){let p=o-f;p>r&&(p=r),_>=a.length&&a.push(this._generateOneMoreBuffer(t));const m=a[_];m.uploadDynamic(e,f,p);const g=t._bufferUpdateIDs[_]||0;d=d||m._updateID<g,d&&(m._updateID=t._updateID,m.uploadStatic(e,f,p)),n.geometry.bind(m.geometry),c.drawElements(c.TRIANGLES,p*6,c.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],i=t._maxSize,r=t._batchSize,n=t._properties;for(let o=0;o<i;o+=r)e.push(new Ql(this.properties,n,r));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new Ql(this.properties,i,e)}uploadVertices(t,e,i,r,n,o){let a=0,h=0,l=0,c=0;for(let u=0;u<i;++u){const d=t[e+u],f=d._texture,_=d.scale.x,p=d.scale.y,m=f.trim,g=f.orig;m?(h=m.x-d.anchor.x*g.width,a=h+m.width,c=m.y-d.anchor.y*g.height,l=c+m.height):(a=g.width*(1-d.anchor.x),h=g.width*-d.anchor.x,l=g.height*(1-d.anchor.y),c=g.height*-d.anchor.y),r[o]=h*_,r[o+1]=c*p,r[o+n]=a*_,r[o+n+1]=c*p,r[o+n*2]=a*_,r[o+n*2+1]=l*p,r[o+n*3]=h*_,r[o+n*3+1]=l*p,o+=n*4}}uploadPosition(t,e,i,r,n,o){for(let a=0;a<i;a++){const h=t[e+a].position;r[o]=h.x,r[o+1]=h.y,r[o+n]=h.x,r[o+n+1]=h.y,r[o+n*2]=h.x,r[o+n*2+1]=h.y,r[o+n*3]=h.x,r[o+n*3+1]=h.y,o+=n*4}}uploadRotation(t,e,i,r,n,o){for(let a=0;a<i;a++){const h=t[e+a].rotation;r[o]=h,r[o+n]=h,r[o+n*2]=h,r[o+n*3]=h,o+=n*4}}uploadUvs(t,e,i,r,n,o){for(let a=0;a<i;++a){const h=t[e+a]._texture._uvs;h?(r[o]=h.x0,r[o+1]=h.y0,r[o+n]=h.x1,r[o+n+1]=h.y1,r[o+n*2]=h.x2,r[o+n*2+1]=h.y2,r[o+n*3]=h.x3,r[o+n*3+1]=h.y3,o+=n*4):(r[o]=0,r[o+1]=0,r[o+n]=0,r[o+n+1]=0,r[o+n*2]=0,r[o+n*2+1]=0,r[o+n*3]=0,r[o+n*3+1]=0,o+=n*4)}}uploadTint(t,e,i,r,n,o){for(let a=0;a<i;++a){const h=t[e+a],l=nt.shared.setValue(h._tintRGB).toPremultiplied(h.alpha,h.texture.baseTexture.alphaMode>0);r[o]=l,r[o+n]=l,r[o+n*2]=l,r[o+n*3]=l,o+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}Ld.extension={name:"particle",type:N.RendererPlugin};W.add(Ld);var $n=(s=>(s[s.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",s[s.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",s))($n||{});const Tr={willReadFrequently:!0},Te=class j{static get experimentalLetterSpacingSupported(){let t=j._experimentalLetterSpacingSupported;if(t!==void 0){const e=H.ADAPTER.getCanvasRenderingContext2D().prototype;t=j._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,r,n,o,a,h,l){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=h,this.fontProperties=l}static measureText(t,e,i,r=j._canvas){i=i??e.wordWrap;const n=e.toFontString(),o=j.measureFont(n);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const a=r.getContext("2d",Tr);a.font=n;const h=(i?j.wordWrap(t,e,r):t).split(/(?:\r\n|\r|\n)/),l=new Array(h.length);let c=0;for(let _=0;_<h.length;_++){const p=j._measureText(h[_],e.letterSpacing,a);l[_]=p,c=Math.max(c,p)}let u=c+e.strokeThickness;e.dropShadow&&(u+=e.dropShadowDistance);const d=e.lineHeight||o.fontSize+e.strokeThickness;let f=Math.max(d,o.fontSize+e.strokeThickness*2)+e.leading+(h.length-1)*(d+e.leading);return e.dropShadow&&(f+=e.dropShadowDistance),new j(t,e,u,f,h,l,d+e.leading,c,o)}static _measureText(t,e,i){let r=!1;j.experimentalLetterSpacingSupported&&(j.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,r=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let n=i.measureText(t).width;return n>0&&(r?n-=e:n+=(j.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=j._canvas){const r=i.getContext("2d",Tr);let n=0,o="",a="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=e,u=j.collapseSpaces(c),d=j.collapseNewlines(c);let f=!u;const _=e.wordWrapWidth+l,p=j.tokenize(t);for(let m=0;m<p.length;m++){let g=p[m];if(j.isNewline(g)){if(!d){a+=j.addLine(o),f=!u,o="",n=0;continue}g=" "}if(u){const b=j.isBreakingSpace(g),y=j.isBreakingSpace(o[o.length-1]);if(b&&y)continue}const v=j.getFromCache(g,l,h,r);if(v>_)if(o!==""&&(a+=j.addLine(o),o="",n=0),j.canBreakWords(g,e.breakWords)){const b=j.wordWrapSplit(g);for(let y=0;y<b.length;y++){let E=b[y],w=E,x=1;for(;b[y+x];){const I=b[y+x];if(!j.canBreakChars(w,I,g,y,e.breakWords))E+=I;else break;w=I,x++}y+=x-1;const T=j.getFromCache(E,l,h,r);T+n>_&&(a+=j.addLine(o),f=!1,o="",n=0),o+=E,n+=T}}else{o.length>0&&(a+=j.addLine(o),o="",n=0);const b=m===p.length-1;a+=j.addLine(g,!b),f=!1,o="",n=0}else v+n>_&&(f=!1,a+=j.addLine(o),o="",n=0),(o.length>0||!j.isBreakingSpace(g)||f)&&(o+=g,n+=v)}return a+=j.addLine(o,!1),a}static addLine(t,e=!0){return t=j.trimRight(t),t=e?`${t}
979`:t,t}static getFromCache(t,e,i,r){let n=i[t];return typeof n!="number"&&(n=j._measureText(t,e,r)+e,i[t]=n),n}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!j.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:j._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:j._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let r=0;r<t.length;r++){const n=t[r],o=t[r+1];if(j.isBreakingSpace(n,o)||j.isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,r,n){return!0}static wordWrapSplit(t){return j.graphemeSegmenter(t)}static measureFont(t){if(j._fonts[t])return j._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=j._canvas,r=j._context;r.font=t;const n=j.METRICS_STRING+j.BASELINE_SYMBOL,o=Math.ceil(r.measureText(n).width);let a=Math.ceil(r.measureText(j.BASELINE_SYMBOL).width);const h=Math.ceil(j.HEIGHT_MULTIPLIER*a);if(a=a*j.BASELINE_MULTIPLIER|0,o===0||h===0)return j._fonts[t]=e,e;i.width=o,i.height=h,r.fillStyle="#f00",r.fillRect(0,0,o,h),r.font=t,r.textBaseline="alphabetic",r.fillStyle="#000",r.fillText(n,0,a);const l=r.getImageData(0,0,o,h).data,c=l.length,u=o*4;let d=0,f=0,_=!1;for(d=0;d<a;++d){for(let p=0;p<u;p+=4)if(l[f+p]!==255){_=!0;break}if(!_)f+=u;else break}for(e.ascent=a-d,f=c-u,_=!1,d=h;d>a;--d){for(let p=0;p<u;p+=4)if(l[f+p]!==255){_=!0;break}if(!_)f-=u;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,j._fonts[t]=e,e}static clearMetrics(t=""){t?delete j._fonts[t]:j._fonts={}}static get _canvas(){if(!j.__canvas){let t;try{const e=new OffscreenCanvas(0,0);if(e.getContext("2d",Tr)?.measureText)return j.__canvas=e,e;t=H.ADAPTER.createCanvas()}catch{t=H.ADAPTER.createCanvas()}t.width=t.height=10,j.__canvas=t}return j.__canvas}static get _context(){return j.__context||(j.__context=j._canvas.getContext("2d",Tr)),j.__context}};Te.METRICS_STRING="|ÉqÅ",Te.BASELINE_SYMBOL="M",Te.BASELINE_MULTIPLIER=1.4,Te.HEIGHT_MULTIPLIER=2,Te.graphemeSegmenter=(()=>
vendor: 5,143 bytes, line 979
979{if(typeof Intl?.Segmenter=="function"){const s=new Intl.Segmenter;return t=>[...s.segment(t)].map(e=>e.segment)}return s=>[...s]})(),Te.experimentalLetterSpacing=!1,Te._fonts={},Te._newlines=[10,13],Te._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let si=Te;const Ab=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Nd=class Hs{constructor(t){this.styleID=0,this.reset(),zo(this,t,t)}clone(){const t={};return zo(t,this,Hs.defaultStyle),new Hs(t)}reset(){zo(this,Hs.defaultStyle,Hs.defaultStyle)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(t){const e=Ho(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)}get fill(){return this._fill}set fill(t){const e=Ho(t);this._fill!==e&&(this._fill=e,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(t){Sb(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.styleID++)}get stroke(){return this._stroke}set stroke(t){const e=Ho(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let r=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!Ab.includes(r)&&(r=`"${r}"`),e[i]=r}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};Nd.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:$n.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let fi=Nd;function Ho(s){const t=nt.shared,e=i=>{const r=t.setValue(i);return r.alpha===1?r.toHex():r.toRgbaString()};return Array.isArray(s)?s.map(e):e(s)}
979function Sb(s,t){if(!Array.isArray(s)||!Array.isArray(t)||s.length!==t.length)return!1;for(let e=0;e<s.length;++e)if(s[e]!==t[e])return!1;return!0}function zo(s,t,e){for(const i in e)Array.isArray(t[i])?s[i]=t[i].slice():s[i]=t[i]}const Cb={texture:!0,children:!1,baseTexture:!0},Od=class Za extends Ft{constructor(t,e,i){let r=!1;i||(i=H.ADAPTER.createCanvas(),r=!0),i.width=3,i.height=3;const n=V.from(i);n.orig=new J,n.trim=new J,super(n),this._ownCanvas=r,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=Za.defaultResolution??H.RESOLUTION,this._autoResolution=Za.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=e,this.localStyleID=-1}static get experimentalLetterSpacing(){return si.experimentalLetterSpacing}static set experimentalLetterSpacing(t){et("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),si.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,r=si.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=r.width,o=r.height,a=r.lines,h=r.lineHeight,l=r.lineWidths,c=r.maxLineWidth,u=r.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,n)+e.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,o)+e.padding*2)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=e.strokeThickness,i.textBaseline=e.textBaseline,i.lineJoin=e.lineJoin,i.miterLimit=e.miterLimit;let d,f;const _=e.dropShadow?2:1;for(let p=0;p<_;++p){const m=e.dropShadow&&p===0,g=m?Math.ceil(Math.max(1,o)+e.padding*2):0,v=g*this._resolution;if(m){i.fillStyle="black",i.strokeStyle="black";const y=e.dropShadowColor,E=e.dropShadowBlur*this._resolution,w=e.dropShadowDistance*this._resolution;i.shadowColor=nt.shared.setValue(y).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=E,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*w,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*w+v}else i.fillStyle=this._generateFillStyle(e,a,r),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let b=(h-u.fontSize)/2;h-u.fontSize<0&&(b=0);for(let y=0;y<a.length;y++)d=e.strokeThickness/2,f=e.strokeThickness/2+y*h+u.ascent+b,e.align==="right"?d+=c-l[y]:e.align==="center"&&(d+=(c-l[y])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(a[y],d+e.padding,f+e.padding-g,!0),e.fill&&this.drawLetterSpacing(a[y],d+e.padding,f+e.padding-g)}this.updateTexture()}drawLetterSpacing(t,e,i,r=!1){const n=this._style.letterSpacing;let o=!1;if(si.experimentalLetterSpacingSupported&&(si.experimentalLetterSpacing?(this.context.letterSpacing=`${n}px`,this.context.textLetterSpacing=`${n}px`,o=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),n===0||o){r?this.context.strokeText(t,e,i):this.context.fillText(t,e,i);return}let a=e;const h=si.graphemeSegmenter(t);let l=this.context.measureText(t).width,c=0;for(let u=0;u<h.length;++u){const d=h[u];r?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let f="";for(let _=u+1;_<h.length;++_)f+=h[_];c=this.context.measureText(f).width,a+=l-c+n,l=c}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=Ym(t);o.data&&(t.width=o.width,t.height=o.height,this.context.putImageData(o.data,0,0))}const e=this._texture,i=this._style,r=i.trim?0:i.padding,n=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-r,e.trim.y=-r,e.orig.width=e._frame.width-r*2,e.orig.height=e._frame.height-r*2,this._onTextureUpdate(),n.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,i){const r=t.fill;if(Array.isArray(r)){if(r.length===1)return r[0]}else return r;let n;const o=t.dropShadow?t.dropShadowDistance:0,a=t.padding||0,h=this.canvas.width/this._resolution-o-a*2,l=this.canvas.height/this._resolution-o-a*2,c=r.slice(),u=t.fillGradientStops.slice();if(!u.length){const d=c.length+1;for(let f=1;f<d;++f)u.push(f/d)}if(c.unshift(r[0]),u.unshift(0),c.push(r[r.length-1]),u.push(1),t.fillGradientType===$n.LINEAR_VERTICAL){n=this.context.createLinearGradient(h/2,a,h/2,l+a);const d=i.fontProperties.fontSize+t.strokeThickness;for(let f=0;f<e.length;f++){const _=i.lineHeight*(f-1)+d,p=i.lineHeight*f;let m=p;f>0&&_>p&&(m=(p+_)/2);const g=p+d,v=i.lineHeight*(f+1);let b=g;f+1<e.length&&v<g&&(b=(g+v)/2);const y=(b-m)/l;for(let E=0;E<c.length;E++){let w=0;typeof u[E]=="number"?w=u[E]:w=E/c.length;let x=Math.min(1,Math.max(0,m/l+w*y));x=Number(x.toFixed(5)),n.addColorStop(x,c[E])}}}else{n=this.context.createLinearGradient(a,l/2,h+a,l/2);const d=c.length+1;let f=1;for(let _=0;_<c.length;_++){let p;typeof u[_]=="number"?p=u[_]:p=f/d,n.addColorStop(p,c[_]),f++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Cb,t),super.destroy(t),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this.updateText(!0);const e=ni(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const e=ni(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},t instanceof fi?this._style=t:this._style=new fi(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}};Od.defaultAutoResolution=!0;let Ud=Od;class Ib{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function Rb(s,t){let e=!1;if(s?._textures?.length){for(let i=0;i<s._textures.length;i++)if(s._textures[i]instanceof V){const r=s._textures[i].baseTexture;t.includes(r)||(t.push(r),e=!0)}}return e}function Mb(s,t){if(s.baseTexture instanceof Q){const e=s.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function Pb(s,t){if(s._texture&&s._texture instanceof V){const e=s._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function kb(s,t){return t instanceof Ud?(t.updateText(!0),!0):!1}function Bb(s,t){if(t instanceof fi){const e=t.toFontString();return si.measureFont(e),!0}return!1}function Db(s,t){if(s instanceof Ud){t.includes(s.style)||t.push(s.style),t.includes(s)||t.push(s);const e=s._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function Fb(s,t){return s instanceof fi?(t.includes(s)||t.push(s),!0):!1}const Gd=class Hd{constructor(t){this.limiter=new Ib(Hd.uploadsPerFrame),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(Db),this.registerFindHook(Fb),this.registerFindHook(Rb),this.registerFindHook(Mb),this.registerFindHook(Pb),this.registerUploadHook(kb),this.registerUploadHook(Bb)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,Yt.system.addOnce(this.tick,this,Gi.UTILITY))):e()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let e=!1;if(t&&!t._destroyed){for(let i=0,r=this.uploadHooks.length;i<r;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)Yt.system.addOnce(this.tick,this,Gi.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,i=t.length;e<i;e++)t[e]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof kt)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&Yt.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};Gd.uploadsPerFrame=4;let Ka=Gd;Object.defineProperties(H,{UPLOADS_PER_FRAME:{get(){return Ka.uploadsPerFrame},set(s){et("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),Ka.uploadsPerFrame=s}}});function zd(s,t){return t instanceof Q?(t._glTextures[s.CONTEXT_UID]||s.texture.bind(t),!0):!1}
979function Lb(s,t){if(!(t instanceof Hi))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:i}=e;for(let r=0;r<i.length;r++){const{texture:n}=i[r].style;n&&zd(s,n.baseTexture)}return e.batchable||s.geometry.bind(e,t._resolveDirectShader(s)),!0}function Nb(s,t){return s instanceof Hi?(t.push(s),!0):!1}class $d extends Ka{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(Nb),this.registerUploadHook(zd),this.registerUploadHook(Lb)}}$d.extension={name:"prepare",type:N.RendererSystem};W.add($d);var Ob=`#version 300 es
980#define SHADER_NAME Tiling-Sprite-100
981
982precision lowp float;
983
984in vec2 vTextureCoord;
985
986out vec4 fragmentColor;
987
988uniform sampler2D uSampler;
989uniform vec4 uColor;
990uniform mat3 uMapCoord;
991uniform vec4 uClampFrame;
992uniform vec2 uClampOffset;
993
994void main(void)
995{
996    vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
997    coord = (uMapCoord * vec3(coord, 1.0)).xy;
998    vec2 unclamped = coord;
999    coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
1000
1001    vec4 texSample = texture(uSampler, coord, unclamped == coord ? 0.0f : -32.0f);// lod-bias very negative to force lod 0
1002
1003    fragmentColor = texSample * uColor;
1004}
1005`,Ub=`#version 300 es
1006#define SHADER_NAME Tiling-Sprite-300
1007
1008precision lowp float;
1009
1010in vec2 aVertexPosition;
1011in vec2 aTextureCoord;
1012
1013uniform mat3 projectionMatrix;
1014uniform mat3 translationMatrix;
1015uniform mat3 uTransform;
1016
1017out vec2 vTextureCoord;
1018
1019void main(void)
1020{
1021    gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
1021)).xy, 0.0, 1.0);
1022
1023    vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1024}
1025`,Gb=`#version 100
1026#ifdef GL_EXT_shader_texture_lod
1027    #extension GL_EXT_shader_texture_lod : enable
1028#endif
1029#define SHADER_NAME Tiling-Sprite-100
1030
1031precision lowp float;
1032
1033varying vec2 vTextureCoord;
1034
1035uniform sampler2D uSampler;
1036uniform vec4 uColor;
1037uniform mat3 uMapCoord;
1038uniform vec4 uClampFrame;
1039uniform vec2 uClampOffset;
1040
1041void main(void)
1042{
1043    vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
1044    coord = (uMapCoord * vec3(coord, 1.0)).xy;
1045    vec2 unclamped = coord;
1046    coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
1047
1048    #ifdef GL_EXT_shader_texture_lod
1049        vec4 texSample = unclamped == coord
1050            ? texture2D(uSampler, coord) 
1051            : texture2DLodEXT(uSampler, coord, 0);
1052    #else
1053        vec4 texSample = texture2D(uSampler, coord);
1054    #endif
1055
1056    gl_FragColor = texSample * uColor;
1057}
1058`,tc=`#version 100
1059#define SHADER_NAME Tiling-Sprite-100
1060
1061precision lowp float;
1062
1063attribute vec2 aVertexPosition;
1064attribute vec2 aTextureCoord;
1065
1066uniform mat3 projectionMatrix;
1067uniform mat3 translationMatrix;
1068uniform mat3 uTransform;
1069
1070varying vec2 vTextureCoord;
1071
1072void main(void)
1073{
1074    gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
1074)).xy, 0.0, 1.0);
1075
1076    vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1077}
1078`,Hb=`#version 100
1079#define SHADER_NAME Tiling-Sprite-Simple-100
1080
1081precision lowp float;
1082
1083varying vec2 vTextureCoord;
1084
1085uniform sampler2D uSampler;
1086uniform vec4 uColor;
1087
1088void main(void)
1089{
1090    vec4 texSample = texture2D(uSampler, vTextureCoord);
1091    gl_FragColor = texSample * uColor;
1092}
1093`;const Er=new ct;class Xd extends Gn{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new Yu,this.state=ke.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=Me.from(tc,Hb,e),this.shader=t.context.webGLVersion>1?Me.from(Ub,Ob,e):Me.from(tc,Gb,e)}render(t){const e=this.renderer,i=this.quad;let r=i.vertices;r[0]=r[6]=t._width*-t.anchor.x,r[1]=r[3]=t._height*-t.anchor.y,r[2]=r[4]=t._width*(1-t.anchor.x),r[5]=r[7]=t._height*(1-t.anchor.y);const n=t.uvRespectAnchor?t.anchor.x:0,o=t.uvRespectAnchor?t.anchor.y:0;r=i.uvs,r[0]=r[6]=-n,r[1]=r[3]=-o,r[2]=r[4]=1-n,r[5]=r[7]=1-o,i.invalidate();const a=t._texture,h=a.baseTexture,l=h.alphaMode>0,c=t.tileTransform.localTransform,u=t.uvMatrix;let d=h.isPowerOfTwo&&a.frame.width===h.width&&a.frame.height===h.height;d&&(h._glTextures[e.CONTEXT_UID]?d=h.wrapMode!==li.CLAMP:h.wrapMode===li.CLAMP&&(h.wrapMode=li.REPEAT));const f=d?this.simpleShader:this.shader,_=a.width,p=a.height,m=t._width,g=t._height;Er.set(c.a*_/m,c.b*_/g,c.c*p/m,c.d*p/g,c.tx/m,c.ty/g),Er.invert(),d?Er.prepend(u.mapCoord):(f.uniforms.uMapCoord=u.mapCoord.toArray(!0),f.uniforms.uClampFrame=u.uClampFrame,f.uniforms.uClampOffset=u.uClampOffset),f.uniforms.uTransform=Er.toArray(!0),f.uniforms.uColor=nt.shared.setValue(t.tint).premultiply(t.worldAlpha,l).toArray(f.uniforms.uColor),f.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),f.uniforms.uSampler=a,e.shader.bind(f),e.geometry.bind(i),this.state.blendMode=Fu(t.blendMode,l),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}Xd.extension={name:"tilingSprite",type:N.RendererPlugin};W.add(Xd);const Vd=class zs{constructor(t,e,i=null){this.linkedSheets=[],this._texture=t instanceof V?t:null,this.baseTexture=t instanceof Q?t:this._texture.baseTexture,this.textures={},this.animations={},this.data=e;const r=this.baseTexture.resource;this.resolution=this._updateResolution(i||(r?r.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(t=null){const{scale:e}=this.data.meta;let i=je(t,null);return i===null&&(i=parseFloat(e??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=zs.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=zs.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const r=this._frameKeys[e],n=this._frames[r],o=n.frame;if(o){let a=null,h=null;const l=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,c=new J(0,0,Math.floor(l.w)/this.resolution,Math.floor(l.h)/this.resolution);n.rotated?a=new J(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.h)/this.resolution,Math.floor(o.w)/this.resolution):a=new J(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(h=new J(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[r]=new V(this.baseTexture,a,c,h,n.rotated?2:0,n.anchor,n.borders),V.addToCache(this.textures[r],r.toString())}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const r=t[e][i];this.animations[e].push(this.textures[r])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*zs.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*zs.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){for(const e in this.textures)this.textures[e].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(this._texture?.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};Vd.BATCH_SIZE=1e3;let ec=Vd;const zb=["jpg","png","jpeg","avif","webp"];function Wd(s,t,e){const i={};if(s.forEach(r=>{i[r]=t}
1093),Object.keys(t.textures).forEach(r=>{i[r]=t.textures[r]}),!e){const r=wt.dirname(s[0]);t.linkedSheets.forEach((n,o)=>{const a=Wd([`${r}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const $b={extension:N.Asset,cache:{test:s=>s instanceof ec,getCacheableAssets:(s,t)=>Wd(s,t,!1)},resolver:{test:s=>{const t=s.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&zb.includes(i)},parse:s=>{const t=s.split(".");return{resolution:parseFloat(H.RETINA_PREFIX.exec(s)?.[1]??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",extension:{type:N.LoadParser,priority:ge.Normal},async testParse(s,t){return wt.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){let i=wt.dirname(t.src);i&&i.lastIndexOf("/")!==i.length-1&&(i+="/");let r=i+s.meta.image;r=ja(r,t.src);const n=(await e.load([r]))[r],o=new ec(n.baseTexture,s,t.src);await o.parse();const a=s?.meta?.related_multi_packs;if(Array.isArray(a)){const h=[];for(const c of a){if(typeof c!="string")continue;let u=i+c;t.data?.ignoreMultiPack||(u=ja(u,t.src),h.push(e.load({src:u,data:{ignoreMultiPack:!0}})))}const l=await Promise.all(h);o.linkedSheets=l,l.forEach(c=>{c.linkedSheets=[o].concat(o.linkedSheets.filter(u=>u!==c))})}return o},unload(s){s.destroy(!0)}}};W.add($b);class wn{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Gr{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const o=e[n].match(/^[a-z]+/gm)[0],a=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),h={};for(const l in a){const c=a[l].split("="),u=c[0],d=c[1].replace(/"/gm,""),f=parseFloat(d),_=isNaN(f)?d:f;h[u]=_}i[o].push(h)}const r=new wn;return i.info.forEach(n=>r.info.push({face:n.face,size:parseInt(n.size,10)})),i.common.forEach(n=>r.common.push({lineHeight:parseInt(n.lineHeight,10)})),i.page.forEach(n=>r.page.push({id:parseInt(n.id,10),file:n.file})),i.char.forEach(n=>r.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),i.kerning.forEach(n=>r.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),i.distanceField.forEach(n=>r.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),r}}class Ja{static test(t){const e=t;return typeof t!="string"&&"getElementsByTagName"in t&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const e=new wn,i=t.getElementsByTagName("info"),r=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning"),h=t.getElementsByTagName("distanceField");for(let l=0;l<i.length;l++)e.info.push({face:i[l].getAttribute("face"),size:parseInt(i[l].getAttribute("size"),10)});for(let l=0;l<r.length;l++)e.common.push({lineHeight:parseInt(r[l].getAttribute("lineHeight"),10)});for(let l=0;l<n.length;l++)e.page.push({id:parseInt(n[l].getAttribute("id"),10)||0,file:n[l].getAttribute("file")});for(let l=0;l<o.length;l++){const c=o[l];e.char.push({id:parseInt(c.getAttribute("id"),10),page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xoffset:parseInt(c.getAttribute("xoffset"),10),yoffset:parseInt(c.getAttribute("yoffset"),10),xadvance:parseInt(c.getAttribute("xadvance"),10)})}for(let l=0;l<a.length;l++)e.kerning.push({first:parseInt(a[l].getAttribute("first"),10),second:parseInt(a[l].getAttribute("second"),10),amount:parseInt(a[l].getAttribute("amount"),10)});for(let l=0;l<h.length;l++)e.distanceField.push({fieldType:h[l].getAttribute("fieldType"),distanceRange:parseInt(h[l].getAttribute("distanceRange"),10)});return e}}class Qa{static test(t){return typeof t=="string"&&t.includes("<font>")?Ja.test(H.ADAPTER.parseXML(t)):!1}static parse(t){return Ja.parse(H.ADAPTER.parseXML(t))}}const $o=[Gr,Ja,Qa];function Xb(s){for(let t=0;t<$o.length;t++)if($o[t].test(s))return $o[t];return null}function Vb(s,t,e,i,r,n){const o=e.fill;if(Array.isArray(o)){if(o.length===1)return o[0]}else return o;let a;const h=e.dropShadow?e.dropShadowDistance:0,l=e.padding||0,c=s.width/i-h-l*2,u=s.height/i-h-l*2,d=o.slice(),f=e.fillGradientStops.slice();if(!f.length){const _=d.length+1;for(let p=1;p<_;++p)f.push(p/_)}
1093if(d.unshift(o[0]),f.unshift(0),d.push(o[o.length-1]),f.push(1),e.fillGradientType===$n.LINEAR_VERTICAL){a=t.createLinearGradient(c/2,l,c/2,u+l);let _=0;const p=(n.fontProperties.fontSize+e.strokeThickness)/u;for(let m=0;m<r.length;m++){const g=n.lineHeight*m;for(let v=0;v<d.length;v++){let b=0;typeof f[v]=="number"?b=f[v]:b=v/d.length;const y=g/u+b*p;let E=Math.max(_,y);E=Math.min(E,1),a.addColorStop(E,d[v]),_=E}}}else{a=t.createLinearGradient(l,u/2,c+l,u/2);const _=d.length+1;let p=1;for(let m=0;m<d.length;m++){let g;typeof f[m]=="number"?g=f[m]:g=p/_,a.addColorStop(g,d[m]),p++}}return a}function Wb(s,t,e,i,r,n,o){const a=e.text,h=e.fontProperties;t.translate(i,r),t.scale(n,n);const l=o.strokeThickness/2,c=-(o.strokeThickness/2);if(t.font=o.toFontString(),t.lineWidth=o.strokeThickness,t.textBaseline=o.textBaseline,t.lineJoin=o.lineJoin,t.miterLimit=o.miterLimit,t.fillStyle=Vb(s,t,o,n,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const u=o.dropShadowColor,d=o.dropShadowBlur*n,f=o.dropShadowDistance*n;t.shadowColor=nt.shared.setValue(u).setAlpha(o.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(o.dropShadowAngle)*f,t.shadowOffsetY=Math.sin(o.dropShadowAngle)*f}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;o.stroke&&o.strokeThickness&&t.strokeText(a,l,c+e.lineHeight-h.descent),o.fill&&t.fillText(a,l,c+e.lineHeight-h.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Hr(s){return s.codePointAt?s.codePointAt(0):s.charCodeAt(0)}function jd(s){return Array.from?Array.from(s):s.split("")}function jb(s){typeof s=="string"&&(s=[s]);const t=[];for(let e=0,i=s.length;e<i;e++){const r=s[e];if(Array.isArray(r)){if(r.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${r.length}.`);const n=r[0].charCodeAt(0),o=r[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,h=o;a<=h;a++)t.push(String.fromCharCode(a))}else t.push(...jd(r))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const Qe=class Ee{constructor(t,e,i){const[r]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,h=je(o.file),l={};this._ownsTextures=i,this.font=r.face,this.size=r.size,this.lineHeight=n.lineHeight/h,this.chars={},this.pageTextures=l;for(let c=0;c<t.page.length;c++){const{id:u,file:d}=t.page[c];l[u]=e instanceof Array?e[c]:e[d],a?.fieldType&&a.fieldType!=="none"&&(l[u].baseTexture.alphaMode=Ht.NO_PREMULTIPLIED_ALPHA,l[u].baseTexture.mipmap=Pe.OFF)}for(let c=0;c<t.char.length;c++){const{id:u,page:d}=t.char[c];let{x:f,y:_,width:p,height:m,xoffset:g,yoffset:v,xadvance:b}=t.char[c];f/=h,_/=h,p/=h,m/=h,g/=h,v/=h,b/=h;const y=new J(f+l[d].frame.x/h,_+l[d].frame.y/h,p,m);this.chars[u]={xOffset:g,yOffset:v,xAdvance:b,kerning:{},texture:new V(l[d].baseTexture,y),page:d}}for(let c=0;c<t.kerning.length;c++){let{first:u,second:d,amount:f}=t.kerning[c];u/=h,d/=h,f/=h,this.chars[d]&&(this.chars[d].kerning[u]=f)}this.distanceFieldRange=a?.distanceRange,this.distanceFieldType=a?.fieldType?.toLowerCase()??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,i){let r;if(t instanceof wn)r=t;else{const o=Xb(t);if(!o)throw new Error("Unrecognized data format for font.");r=o.parse(t)}e instanceof V&&(e=[e]);const n=new Ee(r,e,i);return Ee.available[n.font]=n,n}static uninstall(t){const e=Ee.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete Ee.available[t]}static from(t,e,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:r,padding:n,resolution:o,textureWidth:a,textureHeight:h,...l}=Object.assign({},Ee.defaultOptions,i),c=jb(r),u=e instanceof fi?e:new fi(e),d=a,f=new wn;f.info[0]={face:u.fontFamily,size:u.fontSize},f.common[0]={lineHeight:u.fontSize};let _=0,p=0,m,g,v,b=0;const y=[];for(let w=0;w<c.length;w++){m||(m=H.ADAPTER.createCanvas(),m.width=a,m.height=h,g=m.getContext("2d"),v=new Q(m,{resolution:o,...l}),y.push(new V(v)),f.page.push({id:y.length-1,file:""}));const x=c[w],T=si.measureText(x,u,!1,m),I=T.width,M=Math.ceil(T.height),P=Math.ceil((u.fontStyle==="italic"?2:1)*I);if(p>=h-M*o){if(p===0)throw new Error(`[BitmapFont] textureHeight ${h}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${x}')`);--w,m=null,g=null,v=null,p=0,_=0,b=0;continue}if(b=Math.max(M+T.fontProperties.descent,b),P*o+_>=d){if(_===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${x}')`);--w,p+=b*o,p=Math.ceil(p),_=0,b=0;continue}Wb(m,g,T,_,p,o,u);const k=Hr(T.text);f.char.push({id:k,page:y.length-1,x:_/o,y:p/o,width:P,height:M,xoffset:0,yoffset:0,xadvance:I-(u.dropShadow?u.dropShadowDistance:0)-(u.stroke?u.strokeThickness:0)}),_+=(P+2*n)*o,_=Math.ceil(_)}if(!i?.skipKerning)for(let w=0,x=c.length;w<x;w++){const T=c[w];for(let I=0;I<x;I++){const M=c[I],P=g.measureText(T).width,k=g.measureText(M).width,A=g.measureText(T+M).width-(P+k);A&&f.kerning.push({first:Hr(T),second:Hr(M),amount:A})}}const E=new Ee(f,y,!0);return Ee.available[t]!==void 0&&Ee.uninstall(t),Ee.available[t]=E,E}};Qe.ALPHA=[["a","z"],["A","Z"]," "],Qe.NUMERIC=[["0","9"]],Qe.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Qe.ASCII=[[" ","~"]],Qe.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Qe.ALPHANUMERIC},Qe.available={};let ti=Qe;var Yb=`// Pixi texture info\r
1094varying vec2 vTextureCoord;\r
1095uniform sampler2D uSampler;\r
1096\r
1097// Tint\r
1098uniform vec4 uColor;\r
1099\r
1100// on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\r
1101uniform float uFWidth;\r
1102\r
1103void main(void) {\r
1104\r
1105  // To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\r
1106  vec4 texColor = texture2D(uSampler, vTextureCoord);\r
1107\r
1108  // MSDF\r
1109  float median = texColor.r + texColor.g + texColor.b -\r
1110                  min(texColor.r, min(texColor.g, texColor.b)) -\r
1111                  max(texColor.r, max(texColor.g, texColor.b));\r
1112  // SDF\r
1113  median = min(median, texColor.a);\r
1114\r
1115  float screenPxDistance = uFWidth * (median - 0.5);\r
1116  float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\r
1117  if (median < 0.01) {\r
1118    alpha = 0.0;\r
1119  } else if (median > 0.99) {\r
1120    alpha = 1.0;\r
1121  }\r
1122\r
1123  // Gamma correction for coverage-like alpha\r
1124  float luma = dot(uColor.rgb, vec3(0.299, 0.587, 0.114));\r
1125  float gamma = mix(1.0, 1.0 / 2.2, luma);\r
1126  float coverage = pow(uColor.a * alpha, gamma);  \r
1127\r
1128  // NPM Textures, NPM outputs\r
1129  gl_FragColor = vec4(uColor.rgb, coverage);\r
1130}\r
1131`,qb=`// Mesh material default fragment\r
1132attribute vec2 aVertexPosition;\r
1133attribute vec2 aTextureCoord;\r
1134\r
1135uniform mat3 projectionMatrix;\r
1136uniform mat3 translationMatrix;\r
1137uniform mat3 uTextureMatrix;\r
1138\r
1139varying vec2 vTextureCoord;\r
1140\r
1141void main(void)\r
1142{\r
1143    gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\r
1144\r
1145    vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
1146}\r
1147`;const ic=[],sc=[],rc=[],Zb=class Yd extends kt{constructor(t,e={}){super();const{align:i,tint:r,maxWidth:n,letterSpacing:o,fontName:a,fontSize:h}=Object.assign({},Yd.styleDefaults,e);if(!ti.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new nt(r),this._font=void 0,this._fontName=a,this._fontSize=h,this.text=t,this._maxWidth=n,this._maxLineHeight=0,this._letterSpacing=o,this._anchor=new $e(()=>{this.dirty=!0},this,0,0),this._roundPixels=H.ROUND_PIXELS,this.dirty=!0,this._resolution=H.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){const t=ti.available[this._fontName],e=this.fontSize,i=e/t.size,r=new st,n=[],o=[],a=[],h=this._text.replace(/(?:\r\n|\r)/g,`
1148`)||" ",l=jd(h),c=this._maxWidth*t.size/e,u=t.distanceFieldType==="none"?ic:sc;let d=null,f=0,_=0,p=0,m=-1,g=0,v=0,b=0,y=0;for(let P=0;P<l.length;P++){const k=l[P],A=Hr(k);if(/(?:\s)/.test(k)&&(m=P,g=f,y++),k==="\r"||k===`
1149`){o.push(f),a.push(-1),_=Math.max(_,f),++p,++v,r.x=0,r.y+=t.lineHeight,d=null,y=0;continue}const S=t.chars[A];if(!S)continue;d&&S.kerning[d]&&(r.x+=S.kerning[d]);const X=rc.pop()||{texture:V.EMPTY,line:0,charCode:0,prevSpaces:0,position:new st};X.texture=S.texture,X.line=p,X.charCode=A,X.position.x=Math.round(r.x+S.xOffset+this._letterSpacing/2),X.position.y=Math.round(r.y+S.yOffset),X.prevSpaces=y,n.push(X),f=X.position.x+Math.max(S.xAdvance-S.xOffset,S.texture.orig.width),r.x+=S.xAdvance+this._letterSpacing,b=Math.max(b,S.yOffset+S.texture.height),d=A,m!==-1&&c>0&&r.x>c&&(++v,ds(n,1+m-v,1+P-m),P=m,m=-1,o.push(g),a.push(n.length>0?n[n.length-1].prevSpaces:0),_=Math.max(_,g),p++,r.x=0,r.y+=t.lineHeight,d=null,y=0)}const E=l[l.length-1];E!=="\r"&&E!==`
1150`&&(/(?:\s)/.test(E)&&(f=g),o.push(f),_=Math.max(_,f),a.push(-1));const w=[];for(let P=0;P<=p;P++){let k=0;this._align==="right"?k=_-o[P]:this._align==="center"?k=(_-o[P])/2:this._align==="justify"&&(k=a[P]<0?0:(_-o[P])/a[P]),w.push(k)}const x=n.length,T={},I=[],M=this._activePagesMeshData;u.push(...M);for(let P=0;P<x;P++){const k=n[P].texture,A=k.baseTexture.uid;if(!T[A]){let S=u.pop();if(!S){const q=new yb;let F,tt;t.distanceFieldType==="none"?(F=new Jl(V.EMPTY),tt=Z.NORMAL):(F=new Jl(V.EMPTY,{program:Xe.from(qb,Yb),uniforms:{uFWidth:0}}),tt=Z.NORMAL_NPM);const R=new Kl(q,F);R.blendMode=tt,S={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:R,vertices:null,uvs:null,indices:null}}S.index=0,S.indexCount=0,S.vertexCount=0,S.uvsCount=0,S.total=0;const{_textureCache:X}=this;X[A]=X[A]||new V(k.baseTexture),S.mesh.texture=X[A],S.mesh.tint=this._tintColor.value,I.push(S),T[A]=S}T[A].total++}for(let P=0;P<M.length;P++)I.includes(M[P])||this.removeChild(M[P].mesh);for(let P=0;P<I.length;P++)I[P].mesh.parent!==this&&this.addChild(I[P].mesh);this._activePagesMeshData=I;for(const P in T){const k=T[P],A=k.total;if(!(k.indices?.length>6*A)||k.vertices.length<Kl.BATCHABLE_SIZE*2)k.vertices=new Float32Array(4*2*A),k.uvs=new Float32Array(4*2*A),k.indices=new Uint16Array(6*A);else{const S=k.total,X=k.vertices;for(let q=S*4*2;q<X.length;q++)X[q]=0}k.mesh.size=6*A}for(let P=0;P<x;P++){const k=n[P];let A=k.position.x+w[k.line]*(this._align==="justify"?k.prevSpaces:1);this._roundPixels&&(A=Math.round(A));const S=A*i,X=k.position.y*i,q=k.texture,F=T[q.baseTexture.uid],tt=q.frame,R=q._uvs,C=F.index++;F.indices[C*6+0]=0+C*4,F.indices[C*6+1]=1+C*4,F.indices[C*6+2]=2+C*4,F.indices[C*6+3]=0+C*4,F.indices[C*6+4]=2+C*4,F.indices[C*6+5]=3+C*4,F.vertices[C*8+0]=S,F.vertices[C*8+1]=X,F.vertices[C*8+2]=S+tt.width*i,F.vertices[C*8+3]=X,F.vertices[C*8+4]=S+tt.width*i,F.vertices[C*8+5]=X+tt.height*i,F.vertices[C*8+6]=S,F.vertices[C*8+7]=X+tt.height*i,F.uvs[C*8+0]=R.x0,F.uvs[C*8+1]=R.y0,F.uvs[C*8+2]=R.x1,F.uvs[C*8+3]=R.y1,F.uvs[C*8+4]=R.x2,F.uvs[C*8+5]=R.y2,F.uvs[C*8+6]=R.x3,F.uvs[C*8+7]=R.y3}this._textWidth=_*i,this._textHeight=(r.y+t.lineHeight)*i;for(const P in T){const k=T[P];if(this.anchor.x!==0||this.anchor.y!==0){let q=0;const F=this._textWidth*this.anchor.x,tt=this._textHeight*this.anchor.y;for(let R=0;R<k.total;R++)k.vertices[q++]-=F,k.vertices[q++]-=tt,k.vertices[q++]-=F,k.vertices[q++]-=tt,k.vertices[q++]-=F,k.vertices[q++]-=tt,k.vertices[q++]-=F,k.vertices[q++]-=tt}this._maxLineHeight=b*i;const A=k.mesh.geometry.getBuffer("aVertexPosition"),S=k.mesh.geometry.getBuffer("aTextureCoord"),X=k.mesh.geometry.getIndex();
1150A.data=k.vertices,S.data=k.uvs,X.data=k.indices,A.update(),S.update(),X.update()}for(let P=0;P<n.length;P++)rc.push(n[P]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:e,distanceFieldType:i,size:r}=ti.available[this._fontName];if(i!=="none"){const{a:n,b:o,c:a,d:h}=this.worldTransform,l=Math.sqrt(n*n+o*o),c=Math.sqrt(a*a+h*h),u=(Math.abs(l)+Math.abs(c))/2,d=this.fontSize/r,f=t._view.resolution;for(const _ of this._activePagesMeshData)_.mesh.shader.uniforms.uFWidth=u*e*d*f}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=ti.available[this._fontName];if(!t)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==t&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(t){if(this.tint!==t){this._tintColor.setValue(t);for(let e=0;e<this._activePagesMeshData.length;e++)this._activePagesMeshData[e].mesh.tint=t}}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.dirty=!0)}get fontName(){return this._fontName}set fontName(t){if(!ti.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??ti.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:e}=this,i=ti.available[this._fontName].distanceFieldType==="none"?ic:sc;i.push(...this._activePagesMeshData);for(const r of this._activePagesMeshData)this.removeChild(r.mesh);this._activePagesMeshData=[],i.filter(r=>e[r.mesh.texture.baseTexture.uid]).forEach(r=>{r.mesh.texture=V.EMPTY});for(const r in e)e[r].destroy(),delete e[r];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};Zb.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const Kb=[".xml",".fnt"],Jb={extension:{type:N.LoadParser,priority:ge.Normal},name:"loadBitmapFont",test(s){return Kb.includes(wt.extname(s).toLowerCase())},async testParse(s){return Gr.test(s)||Qa.test(s)},async parse(s,t,e){const i=Gr.test(s)?Gr.parse(s):Qa.parse(s),{src:r}=t,{page:n}=i,o=[];for(let l=0;l<n.length;++l){const c=n[l].file;let u=wt.join(wt.dirname(r),c);u=ja(u,r),o.push(u)}const a=await e.load(o),h=o.map(l=>a[l]);return ti.install(i,h,!0)},async load(s,t){return(await H.ADAPTER.fetch(s)).text()},unload(s){s.destroy()}};W.add(Jb);const th=class ns extends fi{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new ns(Object.keys(ns.defaultOptions).reduce((e,i)=>({...e,[i]:t[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(t=>{URL.revokeObjectURL(t.src),t.refs--,t.refs===0&&(t.fontFace&&document.fonts.delete(t.fontFace),delete ns.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=ns;if(i[t]){const r=i[t];return this._fonts.push(r),r.refs++,this.styleID++,this.fontsDirt
1150y=!0,Promise.resolve()}return H.ADAPTER.fetch(t).then(r=>r.blob()).then(async r=>new Promise((n,o)=>{const a=URL.createObjectURL(r),h=new FileReader;h.onload=()=>n([a,h.result]),h.onerror=o,h.readAsDataURL(r)})).then(async([r,n])=>{const o=Object.assign({family:wt.basename(t,wt.extname(t)),weight:"normal",style:"normal",display:"auto",src:r,dataSrc:n,refs:1,originalUrl:t,fontFace:null},e);i[t]=o,this._fonts.push(o),this.styleID++;const a=new FontFace(o.family,`url(${o.src})`,{weight:o.weight,style:o.style,display:o.display});o.fontFace=a,await a.load(),document.fonts.add(a),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...t){const e=t.filter(i=>!this._overrides.includes(i));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter(i=>this._overrides.includes(i));e.length>0&&(this._overrides=this._overrides.filter(i=>!e.includes(i)),this.styleID++)}toCSS(t){return[`transform: scale(${t})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((t,e)=>`${t}
1151            @font-face {
1152                font-family: "${e.family}";
1153                src: url('${e.dataSrc}');
1154                font-weight: ${e.weight};
1155                font-style: ${e.style};
1156                font-display: ${e.display};
1157            }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=zm(t)),typeof t=="number"?Hm(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),r=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${i}px ${r}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,ns.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(e=>setTimeout(e,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=H.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};th.availableFonts={},th.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let Xo=th;const Ar=class os extends Ft{constructor(t="",e={}){super(V.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,r=V.from(i,{scaleMode:H.SCALE_MODE,resourceOptions:{autoLoad:!1}});r.orig=new J,r.trim=new J,this.texture=r;const n="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(n,"svg"),h=document.createElementNS(n,"foreignObject"),l=document.createElementNS(o,"div"),c=document.createElementNS(o,"style");h.setAttribute("width","10000"),h.setAttribute("height","10000"),h.style.overflow="hidden",a.appendChild(h),this.maxWidth=os.defaultMaxWidth,this.maxHeight=os.defaultMaxHeight,this._domElement=l,this._styleElement=c,this._svgRoot=a,this._foreignObject=h,this._foreignObject.appendChild(c),this._foreignObject.appendChild(l),this._image=i,this._loadImage=new Image,this._autoResolution=os.defaultAutoResolution,this._resolution=os.defaultResolution??H.RESOLUTION,this.text=t,this.style=e}measureText(t){const{text:e,style:i,resolution:r}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(r)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:o,height:a}=n;(o>this.maxWidth||a>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const h=Math.min(this.maxWidth,Math.ceil(o)),l=Math.min(this.maxHeight,Math.ceil(a));return this._svgRoot.setAttribute("width",h.toString()),this._svgRoot.setAttribute("height",l.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:this._style?.toCSS(r)}),this._styleElement.textContent=this._style?.toGlobalCSS()),{width:h+i.padding*2,height:l+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:r}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:o}=this.measureText();i.width=r.width=Math.ceil(Math.max(1,n)),i.height=r.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(h=>{r.onload=async()=>
1157{if(a<this._updateID){h();return}await e.onBeforeDraw(),i.src=r.src,r.onload=null,r.src="",this.updateTexture(),h()};const l=new XMLSerializer().serializeToString(this._svgRoot);r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(l)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:r}=this,{padding:n}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/r,e.trim.height=e._frame.height=i.height/r,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,r),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},os.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&this._style?.cleanFonts(),this._style=e,this._svgRoot?.remove(),this._svgRoot=e,this._domElement?.remove(),this._domElement=e,this._foreignObject?.remove(),this._foreignObject=e,this._styleElement?.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=ni(this.scale.x)||1;this.scale.x=e*t/this._image.width/this.resolution,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(t){this.updateText(!0);const e=ni(this.scale.y)||1;this.scale.y=e*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof Xo?(this.ownsStyle=!1,this._style=t):t instanceof fi?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Xo.from(t)):(this.ownsStyle=!0,this._style=new Xo(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")}};Ar.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Ar.defaultMaxWidth=2024,Ar.defaultMaxHeight=2024,Ar.defaultAutoResolution=!0;const Qb=`
1158precision highp float;
1159
1160uniform sampler2D uDrawingTexture;
1161uniform sampler2D uEraserTexture;
1162
1163varying vec2 vTextureCoord;
1164
1165void main(void) {
1166	vec4 drawingColor = texture2D(uDrawingTexture,vTextureCoord);
1167	vec4 eraserColor = texture2D(uEraserTexture, vTextureCoord);
1168
1169	// Use the alpha of the eraser to determine how much to "erase" from the drawing
1170	float alpha = 1.0 - eraserColor.a;
1171	gl_FragColor = vec4(drawingColor.rgb * alpha, drawingColor.a * alpha);
1172}`;function nc(s,t){if(t<0||t>=s.length-1)throw new Error("Index out of bounds");[s[t],s[t+1]]=[s[t+1],s[t]]}function tv(){let s=[],t=0;return{add_layer:function(e,i,r,n){const o=new kt;t++,o.zIndex=t;const a=Bt.create({width:r,height:n}),h=new Ft(a);o.addChild(h),h.zIndex=t;const l={draw_texture:Bt.create({width:r,height:n}),erase_texture:Bt.create({width:r,height:n}),composite:h},c=new Pt(void 0,Qb,{uEraserTexture:l.erase_texture,uDrawingTexture:l.draw_texture});return h.filters=[c],e.addChild(o),s.push(l),[l,s]},swap_layers:function(e,i){return i==="up"?nc(s,e):nc(s,e-1),s[e]},change_active_layer:function(e){return s[e]},reset(){s.forEach(e=>{e.draw_texture.destroy(!0),e.erase_texture.destroy(!0),e.composite.destroy(!0)}),s=[],t=0},async add_layer_from_blob(e,i,r,n){const o=await createImageBitmap(r),a=V.from(o),[h,l]=ev(a.width,a.height,n.width,n.height),c=new Ft(a);c.zIndex=0,c.width=h,c.height=l;const[u,d]=this.add_layer(e,i,n.width,n.height);return i.render(c,{renderTexture:u.draw_texture}),[u,d]},get_layers(){return s}}}function ev(s,t,e,i){if(s<=e&&t<=i)return[s,t];const r=s/t,n=e/i;let o,a;return r>n?(o=e,a=e/r):(a=i,o=i*r),[o,a]}function iv({target:s,dimensions:[t,e],antialias:i}){const r=window.devicePixelRatio||1,n=new Sd({width:t,height:e,antialias:i,backgroundAlpha:0,eventMode:"static"}),o=n.view;n.stage.sortableChildren=!0,o.style.maxWidth=`${t/r}px`,o.style.maxHeight=`${e/r}px`,o.style.width="100%",o.style.height="100%",s.appendChild(n.view);const a=new kt;a.zIndex=0;const h=new kt;h.zIndex=1,h.sortableChildren=!0;const l=new kt;l.zIndex=1;const c=new kt;c.zIndex=0,l.addChild(a),l.addChild(h),n.stage.addChild(l),n.stage.addChild(c);const u=new Hi;let d=Bt.create({width:t,height:e});const f=new Ft(d);l.mask=f,n.render();function _(g,v){a.removeChildren(),u.beginFill(16777215,1),u.drawRect(0,0,g,v),u.endFill(),d=Bt.create({width:g,height:v}),n.renderer.render(u,{renderTexture:d});const b=new Ft(d);l.mask=b}function p(g,v){n.renderer.resize(g,v),o.style.maxWidth=`${g/r}px`,o.style.maxHeight=`${v/r}px`,_(g,v)}async function m(g,v,[b,y]){const E=await Vo(n.renderer,a,v,b,y),w=await Promise.all(g.map(T=>Vo(n.renderer,T.composite,v,b,y))),x=await Vo(n.renderer,l,v,b,y);return{background:E,layers:w,composite:x}}return{layer_container:h,renderer:n.renderer,destroy:()=>n.destroy(!0),view:n.view,background_container:a,mask_container:l,resize:p,get_blobs:m}}function qd(s){const t=new Hi;return t.eventMode="none",t.zIndex=s,t}function Ut(s,t,e){return s<t?t:s>e?e:s}function Vo(s,t,e,i,r){return new Promise(n=>{const o=s.extract.canvas(t,new J(0,0,i,r));let a=document.createElement("canvas");a.width=e.width,a.height=e.height;let h=a.getContext("2d");
1172if(!h)throw n(null),new Error("Could not create canvas context");h.drawImage(o,e.x,e.y,e.width,e.height,0,0,e.width,e.height),a.toBlob?.(l=>{l||n(null),n(l)})})}function eh(s){return{command:s||null,next:null,previous:null,push:function(t){const e=eh(t);e.previous=this,this.next=e}}}function sv(){let s=eh();const t=Ot(!1),e=Ot(!1),i=Ot(s);return{undo:function(){s.previous&&(s.command?.undo(),s=s.previous),t.set(!!s.previous),e.set(!!s.next),i.set(s)},redo:function(){s.next&&(s.next.command?.execute(),s=s.next),t.set(!!s.previous),e.set(!!s.next),i.set(s)},execute:function(r){r.execute(),s.push(r),s=s.next,t.set(!!s.previous),e.set(!!s.next),i.set(s)},can_undo:t,can_redo:e,current_history:i,reset:function(){s=eh(),t.set(!1),e.set(!1),i.set(s)}}}function Wo(s,t,e,i=new nt("black"),r){const n=new nt(i);s.beginFill(n),s.drawCircle(t,e,r),s.endFill()}function rv(s,t){let e=[];const i=t.x-s.x,r=t.y-s.y,n=Math.sqrt(i*i+r*r),o=Math.ceil(n/2),a=i/o,h=r/o;for(let l=0;l<o;l++){const c=s.x+l*a,u=s.y+l*h;e.push({x:c,y:u})}return e}function nv(s,t,e,i){const r=[];let n,o,a,h=!1,l=0;return{drawing:!1,start:function({x:c,y:u,size:d,color:f=new nt("black"),opacity:_,set_initial_texture:p=!0}){p&&(a=Bt.create({width:e.draw_texture.width,height:e.draw_texture.height}),s.render(e.composite,{renderTexture:a})),n={x:c,y:u,size:d,color:f,opacity:_},r.push({x:c,y:u}),o=qd(l++),Wo(o,c,u,f,d),s.render(o,{renderTexture:i==="draw"?e.draw_texture:e.erase_texture,clear:!1}),this.drawing=!0},continue:function({x:c,y:u}){const d=r[r.length-1],f=rv(d,{x:c,y:u});for(let _=0;_<f.length;_++){const{x:p,y:m}=f[_];Wo(o,p,m,n.color,n.size),r.push({x:p,y:m})}s.render(o,{renderTexture:i==="draw"?e.draw_texture:e.erase_texture,clear:!1}),o.clear()},stop:function(){const c=Bt.create({width:e.draw_texture.width,height:e.draw_texture.height});s.render(e.composite,{renderTexture:c}),s.render(new Ft(c),{renderTexture:e.draw_texture});const u=new Hi().beginFill(0,0).drawRect(0,0,e.erase_texture.width,e.erase_texture.height).endFill();s.render(u,{renderTexture:e.erase_texture,clear:!0}),h=!0,this.drawing=!1},execute:function(){if(!h){for(let c=1;c<r.length;c++){const{x:u,y:d}=r[c];Wo(o,u,d,n.color,n.size)}s.render(o,{renderTexture:i==="draw"?e.draw_texture:e.erase_texture,clear:!1}),this.stop()}},undo:function(){const c=new Hi().beginFill(0,0).drawRect(0,0,e.erase_texture.width,e.erase_texture.height).endFill();s.render(new Ft(a),{renderTexture:e.draw_texture}),s.render(c,{renderTexture:e.erase_texture,clear:!0}),this.stop(),h=!1}}}function Th(s,t){const e=i=>{s&&!s.contains(i.target)&&!i.defaultPrevented&&t(i)};return document.addEventListener("mousedown",e,!0),{destroy(){document.removeEventListener("mousedown",e,!0)}}}const{SvelteComponent:ov,append:oc,attr:Sr,binding_callbacks:ac,detach:jo,element:Cr,flush:av,init:hv,insert:Yo,listen:Ir,noop:hc,run_all:lv,safe_not_equal:cv,set_style:be,space:uv}=window.__gradio__svelte__internal,{tick:dv}=window.__gradio__svelte__internal;function fv(s){let t,e,i=`translate(${s[1][0]}px,${s[1][1]}px)`,r,n,o,a=`translateX(${s[3]}px)`,h,l;return{c(){t=Cr("div"),e=Cr("div"),r=uv(),n=Cr("div"),o=Cr("div"),Sr(e,"class","marker svelte-90y9cx"),be(e,"transform",i),be(e,"background",s[0]),Sr(t,"class","color-gradient svelte-90y9cx"),be(t,"--hue",s[2]),Sr(o,"class","marker svelte-90y9cx"),be(o,"background","hsl("+s[2]+", 100%, 50%)"),be(o,"transform",a),Sr(n,"class","hue-slider svelte-90y9cx")},m(c,u){Yo(c,t,u),oc(t,e),s[10](t),Yo(c,r,u),Yo(c,n,u),oc(n,o),s[11](n),h||(l=[Ir(window,"mousemove",s[8]),Ir(window,"mouseup",s[9]),Ir(t,"mousedown",s[7]),Ir(n,"mousedown",s[6])],h=!0)},p(c,[u]){u&2&&i!==(i=`translate(${c[1][0]}px,${c[1][1]}px)`)&&be(e,"transform",i),u&1&&be(e,"background",c[0]),u&4&&be(t,"--hue",c[2]),u&4&&be(o,"background","hsl("+c[2]+", 100%, 50%)"),u&8&&a!==(a=`translateX(${c[3]}px)`)&&be(o,"transform",a)},i:hc,o:hc,d(c){c&&(jo(t),jo(r),jo(n)),s[10](null),s[11](null),h=!1,lv(l)}}}function lc(s){const t=s.s,e=s.v;let i=t*e;const r=s.h/60;let n=i*(1-Math.abs(r%2-1));const o=e-i;i=i+o,n=n+o;const a=Math.floor(r)%6,h=[i,n,o,o,n,i][a],l=[n,i,i,n,o,o][a],c=[o,o,n,i,i,n][a];return`rgba(${h*255}, ${l*255}, ${c*255}, ${s.a})`}function _v(s,t,e){let{color:i="rgb(255, 255, 255)"}=t,r=[0,0],n=null,o=!1,a=[0,0],h=0,l=0,c=null,u=!1;function d(x){c=x.currentTarget.getBoundingClientRect(),u=!0,f(x.clientX)}function f(x){if(!c)return;const T=Ut(x-c.left,0,c.width);e(3,l=T);const I=T/c.width*360;e(2,h=I),e(0,i=lc({h:I,s:a[0],v:a[1],a:1}))}function _(x,T){if(!n)return;const I=Ut(x-n.left,0,n.width),M=Ut(T-n.top,0,n.height);e(1,r=[I,M]);const P={h:h*1,s:I/n.width,v:1-M/n.height,a:1};a=[P.s,P.v],e(0,i=lc(P))}function p(x){o=!0,n=x.currentTarget.getBoundingClientRect(),_(x.clientX,x.clientY)}function m(x){o&&_(x.clientX,x.clientY),u&&f(x.clientX)}function g(){o&&(o=!1),u&&(u=!1)}async function v(x){if(o||u||(await dv(),!x))return;n||(n=b.getBoundingClientRect()),c||(c=y.getBoundingClientRect());const T=$(x).toHsv(),I=T.s*n.width,M=(1-T.v)*n.height;e(1,r=[I,M]),a=[T.s,T.v],e(2,h=T.h),e(3,l=T.h/360*c.width)}let b,y;function E(x){ac[x?"unshift":"push"](()=>{b=x,e(4,b)})}function w(x){ac[x?"unshift":"push"](()=>{y=x,e(5,y)})}return s.$$set=x=>{"color"in x&&e(0,i=x.color)},s.$$.update=()=>{s.$$.dirty&1&&v(i)},[i,r,h,l,b,y,d,p,m,g,E,w]}class pv extends ov{constructor(t){super(),hv(this,t,_v,fv,cv,{color:0})}get color(){return this.$$.ctx[0]}set color(t){this.$$set({color:t}),av()}}
1172const{SvelteComponent:mv,append:Fi,attr:ci,create_component:gv,destroy_component:bv,destroy_each:Zd,detach:vs,element:Ve,ensure_array_like:Tn,flush:qi,init:vv,insert:ys,listen:Eh,mount_component:yv,safe_not_equal:xv,set_style:En,space:zr,toggle_class:re,transition_in:wv,transition_out:Tv}=window.__gradio__svelte__internal,{createEventDispatcher:Ev}=window.__gradio__svelte__internal;function cc(s,t,e){const i=s.slice();return i[14]=t[e],i[16]=e,i}function uc(s,t,e){const i=s.slice();return i[14]=t[e],i[16]=e,i}function dc(s){let t;return{c(){t=Ve("span"),ci(t,"class","svelte-287ern"),re(t,"lg",s[1])},m(e,i){ys(e,t,i)},p(e,i){i&2&&re(t,"lg",e[1])},d(e){e&&vs(t)}}}function fc(s){let t,e,i,r,n,o=Tn(s[1]),a=[];for(let h=0;h<o.length;h+=1)a[h]=_c(uc(s,o,h));return{c(){t=Ve("div");for(let h=0;h<a.length;h+=1)a[h].c();e=zr(),i=Ve("button"),ci(i,"class","color colorpicker svelte-287ern"),re(i,"hidden",!s[0]),ci(t,"class","swatch svelte-287ern")},m(h,l){ys(h,t,l);for(let c=0;c<a.length;c+=1)a[c]&&a[c].m(t,null);Fi(t,e),Fi(t,i),r||(n=Eh(i,"click",s[5]),r=!0)},p(h,l){if(l&22){o=Tn(h[1]);let c;for(c=0;c<o.length;c+=1){const u=uc(h,o,c);a[c]?a[c].p(u,l):(a[c]=_c(u),a[c].c(),a[c].m(t,e))}for(;c<a.length;c+=1)a[c].d(1);a.length=o.length}l&1&&re(i,"hidden",!h[0])},d(h){h&&vs(t),Zd(a,h),r=!1,n()}}}function _c(s){let t,e,i;function r(){return s[10](s[16],s[14])}return{c(){t=Ve("button"),ci(t,"class","color svelte-287ern"),En(t,"background-color",s[14]),re(t,"empty",s[14]===null),re(t,"selected",`edit-${s[16]}`===s[2])},m(n,o){ys(n,t,o),e||(i=Eh(t,"click",r),e=!0)},p(n,o){s=n,o&2&&En(t,"background-color",s[14]),o&2&&re(t,"empty",s[14]===null),o&4&&re(t,"selected",`edit-${s[16]}`===s[2])},d(n){n&&vs(t),e=!1,i()}}}function pc(s){let t,e,i;function r(){return s[11](s[16],s[14])}return{c(){t=Ve("button"),ci(t,"class","color svelte-287ern"),En(t,"background-color",s[14]),re(t,"empty",s[14]===null),re(t,"selected",`select-${s[16]}`===s[2])},m(n,o){ys(n,t,o),e||(i=Eh(t,"click",r),e=!0)},p(n,o){s=n,o&8&&En(t,"background-color",s[14]),o&8&&re(t,"empty",s[14]===null),o&4&&re(t,"selected",`select-${s[16]}`===s[2])},d(n){n&&vs(t),e=!1,i()}}}function Av(s){let t,e,i,r,n,o,a,h,l,c=!s[0]&&dc(s);r=new k_({});let u=s[1]&&fc(s),d=Tn(s[3]),f=[];for(let _=0;_<d.length;_+=1)f[_]=pc(cc(s,d,_));return{c(){c&&c.c(),t=zr(),e=Ve("div"),i=Ve("span"),gv(r.$$.fragment),n=zr(),o=Ve("div"),u&&u.c(),a=zr(),h=Ve("menu");for(let _=0;_<f.length;_+=1)f[_].c();ci(i,"class","icon-wrap svelte-287ern"),ci(h,"class","swatch svelte-287ern"),ci(e,"class","swatch-wrap svelte-287ern")},m(_,p){c&&c.m(_,p),ys(_,t,p),ys(_,e,p),Fi(e,i),yv(r,i,null),Fi(e,n),Fi(e,o),u&&u.m(o,null),Fi(o,a),Fi(o,h);for(let m=0;m<f.length;m+=1)f[m]&&f[m].m(h,null);l=!0},p(_,[p]){if(_[0]?c&&(c.d(1),c=null):c?c.p(_,p):(c=dc(_),c.c(),c.m(t.parentNode,t)),_[1]?u?u.p(_,p):(u=fc(_),u.c(),u.m(o,a)):u&&(u.d(1),u=null),p&28){d=Tn(_[3]);let m;for(m=0;m<d.length;m+=1){const g=cc(_,d,m);f[m]?f[m].p(g,p):(f[m]=pc(g),f[m].c(),f[m].m(h,null))}for(;m<f.length;m+=1)f[m].d(1);f.length=d.length}},i(_){l||(wv(r.$$.fragment,_),l=!0)},o(_){Tv(r.$$.fragment,_),l=!1},d(_){_&&(vs(t),vs(e)),c&&c.d(_),bv(r),u&&u.d(),Zd(f,_)}}}function Sv(s,t,e){let i,{selected_color:r}=t,{colors:n}=t,{user_colors:o=[]}=t,{show_empty:a=!1}=t,{current_mode:h="hex"}=t,{color_picker:l=!1}=t;const c=Ev();function u(g,v){return v==="hex"?$(g).toHexString():v==="rgb"?$(g).toRgbString():$(g).toHslString()}let d=`select-${n.findIndex(g=>u(g,h)===u(r,h))}`;function f(g,v){e(2,d=`${g}-${v.index}`),c(g,v)}function _(){c("select",{index:null,color:r}),e(0,l=!l)}const p=(g,v)=>f("edit",{index:g,color:v}),m=(g,v)=>f("select",{index:g,color:v});return s.$$set=g=>{"selected_color"in g&&e(6,r=g.selected_color),"colors"in g&&e(7,n=g.colors),"user_colors"in g&&e(1,o=g.user_colors),"show_empty"in g&&e(8,a=g.show_empty),"current_mode"in g&&e(9,h=g.current_mode),"color_picker"in g&&e(0,l=g.color_picker)},s.$$.update=()=>{s.$$.dirty&384&&e(3,i=a?n:n.filter(g=>g))},[l,o,d,i,f,_,r,n,a,h,p,m]}class Cv extends mv{constructor(t){super(),vv(this,t,Sv,Av,xv,{selected_color:6,colors:7,user_colors:1,show_empty:8,current_mode:9,color_picker:0})}get selected_color(){return this.$$.ctx[6]}set selected_color(t){this.$$set({selected_color:t}),qi()}get colors(){return this.$$.ctx[7]}set colors(t){this.$$set({colors:t}),qi()}get user_colors(){return this.$$.ctx[1]}set user_colors(t){this.$$set({user_colors:t}),qi()}get show_empty(){return this.$$.ctx[8]}set show_empty(t){this.$$set({show_empty:t}),qi()}get current_mode(){return this.$$.ctx[9]}set current_mode(t){this.$$set({current_mode:t}),qi()}get color_picker(){return this.$$.ctx[0]}set color_picker(t){this.$$set({color_picker:t}),qi()}}const{SvelteComponent:Iv,append:Le,attr:ei,create_component:Rv,destroy_component:Mv,destroy_each:Pv,detach:Kd,element:ii,ensure_array_like:mc,flush:gc,init:kv,insert:Jd,listen:$r,mount_component:Bv,run_all:Dv,safe_not_equal:Fv,set_style:bc,space:qo,toggle_class:vc,transition_in:Qd,transition_out:tf}=window.__gradio__svelte__internal,{createEventDispatcher:Lv}=window.__gradio__svelte__internal;function yc(s,t,e){const i=s.slice();return i[11]=t[e][0],i[12]=t[e][1],i}function Nv(s){let t,e;return t=new b_({}),{c(){Rv(t.$$.fragment)},m(i,r){Bv(t,i,r),e=!0},i(i){e||(Qd(t.$$.fragment,i),e=!0)},o(i){tf(t.$$.fragment,i),e=!1},d(i){Mv(t,i)}}}function xc(s){let t,e,i;function r(){return s[8](s[12])}return{c(){t=ii("button"),t.textContent=`${s[11]}`,ei(t,"class","button svelte-w84deg"),vc(t,"active",s[1]===s[12])},m(n,o){Jd(n,t,o),e||(i=$r(t,"click",r),e=!0)},p(n,o){s=n,o&10&&vc(t,"active",s[1]===s[12])},d(n){n&&Kd(t),e=!1,i()}}}function Ov(s){let t,e,i,r,n,o,a,h,l,c,u,d,f,_=s[5]&&Nv(),p=mc(s[3]),m=[];for(let g=0;g<p.length;g+=1)m[g]=xc(yc(s,p,g));return{c(){t=ii("div"),e=ii("button"),i=qo(),r=ii("div"),n=ii("div"),o=ii("input"),a=qo(),h=ii("button"),_&&_.c(),l=qo(),c=ii("div");for(let g=0;g<m.length;g+=1)m[g].c();ei(e,"class","swatch svelte-w84deg"),bc(e,"background",s[0]),ei(o,"type","text"),o.value=s[2],ei(o,"class","svelte-w84deg"),ei(h,"class","eyedropper svelte-w84deg"),ei(n,"class","input-wrap svelte-w84deg"),ei(c,"class","buttons svelte-w84deg"),ei(t,"class","input svelte-w84deg")},m(g,v){Jd(g,t,v),Le(t,e),Le(t,i),Le(t,r),Le(r,n),Le(n,o),Le(n,a),Le(n,h),_&&_.m(h,null),Le(r,l),Le(r,c);for(let b=0;b<m.length;b+=1)m[b]&&m[b].m(c,null);u=!0,d||(f=[$r(e,"click",s[6]),$r(o,"change",s[7]),$r(h,"click",s[4])],d=!0)},p(g,[v]){if(v&1&&bc(e,"background",g[0]),(!u||v&4&&o.value!==g[2])&&(o.value=g[2]),v&10){p=mc(g[3]);let b;for(b=0;b<p.length;b+=1){const y=yc(g,p,b);m[b]?m[b].p(y,v):(m[b]=xc(y),m[b].c(),m[b].m(c,null))}for(;b<m.length;b+=1)m[b].d(1);m.length=p.length}},i(g){u||(Qd(_),u=!0)},o(g){tf(_),u=!1},d(g){g&&Kd(t),_&&_.d(),Pv(m,g),d=!1,Dv(f)}}}function Uv(s,t,e){let i,{color:r}=t,{current_mode:n="hex"}=t;const o=Lv(),a=[["Hex","hex"],["RGB","rgb"],["HSL","hsl"]];function h(_,p){return p==="hex"?$(_).toHexString():p==="rgb"?$(_).toRgbString():$(_).toHslString()}function l(){new EyeDropper().open().then(p=>{e(0,r=p.sRGBHex)})}const c=!!window.EyeDropper;function u(){o("selected",i),o("close")}const d=_=>e(0,r=_.currentTarget.value),f=_=>e(1,n=_);return s.$$set=_=>{"color"in _&&e(0,r=_.color),"current_mode"in _&&e(1,n=_.current_mode)},s.$$.update=()=>{s.$$.dirty&3&&e(2,i=h(r,n)),s.$$.dirty&4&&i&&o("selected",i)},[r,n,i,a,l,c,u,d,f]}class Gv extends Iv{constructor(t){super(),kv(this,t,Uv,Ov,Fv,{color:0,current_mode:1})}get color(){return this.$$.ctx[0]}set color(t){this.$$set({color:t}),gc()}get current_mode(){return this.$$.ctx[1]}set current_mode(t){this.$$set({current_mode:t}),gc()}}const{SvelteComponent:Hv,action_destroyer:zv,add_iframe_resize_listener:$v,add_render_callback:wc,append:Zo,attr:Ne,binding_callbacks:Xv,create_component:Vv,destroy_component:Wv,detach:jv,element:Ko,flush:Jo,init:Yv,insert:qv,listen:Qo,mount_component:Zv,run_all:Kv,safe_not_equal:Jv,set_input_value:Tc,space:Qv,to_number:ty,toggle_class:Zi,transition_in:ey,transition_out:iy}=window.__gradio__svelte__internal,{createEventDispatcher:sy}=window.__gradio__svelte__internal;function ry(s){let t,e,i,r,n,o,a,h,l;return wc(s[11]),i=new qf({}),{c(){t=Ko("div"),e=Ko("span"),Vv(i.$$.fragment),r=Qv(),n=Ko("input"),Ne(e,"class","svelte-12m4nbd"),Ne(n,"type","range"),Ne(n,"min",s[1]),Ne(n,"max",s[2]),Ne(n,"step",1),Ne(n,"class","svelte-12m4nbd"),Ne(t,"class","wrap svelte-12m4nbd"),wc(()=>s[15].call(t)),Zi(t,"right",s[8]),Zi(t,"top",s[9]),Zi(t,"bottom",!s[9])},m(c,u){qv(c,t,u),Zo(t,e),Zv(i,e,null),Zo(t,r),Zo(t,n),Tc(n,s[0]),s[14](t),o=$v(t,s[15].bind(t)),a=!0,h||(l=[Qo(window,"resize",s[11]),Qo(n,"change",s[12]),Qo(n,"input",s[
117212]),zv(Th.call(null,t,s[13]))],h=!0)},p(c,[u]){(!a||u&2)&&Ne(n,"min",c[1]),(!a||u&4)&&Ne(n,"max",c[2]),u&1&&Tc(n,c[0]),(!a||u&256)&&Zi(t,"right",c[8]),(!a||u&512)&&Zi(t,"top",c[9]),(!a||u&512)&&Zi(t,"bottom",!c[9])},i(c){a||(ey(i.$$.fragment,c),a=!0)},o(c){iy(i.$$.fragment,c),a=!1},d(c){c&&jv(t),Wv(i),s[14](null),o(),h=!1,Kv(l)}}}function ny(s,t,e){let{selected_size:i}=t,{min:r}=t,{max:n}=t;const o=sy();let a=0,h=0,l=0,c=0,u,d=!1,f=!1;function _(){e(4,h=window.innerHeight),e(3,a=window.innerWidth)}function p(){i=ty(this.value),e(0,i)}const m=()=>o("click_outside");function g(b){Xv[b?"unshift":"push"](()=>{u=b,e(7,u)})}function v(){l=this.clientWidth,c=this.clientHeight,e(5,l),e(6,c)}return s.$$set=b=>{"selected_size"in b&&e(0,i=b.selected_size),"min"in b&&e(1,r=b.min),"max"in b&&e(2,n=b.max)},s.$$.update=()=>{if(s.$$.dirty&248&&u&&(a||h||c||l)){const b=u.getBoundingClientRect();e(8,d=b.width+30>a/2),e(9,f=b.y<80)}},[i,r,n,a,h,l,c,u,d,f,o,_,p,m,g,v]}class oy extends Hv{constructor(t){super(),Yv(this,t,ny,ry,Jv,{selected_size:0,min:1,max:2})}get selected_size(){return this.$$.ctx[0]}set selected_size(t){this.$$set({selected_size:t}),Jo()}get min(){return this.$$.ctx[1]}set min(t){this.$$set({min:t}),Jo()}get max(){return this.$$.ctx[2]}set max(t){this.$$set({max:t}),Jo()}}const{SvelteComponent:ay,action_destroyer:hy,add_flush_callback:An,add_iframe_resize_listener:ly,add_render_callback:Ec,append:ta,attr:ef,bind:Sn,binding_callbacks:Js,check_outros:ih,create_component:Cn,destroy_component:In,detach:Xn,element:sf,empty:cy,flush:he,group_outros:sh,init:uy,insert:Vn,listen:dy,mount_component:Rn,run_all:fy,safe_not_equal:_y,space:Xr,toggle_class:ve,transition_in:Wt,transition_out:Se}=window.__gradio__svelte__internal,{createEventDispatcher:py}=window.__gradio__svelte__internal;function Ac(s){let t,e,i=s[7]&&Sc(s);return{c(){i&&i.c(),t=cy()},m(r,n){i&&i.m(r,n),Vn(r,t,n),e=!0},p(r,n){r[7]?i?(i.p(r,n),n[0]&128&&Wt(i,1)):(i=Sc(r),i.c(),Wt(i,1),i.m(t.parentNode,t)):i&&(sh(),Se(i,1,1,()=>{i=null}),ih())},i(r){e||(Wt(i),e=!0)},o(r){Se(i),e=!1},d(r){r&&Xn(t),i&&i.d(r)}}}function Sc(s){let t,e,i,r,n,o;function a(u){s[23](u)}let h={};s[0]!==void 0&&(h.color=s[0]),t=new pv({props:h}),Js.push(()=>Sn(t,"color",a));function l(u){s[24](u)}let c={color:s[0]};return s[13]!==void 0&&(c.current_mode=s[13]),r=new Gv({props:c}),Js.push(()=>Sn(r,"current_mode",l)),r.$on("close",s[25]),r.$on("selected",s[26]),{c(){Cn(t.$$.fragment),i=Xr(),Cn(r.$$.fragment)},m(u,d){Rn(t,u,d),Vn(u,i,d),Rn(r,u,d),o=!0},p(u,d){const f={};!e&&d[0]&1&&(e=!0,f.color=u[0],An(()=>e=!1)),t.$set(f);const _={};d[0]&1&&(_.color=u[0]),!n&&d[0]&8192&&(n=!0,_.current_mode=u[13],An(()=>n=!1)),r.$set(_)},i(u){o||(Wt(t.$$.fragment,u),Wt(r.$$.fragment,u),o=!0)},o(u){Se(t.$$.fragment,u),Se(r.$$.fragment,u),o=!1},d(u){u&&Xn(i),In(t,u),In(r,u)}}}function Cc(s){let t,e,i;function r(o){s[27](o)}let n={colors:s[3],user_colors:s[4]==="defaults"?s[1]:null,selected_color:s[0],current_mode:s[13]};return s[7]!==void 0&&(n.color_picker=s[7]),t=new Cv({props:n}),Js.push(()=>Sn(t,"color_picker",r)),t.$on("select",s[28]),t.$on("edit",s[29]),{c(){Cn(t.$$.fragment)},m(o,a){Rn(t,o,a),i=!0},p(o,a){const h={};a[0]&8&&(h.colors=o[3]),a[0]&18&&(h.user_colors=o[4]==="defaults"?o[1]:null),a[0]&1&&(h.selected_color=o[0]),a[0]&8192&&(h.current_mode=o[13]),!e&&a[0]&128&&(e=!0,h.color_picker=o[7],An(()=>e=!1)),t.$set(h)},i(o){i||(Wt(t.$$.fragment,o),i=!0)},o(o){Se(t.$$.fragment,o),i=!1},d(o){In(t,o)}}}function Ic(s){let t;return{c(){t=sf("div"),ef(t,"class","sep svelte-gtuiq3")},m(e,i){Vn(e,t,i)},d(e){e&&Xn(t)}}}function my(s){let t,e,i,r,n,o,a,h,l,c;Ec(s[22]);let u=s[4]==="defaults"&&Ac(s),d=s[6]&&Cc(s),f=(s[7]||s[6])&&Ic();function _(m){s[30](m)}let p={max:s[5][0]/10,min:1};return s[2]!==void 0&&(p.selected_size=s[2]),n=new oy({props:p}),Js.push(()=>Sn(n,"selected_size",_)),{c(){t=sf("div"),u&&u.c(),e=Xr(),d&&d.c(),i=Xr(),f&&f.c(),r=Xr(),Cn(n.$$.fragment),ef(t,"class","wrap svelte-gtuiq3"),Ec(()=>s[33].call(t)),ve(t,"padded",!s[7]),ve(t,"anchor_default",s[14]==="default"),ve(t,"anchor_center",s[14]==="center"),ve(t,"anchor_top",s[14]==="top"),ve(t,"anchor",`${s[15]}px`)},m(m,g){Vn(m,t,g),u&&u.m(t,null),ta(t,e),d&&d.m(t,null),ta(t,i),f&&f.m(t,null),ta(t,r),Rn(n,t,null),s[32](t),a=ly(t,s[33].bind(t)),h=!0,l||(c=[dy(window,"resize",s[22]),hy(Th.call(null,t,s[31]))],l=!0)},p(m,g){m[4]==="defaults"?u?(u.p(m,g),g[0]&16&&Wt(u,1)):(u=Ac(m),u.c(),Wt(u,1),u.m(t,e)):u&&(sh(),Se(u,1,1,()=>{u=null}),ih()),m[6]?d?(d.p(m,g),g[0]&64&&Wt(d,1)):(d=Cc(m),d.c(),Wt(d,1),d.m(t,i)):d&&(sh(),Se(d,1,1,()=>{d=null}),ih()),m[7]||m[6]?f||(f=Ic(),f.c(),f.m(t,r)):f&&(f.d(1),f=null);const v={};g[0]&32&&(v.max=m[5][0]/10),!o&&g[0]&4&&(o=!0,v.selected_size=m[2],An(()=>
1172o=!1)),n.$set(v),(!h||g[0]&128)&&ve(t,"padded",!m[7]),(!h||g[0]&16384)&&ve(t,"anchor_default",m[14]==="default"),(!h||g[0]&16384)&&ve(t,"anchor_center",m[14]==="center"),(!h||g[0]&16384)&&ve(t,"anchor_top",m[14]==="top"),(!h||g[0]&32768)&&ve(t,"anchor",`${m[15]}px`)},i(m){h||(Wt(u),Wt(d),Wt(n.$$.fragment,m),h=!0)},o(m){Se(u),Se(d),Se(n.$$.fragment,m),h=!1},d(m){m&&Xn(t),u&&u.d(),d&&d.d(),f&&f.d(),In(n),s[32](null),a(),l=!1,fy(c)}}}function gy(s,t,e){let{colors:i}=t,{selected_color:r}=t,{color_mode:n=void 0}=t,{recent_colors:o=[]}=t,{selected_size:a}=t,{dimensions:h}=t,{parent_width:l}=t,{parent_height:c}=t,{parent_left:u}=t,{toolbar_box:d}=t,{show_swatch:f}=t,_=!1,p="hex",m=null;const g=py();function v({index:O,color:pt},Tt){Tt==="user"&&!pt&&(m=O,e(7,_=!0)),pt&&(e(0,r=pt),Tt==="core"&&e(7,_=!1))}function b(O){m!==null&&e(1,o[m]=O,o)}let y=0,E=0,w=0,x=0,T,I="default",M=0;function P(){e(9,E=window.innerHeight),e(8,y=window.innerWidth)}function k(O){r=O,e(0,r)}function A(O){p=O,e(13,p)}const S=()=>e(7,_=!1),X=({detail:O})=>e(0,r=O);function q(O){_=O,e(7,_)}const F=({detail:O})=>v(O,"core"),tt=({detail:O})=>v(O,"user");function R(O){a=O,e(2,a)}const C=()=>g("click_outside");function K(O){Js[O?"unshift":"push"](()=>{T=O,e(12,T)})}function it(){w=this.clientWidth,x=this.clientHeight,e(10,w),e(11,x)}return s.$$set=O=>{"colors"in O&&e(3,i=O.colors),"selected_color"in O&&e(0,r=O.selected_color),"color_mode"in O&&e(4,n=O.color_mode),"recent_colors"in O&&e(1,o=O.recent_colors),"selected_size"in O&&e(2,a=O.selected_size),"dimensions"in O&&e(5,h=O.dimensions),"parent_width"in O&&e(18,l=O.parent_width),"parent_height"in O&&e(19,c=O.parent_height),"parent_left"in O&&e(20,u=O.parent_left),"toolbar_box"in O&&e(21,d=O.toolbar_box),"show_swatch"in O&&e(6,f=O.show_swatch)},s.$$.update=()=>{if(s.$$.dirty[0]&1&&b(r),s.$$.dirty[0]&3940224&&T&&(y||E||x||w)){const O=T.getBoundingClientRect();O.width>l||(l>O.width+230*2+25?(e(14,I="default"),e(15,M=d.right-u+24)):e(14,I="center")),O.height+50>c&&e(14,I="top")}},[r,o,a,i,n,h,f,_,y,E,w,x,T,p,I,M,g,v,l,c,u,d,P,k,A,S,X,q,F,tt,R,C,K,it]}class by extends ay{constructor(t){super(),uy(this,t,gy,my,_y,{colors:3,selected_color:0,color_mode:4,recent_colors:1,selected_size:2,dimensions:5,parent_width:18,parent_height:19,parent_left:20,toolbar_box:21,show_swatch:6},null,[-1,-1])}get colors(){return this.$$.ctx[3]}set colors(t){this.$$set({colors:t}),he()}get selected_color(){return this.$$.ctx[0]}set selected_color(t){this.$$set({selected_color:t}),he()}get color_mode(){return this.$$.ctx[4]}set color_mode(t){this.$$set({color_mode:t}),he()}get recent_colors(){return this.$$.ctx[1]}set recent_colors(t){this.$$set({recent_colors:t}),he()}get selected_size(){return this.$$.ctx[2]}set selected_size(t){this.$$set({selected_size:t}),he()}get dimensions(){return this.$$.ctx[5]}set dimensions(t){this.$$set({dimensions:t}),he()}get parent_width(){return this.$$.ctx[18]}set parent_width(t){this.$$set({parent_width:t}),he()}get parent_height(){return this.$$.ctx[19]}set parent_height(t){this.$$set({parent_height:t}),he()}get parent_left(){return this.$$.ctx[20]}set parent_left(t){this.$$set({parent_left:t}),he()}get toolbar_box(){return this.$$.ctx[21]}set toolbar_box(t){this.$$set({toolbar_box:t}),he()}get show_swatch(){return this.$$.ctx[6]}set show_swatch(t){this.$$set({show_swatch:t}),he()}}const{SvelteComponent:vy,add_flush_callback:ea,attr:yy,bind:ia,binding_callbacks:sa,check_outros:xy,component_subscribe:Ei,create_component:wy,destroy_component:Ty,detach:Vr,element:rf,empty:Ey,flush:ks,group_outros:Ay,init:Sy,insert:Wr,listen:Cy,mount_component:Iy,safe_not_equal:Ry,set_style:Kt,space:My,transition_in:jr,transition_out:rh}=window.__gradio__svelte__internal,{getContext:Rc,onMount:Py,tick:UT}=window.__gradio__svelte__internal;function Mc(s){let t,e,i,r,n,o;function a(u){s[25](u)}function h(u){s[26](u)}function l(u){s[27](u)}let c={show_swatch:s[1]==="draw",colors:s[12],color_mode:s[0],dimensions:s[5],parent_width:s[4].parent_width,parent_height:s[4].parent_height,parent_left:s[4].parent_left,toolbar_box:s[11]};return s[2]!==void 0&&(c.selected_color=s[2]),s[8]!==void 0&&(c.recent_colors=s[8]),s[3]!==void 0&&(c.selected_size=s[3]),e=new by({props:c}),sa.push(()=>ia(e,"selected_color",a)),sa.push(()=>ia(e,"recent_colors",h)),sa.push(()=>ia(e,"selected_size",l)),e.$on("click_outside",s[28]),{c(){t=rf("div"),wy(e.$$.fragment)},m(u,d){Wr(u,t,d),Iy(e,t,null),o=!0},p(u,d){const f={};d[0]&2&&(f.show_swatch=u[1]==="draw"),d[0]&1&&(f.color_mode=u[0]),d[0]&32&&(f.dimensions=u[5]),d[0]&16&&(f.parent_width=u[4].parent_width),d[0]&16&&(f.parent_height=u[4].parent_height),d[0]&16&&(f.parent_left=u[4].parent_left),d[0]&2048&&(f.toolbar_box=u[11]),!i&&d[0]&4&&(i=!0,f.selected_color=u[2],ea(()=>i=!1)),!r&&d[0]&256&&(r=!0,f.recent_colors=u[8],ea(()=>r=!1)),!n&&d[0]&8&&(n=!0,f.selected_size=u[3],ea(()=>n=!1)),e.$set(f)},i(u){o||(jr(e.$$.fragment,u),o=!0)},o(u){rh(e.$$.fragment,u),o=!1},d(u){u&&Vr(t),Ty(e)}}}function ky(s){let t,e=`translate(${s[9].x}px, ${s[9].y}px)`,i=`${s[4].child_top-s[4].parent_top-s[10]/2}px`,r=`${s[4].child_left-s[4].parent_left-s[10]/2}px`,n=`${s[10]}px`,o=`${s[10]}px`,a,h,l,c,u,d=s[6]&&Mc(s);return{c(){t=rf("span"),a=My(),d&&d.c(),h=Ey(),yy(t,"class","svelte-btgkrd"),Kt(t,"transform",e),Kt(t,"top",i),Kt(t,"left",r),Kt
1172(t,"width",n),Kt(t,"height",o),Kt(t,"opacity",s[7]?1:0)},m(f,_){Wr(f,t,_),Wr(f,a,_),d&&d.m(f,_),Wr(f,h,_),l=!0,c||(u=Cy(window,"keydown",s[24]),c=!0)},p(f,_){_[0]&512&&e!==(e=`translate(${f[9].x}px, ${f[9].y}px)`)&&Kt(t,"transform",e),_[0]&1040&&i!==(i=`${f[4].child_top-f[4].parent_top-f[10]/2}px`)&&Kt(t,"top",i),_[0]&1040&&r!==(r=`${f[4].child_left-f[4].parent_left-f[10]/2}px`)&&Kt(t,"left",r),_[0]&1024&&n!==(n=`${f[10]}px`)&&Kt(t,"width",n),_[0]&1024&&o!==(o=`${f[10]}px`)&&Kt(t,"height",o),_[0]&128&&Kt(t,"opacity",f[7]?1:0),f[6]?d?(d.p(f,_),_[0]&64&&jr(d,1)):(d=Mc(f),d.c(),jr(d,1),d.m(h.parentNode,h)):d&&(Ay(),rh(d,1,1,()=>{d=null}),xy())},i(f){l||(jr(d),l=!0)},o(f){rh(d),l=!1},d(f){f&&(Vr(t),Vr(a),Vr(h)),d&&d.d(f),c=!1,u()}}}function By(s,t,e){let i,r,n,o,a,h,l,c,{default_size:u}=t,{default_color:d=void 0}=t,{colors:f=void 0}=t,{color_mode:_=void 0}=t,{mode:p}=t;const m=f?f.map(pt).filter((L,Mt)=>Mt<4):[];let g=d==="auto"?m[0]:d?pt(d):"black",v=!1;const{pixi:b,dimensions:y,current_layer:E,command_manager:w,register_context:x,editor_box:T,crop:I,toolbar_box:M}=Rc(As);Ei(s,b,L=>e(31,o=L)),Ei(s,y,L=>e(5,n=L)),Ei(s,E,L=>e(34,l=L)),Ei(s,T,L=>e(4,r=L)),Ei(s,I,L=>e(33,h=L)),Ei(s,M,L=>e(11,c=L));const{active_tool:P,register_tool:k,current_color:A}=Rc(kn);Ei(s,P,L=>e(32,a=L));let S=!1,X;function q(L,Mt){const Lt=Ut(Math.min(L,Mt),500,1e3);return Math.round(Lt*2/100)}let F=u==="auto"?q(...n):u;function tt(L){a===p&&(S=!0,!(!o||!l)&&(X=nv(o.renderer,o.layer_container,l,p),X.start({x:L.screen.x,y:L.screen.y,color:g||void 0,size:F,opacity:1})))}function R(L){!o||!l||a===p&&(X.stop(),w.execute(X),S=!1)}function C(L){if(a!==p)return;S&&X.continue({x:L.screen.x,y:L.screen.y});const Mt=h[0]*n[0],Lt=h[1]*n[1];Mt>L.screen.x||Lt>L.screen.y||L.screen.x>Mt+h[2]*n[0]||L.screen.y>Lt+h[3]*n[1]?(e(7,K=!1),document.body.style.cursor="auto"):(e(7,K=!0),document.body.style.cursor="none"),K&&e(9,Tt={x:L.clientX-r.child_left,y:L.clientY-r.child_top})}let K=!1;async function it(L){o?.layer_container[L]("pointerdown",tt),o?.layer_container[L]("pointerup",R),o?.layer_container[L]("pointermove",C),o?.layer_container[L]("pointerenter",Mt=>{a===p&&(e(7,K=!0),document.body.style.cursor="none")}),o?.layer_container[L]("pointerleave",()=>(e(7,K=!1),document.body.style.cursor="auto"))}x(p,{init_fn:()=>{it("on")},reset_fn:()=>{it("off")}}),Py(()=>{const L=k(p,{cb:at});return()=>{L(),it("off")}});let O=[null,null,null];function pt(L){return $(L).toRgbString()}let Tt={x:0,y:0};function U(){let L=null;return function(Lt){const Ye=()=>{if(L&&clearTimeout(L),Lt!==void 0){e(6,v=Lt);return}e(6,v=!v)};L&&clearTimeout(L),L=setTimeout(Ye,100)}}const at=U(),At=({key:L})=>L==="Escape"&&at(!1);function mt(L){g=L,e(2,g)}function rt(L){O=L,e(8,O)}function lt(L){F=L,e(3,F)}const St=()=>at();return s.$$set=L=>{"default_size"in L&&e(21,u=L.default_size),"default_color"in L&&e(22,d=L.default_color),"colors"in L&&e(23,f=L.colors),"color_mode"in L&&e(0,_=L.color_mode),"mode"in L&&e(1,p=L.mode)},s.$$.update=()=>{s.$$.dirty[0]&6&&p==="draw"&&A.set(g),s.$$.dirty[0]&56&&e(10,i=F/n[0]*r.child_width*2)},[_,p,g,F,r,n,v,K,O,Tt,i,c,m,b,y,E,T,I,M,P,at,u,d,f,At,mt,rt,lt,St]}class nf extends vy{constructor(t){super(),Sy(this,t,By,ky,Ry,{default_size:21,default_color:22,colors:23,color_mode:0,mode:1},null,[-1,-1])}get default_size(){return this.$$.ctx[21]}set default_size(t){this.$$set({default_size:t}),ks()}get default_color(){return this.$$.ctx[22]}set default_color(t){this.$$set({default_color:t}),ks()}get colors(){return this.$$.ctx[23]}set colors(t){this.$$set({colors:t}),ks()}get color_mode(){return this.$$.ctx[0]}set color_mode(t){this.$$set({color_mode:t}),ks()}get mode(){return this.$$.ctx[1]}set mode(t){this.$$set({mode:t}),ks()}}function Pc(s,t,e,i=0){let r,n;const o=new Hi;let a,h,l,c,u=gu(i,{stiffness:.1,damping:.5}),d=i;u.subscribe(m=>{h&&(d=m,f(l,c,h,!0))});function f(m,g,v,b){o.clear(),b&&(o.beginFill(16777215,d),o.drawRect(0,0,m,g),o.endFill()),o.beginFill(16777215,1),o.drawRect(...v),o.endFill(),s.render(o,{renderTexture:r})}let _=!0,p=!1;return{start:(m,g,v,b=!0,y=!0)=>{_=!1,r=Bt.create({width:m,height:g}),f(m,g,v,b),n=new Ft(r),t.mask=n,l=m,c=g,y&&(a=JSON.parse(JSON.stringify(v)))},continue:(m,g=!0)=>{h=JSON.parse(JSON.stringify(m)),d===.2?f(l,c,h,g):u.set(.2)},undo(){this.start(l,c,a,!1),e.set([a[0]/l,a[1]/c,a[2]/l,a[3]/c]),_=!0},stop(){return p=!0,d},execute(){_?(this.start(l,c,h,!1),e.set([h[0]/l,h[1]/c,h[2]/l,h[3]/c]),_=!0):(p||u.set(0),e.set([h[0]/l,h[1]/c,h[2]/l,h[3]/c]),_=!0)}}}function of(s,t,e,i,r,n){let o=s,a=t;(e.includes("t")||e.includes("b")||e=="c")&&(o=t*i),(e.includes("l")||e.includes("r")||e=="c")&&(a=s/i),a=a||o/i,o=o||a*i,o>r&&(o=r,a=o/i),a>n&&(a=n,o=a*i);let h=0,l=0;return e.includes("r")?h=s-o:e.includes("l")?h=0:h=(s-o)/2,e.includes("b")?l=t-a:e.includes("t")?l=0:l=(t-a)/2,{new_width:o,new_height:a,x_offset:h,y_offset:l}}const{SvelteComponent:Dy,append:Fy,attr:Rr,binding_callbacks:Ly,detach:Ny,element:kc,flush:Ai,init:Oy,insert:Uy,listen:ra,noop:Bc,run_all:Gy,safe_not_equal:Hy,set_style:Dc}=window.__gradio__svelte__internal,{tick:zy,createEventDispatcher:$y}=window.__gradio__svelte__internal;function Xy(s){let t,e,i,r,n,o;return{c(){t=kc("div"),e=kc("div"),Rr(e,"class",i="handle "+s[0]+" "+s[1]+" svelte-1x33xzn"),Rr(t,"class",r="hitbox "+s[1]+" svelte-1x33xzn"),Dc(t,"transform",s[3])},m(a,h){Uy(a,t,h),Fy(t,e),s[12](e),n||(o=[ra(window,"mousemove",s[5]),ra(window,"mouseup",s[6]),ra(t,"mousedown",s[4])],n=!0)}
1172,p(a,[h]){h&3&&i!==(i="handle "+a[0]+" "+a[1]+" svelte-1x33xzn")&&Rr(e,"class",i),h&2&&r!==(r="hitbox "+a[1]+" svelte-1x33xzn")&&Rr(t,"class",r),h&8&&Dc(t,"transform",a[3])},i:Bc,o:Bc,d(a){a&&Ny(t),s[12](null),n=!1,Gy(o)}}}function Vy(s,t,e){let i,{type:r="corner"}=t,{location:n}=t,{x1:o=0}=t,{y1:a=0}=t,{x2:h=0}=t,{y2:l=0}=t,c,u=0,d=0,f=!1;const _=$y();let{dragging:p=!1}=t,m;function g(w){c=m.getBoundingClientRect(),f=!0,e(11,p=!0),["tl","bl","l"].includes(n)&&(d=w.clientX-c.right),["tl","tr","t"].includes(n)&&(u=w.clientY-c.bottom),["tr","r","br"].includes(n)&&(d=w.clientX-c.left),["br","b","bl"].includes(n)&&(u=w.clientY-c.top)}function v(w){if(!f)return;const x=w.clientY-u,T=w.clientY-u,I=w.clientX-d,M=w.clientX-d;["tl","bl","l"].includes(n)&&e(7,o=I),["tl","tr","t"].includes(n)&&e(8,a=x),["tr","r","br"].includes(n)&&e(9,h=M),["br","b","bl"].includes(n)&&e(10,l=T)}async function b(w){await zy(),f=!1,e(11,p=!1)}function y(w,x,T,I,M){let P,k,A,S;return c&&(["tl","l","bl"].includes(w)&&(k=x),["tl","t","tr"].includes(w)&&(P=I),["tr","r","br"].includes(w)&&(A=T),["br","b","bl"].includes(w)&&(S=M)),_("change",{top:P,bottom:S,left:k,right:A}),""}function E(w){Ly[w?"unshift":"push"](()=>{m=w,e(2,m)})}return s.$$set=w=>{"type"in w&&e(0,r=w.type),"location"in w&&e(1,n=w.location),"x1"in w&&e(7,o=w.x1),"y1"in w&&e(8,a=w.y1),"x2"in w&&e(9,h=w.x2),"y2"in w&&e(10,l=w.y2),"dragging"in w&&e(11,p=w.dragging)},s.$$.update=()=>{s.$$.dirty&1922&&e(3,i=y(n,o,h,a,l))},[r,n,m,i,g,v,b,o,a,h,l,p,E]}class Wy extends Dy{constructor(t){super(),Oy(this,t,Vy,Xy,Hy,{type:0,location:1,x1:7,y1:8,x2:9,y2:10,dragging:11})}get type(){return this.$$.ctx[0]}set type(t){this.$$set({type:t}),Ai()}get location(){return this.$$.ctx[1]}set location(t){this.$$set({location:t}),Ai()}get x1(){return this.$$.ctx[7]}set x1(t){this.$$set({x1:t}),Ai()}get y1(){return this.$$.ctx[8]}set y1(t){this.$$set({y1:t}),Ai()}get x2(){return this.$$.ctx[9]}set x2(t){this.$$set({x2:t}),Ai()}get y2(){return this.$$.ctx[10]}set y2(t){this.$$set({y2:t}),Ai()}get dragging(){return this.$$.ctx[11]}set dragging(t){this.$$set({dragging:t}),Ai()}}const{SvelteComponent:jy,add_flush_callback:Yy,append:na,attr:Yr,bind:qy,binding_callbacks:Zy,check_outros:Ky,create_component:Jy,destroy_component:Qy,destroy_each:Fc,detach:af,element:qr,ensure_array_like:oa,flush:Ki,group_outros:tx,init:ex,insert:hf,listen:aa,mount_component:ix,noop:lf,run_all:sx,safe_not_equal:rx,set_style:Je,space:nx,subscribe:ox,toggle_class:Lc,transition_in:Zr,transition_out:nh}=window.__gradio__svelte__internal,{createEventDispatcher:ax}=window.__gradio__svelte__internal;function hx(s,t,e){const i=s.slice();return i[30]=t[e],i}function Nc(s,t,e){const i=s.slice();return i[33]=t[e],i}function Oc(s){let t,e,i;function r(a){s[20](a)}function n(...a){return s[21](s[33],...a)}let o={location:s[33]};return s[1]!==void 0&&(o.dragging=s[1]),t=new Wy({props:o}),Zy.push(()=>qy(t,"dragging",r)),t.$on("change",n),{c(){Jy(t.$$.fragment)},m(a,h){ix(t,a,h),i=!0},p(a,h){s=a;const l={};!e&&h[0]&2&&(e=!0,l.dragging=s[1],Yy(()=>e=!1)),t.$set(l)},i(a){i||(Zr(t.$$.fragment,a),i=!0)},o(a){nh(t.$$.fragment,a),i=!1},d(a){Qy(t,a)}}}function lx(s){let t;return{c(){t=qr("div"),Yr(t,"class","svelte-12y7ld0")},m(e,i){hf(e,t,i)},p:lf,d(e){e&&af(t)}}}function cx(s){let t,e,i,r,n=`${s[3]}px`,o=`${s[2]}px`,a=`${s[4]}px`,h=`${s[5]}px`,l,c,u,d=oa(s[7]),f=[];for(let g=0;g<d.length;g+=1)f[g]=Oc(Nc(s,d,g));const _=g=>nh(f[g],1,1,()=>{f[g]=null});let p=oa({length:25}),m=[];for(let g=0;g<p.length;g+=1)m[g]=lx(hx(s,p,g));return{c(){t=qr("div"),e=qr("div");for(let g=0;g<f.length;g+=1)f[g].c();i=nx(),r=qr("div");for(let g=0;g<m.length;g+=1)m[g].c();Yr(r,"class","grid svelte-12y7ld0"),Lc(r,"finished",s[6]),Yr(e,"class","box svelte-12y7ld0"),Je(e,"width",n),Je(e,"height",o),Je(e,"top",a),Je(e,"left",h),Yr(t,"class","wrap svelte-12y7ld0")},m(g,v){hf(g,t,v),na(t,e);for(let b=0;b<f.length;b+=1)f[b]&&f[b].m(e,null);na(e,i),na(e,r);for(let b=0;b<m.length;b+=1)m[b]&&m[b].m(r,null);l=!0,c||(u=[aa(window,"mousemove",s[11]),aa(window,"mouseup",s[10]),aa(r,"mousedown",s[9])],c=!0)},p(g,v){if(v[0]&386){d=oa(g[7]);let b;for(b=0;b<d.length;b+=1){const y=Nc(g,d,b);f[b]?(f[b].p(y,v),Zr(f[b],1)):(f[b]=Oc(y),f[b].c(),Zr(f[b],1),f[b].m(e,i))}for(tx(),b=d.length;b<f.length;b+=1)_(b);Ky()}(!l||v[0]&64)&&Lc(r,"finished",g[6]),v[0]&8&&n!==(n=`${g[3]}px`)&&Je(e,"width",n),v[0]&4&&o!==(o=`${g[2]}px`)&&Je(e,"height",o),v[0]&16&&a!==(a=`${g[4]}px`)&&Je(e,"top",a),v[0]&32&&h!==(h=`${g[5]}px`)&&Je(e,"left",h)},i(g){if(!l){for(let v=0;v<d.length;v+=1)Zr(f[v]);l=!0}},o(g){f=f.filter(Boolean);for(let v=0;v<f.length;v+=1)nh(f[v]);l=!1},d(g){g&&af(t),Fc(f,g),Fc(m,g),c=!1,sx(u)}}}function ux(s,t,e){let i,r=lf,n=()=>(r(),r=ox(o,R=>e(19,i=R)),o);s.$$.on_destroy.push(()=>r());let{editor_box:o}=t;n();let{crop_constraint:a}=t;const h=ax();let l=i.child_height,c=i.child_width,u=i.child_top-i.parent_top,d=i.child_left-i.parent_left,f=i.child_right-i.parent_left,_=0,p=!1,{w_p:m}=t,{h_p:g}=t,{l_p:v}=t,{t_p:b}=t;const y=["tl","br","tr","bl","t","b","l","r"];let E,w,x=!1;function T(){w&&clearTimeout(w),e(17,w=setTimeout(()=>{x&&(h("crop_end",{x:v,y:b,width:m,height:g}),x=!1),e(6,E=!0),e(18,A=!1)},1e3))}function I({top:R,bottom:C,left:K,right:it},O){e(4,u=Ut(R?R-i.parent_top:u,i.child_top-i.parent_top,i.child_bottom-i.parent_top)),e(5,d=Ut(K?K-i.parent_left:d,i.child_left-i.parent_left,i.child_right-i.parent_left)),f=Ut(it?it-i.parent_left:f,i.child_left-i.parent_left,i.child_right-i.parent_left),_=Ut(C?C-i.parent_top:_,i.child_top-i.parent_top,i.child_bottom-i.parent_top),e(3,c=Ut(it?it-d-i.parent_left:c,0,f-d)),e(3,c=Ut(K?f-K+i.parent_left:c,0,f-d)),e(2,l=Ut(C?C-u-i.parent_top:l,0,_-u)),e(2,l=Ut(R?_-R+i.parent_top:l,0,_-u));const pt={tl:"br",tr:"bl",bl:"tr",br:"tl",t:"b",b:"t",l:"r",r:"l",c:"c"};if(a){const Tt=["t","b"].includes(O)?i.child_width:f-d,U=["l","r"].includes(O)?i.child_height:_-u;let at=of(c,l,pt[O],a,Tt,U);e(3,c=at.new_width),e(2,l=at.new_height),e(5,d=d+at.x_offset),e(4,u=u+at.y_offset),f=d+c,_=u+l}e(12,m=c/i.child_width),e(13,g=l/i.child_height),e(14,v=(d-i.child_left+i.parent_left)/i.child_width),e(15,b=(u-i.child_top+i.parent_top)/i.child_height),h(x?"crop_continue":"crop_start",{x:v,y:b,width:m,height:g}),x=!0}function M(){e(3,c=m*i.child_width),e(2,l=g*i.child_height),e(5,d=v*i.child_width+(i.child_left-i.parent_left)),e(4,u=b*i.child_height+(i.child_top-i.parent_top)),f=d+c,_=u+l}let P=0,k=0,A=!1;function S(R){e(18,A=!0),P=R.clientX,k=R.clientY,E&&(e(6,E=!1),h("crop_start",{x:v,y:b,width:m,height:g}))}function X(R){A&&e(18,A=!1)}function q(R){if(!A)return;const C=R.clientX-P,K=R.clientY-k;
1172e(5,d=Ut(d+C,i.child_left-i.parent_left,i.child_right-i.parent_left-c)),e(4,u=Ut(u+K,i.child_top-i.parent_top,i.child_bottom-i.parent_top-l)),f=d+c,_=u+l,e(14,v=(d-i.child_left+i.parent_left)/i.child_width),e(15,b=(u-i.child_top+i.parent_top)/i.child_height),P=R.clientX,k=R.clientY,h("crop_continue",{x:v,y:b,width:m,height:g}),x=!0}function F(R){p=R,e(1,p)}const tt=(R,{detail:C})=>I(C,R);return s.$$set=R=>{"editor_box"in R&&n(e(0,o=R.editor_box)),"crop_constraint"in R&&e(16,a=R.crop_constraint),"w_p"in R&&e(12,m=R.w_p),"h_p"in R&&e(13,g=R.h_p),"l_p"in R&&e(14,v=R.l_p),"t_p"in R&&e(15,b=R.t_p)},s.$$.update=()=>{s.$$.dirty[0]&393218&&(p||A?(clearTimeout(w),e(6,E=!1)):T()),s.$$.dirty[0]&524288&&i&&M()},[o,p,l,c,u,d,E,y,I,S,X,q,m,g,v,b,a,w,A,i,F,tt]}class dx extends jy{constructor(t){super(),ex(this,t,ux,cx,rx,{editor_box:0,crop_constraint:16,w_p:12,h_p:13,l_p:14,t_p:15},null,[-1,-1])}get editor_box(){return this.$$.ctx[0]}set editor_box(t){this.$$set({editor_box:t}),Ki()}get crop_constraint(){return this.$$.ctx[16]}set crop_constraint(t){this.$$set({crop_constraint:t}),Ki()}get w_p(){return this.$$.ctx[12]}set w_p(t){this.$$set({w_p:t}),Ki()}get h_p(){return this.$$.ctx[13]}set h_p(t){this.$$set({h_p:t}),Ki()}get l_p(){return this.$$.ctx[14]}set l_p(t){this.$$set({l_p:t}),Ki()}get t_p(){return this.$$.ctx[15]}set t_p(t){this.$$set({t_p:t}),Ki()}}const{SvelteComponent:fx,check_outros:_x,component_subscribe:Ji,create_component:px,destroy_component:mx,detach:gx,empty:bx,flush:vx,group_outros:yx,init:xx,insert:wx,mount_component:Tx,safe_not_equal:Ex,transition_in:Kr,transition_out:oh}=window.__gradio__svelte__internal,{getContext:Uc,onDestroy:GT,onMount:Ax,tick:HT}=window.__gradio__svelte__internal;function Gc(s){let t,e;return t=new dx({props:{crop_constraint:s[0],w_p:s[1],h_p:s[2],l_p:s[3],t_p:s[4],editor_box:s[9]}}),t.$on("crop_start",s[20]),t.$on("crop_continue",s[21]),t.$on("crop_end",s[22]),{c(){px(t.$$.fragment)},m(i,r){Tx(t,i,r),e=!0},p(i,r){const n={};r[0]&1&&(n.crop_constraint=i[0]),r[0]&2&&(n.w_p=i[1]),r[0]&4&&(n.h_p=i[2]),r[0]&8&&(n.l_p=i[3]),r[0]&16&&(n.t_p=i[4]),t.$set(n)},i(i){e||(Kr(t.$$.fragment,i),e=!0)},o(i){oh(t.$$.fragment,i),e=!1},d(i){mx(t,i)}}}function Sx(s){let t,e,i=s[5]==="crop"&&s[6]&&Gc(s);return{c(){i&&i.c(),t=bx()},m(r,n){i&&i.m(r,n),wx(r,t,n),e=!0},p(r,n){r[5]==="crop"&&r[6]?i?(i.p(r,n),n[0]&96&&Kr(i,1)):(i=Gc(r),i.c(),Kr(i,1),i.m(t.parentNode,t)):i&&(yx(),oh(i,1,1,()=>{i=null}),_x())},i(r){e||(Kr(i),e=!0)},o(r){oh(i),e=!1},d(r){r&&gx(t),i&&i.d(r)}}}function Cx(s,t,e){let i,r,n,o,a,h;const{active_tool:l,register_tool:c}=Uc(kn);Ji(s,l,R=>e(5,h=R));const{dimensions:u,editor_box:d,pixi:f,crop:_,command_manager:p,current_history:m}=Uc(As);Ji(s,u,R=>e(18,n=R)),Ji(s,d,R=>e(16,i=R)),Ji(s,f,R=>e(19,o=R)),Ji(s,_,R=>e(17,r=R)),Ji(s,m,R=>e(27,a=R));let g,{crop_constraint:v}=t,b=null,y=1,E=1,w=0,x=0,T=0,I=!1,M=null;async function P(){if(M||a.previous)return;const{new_height:R,new_width:C,x_offset:K,y_offset:it}=of(i.child_width,i.child_height,"c",b,i.child_width,i.child_height);e(1,y=C/i.child_width),e(2,E=R/i.child_height),e(3,w=K/i.child_width),e(4,x=it/i.child_height),M=Pc(o.renderer,o.mask_container,_,.2),M.start(...n,X,!1),M.continue([w*n[0],x*n[1],y*n[0],E*n[1]],!1),M.stop(),M.execute(),M=null,T=0}function k(R,{x:C,y:K,width:it,height:O}){if(o){if(R==="start")g&&(T=g.stop(),g=null),g=Pc(o?.renderer,o.mask_container,_,T),g.start(...n,X);else if(R==="continue"){if(!g)return;g.continue([C*n[0],K*n[1],it*n[0],O*n[1]])}else if(R==="stop"){if(!g)return;p.execute(g)}e(15,I=!0)}}let A=!1;function S(){if(A||!i.child_height)return;const R=i.child_height,C=i.child_width,K=i.child_top-i.parent_top,it=i.child_left-i.parent_left;e(1,y=C/i.child_width),e(2,E=R/i.child_height),e(3,w=(it-i.child_left+i.parent_left)/i.child_width),e(4,x=(K-i.child_top+i.parent_top)/i.child_height),e(6,A=!0)}let X;Ax(()=>c("crop"));const q=({detail:R})=>k("start",R),F=({detail:R})=>k("continue",R),tt=({detail:R})=>k("stop",R);return s.$$set=R=>{"crop_constraint"in R&&e(14,v=R.crop_constraint)},s.$$.update=()=>{if(s.$$.dirty[0]&16384)if(typeof v=="string"){const[R,C]=v.split(":");e(0,b=parseInt(R)/parseInt(C))}else Array.isArray(v)&&e(0,b=v[0]/v[1]);s.$$.dirty[0]&557089&&!I&&b&&o&&h&&requestAnimationFrame(()=>{P()}),s.$$.dirty[0]&131072&&(e(3,w=r[0]),e(4,x=r[1]),e(1,y=r[2]),e(2,E=r[3])),s.$$.dirty[0]&262174&&(X=[w*n[0],x*n[1],y*n[0],E*n[1]]),s.$$.dirty[0]&65536&&i&&S()},[b,y,E,w,x,h,A,l,u,d,f,_,m,k,v,I,i,r,n,o,q,F,tt]}class Ix extends fx{constructor(t){super(),xx(this,t,Cx,Sx,Ex,{crop_constraint:14},null,[-1,-1])}get crop_constraint(){return this.$$.ctx[14]}set crop_constraint(t){this.$$set({crop_constraint:t}),vx()}}function Rx(s,t,e,i){let r;return{async start(){s.removeChildren();const n=await createImageBitmap(e),o=V.from(n);return r=new Ft(o),[r.width,r.height]},async execute(){i(r.width,r.height),r.zIndex=0,s.addChild(r)}
1172,undo(){s.removeChildAt(0)}}}function Mx(s,t,e,i,r,n){let o;return{start(){s.removeChildren();const a=qd(1),h=Bt.create({width:i,height:r});return a.beginFill(new nt(e)),a.drawRect(0,0,i,r),a.endFill(),t.render(a,{renderTexture:h}),o=new Ft(h),[o.width,o.height]},async execute(){n(o.width,o.height),o.zIndex=1,s.addChild(o)},undo(){s.removeChildren()}}}const{SvelteComponent:Px,append:Jr,attr:Xs,binding_callbacks:kx,bubble:ha,check_outros:ah,component_subscribe:Mr,create_component:Ah,destroy_component:Sh,detach:ps,element:Vs,empty:cf,ensure_array_like:Hc,flush:Oe,group_outros:hh,init:Bx,insert:ms,is_function:Dx,listen:Fx,mount_component:Ch,outro_and_destroy_block:Lx,safe_not_equal:Nx,set_store_value:Bs,set_style:Qi,space:la,transition_in:Ce,transition_out:ai,update_keyed_each:Ox}=window.__gradio__svelte__internal,{getContext:zc,onMount:zT,tick:Ux,createEventDispatcher:Gx}=window.__gradio__svelte__internal;function $c(s,t,e){const i=s.slice();return i[34]=t[e].icon,i[35]=t[e].label,i[36]=t[e].id,i[37]=t[e].cb,i}function Xc(s){let t,e=[],i=new Map,r,n,o,a,h,l,c,u=Hc(s[8]);const d=p=>p[36];for(let p=0;p<u.length;p+=1){let m=$c(s,u,p),g=d(m);i.set(g,e[p]=Vc(g,m))}let f={hidden:!0,filetype:"image/*",root:s[1],disable_click:!s[2].includes("upload"),format:"blob",upload:s[5],stream_handler:s[6]};h=new Pf({props:f}),s[19](h),h.$on("load",s[14]),h.$on("error",s[20]);let _=s[0]==="webcam"&&Wc(s);return{c(){t=Vs("div");for(let p=0;p<e.length;p+=1)e[p].c();r=la(),n=Vs("span"),o=la(),a=Vs("div"),Ah(h.$$.fragment),l=la(),_&&_.c(),Xs(n,"class","sep svelte-14kbe6e"),Xs(t,"class","source-wrap svelte-14kbe6e"),Xs(a,"class","upload-container")},m(p,m){ms(p,t,m);for(let g=0;g<e.length;g+=1)e[g]&&e[g].m(t,null);Jr(t,r),Jr(t,n),ms(p,o,m),ms(p,a,m),Ch(h,a,null),Jr(a,l),_&&_.m(a,null),c=!0},p(p,m){m[0]&256&&(u=Hc(p[8]),hh(),e=Ox(e,m,d,1,p,u,i,t,Lx,Vc,r,$c),ah());const g={};m[0]&2&&(g.root=p[1]),m[0]&4&&(g.disable_click=!p[2].includes("upload")),m[0]&32&&(g.upload=p[5]),m[0]&64&&(g.stream_handler=p[6]),h.$set(g),p[0]==="webcam"?_?(_.p(p,m),m[0]&1&&Ce(_,1)):(_=Wc(p),_.c(),Ce(_,1),_.m(a,null)):_&&(hh(),ai(_,1,1,()=>{_=null}),ah())},i(p){if(!c){for(let m=0;m<u.length;m+=1)Ce(e[m]);Ce(h.$$.fragment,p),Ce(_),c=!0}},o(p){for(let m=0;m<e.length;m+=1)ai(e[m]);ai(h.$$.fragment,p),ai(_),c=!1},d(p){p&&(ps(t),ps(o),ps(a));for(let m=0;m<e.length;m+=1)e[m].d();s[19](null),Sh(h),_&&_.d()}}}function Vc(s,t){let e,i,r;return i=new cs({props:{Icon:t[34],size:"medium",padded:!1,label:t[35]+" button",hasPopup:!0,transparent:!0}}),i.$on("click",function(){Dx(t[37])&&t[37].apply(this,arguments)}),{key:s,first:null,c(){e=cf(),Ah(i.$$.fragment),this.first=e},m(n,o){ms(n,e,o),Ch(i,n,o),r=!0},p(n,o){t=n;const a={};o[0]&256&&(a.Icon=t[34]),o[0]&256&&(a.label=t[35]+" button"),i.$set(a)},i(n){r||(Ce(i.$$.fragment,n),r=!0)},o(n){ai(i.$$.fragment,n),r=!1},d(n){n&&ps(e),Sh(i,n)}}}function Wc(s){let t,e,i,r=`${s[9].child_width}px`,n=`${s[9].child_height}px`,o=`${s[9].child_top-s[9].parent_top}px`,a;return i=new Cf({props:{upload:s[5],root:s[1],mirror_webcam:s[3],streaming:!1,mode:"image",include_audio:!1,i18n:s[4]}}),i.$on("capture",s[14]),i.$on("error",s[21]),i.$on("drag",s[22]),{c(){t=Vs("div"),e=Vs("div"),Ah(i.$$.fragment),Xs(e,"class","modal-inner svelte-14kbe6e"),Xs(t,"class","modal svelte-14kbe6e"),Qi(t,"max-width",r),Qi(t,"max-height",n),Qi(t,"top",o)},m(h,l){ms(h,t,l),Jr(t,e),Ch(i,e,null),a=!0},p(h,l){const c={};l[0]&32&&(c.upload=h[5]),l[0]&2&&(c.root=h[1]),l[0]&8&&(c.mirror_webcam=h[3]),l[0]&16&&(c.i18n=h[4]),i.$set(c),l[0]&512&&r!==(r=`${h[9].child_width}px`)&&Qi(t,"max-width",r),l[0]&512&&n!==(n=`${h[9].child_height}px`)&&Qi(t,"max-height",n),l[0]&512&&o!==(o=`${h[9].child_top-h[9].parent_top}px`)&&Qi(t,"top",o)},i(h){a||(Ce(i.$$.fragment,h),a=!0)},o(h){ai(i.$$.fragment,h),a=!1},d(h){h&&ps(t),Sh(i)}}}function Hx(s){let t,e,i,r,n=s[2].length&&Xc(s);return{c(){n&&n.c(),t=cf()},m(o,a){n&&n.m(o,a),ms(o,t,a),e=!0,i||(r=Fx(window,"keydown",s[15]),i=!0)},p(o,a){o[2].length?n?(n.p(o,a),a[0]&4&&Ce(n,1)):(n=Xc(o),n.c(),Ce(n,1),n.m(t.parentNode,t)):n&&(hh(),ai(n,1,1,()=>{n=null}),ah())},i(o){e||(Ce(n),e=!0)},o(o){ai(n),e=!1},d(o){o&&ps(t),n&&n.d(o),i=!1,r()}}}function zx(s,t,e){let i,r,n,o,a,{background_file:h}=t,{root:l}=t,{sources:c=["upload","webcam","clipboard"]}=t,{mirror_webcam:u=!0}=t,{i18n:d}=t,{upload:f}=t,{stream_handler:_}=t;const{active_tool:p}=zc(kn);Mr(s,p,C=>e(26,o=C));const{pixi:m,dimensions:g,register_context:v,reset:b,editor_box:y}=zc(As);Mr(s,m,C=>e(25,n=C)),Mr(s,g,C=>e(24,r=C)),Mr(s,y,C=>e(9,a=C));let{active_mode:E=null}=t,w;Gx();const x={upload:{icon:fh,label:"Upload",order:0,id:"bg_upload",cb(){T.open_file_upload(),Bs(p,o="bg",o)}},webcam:{icon:Bf,label:"Webcam",order:1,id:"bg_webcam",cb(){e(0,E="webcam"),Bs(p,o="bg",o)}},clipboard:{icon:kf,label:"Paste",order:2,id:"bg_clipboard",cb(){I(),Bs(p,o=null,o)}}};let T;async function I(){const C=await navigator.clipboard.read();for(let K=0;K<C.length;K++){const it=C[K].types.find(O=>O.startsWith("image/"));if(it){const O=await C[K].getType(it);e(18,w=O||null)}}}function M(C){const K=C.detail;e(18,w=K),e(0,E=null)}let P=!0;async function k(){if(n&&w){const C=Rx(n.background_container,n.renderer,w,n.resize);Bs(g,r=await C.start(),r),P&&b(!1,r),C.execute(),P=!0,await Ux(),e(16,X=!0)}}async function A(C){if(!C||!C.url)return;P=!1;const it=await(await fetch(C.url)).blob();e(18,w=it)}function S(C){C.key==="Escape"&&e(0,E=null)}let{bg:X=!1}=t;v("bg",{init_fn:()=>
1172{if(!n)return;const C=Mx(n.background_container,n.renderer,"black",...r,n.resize);Bs(g,r=C.start(),r),C.execute()},reset_fn:()=>{}});function q(C){kx[C?"unshift":"push"](()=>{T=C,e(7,T)})}function F(C){ha.call(this,s,C)}function tt(C){ha.call(this,s,C)}function R(C){ha.call(this,s,C)}return s.$$set=C=>{"background_file"in C&&e(17,h=C.background_file),"root"in C&&e(1,l=C.root),"sources"in C&&e(2,c=C.sources),"mirror_webcam"in C&&e(3,u=C.mirror_webcam),"i18n"in C&&e(4,d=C.i18n),"upload"in C&&e(5,f=C.upload),"stream_handler"in C&&e(6,_=C.stream_handler),"active_mode"in C&&e(0,E=C.active_mode),"bg"in C&&e(16,X=C.bg)},s.$$.update=()=>{s.$$.dirty[0]&4&&e(8,i=c.map(C=>x[C]).sort((C,K)=>C.order-K.order)),s.$$.dirty[0]&262144&&w&&k(),s.$$.dirty[0]&131072&&A(h)},[E,l,c,u,d,f,_,T,i,a,p,m,g,y,M,S,X,h,w,q,F,tt,R]}class $x extends Px{constructor(t){super(),Bx(this,t,zx,Hx,Nx,{background_file:17,root:1,sources:2,mirror_webcam:3,i18n:4,upload:5,stream_handler:6,active_mode:0,bg:16},null,[-1,-1])}get background_file(){return this.$$.ctx[17]}set background_file(t){this.$$set({background_file:t}),Oe()}get root(){return this.$$.ctx[1]}set root(t){this.$$set({root:t}),Oe()}get sources(){return this.$$.ctx[2]}set sources(t){this.$$set({sources:t}),Oe()}get mirror_webcam(){return this.$$.ctx[3]}set mirror_webcam(t){this.$$set({mirror_webcam:t}),Oe()}get i18n(){return this.$$.ctx[4]}set i18n(t){this.$$set({i18n:t}),Oe()}get upload(){return this.$$.ctx[5]}set upload(t){this.$$set({upload:t}),Oe()}get stream_handler(){return this.$$.ctx[6]}set stream_handler(t){this.$$set({stream_handler:t}),Oe()}get active_mode(){return this.$$.ctx[0]}set active_mode(t){this.$$set({active_mode:t}),Oe()}get bg(){return this.$$.ctx[16]}set bg(t){this.$$set({bg:t}),Oe()}}const{SvelteComponent:Xx,append:Pr,attr:lh,check_outros:Vx,create_component:Qr,destroy_component:tn,detach:uf,element:ch,flush:kr,group_outros:Wx,init:jx,insert:df,mount_component:en,safe_not_equal:Yx,space:ca,transition_in:Bi,transition_out:as}=window.__gradio__svelte__internal,{createEventDispatcher:qx}=window.__gradio__svelte__internal;function jc(s){let t,e,i;return e=new cs({props:{disabled:!s[2],Icon:Rf,label:"Save changes",background:"var(--color-green-500)",color:"#fff"}}),e.$on("click",s[8]),{c(){t=ch("div"),Qr(e.$$.fragment),lh(t,"class","row-wrap save svelte-4lttvb")},m(r,n){df(r,t,n),en(e,t,null),i=!0},p(r,n){const o={};n&4&&(o.disabled=!r[2]),e.$set(o)},i(r){i||(Bi(e.$$.fragment,r),i=!0)},o(r){as(e.$$.fragment,r),i=!1},d(r){r&&uf(t),tn(e)}}}function Zx(s){let t,e,i,r,n,o,a,h,l;i=new cs({props:{disabled:!s[0],Icon:Mf,label:"Undo"}}),i.$on("click",s[5]),n=new cs({props:{disabled:!s[1],Icon:G_,label:"Redo"}}),n.$on("click",s[6]),a=new cs({props:{Icon:Y_,label:"Clear canvas"}}),a.$on("click",s[7]);let c=s[3]&&jc(s);return{c(){t=ch("div"),e=ch("div"),Qr(i.$$.fragment),r=ca(),Qr(n.$$.fragment),o=ca(),Qr(a.$$.fragment),h=ca(),c&&c.c(),lh(e,"class","row-wrap svelte-4lttvb"),lh(t,"class","controls-wrap svelte-4lttvb")},m(u,d){df(u,t,d),Pr(t,e),en(i,e,null),Pr(e,r),en(n,e,null),Pr(e,o),en(a,e,null),Pr(t,h),c&&c.m(t,null),l=!0},p(u,[d]){const f={};d&1&&(f.disabled=!u[0]),i.$set(f);const _={};d&2&&(_.disabled=!u[1]),n.$set(_),u[3]?c?(c.p(u,d),d&8&&Bi(c,1)):(c=jc(u),c.c(),Bi(c,1),c.m(t,null)):c&&(Wx(),as(c,1,1,()=>{c=null}),Vx())},i(u){l||(Bi(i.$$.fragment,u),Bi(n.$$.fragment,u),Bi(a.$$.fragment,u),Bi(c),l=!0)},o(u){as(i.$$.fragment,u),as(n.$$.fragment,u),as(a.$$.fragment,u),as(c),l=!1},d(u){u&&uf(t),tn(i),tn(n),tn(a),c&&c.d()}}}function Kx(s,t,e){let{can_undo:i=!1}=t,{can_redo:r=!1}=t,{can_save:n=!1}=t,{changeable:o=!1}=t;const a=qx(),h=d=>{a("undo"),d.stopPropagation()},l=d=>{a("redo"),d.stopPropagation()},c=d=>{a("remove_image"),d.stopPropagation()},u=d=>{a("save"),d.stopPropagation()};return s.$$set=d=>{"can_undo"in d&&e(0,i=d.can_undo),"can_redo"in d&&e(1,r=d.can_redo),"can_save"in d&&e(2,n=d.can_save),"changeable"in d&&e(3,o=d.changeable)},[i,r,n,o,a,h,l,c,u]}class Jx extends Xx{constructor(t){super(),jx(this,t,Kx,Zx,Yx,{can_undo:0,can_redo:1,can_save:2,changeable:3})}get can_undo(){return this.$$.ctx[0]}set can_undo(t){this.$$set({can_undo:t}
1172),kr()}get can_redo(){return this.$$.ctx[1]}set can_redo(t){this.$$set({can_redo:t}),kr()}get can_save(){return this.$$.ctx[2]}set can_save(t){this.$$set({can_save:t}),kr()}get changeable(){return this.$$.ctx[3]}set changeable(t){this.$$set({changeable:t}),kr()}}const{SvelteComponent:Qx,append:Si,attr:ts,binding_callbacks:Yc,component_subscribe:Jt,create_component:tw,create_slot:ew,destroy_component:iw,detach:sw,element:Ds,flush:Ue,get_all_dirty_from_scope:rw,get_slot_changes:nw,init:ow,insert:aw,listen:hw,mount_component:lw,safe_not_equal:cw,set_store_value:qc,set_style:ye,space:ua,toggle_class:Zc,transition_in:Kc,transition_out:Jc,update_slot_base:uw}=window.__gradio__svelte__internal,{onMount:dw,setContext:fw,createEventDispatcher:_w,tick:pw}=window.__gradio__svelte__internal;function mw(s){let t,e,i,r,n,o=`translate(${s[6].x}px, ${s[6].y}px)`,a,h,l,c,u=`${s[7][2]*s[8].child_width+1}px`,d=`${s[7][3]*s[8].child_height+1}px`,f=`${s[7][1]*s[8].child_height+(s[8].child_top-s[8].parent_top)-.5}px`,_=`${s[7][0]*s[8].child_width+(s[8].child_left-s[8].parent_left)-.5}px`,p,m,g;e=new Jx({props:{can_undo:s[10],can_redo:s[11],can_save:s[9]!==s[5],changeable:s[1]}}),e.$on("undo",s[17].undo),e.$on("redo",s[17].redo),e.$on("remove_image",s[2]),e.$on("save",s[26]);const v=s[38].default,b=ew(v,s,s[37],null);return{c(){t=Ds("div"),tw(e.$$.fragment),i=ua(),r=Ds("div"),n=Ds("div"),a=ua(),h=Ds("div"),b&&b.c(),l=ua(),c=Ds("div"),ts(n,"class","stage-wrap svelte-1sbaaot"),Zc(n,"bg",!s[0]),ye(n,"transform",o),ts(r,"class","wrap svelte-1sbaaot"),ts(h,"class","tools-wrap svelte-1sbaaot"),ts(c,"class","border svelte-1sbaaot"),ye(c,"width",u),ye(c,"height",d),ye(c,"top",f),ye(c,"left",_),ts(t,"data-testid","image"),ts(t,"class","image-container svelte-1sbaaot")},m(y,E){aw(y,t,E),lw(e,t,null),Si(t,i),Si(t,r),Si(r,n),s[40](n),s[41](r),Si(t,a),Si(t,h),b&&b.m(h,null),Si(t,l),Si(t,c),p=!0,m||(g=hw(window,"scroll",s[39]),m=!0)},p(y,E){const w={};E[0]&1024&&(w.can_undo=y[10]),E[0]&2048&&(w.can_redo=y[11]),E[0]&544&&(w.can_save=y[9]!==y[5]),E[0]&2&&(w.changeable=y[1]),e.$set(w),(!p||E[0]&1)&&Zc(n,"bg",!y[0]),E[0]&64&&o!==(o=`translate(${y[6].x}px, ${y[6].y}px)`)&&ye(n,"transform",o),b&&b.p&&(!p||E[1]&64)&&uw(b,v,y,y[37],p?nw(v,y[37],E,null):rw(y[37]),null),E[0]&384&&u!==(u=`${y[7][2]*y[8].child_width+1}px`)&&ye(c,"width",u),E[0]&384&&d!==(d=`${y[7][3]*y[8].child_height+1}px`)&&ye(c,"height",d),E[0]&384&&f!==(f=`${y[7][1]*y[8].child_height+(y[8].child_top-y[8].parent_top)-.5}px`)&&ye(c,"top",f),E[0]&384&&_!==(_=`${y[7][0]*y[8].child_width+(y[8].child_left-y[8].parent_left)-.5}px`)&&ye(c,"left",_)},i(y){p||(Kc(e.$$.fragment,y),Kc(b,y),p=!0)},o(y){Jc(e.$$.fragment,y),Jc(b,y),p=!1},d(y){y&&sw(t),iw(e),s[40](null),s[41](null),b&&b.d(y),m=!1,g()}}}const As=Symbol("editor");function gw(s,t,e){let i,r,n,o,a,h,l,c,u,d,f,_,p,{$$slots:m={},$$scope:g}=t,{antialias:v=!0}=t,{crop_size:b}=t,{changeable:y=!1}=t,{history:E}=t,{bg:w=!1}=t,{sources:x}=t;const T=_w();let{crop_constraint:I=!1}=t,{canvas_size:M}=t,k=Ot(M||[800,600]);Jt(s,k,z=>e(46,l=z));let{height:A=0}=t,S=Ot({parent_width:0,parent_height:0,parent_top:0,parent_left:0,parent_right:0,parent_bottom:0,child_width:0,child_height:0,child_top:0,child_left:0,child_right:0,child_bottom:0});Jt(s,S,z=>e(8,f=z));const X=Ot([0,0,1,1]);Jt(s,X,z=>e(7,d=z));const q=gu({x:0,y:0},{stiffness:.1,damping:.5});Jt(s,q,z=>e(6,u=z));const F=Ot(null);Jt(s,F,z=>e(45,h=z));const tt=sv(),{can_redo:R,can_undo:C,current_history:K}=tt;Jt(s,R,z=>e(11,p=z)),Jt(s,C,z=>e(10,_=z)),Jt(s,K,z=>e(5,n=z));const it=Ot("bg");Jt(s,it,z=>e(36,r=z));const O=Ot({});Jt(s,O,z=>e(43,o=z));const pt=Ot({});Jt(s,pt,z=>e(47,c=z));const Tt=Ot([]);Jt(s,Tt,z=>e(44,a=z));const U=Ot(new DOMRect),at=["bg","layers","crop","draw","erase"],At=fw(As,{pixi:F,current_layer:Ot(null),dimensions:k,editor_box:S,toolbar_box:U,active_tool:it,crop:X,position_spring:q,command_manager:tt,current_history:K,register_context:(z,{reset_fn:Nt,init_fn:zt})=>{Tt.update(ht=>[...ht,z]),pt.update(ht=>({...ht,[z]:zt})),O.update(ht=>({...ht,[z]:Nt}))},reset:(z,Nt)=>{e(0,w=!1);const zt=a.sort((ht,Ct)=>at.indexOf(ht)-at.indexOf(Ct));for(const ht of zt)ht in o&&typeof o[ht]=="function"&&o[ht]?.();for(const ht of zt){if(ht in c&&typeof c[ht]=="function"){if(ht==="bg"&&!z)continue;c[ht]?.(Nt)}tt.reset(),h?.resize?.(...Nt)}}});let mt,rt;function lt(z,Nt){if(!z||!Nt)return;const{width:zt,height:ht,top:Ct,left:yi,right:Zn,bottom:Kn}=rt.getBoundingClientRect(),{width:Jn,height:Qn,top:Tf,left:Ef,right:Af,bottom:Sf}=Nt.getBoundingClientRect();S.set({child_width:Jn,child_height:Qn,child_left:Ef,child_right:Af,child_top:Tf,child_bottom:Sf,parent_width:zt,parent_height:ht,parent_left:yi,parent_right:Zn,parent_top:Ct,parent_bottom:Kn})}function St(){requestAnimationFrame(()=>{pw().then(z=>qc(it,r="crop",r))})}function L(){if(!f)return;const[z,Nt,zt,ht]=d,Ct=z*f.child_width,yi=Nt*f.child_height,Zn=zt*f.child_width,Kn=ht*f.child_height,Jn=.5*f.child_width-Ct-Zn/2,Qn=.5*f.child_height-yi-Kn/2;q.set({x:Jn,y:Qn}
1172)}async function Mt(){if(!h||!h.get_layers)return{background:null,layers:[],composite:null};const[z,Nt,zt,ht]=d;return h?.get_blobs(h.get_layers(),new J(Math.round(z*l[0]),Math.round(Nt*l[1]),Math.round(zt*l[0]),Math.round(ht*l[1])),l)}function Lt(){At.reset(!0,i||l),x.length?D("bg"):D("draw"),T("clear")}dw(()=>{const Nt=iv({target:mt,dimensions:M||b||[800,600],antialias:v});function zt(Ct,yi){Nt.resize(Ct,yi),k.set([Ct,yi])}F.set({...Nt,resize:zt});const ht=new ResizeObserver(Ct=>{for(const yi of Ct)lt(rt,mt)});ht.observe(rt),ht.observe(mt);for(const Ct of a)Ct in c&&typeof c[Ct]=="function"&&c[Ct]?.(l);return zt(...l),()=>{h?.destroy(),ht.disconnect();for(const Ct of a)Ct in o&&o[Ct]?.()}});let Ye=n;function Ss(){e(9,Ye=n),T("save")}function D(z){qc(it,r=z,r)}const qn=()=>lt(rt,mt);function xf(z){Yc[z?"unshift":"push"](()=>{mt=z,e(3,mt)})}function wf(z){Yc[z?"unshift":"push"](()=>{rt=z,e(4,rt)})}return s.$$set=z=>{"antialias"in z&&e(29,v=z.antialias),"crop_size"in z&&e(30,b=z.crop_size),"changeable"in z&&e(1,y=z.changeable),"history"in z&&e(27,E=z.history),"bg"in z&&e(0,w=z.bg),"sources"in z&&e(31,x=z.sources),"crop_constraint"in z&&e(32,I=z.crop_constraint),"canvas_size"in z&&e(33,M=z.canvas_size),"height"in z&&e(28,A=z.height),"$$scope"in z&&e(37,g=z.$$scope)},s.$$.update=()=>{s.$$.dirty[1]&4&&(i=M),s.$$.dirty[0]&256&&e(28,A=f.child_height),s.$$.dirty[0]&32&&(n.previous,T("change")),s.$$.dirty[0]&32|s.$$.dirty[1]&32&&e(27,E=!!n.previous||r!=="bg"),s.$$.dirty[0]&134217729|s.$$.dirty[1]&2&&I&&w&&!E&&St(),s.$$.dirty[0]&128&&d&&L(),s.$$.dirty[0]&88&&u&&lt(rt,mt)},[w,y,Lt,mt,rt,n,u,d,f,Ye,_,p,k,S,X,q,F,tt,R,C,K,it,O,pt,Tt,lt,Ss,E,A,v,b,x,I,M,Mt,D,r,g,m,qn,xf,wf]}class bw extends Qx{constructor(t){super(),ow(this,t,gw,mw,cw,{antialias:29,crop_size:30,changeable:1,history:27,bg:0,sources:31,crop_constraint:32,canvas_size:33,height:28,get_blobs:34,handle_remove:2,set_tool:35},null,[-1,-1])}get antialias(){return this.$$.ctx[29]}set antialias(t){this.$$set({antialias:t}),Ue()}get crop_size(){return this.$$.ctx[30]}set crop_size(t){this.$$set({crop_size:t}),Ue()}get changeable(){return this.$$.ctx[1]}set changeable(t){this.$$set({changeable:t}),Ue()}get history(){return this.$$.ctx[27]}set history(t){this.$$set({history:t}),Ue()}get bg(){return this.$$.ctx[0]}set bg(t){this.$$set({bg:t}),Ue()}get sources(){return this.$$.ctx[31]}set sources(t){this.$$set({sources:t}),Ue()}get crop_constraint(){return this.$$.ctx[32]}set crop_constraint(t){this.$$set({crop_constraint:t}),Ue()}get canvas_size(){return this.$$.ctx[33]}set canvas_size(t){this.$$set({canvas_size:t}),Ue()}get height(){return this.$$.ctx[28]}set height(t){this.$$set({height:t}),Ue()}get get_blobs(){return this.$$.ctx[34]}get handle_remove(){return this.$$.ctx[2]}get set_tool(){return this.$$.ctx[35]}}const{SvelteComponent:vw,action_destroyer:yw,append:jt,attr:fe,check_outros:xw,component_subscribe:da,create_component:ww,destroy_block:Tw,destroy_component:Ew,detach:Wn,element:We,empty:Aw,ensure_array_like:Qc,flush:tu,group_outros:Sw,init:Cw,insert:jn,is_function:Iw,listen:Ih,mount_component:Rw,run_all:Mw,safe_not_equal:Pw,set_data:ff,set_store_value:Br,space:uh,text:Mn,toggle_class:Pn,transition_in:sn,transition_out:dh,update_keyed_each:kw}=window.__gradio__svelte__internal,{getContext:Bw,onMount:Dw,tick:eu}=window.__gradio__svelte__internal;function iu(s,t,e){const i=s.slice();return i[19]=t[e],i[21]=e,i}function su(s){let t,e,i,r,n,o=s[2].findIndex(s[11])+1+"",a,h,l,c,u,d,f,_;r=new A_({});let p=s[1]&&ru(s);return{c(){t=We("div"),e=We("button"),i=We("span"),ww(r.$$.fragment),n=Mn(" Layer "),a=Mn(o),h=uh(),p&&p.c(),l=uh(),c=We("span"),fe(i,"class","icon svelte-wbw3z5"),fe(e,"aria-label","Show Layers"),fe(e,"class","svelte-wbw3z5"),fe(c,"class","sep svelte-wbw3z5"),fe(t,"class","layer-wrap svelte-wbw3z5"),Pn(t,"closed",!s[1])},m(m,g){jn(m,t,g),jt(t,e),jt(e,i),Rw(r,i,null),jt(e,n),jt(e,a),jt(t,h),p&&p.m(t,null),jt(t,l),jt(t,c),d=!0,f||(_=[Ih(e,"click",s[12]),yw(u=Th.call(null,t,s[14]))],f=!0)},p(m,g){(!d||g&12)&&o!==(o=m[2].findIndex(m[11])+1+"")&&ff(a,o),m[1]?p?p.p(m,g):(p=ru(m),p.c(),p.m(t,l)):p&&(p.d(1),p=null),u&&Iw(u.update)&&g&2&&u.update.call(null,m[14]),(!d||g&2)&&Pn(t,"closed",!m[1])},i(m){d||(sn(r.$$.fragment,m),d=!0)},o(m){dh(r.$$.fragment,m),d=!1},d(m){m&&Wn(t),Ew(r),p&&p.d(),f=!1,Mw(_)}}}function ru(s){let t,e=[],i=new Map,r,n,o,a,h,l=Qc(s[2]);const c=u=>u[21];for(let u=0;u<l.length;u+=1){let d=iu(s,l,u),f=c(d);i.set(f,e[u]=nu(f,d))}return{c(){t=We("ul");for(let u=0;u<e.length;u+=1)e[u].c();r=uh(),n=We("li"),o=We("button"),o.textContent="+",fe(o,"aria-label","Add Layer"),fe(o,"class","svelte-wbw3z5"),fe(n,"class","svelte-wbw3z5"),fe(t,"class","svelte-wbw3z5")},m(u,d){jn(u,t,d);for(let f=0;f<e.length;f+=1)e[f]&&e[f].m(t,null);jt(t,r),jt(t,n),jt(n,o),a||(h=Ih(o,"click",s[8]),a=!0)},p(u,d){d&140&&(l=Qc(u[2]),e=kw(e,d,c,1,u,l,i,t,Tw,nu,r,iu))},d(u){u&&Wn(t);for(let d=0;d<e.length;d+=1)e[d].d();a=!1,h()}}}function nu(s,t){let e,i,r,n=t[21]+1+"",o,a,h;function l(){return t[13](t[21])}return{key:s,first:null,c(){e=We("li"),i=We("button"),r=Mn("Layer "),o=Mn(n),fe(i,"class","svelte-wbw3z5"),Pn(i,"selected_layer",t[3]===t[19]),fe(e,"class","svelte-wbw3z5"),this.first=e},m(c,u){jn(c,e,u),jt(e,i),jt(i,r),jt(i,o),a||(h=Ih(i,"click",l),a=!0)},p(c,u){t=c,u&4&&n!==(n=t[21]+1+"")&&ff(o,n),u&12&&Pn(i,"selected_layer",t[3]===t[19])},d(c){c&&Wn(e),a=!1,h()}}}function Fw(s){let t,e,i=s[0]&&su(s);return{c(){i&&i.c(),t=Aw()},m(r,n){i&&i.m(r,n),jn(r,t,n),e=!0},p(r,[n]){r[0]?i?(i.p(r,n),n&1&&sn(i,1)):(i=su(r),i.c(),sn(i,1),i.m(t.parentNode,t)):i&&(Sw(),dh(i,1,1,()=>{i=null}),xw())},i(r){e||(sn(i),e=!0)},o(r){dh(i),e=!1},d(r){r&&Wn(t),i&&i.d(r)}}}function Lw(s){return s!==null}function Nw(s,t,e){let i,r,n,o=!1,{layer_files:a=[]}=t,{enable_layers:h=!0}=t;const{pixi:l,current_layer:c,dimensions:u,register_context:d}=Bw(As);da(s,l,w=>e(15,i=w)),da(s,c,w=>e(3,r=w)),da(s,u,w=>e(10,n=w));const f=tv();let _=[];d("layers",{init_fn:()=>{m()},reset_fn:()=>{f.reset()}});async function p(){_.some(x=>x.composite.texture?.width!=n[0]||x.composite.texture?.height!=n[1])&&(f.reset(),!a||a.length==0?m():g(a))}async function m(){if(!i)return;const[w,x]=f.add_layer(i.layer_container,i.renderer,...n);Br(c,r=w,r),e(2,_=x)}async function g(w){if(await eu(),!w||w.length==0){f.reset(),m();return}if(!i)return;const x=await Promise.all(w.map(M=>!M||!M.url?null:fetch(M.url))),T=await Promise.all(x.map(M=>M?M.blob():null));f.reset();let I=null;for(const M of T.filter(Lw))I=await f.add_layer_from_blob(i.layer_container,i.renderer,M,i.view);I&&(Br(c,r=I[0],r),e(2,_=I[1]))}Dw(async()=>{await eu(),i&&Br(l,i={...i,get_layers:f.get_layers},i)});const v=w=>w===r,b=()=>e(1,o=!o),y=w=>Br(c,r=f.change_active_layer(w),r),E=()=>e(1,o=!1);return s.$$set=w=>{"layer_files"in w&&e(9,a=w.layer_files),"enable_layers"in w&&e(0,h=w.enable_layers)},s.$$.update=()=>{s.$$.dirty&1024&&p(),s.$$.dirty&512&&g(a)},[h,o,_,r,l,c,u,f,m,a,n,v,b,y,E]}class Ow extends vw{constructor(t){super(),Cw(this,t,Nw,Fw,Pw,{layer_files:9,enable_layers:0})}get layer_files(){return this.$$.ctx[9]}set layer_files(t){this.$$set({layer_files:t}),tu()}get enable_layers(){return this.$$.ctx[0]}set enable_layers(t){this.$$set({enable_layers:t}),tu()}}const{SvelteComponent:Uw,add_flush_callback:Ws,append:ou,attr:_f,bind:js,binding_callbacks:gs,bubble:Gw,check_outros:fa,create_component:_i,destroy_component:pi,detach:te,element:Yn,empty:pf,flush:yt,group_outros:_a,init:Hw,insert:ee,mount_component:mi,safe_not_equal:zw,set_style:au,space:hi,transition_in:It,transition_out:Gt}=window.__gradio__svelte__internal,{createEventDispatcher:$w}=window.__gradio__svelte__internal;function hu(s){let t,e;return t=new Ix({props:{crop_constraint:s[21]}}),{c(){_i(t.$$.fragment)},m(i,r){mi(t,i,r),e=!0},p(i,r){const n={};r[0]&2097152&&(n.crop_constraint=i[21]),t.$set(n)},i(i){e||(It(t.$$.fragment,i),e=!0)},o(i){Gt(t.$$.fragment,i),e=!1},d(i){pi(t,i)}}}function lu(s){let t,e;return t=new nf({props:{color_mode:s[0].color_mode,default_color:s[0].default_color,default_size:s[0].default_size,colors:s[0].colors,mode:"draw"}}),{c(){_i(t.$$.fragment)},m(i,r){mi(t,i,r),e=!0},p(i,r){const n={};r[0]&1&&(n.color_mode=i[0].color_mode),r[0]&1&&(n.default_color=i[0].default_color),r[0]&1&&(n.default_size=i[0].default_size),r[0]&1&&(n.colors=i[0].colors),t.$set(n)},i(i){e||(It(t.$$.fragment,i),e=!0)},o(i){Gt(t.$$.fragment,i),e=!1},d(i){pi(t,i)}}}function cu(s){let t,e;return t=new nf({props:{default_size:s[1].default_size,mode:"erase"}}),{c(){_i(t.$$.fragment)},m(i,r){mi(t,i,r),e=!0},p(i,r){const n={};r[0]&2&&(n.default_size=i[1].default_size),t.$set(n)},i(i){e||(It(t.$$.fragment,i),e=!0)},o(i){Gt(t.$$.fragment,i),e=!1},d(i){pi(t,i)}}}function Xw(s){let t,e,i,r,n,o,a=s[10].includes("crop"),h,l,c,u;t=new Ow({props:{layer_files:s[9]?.layers||null,enable_layers:s[11]}});function d(v){s[28](v)}function f(v){s[29](v)}let _={i18n:s[4],root:s[5],sources:s[2],upload:s[14],stream_handler:s[15],background_file:s[9]?.background||s[9]?.composite||null};s[17]!==void 0&&(_.bg=s[17]),s[19]!==void 0&&(_.active_mode=s[19]),i=new $x({props:_}),gs.push(()=>js(i,"bg",d)),gs.push(()=>js(i,"active_mode",f));let p=a&&hu(s),m=s[0]&&lu(s),g=s[0]&&s[1]&&cu(s);return{c(){_i(t.$$.fragment),e=hi(),_i(i.$$.fragment),o=hi(),p&&p.c(),h=hi(),m&&m.c(),l=hi(),g&&g.c(),c=pf()},m(v,b){mi(t,v,b),ee(v,e,b),mi(i,v,b),ee(v,o,b),p&&p.m(v,b),ee(v,h,b),m&&m.m(v,b),ee(v,l,b),g&&g.m
1172(v,b),ee(v,c,b),u=!0},p(v,b){const y={};b[0]&512&&(y.layer_files=v[9]?.layers||null),b[0]&2048&&(y.enable_layers=v[11]),t.$set(y);const E={};b[0]&16&&(E.i18n=v[4]),b[0]&32&&(E.root=v[5]),b[0]&4&&(E.sources=v[2]),b[0]&16384&&(E.upload=v[14]),b[0]&32768&&(E.stream_handler=v[15]),b[0]&512&&(E.background_file=v[9]?.background||v[9]?.composite||null),!r&&b[0]&131072&&(r=!0,E.bg=v[17],Ws(()=>r=!1)),!n&&b[0]&524288&&(n=!0,E.active_mode=v[19],Ws(()=>n=!1)),i.$set(E),b[0]&1024&&(a=v[10].includes("crop")),a?p?(p.p(v,b),b[0]&1024&&It(p,1)):(p=hu(v),p.c(),It(p,1),p.m(h.parentNode,h)):p&&(_a(),Gt(p,1,1,()=>{p=null}),fa()),v[0]?m?(m.p(v,b),b[0]&1&&It(m,1)):(m=lu(v),m.c(),It(m,1),m.m(l.parentNode,l)):m&&(_a(),Gt(m,1,1,()=>{m=null}),fa()),v[0]&&v[1]?g?(g.p(v,b),b[0]&3&&It(g,1)):(g=cu(v),g.c(),It(g,1),g.m(c.parentNode,c)):g&&(_a(),Gt(g,1,1,()=>{g=null}),fa())},i(v){u||(It(t.$$.fragment,v),It(i.$$.fragment,v),It(p),It(m),It(g),u=!0)},o(v){Gt(t.$$.fragment,v),Gt(i.$$.fragment,v),Gt(p),Gt(m),Gt(g),u=!1},d(v){v&&(te(e),te(o),te(h),te(l),te(c)),pi(t,v),pi(i,v),p&&p.d(v),m&&m.d(v),g&&g.d(v)}}}function uu(s){let t,e,i,r=s[2]&&s[2].length&&du(),n=s[2]&&s[2].length&&s[0]&&fu(),o=s[0]&&_u();return{c(){t=Yn("div"),r&&r.c(),e=hi(),n&&n.c(),i=hi(),o&&o.c(),_f(t,"class","empty wrap svelte-af64j7"),au(t,"height",`${s[20]}px`)},m(a,h){ee(a,t,h),r&&r.m(t,null),ou(t,e),n&&n.m(t,null),ou(t,i),o&&o.m(t,null)},p(a,h){a[2]&&a[2].length?r||(r=du(),r.c(),r.m(t,e)):r&&(r.d(1),r=null),a[2]&&a[2].length&&a[0]?n||(n=fu(),n.c(),n.m(t,i)):n&&(n.d(1),n=null),a[0]?o||(o=_u(),o.c(),o.m(t,null)):o&&(o.d(1),o=null),h[0]&1048576&&au(t,"height",`${a[20]}px`)},d(a){a&&te(t),r&&r.d(),n&&n.d(),o&&o.d()}}}function du(s){let t;return{c(){t=Yn("div"),t.textContent="Upload an image"},m(e,i){ee(e,t,i)},d(e){e&&te(t)}}}function fu(s){let t;return{c(){t=Yn("div"),t.textContent="or",_f(t,"class","or svelte-af64j7")},m(e,i){ee(e,t,i)},d(e){e&&te(t)}}}function _u(s){let t;return{c(){t=Yn("div"),t.textContent="select the draw tool to start"},m(e,i){ee(e,t,i)},d(e){e&&te(t)}}}function Vw(s){let t,e,i,r;t=new Fp({props:{i18n:s[4],$$slots:{default:[Xw]},$$scope:{ctx:s}}});let n=!s[17]&&!s[18]&&s[19]!=="webcam"&&s[12]!=="error"&&uu(s);return{c(){_i(t.$$.fragment),e=hi(),n&&n.c(),i=pf()},m(o,a){mi(t,o,a),ee(o,e,a),n&&n.m(o,a),ee(o,i,a),r=!0},p(o,a){const h={};a[0]&16&&(h.i18n=o[4]),a[0]&2805303|a[1]&256&&(h.$$scope={dirty:a,ctx:o}),t.$set(h),!o[17]&&!o[18]&&o[19]!=="webcam"&&o[12]!=="error"?n?n.p(o,a):(n=uu(o),n.c(),n.m(i.parentNode,i)):n&&(n.d(1),n=null)},i(o){r||(It(t.$$.fragment,o),r=!0)},o(o){Gt(t.$$.fragment,o),r=!1},d(o){o&&(te(e),te(i)),pi(t,o),n&&n.d(o)}}}function Ww(s){let t,e,i,r,n,o,a;t=new Df({props:{show_label:s[7],Icon:fh,label:s[6]||s[4]("image.image")}});function h(d){s[31](d)}function l(d){s[32](d)}function c(d){s[33](d)}let u={canvas_size:s[13],crop_size:Array.isArray(s[3])?s[3]:void 0,changeable:s[8],sources:s[2],crop_constraint:!!s[21],$$slots:{default:[Vw]},$$scope:{ctx:s}};return s[20]!==void 0&&(u.height=s[20]),s[18]!==void 0&&(u.history=s[18]),s[17]!==void 0&&(u.bg=s[17]),i=new bw({props:u}),s[30](i),gs.push(()=>js(i,"height",h)),gs.push(()=>js(i,"history",l)),gs.push(()=>js(i,"bg",c)),i.$on("save",s[34]),i.$on("change",s[23]),i.$on("clear",s[35]),{c(){_i(t.$$.fragment),e=hi(),_i(i.$$.fragment)},m(d,f){mi(t,d,f),ee(d,e,f),mi(i,d,f),a=!0},p(d,f){const _={};f[0]&128&&(_.show_label=d[7]),f[0]&80&&(_.label=d[6]||d[4]("image.image")),t.$set(_);const p={};f[0]&8192&&(p.canvas_size=d[13]),f[0]&8&&(p.crop_size=Array.isArray(d[3])?d[3]:void 0),f[0]&256&&(p.changeable=d[8]),f[0]&4&&(p.sources=d[2]),f[0]&2097152&&(p.crop_constraint=!!d[21]),f[0]&4120119|f[1]&256&&(p.$$scope={dirty:f,ctx:d}),!r&&f[0]&1048576&&(r=!0,p.height=d[20],Ws(()=>r=!1)),!n&&f[0]&262144&&(n=!0,p.history=d[18],Ws(()=>n=!1)),!o&&f[0]&131072&&(o=!0,p.bg=d[17],Ws(()=>o=!1)),i.$set(p)},i(d){a||(It(t.$$.fragment,d),It(i.$$.fragment,d),a=!0)},o(d){Gt(t.$$.fragment,d),Gt(i.$$.fragment,d),a=!1},d(d){d&&te(e),pi(t,d),s[30](null),pi(i,d)}}}function jw(s){return!!s}function Yw(s){return!!s}function pu(){return new Promise(s=>setTimeout(()=>s(),30))}function qw(s,t,e){let i,{brush:r}=t,{eraser:n}=t,{sources:o}=t,{crop_size:a=null}=t,{i18n:h}=t,{root:l}=t,{label:c=void 0}=t,{show_label:u}=t,{changeable:d=!1}=t,{value:f={background:null,layers:[],composite:null}}=t,{transforms:_=["crop"]}=t,{layers:p}=t,{accept_blobs:m}=t,{status:g="complete"}=t,{canvas_size:v}=t,{realtime:b}=t,{upload:y}=t,{stream_handler:E}=t;const w=$w();let x;async function T(){const U=await x.get_blobs(),at=U.background?y(await to([new File([U.background],"background.png")]),l):Promise.resolve(null),At=U.layers.filter(jw).map(async(L,Mt)=>y(await to([new File([L],`layer_${Mt}.png`)]),l)),mt=U.composite?y(await to([new File([U.composite],"composite.png")]),l):Promise.resolve(null),[rt,lt,...St]=await Promise.all([at,mt,...At]);return{background:Array.isArray(rt)?rt[0]:rt,layers:St.flatMap(L=>Array.isArray(L)?L:[L]).filter(Yw),composite:Array.isArray(lt)?lt[0]:lt}}function I(U){x&&U==null&&x.handle_remove()}let M=!1,P=!1,{image_id:k=null}=t,A=!1,S=!1;async function X(U){if(!b)return;if(A){S=!0;return}A=!0,await pu();const at=await x.get_blobs(),At=[];let mt=Math.random().toString(36).substring(2);at.background&&At.push([mt,"background",new File([at.background],"background.png"),null]),at.composite&&At.push([mt,"composite",new File([at.composite],"composite.png"),null]),at.layers.forEac
1172h((rt,lt)=>{rt&&At.push([mt,"layer",new File([rt],`layer_${lt}.png`),lt])}),await Promise.all(At.map(async([rt,lt,St,L])=>m({binary:!0,data:{file:St,id:rt,type:lt,index:L}}))),e(24,k=mt),w("change"),await pu(),A=!1,S&&(S=!1,A=!1,X())}let q=null,F=0;function tt(U){M=U,e(17,M)}function R(U){q=U,e(19,q)}function C(U){gs[U?"unshift":"push"](()=>{x=U,e(16,x)})}function K(U){F=U,e(20,F)}function it(U){P=U,e(18,P)}function O(U){M=U,e(17,M)}function pt(U){Gw.call(this,s,U)}const Tt=()=>w("clear");return s.$$set=U=>{"brush"in U&&e(0,r=U.brush),"eraser"in U&&e(1,n=U.eraser),"sources"in U&&e(2,o=U.sources),"crop_size"in U&&e(3,a=U.crop_size),"i18n"in U&&e(4,h=U.i18n),"root"in U&&e(5,l=U.root),"label"in U&&e(6,c=U.label),"show_label"in U&&e(7,u=U.show_label),"changeable"in U&&e(8,d=U.changeable),"value"in U&&e(9,f=U.value),"transforms"in U&&e(10,_=U.transforms),"layers"in U&&e(11,p=U.layers),"accept_blobs"in U&&e(25,m=U.accept_blobs),"status"in U&&e(12,g=U.status),"canvas_size"in U&&e(13,v=U.canvas_size),"realtime"in U&&e(26,b=U.realtime),"upload"in U&&e(14,y=U.upload),"stream_handler"in U&&e(15,E=U.stream_handler),"image_id"in U&&e(24,k=U.image_id)},s.$$.update=()=>{s.$$.dirty[0]&131072&&M&&w("upload"),s.$$.dirty[0]&512&&I(f),s.$$.dirty[0]&8&&e(21,i=a),s.$$.dirty[0]&65540&&x&&x.set_tool&&(o&&o.length?x.set_tool("bg"):x.set_tool("draw"))},[r,n,o,a,h,l,c,u,d,f,_,p,g,v,y,E,x,M,P,q,F,i,w,X,k,m,b,T,tt,R,C,K,it,O,pt,Tt]}class Zw extends Uw{constructor(t){super(),Hw(this,t,qw,Ww,zw,{brush:0,eraser:1,sources:2,crop_size:3,i18n:4,root:5,label:6,show_label:7,changeable:8,value:9,transforms:10,layers:11,accept_blobs:25,status:12,canvas_size:13,realtime:26,upload:14,stream_handler:15,get_data:27,image_id:24},null,[-1,-1])}get brush(){return this.$$.ctx[0]}set brush(t){this.$$set({brush:t}),yt()}get eraser(){return this.$$.ctx[1]}set eraser(t){this.$$set({eraser:t}),yt()}get sources(){return this.$$.ctx[2]}set sources(t){this.$$set({sources:t}),yt()}get crop_size(){return this.$$.ctx[3]}set crop_size(t){this.$$set({crop_size:t}),yt()}get i18n(){return this.$$.ctx[4]}set i18n(t){this.$$set({i18n:t}),yt()}get root(){return this.$$.ctx[5]}set root(t){this.$$set({root:t}),yt()}get label(){return this.$$.ctx[6]}set label(t){this.$$set({label:t}),yt()}get show_label(){return this.$$.ctx[7]}set show_label(t){this.$$set({show_label:t}),yt()}get changeable(){return this.$$.ctx[8]}set changeable(t){this.$$set({changeable:t}),yt()}get value(){return this.$$.ctx[9]}set value(t){this.$$set({value:t}),yt()}get transforms(){return this.$$.ctx[10]}set transforms(t){this.$$set({transforms:t}),yt()}get layers(){return this.$$.ctx[11]}set layers(t){this.$$set({layers:t}),yt()}get accept_blobs(){return this.$$.ctx[25]}set accept_blobs(t){this.$$set({accept_blobs:t}),yt()}get status(){return this.$$.ctx[12]}set status(t){this.$$set({status:t}),yt()}get canvas_size(){return this.$$.ctx[13]}set canvas_size(t){this.$$set({canvas_size:t}),yt()}get realtime(){return this.$$.ctx[26]}set realtime(t){this.$$set({realtime:t}),yt()}get upload(){return this.$$.ctx[14]}set upload(t){this.$$set({upload:t}),yt()}get stream_handler(){return this.$$.ctx[15]}set stream_handler(t){this.$$set({stream_handler:t}),yt()}get get_data(){return this.$$.ctx[27]}get image_id(){return this.$$.ctx[24]}set image_id(t){this.$$set({image_id:t}),yt()}}const{SvelteComponent:Kw,add_flush_callback:Jw,assign:mf,bind:Qw,binding_callbacks:gf,bubble:tT,check_outros:eT,create_component:xs,destroy_component:ws,detach:Rh,empty:iT,flush:ot,get_spread_object:bf,get_spread_update:vf,group_outros:sT,init:rT,insert:Mh,mount_component:Ts,not_equal:nT,space:yf,transition_in:gi,transition_out:bi}=window.__gradio__svelte__internal,{tick:oT}=window.__gradio__svelte__internal;function aT(s){let t,e;return t=new mu({props:{visible:s[3],variant:s[4]===null?"dashed":"solid",border_mode:s[29]?"focus":"base",padding:!1,elem_id:s[1],elem_classes:s[2],height:s[9]||void 0,width:s[10],allow_overflow:!1,container:s[12],scale:s[13],min_width:s[14],$$slots:{default:[lT]},$$scope:{ctx:s}}}),{c(){xs(t.$$.fragment)},m(i,r){Ts(t,i,r),e=!0},p(i,r){const n={};r[0]&8&&(n.visible=i[3]),r[0]&16&&(n.variant=i[4]===null?"dashed":"solid"),r[0]&536870912&&(n.border_mode=i[29]?"focus":"base"),r[0]&2&&(n.elem_id=i[1]),r[0]&4&&(n.elem_classes=i[2]),r[0]&512&&(n.height=i[9]||void 0),r[0]&1024&&(n.width=i[10]),r[0]&4096&&(n.container=i[12]),r[0]&8192&&(n.scale=i[13]),r[0]&16384&&(n.min_width=i[14]),r[0]&1073545585|r[1]&1048576&&(n.$$scope={dirty:r,ctx:i}),t.$set(n)},i(i){e||(gi(t.$$.fragment,i),e=!0)},o(i){bi(t.$$.fragment,i),e=!1},d(i){ws(t,i)}}}function hT(s){let t,e;return t=new mu({props:{visible:s[3],variant:"solid",border_mode:s[29]?"focus":"base",padding:!1,elem_id:s[1],elem_classes:s[2],height:s[9]||void 0,width:s[10],allow_overflow:!1,container:s[12],scale:s[13],min_width:s[14],$$slots:{default:[cT]},$$scope:{ctx:s}}}),{c(){xs(t.$$.fragment)},m(i,r){Ts(t,i,r),e=!0},p(i,r){const n={};r[0]&8&&(n.visible=i[3]),r[0]&536870912&&(n.border_mode=i[29]?"focus":"base"),r[0]&2&&(n.elem_id=i[1]),r[0]&4&&(n.elem_classes=i[2]),r[0]&512&&(n.height=i[9]||void 0),r[0]&1024&&(n.width=i[10]),r[0]&4096&&(n.container=i[12]),r[0]&8192&&(n.scale=i[13]),r[0]&16384&&(n.min_width=i[14]),r[0]&67143921|r[1]&1048576&&(n.$$scope={dirty:r,ctx:i}),t.$set(n)},i(i){e||(gi(t.$$.fragment,i),e=!0)},o(i){bi(t.$$.fragment,i),e=!1},d(i){ws(t,i)}}}function lT(s){let t,e,i,r,n;const o=[{autoscroll:s[26].autoscroll},{i18n:s[26].i18n},s[0]];let a={};for(let c=0;c<o.length;c+=1)a=mf(a,o[c]);t=new bu({props:a}),t.$on("clear_status",s[38]);function h(c){s[39](c)}let l={canvas_size:s[25],crop_size:s[20],value:s[4],root:s[8],sources:s[16],label:s[5],show_label:s[6],brush:s[18],eraser:s[19],changeable:s[23].includes("apply"),realtime:s[23].includes("change"),i18n:s[26].i18n,transforms:s[21],accept_blobs:s[24].accept_blobs,layers:s[22],status:s[0]?.status,upload:s[26].client.upload,stream_handler:s[26].client.stream};return s[28]!==void 0&&(l.image_id=s[28]),i=new Zw({props:l}),gf.push(()=>Qw(i,"image_id",h)),s[40](i),i.$on("change",s[41]),i.$on("save",s[42]),i.$on("edit",s[43]),i.$on("clear",s[44]),i.$on("drag",s[45]),i.$on("upload",s[46]),i.$on("share",s[47]),i.$on("error",s[48]),i.$on("error",s[49]),{c(){xs(t.$$.fragment),e=yf(),xs(i.$$.fragment)},m(c,u){Ts(t,c,u),Mh(c,e,u),Ts(i,c,u),n=!0},p(c,u){const d=u[0]&67108865?vf(o,[u[0]&67108864&&{autoscroll:c[26].autoscroll},u[0]&67108864&&{i18n:c[26].i18n},u[0]&1&&bf(c[0])]):{};t.$set(d);const f={};u[0]&33554432&&(f.canvas_size=c[25]),u[0]&1048576&&(f.crop_size=c[20]),u[0]&16&&(f.value=c[4]),u[0]&256&&(f.root=c[8]),u[0]&65536&&(f.sources=c[16]),u[0]&32&&(f.label=c[5]),u[0]&64&&(f.show_label=c[6]),u[0]&262144&&(f.brush=c[18]),u[0]&524288&&(f.eraser=c[19]),u[0]&8388608&&(f.changeable=c[23].includes("apply")),u[0]&8388608&&(f.realtime=c[23].includes("change")),u[0]&67108864&&(f.i18n=c[26].i18n),u[0]&2097152&&(f.transforms=c[21]),u[0]&16777216&&(f.accept_blobs=c[24].accept_blobs),u[0]&4194304&&(f.layers=c[22]),u[0]&1&&(f.status=c[0]?.status),u[0]&67108864&&(f.upload=c[26].client.upload),u[0]&67108864&&(f.
1172stream_handler=c[26].client.stream),!r&&u[0]&268435456&&(r=!0,f.image_id=c[28],Jw(()=>r=!1)),i.$set(f)},i(c){n||(gi(t.$$.fragment,c),gi(i.$$.fragment,c),n=!0)},o(c){bi(t.$$.fragment,c),bi(i.$$.fragment,c),n=!1},d(c){c&&Rh(e),ws(t,c),s[40](null),ws(i,c)}}}function cT(s){let t,e,i,r;const n=[{autoscroll:s[26].autoscroll},{i18n:s[26].i18n},s[0]];let o={};for(let a=0;a<n.length;a+=1)o=mf(o,n[a]);return t=new bu({props:o}),t.$on("clear_status",s[34]),i=new If({props:{value:s[4]?.composite||null,label:s[5],show_label:s[6],show_download_button:s[7],selectable:s[11],show_share_button:s[15],i18n:s[26].i18n}}),i.$on("select",s[35]),i.$on("share",s[36]),i.$on("error",s[37]),{c(){xs(t.$$.fragment),e=yf(),xs(i.$$.fragment)},m(a,h){Ts(t,a,h),Mh(a,e,h),Ts(i,a,h),r=!0},p(a,h){const l=h[0]&67108865?vf(n,[h[0]&67108864&&{autoscroll:a[26].autoscroll},h[0]&67108864&&{i18n:a[26].i18n},h[0]&1&&bf(a[0])]):{};t.$set(l);const c={};h[0]&16&&(c.value=a[4]?.composite||null),h[0]&32&&(c.label=a[5]),h[0]&64&&(c.show_label=a[6]),h[0]&128&&(c.show_download_button=a[7]),h[0]&2048&&(c.selectable=a[11]),h[0]&32768&&(c.show_share_button=a[15]),h[0]&67108864&&(c.i18n=a[26].i18n),i.$set(c)},i(a){r||(gi(t.$$.fragment,a),gi(i.$$.fragment,a),r=!0)},o(a){bi(t.$$.fragment,a),bi(i.$$.fragment,a),r=!1},d(a){a&&Rh(e),ws(t,a),ws(i,a)}}}function uT(s){let t,e,i,r;const n=[hT,aT],o=[];function a(h,l){return h[17]?1:0}return t=a(s),e=o[t]=n[t](s),{c(){e.c(),i=iT()},m(h,l){o[t].m(h,l),Mh(h,i,l),r=!0},p(h,l){let c=t;t=a(h),t===c?o[t].p(h,l):(sT(),bi(o[c],1,1,()=>{o[c]=null}),eT(),e=o[t],e?e.p(h,l):(e=o[t]=n[t](h),e.c()),gi(e,1),e.m(i.parentNode,i))},i(h){r||(gi(e),r=!0)},o(h){bi(e),r=!1},d(h){h&&Rh(i),o[t].d(h)}}}function dT(){return new Promise(s=>{requestAnimationFrame(()=>requestAnimationFrame(()=>s()))})}function fT(s,t,e){let{elem_id:i=""}=t,{elem_classes:r=[]}=t,{visible:n=!0}=t,{value:o={background:null,layers:[],composite:null}}=t,{label:a}=t,{show_label:h}=t,{show_download_button:l}=t,{root:c}=t,{value_is_output:u=!1}=t,{height:d}=t,{width:f}=t,{_selectable:_=!1}=t,{container:p=!0}=t,{scale:m=null}=t,{min_width:g=void 0}=t,{loading_status:v}=t,{show_share_button:b=!1}=t,{sources:y=["upload","clipboard","webcam"]}=t,{interactive:E}=t,{brush:w}=t,{eraser:x}=t,{crop_size:T=null}=t,{transforms:I=["crop"]}=t,{layers:M=!0}=t,{attached_events:P=[]}=t,{server:k}=t,{canvas_size:A}=t,{gradio:S}=t,X,q=null;async function F(){if(q){const qn={id:q};return e(28,q=null),qn}return await X.get_data()}let tt;async function R(){await dT(),o&&(o.background||o.layers?.length||o.composite)&&S.dispatch("change")}function C(){S.dispatch("apply")}function K(){S.dispatch("change"),u||(S.dispatch("input"),oT().then(D=>e(32,u=!1)))}const it=()=>S.dispatch("clear_status",v),O=({detail:D})=>S.dispatch("select",D),pt=({detail:D})=>S.dispatch("share",D),Tt=({detail:D})=>S.dispatch("error",D),U=()=>S.dispatch("clear_status",v);function at(D){q=D,e(28,q)}function At(D){gf[D?"unshift":"push"](()=>{X=D,e(27,X)})}const mt=()=>K(),rt=D=>C(),lt=()=>S.dispatch("edit"),St=()=>S.dispatch("clear"),L=({detail:D})=>e(29,tt=D),Mt=()=>S.dispatch("upload"),Lt=({detail:D})=>S.dispatch("share",D),Ye=({detail:D})=>{e(0,v=v||{}),e(0,v.status="error",v),S.dispatch("error",D)};function Ss(D){tT.call(this,s,D)}return s.$$set=D=>{"elem_id"in D&&e(1,i=D.elem_id),"elem_classes"in D&&e(2,r=D.elem_classes),"visible"in D&&e(3,n=D.visible),"value"in D&&e(4,o=D.value),"label"in D&&e(5,a=D.label),"show_label"in D&&e(6,h=D.show_label),"show_download_button"in D&&e(7,l=D.show_download_button),"root"in D&&e(8,c=D.root),"value_is_output"in D&&e(32,u=D.value_is_output),"height"in D&&e(9,d=D.height),"width"in D&&e(10,f=D.width),"_selectable"in D&&e(11,_=D._selectable),"container"in D&&e(12,p=D.container),"scale"in D&&e(13,m=D.scale),"min_width"in D&&e(14,g=D.min_width),"loading_status"in D&&e(0,v=D.loading_status),"show_share_button"in D&&e(15,b=D.show_share_button),"sources"in D&&e(16,y=D.sources),"interactive"in D&&e(17,E=D.interactive),"brush"in D&&e(18,w=D.brush),"eraser"in D&&e(19,x=D.eraser),"crop_size"in D&&e(20,T=D.crop_size),"transforms"in D&&e(21,I=D.transforms),"layers"in D&&e(22,M=D.layers),"attached_events"in D&&e(23,P=D.attached_events),"server"in D&&e(24,k=D.server),"canvas_size"in D&&e(25,A=D.c
vendor: 3,184 bytes, lines 1172-1173
1172anvas_size),"gradio"in D&&e(26,S=D.gradio)},s.$$.update=()=>{s.$$.dirty[0]&16&&o&&R()},[v,i,r,n,o,a,h,l,c,d,f,_,p,m,g,b,y,E,w,x,T,I,M,P,k,A,S,X,q,tt,C,K,u,F,it,O,pt,Tt,U,at,At,mt,rt,lt,St,L,Mt,Lt,Ye,Ss]}class $T extends Kw{constructor(t){super(),rT(this,t,fT,uT,nT,{elem_id:1,elem_classes:2,visible:3,value:4,label:5,show_label:6,show_download_button:7,root:8,value_is_output:32,height:9,width:10,_selectable:11,container:12,scale:13,min_width:14,loading_status:0,show_share_button:15,sources:16,interactive:17,brush:18,eraser:19,crop_size:20,transforms:21,layers:22,attached_events:23,server:24,canvas_size:25,gradio:26,get_value:33},null,[-1,-1])}get elem_id(){return this.$$.ctx[1]}set elem_id(t){this.$$set({elem_id:t}),ot()}get elem_classes(){return this.$$.ctx[2]}set elem_classes(t){this.$$set({elem_classes:t}),ot()}get visible(){return this.$$.ctx[3]}set visible(t){this.$$set({visible:t}),ot()}get value(){return this.$$.ctx[4]}set value(t){this.$$set({value:t}),ot()}get label(){return this.$$.ctx[5]}set label(t){this.$$set({label:t}),ot()}get show_label(){return this.$$.ctx[6]}set show_label(t){this.$$set({show_label:t}),ot()}get show_download_button(){return this.$$.ctx[7]}set show_download_button(t){this.$$set({show_download_button:t}),ot()}get root(){return this.$$.ctx[8]}set root(t){this.$$set({root:t}),ot()}get value_is_output(){return this.$$.ctx[32]}set value_is_output(t){this.$$set({value_is_output:t}),ot()}get height(){return this.$$.ctx[9]}set height(t){this.$$set({height:t}),ot()}get width(){return this.$$.ctx[10]}set width(t){this.$$set({width:t}),ot()}get _selectable(){return this.$$.ctx[11]}set _selectable(t){this.$$set({_selectable:t}),ot()}get container(){return this.$$.ctx[12]}set container(t){this.$$set({container:t}),ot()}get scale(){return this.$$.ctx[13]}set scale(t){this.$$set({scale:t}),ot()}get min_width(){return this.$$.ctx[14]}set min_width(t){this.$$set({min_width:t}),ot()}get loading_status(){return this.$$.ctx[0]}set loading_status(t){this.$$set({loading_status:t}),ot()}get show_share_button(){return this.$$.ctx[15]}set show_share_button(t){this.$$set({show_share_button:t}),ot()}get sources(){return this.$$.ctx[16]}set sources(t){this.$$set({sources:t}),ot()}get interactive(){return this.$$.ctx[17]}set interactive(t){this.$$set({interactive:t}),ot()}get brush(){return this.$$.ctx[18]}set brush(t){this.$$set({brush:t}),ot()}get eraser(){return this.$$.ctx[19]}set eraser(t){this.$$set({eraser:t}),ot()}get crop_size(){return this.$$.ctx[20]}set crop_size(t){this.$$set({crop_size:t}),ot()}get transforms(){return this.$$.ctx[21]}set transforms(t){this.$$set({transforms:t}),ot()}get layers(){return this.$$.ctx[22]}set layers(t){this.$$set({layers:t}),ot()}get attached_events(){return this.$$.ctx[23]}set attached_events(t){this.$$set({attached_events:t}),ot()}get server(){return this.$$.ctx[24]}set server(t){this.$$set({server:t}),ot()}get canvas_size(){return this.$$.ctx[25]}set canvas_size(t){this.$$set({canvas_size:t}),ot()}get gradio(){return this.$$.ctx[26]}set gradio(t){this.$$set({gradio:t}),ot()}get get_value(){return this.$$.ctx[33]}}export{$T as default};
1173//# sourceMappingURL=Index-YhvySncB.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.