1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chunks/VPAlgoliaSearchBox.BVtHE2fX.js","assets/chunks/framework.Cauo9aFl.js","assets/chunks/shoelace.Ls2kLUQv.js","assets/chunks/chunk.FZBLJ4XG.D2VuoQ9X.js","assets/chunks/base-path.r-Ppr3Mh.js","assets/chunks/index.BIwviW0q.js","assets/chunks/choose.DDdumiaH.js"])))=>i.map(i=>d[i]); 2var gae=Object.defineProperty;var mae=(mE,hm,yE)=>hm in mE?gae(mE,hm,{enumerable:!0,configurable:!0,writable:!0,value:yE}):mE[hm]=yE;var W=(mE,hm,yE)=>mae(mE,typeof hm!="symbol"?hm+"":hm,yE);import{d as ir,c as Ut,r as Ft,n as xo,o as lt,a as qS,t as No,b as Er,w as Jt,T as KQ,e as Ke,_ as jr,u as xEt,i as yae,f as vae,g as qQ,h as ni,j as Kt,k as yt,l as ZS,m as ZQ,p as co,q as Dy,s as yV,v as Py,x as vV,y as JQ,z as _ae,A as bae,F as bn,B as Yh,C as JS,D as _V,E as Ar,G as SEt,H as Fy,I as TEt,J as KU,K as Jw,L as bV,M as wae,N as REt,O as Eae,P as CEt,Q as MEt,R as wV,S as Aae,U as xae,V as JB,W as BEt,X as OEt,Y as Sae,Z as Tae,$ as IEt,a0 as Rae,a1 as Cae,a2 as Mae,a3 as Bae}from"./framework.Cauo9aFl.js";let QQ,ttt,Qw,Gl,Sv,$h,I,Tv,Ci,Hh,sr,Kh,tE,qh,Zs,Lc,vt,Pa,DEt,al,Ny,PEt,So,em,FEt,Fa,eE,rE,ed,oc,iE,ett,Zh,ky,tp,QB,rtt,Rv,qU,Uc,itt,Cv,ll,stt,ott,ntt,att,ltt,QS,ctt,htt,gh,tO,eO,Ly,utt,Uy,Yd,me,rO,iO,we,EV,Pr,ZU,dtt,Na,sO,oO,nO,NEt,kEt,sE,$d,LEt,UEt,GEt,WEt,Gy,or,jEt,XEt,zEt,VEt,Wy,YEt,$Et,oE,Jh,aO,lO,ftt,ptt,Qh,Ni,ep,nc,gtt,We,nE,Pe,fe,wt,jt,rd,jy,qo,ac,Mv,ko,ka,To,Mi,La,Wl,cl,hl,tu,Gc,mh,ul,_a,yi,Hn,cs,AV,Nt,yh,JU,Fs,Bi,Ns,ba,_o,_e,ze,be,Zi,he,Ce,Gt,et,ae,$t,_t,Mt,xt,Yt,ue,ai,ke,Js,ks,bo,ro,Ls,Xy,wa,Wc,id,ki,Lo,Kn,je,zy,vh,Vy,Zr,Hd,Nn,QU,HEt,mtt,cO,xV,tG,Ro,hs,ho,KEt,SV,eG,Bt,TV,us,Qt,Ea,Aa,it,Yy,hO,aE,cr,uo,ye,Uo,wn,En,le,Ve,rG,iG,uO,tT,eT,lE,dO,rp,An,fO,qEt,Bv,RV,lc,qn,Zt,xn,io,Zn,vi,Xr,X,Ee,cE,Zo,eu,ytt,Be,ru,rm,$y,CV,MV,Ua,ce,hE,vtt,_tt,BV,btt,wtt,OV,Ett,Att,xtt,sG,so,Ae,xa,Ii,Us,Sa,Ov,IV,oG,nG,aG,ZEt,DV,wo,dl,Gs,qe,kn,kt,hr,Di,rT,Go,Hy,di,lG,Jn,sd,Ta,Eo,Stt,PV,Oi,li,jl,Re,Li,oo,rr,Ra,Pi,FV,Ttt,im,Sr,_h,cG,uE,Sn,sm,om,te,Wo,hG,uG,nm,NV,dE,pO,dG,Rtt,Ctt,kV,Mtt,LV,JEt,fG,pG,gG,gO,mO,ip,QEt,t1t,e1t,yO,Btt,vO,mG,_O,Ott,Itt,Dtt,Ptt,Ftt,Ntt,ktt,Ltt,Utt,Gtt,Wtt,UV,bO,Tn,jc,Ca,Ga,Xc,Qn,Ln,iu,Ji,nt,Iv,wO,jtt,yG,GV,Kd,Xtt,ztt,iT,am,Vtt,Ytt,vG,su,lm,_G,$tt,Htt,Ktt,qtt,WV,Ztt,Jtt,bh,r1t,Qtt,bG,tet,Ky,sT,Dv,EO,jV,XV,zV,VV,eet,oT,ret,YV,Pv,ds,zc,qy,ou,iet,$V,set,Zy,wG,oet,HV,KV,qV,nu,au,ZV,sp,xr,net,fE,EG,cm,AG,dt,Wa,i1t,Vc,Et,ne,op,Ao,Tr,wh,Oae=(async()=>{var mEt,yEt,zQ,VQ;function mE(t,e){for(var r=0;r<e.length;r++){const i=e[r];if(typeof i!="string"&&!Array.isArray(i)){for(const s in i)if(s!=="default"&&!(s in t)){const o=Object.getOwnPropertyDescriptor(i,s);o&&Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>i[s]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}let hm,yE,det,fet;hm=ir({__name:"VPBadge",props:{text:null,type:{default:"tip"}},setup(t){return(e,r)=>(lt(),Ut("span",{class:xo(["VPBadge",t.type])},[Ft(e.$slots,"default",{},()=>[qS(No(t.text),1)])],2))}}),yE={key:0,class:"VPBackdrop"},det=ir({__name:"VPBackdrop",props:{show:{type:Boolean}},setup(t){return(e,r)=>(lt(),Er(KQ,{name:"fade"},{default:Jt(()=>[t.show?(lt(),Ut("div",yE)):Ke("",!0)]),_:1}))}}),fet=jr(det,[["__scopeId","data-v-f3f5bc10"]]),Ci=xEt;function B1t(t,e){let r,i=!1;return()=>{r&&clearTimeout(r),i?r=setTimeout(t,e):(t(),(i=!0)&&setTimeout(()=>i=!1,e))}}function oY(t){return t.startsWith("/")?t:`/${t}`}function nY(t){const{pathname:e,search:r,hash:i,protocol:s}=new URL(t,"http://a.com");if(yae(t)||t.startsWith("#")||!s.startsWith("http")||!vae(e))return t;const{site:o}=Ci(),n=e.endsWith("/")||e.endsWith(".html")?t:t.replace(/(?:(^\.+)\/)?.*$/,`$1${e.replace(/(\.md)?$/,o.value.cleanUrls?"":".html")}${r}${i}`);return qQ(n)}function CO({correspondingLink:t=!1}={}){const{site:e,localeIndex:r,page:i,theme:s,hash:o}=Ci(),n=ni(()=>{var a,l;return{label:(a=e.value.locales[r.value])==null?void 0:a.label,link:((l=e.value.locales[r.value])==null?void 0:l.link)||(r.value==="root"?"/":`/${r.value}/`)}});return{localeLinks:ni(()=>Object.entries(e.value.locales).flatMap(([a,l])=>n.value.label===l.label?[]:{text:l.label,link:O1t(l.link||(a==="root"?"/":`/${a}/`),s.value.i18nRouting!==!1&&t,i.value.relativePath.slice(n.value.link.length-1),!e.value.cleanUrls)+o.value})),currentLang:n}}function O1t(t,e,r,i){return e?t.replace(/\/$/,"")+oY(r.replace(/(^|\/)index\.md$/,"$1").replace(/\.md$/,i?".html":"")):t}const I1t={class:"NotFound"},D1t={class:"code"},P1t={class:"title"},F1t={class:"quote"},N1t={class:"action"},k1t=["href","aria-label"],L1t=ir({__name:"NotFound",setup(t){const{theme:e}=Ci(),{currentLang:r}=CO();return(i,s)=>{var o,n,a,l,c;return lt(),Ut("div",I1t,[Kt("p",D1t,No(((o=yt(e).notFound)==null?void 0:o.code)??"404"),1),Kt("h1",P1t,No(((n=yt(e).notFound)==null?void 0:n.title)??"PAGE NOT FOUND"),1),s[0]||(s[0]=Kt("div",{class:"divider"},null,-1)),Kt("blockquote",F1t,No(((a=yt(e).notFound)==null?void 0:a.quote)??"But if you don't change your direction, and if you keep looking, you may end up where you are heading."),1),Kt("div",N1t,[Kt("a",{class:"link",href:yt(qQ)(yt(r).link),"aria-label":((l=yt(e).notFound)==null?void 0:l.linkLabel)??"go to home"},No(((c=yt(e).notFound)==null?void 0:c.linkText)??"Take me home"),9,k1t)])])}}}),U1t=jr(L1t,[["__scopeId","data-v-b3c77295"]]);function pet(t,e){if(Array.isArray(t))return DG(t);if(t==null)return[];e=oY(e);const r=Object.keys(t).sort((s,o)=>o.split("/").length-s.split("/").length).find(s=>e.startsWith(oY(s))),i=r?t[r]:[];return Array.isArray(i)?DG(i):DG(i.items,i.base)}function G1t(t){const e=[];let r=0;for(const i in t){const s=t[i];if(s.items){r=e.push(s);continue}e[r]||e.push({items:[]}),e[r].items.push(s)}return e}function W1t(t){const e=[];function r(i){for(const s of i)s.text&&s.link&&e.push({text:s.text,link:s.link,docFooterText:s.docFooterText}),s.items&&r(s.items)}return r(t),e}function aY(t,e){return Array.isArray(e)?e.some(r=>aY(t,r)):ZS(t,e.link)?!0:e.items?aY(t,e.items):!1}function DG(t,e){return[...t].map(r=>{const i={...r},s=i.base||e;return s&&i.link&&(i.link=s+i.link),i.items&&(i.items=DG(i.items,s)),i})}function t0(){const{frontmatter:t,page:e,theme:r}=Ci(),i=ZQ("(min-width: 960px)"),s=co(!1),o=ni(()=>{const p=r.value.sidebar,m=e.value.relativePath;return p?pet(p,m):[]}),n=co(o.value);Dy(o,(p,m)=>{JSON.stringify(p)!==JSON.stringify(m)&&(n.value=o.value)});const a=ni(()=>t.value.sidebar!==!1&&n.value.length>0&&t.value.layout!=="home"),l=ni(()=>c?t.value.aside==null?r.value.aside==="left":t.value.aside==="left":!1),c=ni(()=>t.value.layout==="home"?!1:t.value.aside!=null?!!t.value.aside:r.value.aside!==!1),h=ni(()=>a.value&&i.value),u=ni(()=>a.value?G1t(n.value):[]);function d(){s.value=!0}function f(){s.value=!1}function g(){s.value?f():d()}return{isOpen:s,sidebar:n,sidebarGroups:u,hasSidebar:a,hasAside:c,leftAside:l,isSidebarEnabled:h,open:d,close:f,toggle:g}}function j1t(t,e){let r;yV(()=>{r=t.value?document.activeElement:void 0}),Py(()=>{window.addEventListener("keyup",i)}),vV(()=>{window.removeEventListener("keyup",i)});function i(s){s.key==="Escape"&&t.value&&(e(),r==null||r.focus())}}function X1t(t){const{page:e,hash:r}=Ci(),i=co(!1),s=ni(()=>t.value.collapsed!=null),o=ni(()=>!!t.value.link),n=co(!1),a=()=>{n.value=ZS(e.value.relativePath,t.value.link)};Dy([e,t,r],a),Py(a);const l=ni(()=>n.value?!0:t.value.items?aY(e.value.relativePath,t.value.items):!1),c=ni(()=>!!(t.value.items&&t.value.items.length));yV(()=>{i.value=!!(s.value&&t.value.collapsed)}),JQ(()=>{(n.value||l.value)&&(i.value=!1)});function h(){s.value&&(i.value=!i.value)}return{collapsed:i,collapsible:s,isLink:o,isActiveLink:n,hasActiveLink:l,hasChildren:c,toggle:h}}function z1t(){const{hasSidebar:t}=t0(),e=ZQ("(min-width: 960px)"),r=ZQ("(min-width: 1280px)");return{isAsideEnabled:ni(()=>!r.value&&!e.value?!1:t.value?r.value:e.value)}}const V1t=/\b(?:VPBadge|header-anchor|footnote-ref|ignore-header)\b/,lY=[];function get(t){return typeof t.outline=="object"&&!Array.isArray(t.outline)&&t.outline.label||t.outlineTitle||"On this page"}function cY(t){const e=[...document.querySelectorAll(".VPDoc :where(h1,h2,h3,h4,h5,h6)")].filter(r=>r.id&&r.hasChildNodes()).map(r=>{const i=Number(r.tagName[1]);return{element:r,title:Y1t(r),link:"#"+r.id,level:i}});return $1t(e,t)}function Y1t(t){let e="";for(const r of t.childNodes)if(r.nodeType===1){if(V1t.test(r.className))continue;e+=r.textContent}else r.nodeType===3&&(e+=r.textContent);return e.trim()}function $1t(t,e){if(e===!1)return[];const r=(typeof e=="object"&&!Array.isArray(e)?e.level:e)||2,[i,s]=typeof r=="number"?[r,r]:r==="deep"?[2,6]:r;return q1t(t,i,s)}function H1t(t,e){const{isAsideEnabled:r}=z1t(),i=B1t(o,100);let s=null;Py(()=>{requestAnimationFrame(o),window.addEventListener("scroll",i)}),_ae(()=>{n(location.hash)}),vV(()=>{window.removeEventListener("scroll",i)});function o(){if(!r.value)return;const a=window.scrollY,l=window.innerHeight,c=document.body.offsetHeight,h=Math.abs(a+l-c)<1,u=lY.map(({element:f,link:g})=>({link:g,top:K1t(f)})).filter(({top:f})=>!Number.isNaN(f)).sort((f,g)=>f.top-g.top);if(!u.length){n(null);return}if(a<1){n(null);return}if(h){n(u[u.length-1].link);return}let d=null;for(const{link:f,top:g}of u){if(g>a+bae()+4)break;d=f}n(d)}function n(a){s&&s.classList.remove("active"),a==null?s=null:s=t.value.querySelector(`a[href="${decodeURIComponent(a)}"]`);const l=s;l?(l.classList.add("active"),e.value.style.top=l.offsetTop+39+"px",e.value.style.opacity="1"):(e.value.style.top="33px",e.value.style.opacity="0")}}function K1t(t){let e=0;for(;t!==document.body;){if(t===null)return NaN;e+=t.offsetTop,t=t.offsetParent}return e}function q1t(t,e,r){lY.length=0;const i=[],s=[];return t.forEach(o=>{const n={...o,children:[]};let a=s[s.length-1];for(;a&&a.level>=n.level;)s.pop(),a=s[s.length-1];if(n.element.classList.contains("ignore-header")||a&&"shouldIgnore"in a){s.push({level:n.level,shouldIgnore:!0});return}n.level>r||n.level<e||(lY.push({element:n.element,link:n.link}),a?a.children.push(n):i.push(n),s.push(n))}),i}const Z1t=["href","title"],J1t=ir({__name:"VPDocOutlineItem",props:{headers:null,root:{type:Boolean}},setup(t){function e({target:r}){var s;const i=r.href.split("#")[1];(s=document.getElementById(decodeURIComponent(i)))==null||s.focus({preventScroll:!0})}return(r,i)=>{const s=JS("VPDocOutlineItem",!0);return lt(),Ut("ul",{class:xo(["VPDocOutlineItem",t.root?"root":"nested"])},[(lt(!0),Ut(bn,null,Yh(t.headers,({children:o,link:n,title:a})=>(lt(),Ut("li",null,[Kt("a",{class:"outline-link",href:n,onClick:e,title:a},No(a),9,Z1t),o!=null&&o.length?(lt(),Er(s,{key:0,headers:o},null,8,["headers"])):Ke("",!0)]))),256))],2)}}}),met=jr(J1t,[["__scopeId","data-v-cdfdecb3"]]),Q1t={class:"content"},tAt={"aria-level":"2",class:"outline-title",id:"doc-outline-aria-label",role:"heading"},eAt=ir({__name:"VPDocAsideOutline",setup(t){const{frontmatter:e,theme:r}=Ci(),i=SEt([]);_V(()=>{i.value=cY(e.value.outline??r.value.outline)});const s=co(),o=co();return H1t(s,o),(n,a)=>(lt(),Ut("nav",{"aria-labelledby":"doc-outline-aria-label",class:xo(["VPDocAsideOutline",{"has-outline":i.value.length>0}]),ref_key:"container",ref:s},[Kt("div",Q1t,[Kt("div",{class:"outline-marker",ref_key:"marker",ref:o},null,512),Kt("div",tAt,No(yt(get)(yt(r))),1),Ar(met,{headers:i.value,root:!0},null,8,["headers"])])],2))}}),rAt=jr(eAt,[["__scopeId","data-v-39605db6"]]),iAt={class:"VPDocAsideCarbonAds"},sAt=ir({__name:"VPDocAsideCarbonAds",props:{carbonAds:null},setup(t){const e=()=>null;return(r,i)=>(lt(),Ut("div",iAt,[Ar(yt(e),{"carbon-ads":t.carbonAds},null,8,["carbon-ads"])]))}}),oAt={class:"VPDocAside"},nAt=ir({__name:"VPDocAside",setup(t){const{theme:e}=Ci();return(r,i)=>(lt(),Ut("div",oAt,[Ft(r.$slots,"aside-top",{},void 0,!0),Ft(r.$slots,"aside-outline-before",{},void 0,!0),Ar(rAt),Ft(r.$slots,"aside-outline-after",{},void 0,!0),i[0]||(i[0]=Kt("div",{class:"spacer"},null,-1)),Ft(r.$slots,"aside-ads-before",{},void 0,!0),yt(e).carbonAds?(lt(),Er(sAt,{key:0,"carbon-ads":yt(e).carbonAds},null,8,["carbon-ads"])):Ke("",!0),Ft(r.$slots,"aside-ads-after",{},void 0,!0),Ft(r.$slots,"aside-bottom",{},void 0,!0)]))}}),aAt=jr(nAt,[["__scopeId","data-v-25989e6f"]]);function lAt(){const{theme:t,page:e}=Ci();return ni(()=>{const{text:r="Edit this page",pattern:i=""}=t.value.editLink||{};let s;return typeof i=="function"?s=i(e.value):s=i.replace(/:path/g,e.value.filePath),{url:s,text:r}})}function cAt(){const{page:t,theme:e,frontmatter:r}=Ci();return ni(()=>{var c,h,u,d,f,g,p,m;const i=pet(e.value.sidebar,t.value.relativePath),s=W1t(i),o=hAt(s,v=>v.link.replace(/[?#].*$/,"")),n=o.findIndex(v=>ZS(t.value.relativePath,v.link)),a=((c=e.value.docFooter)==null?void 0:c.prev)===!1&&!r.value.prev||r.value.prev===!1,l=((h=e.value.docFooter)==null?void 0:h.next)===!1&&!r.value.next||r.value.next===!1;return{prev:a?void 0:{text:(typeof r.value.prev=="string"?r.value.prev:typeof r.value.prev=="object"?r.value.prev.text:void 0)??((u=o[n-1])==null?void 0:u.docFooterText)??((d=o[n-1])==null?void 0:d.text),link:(typeof r.value.prev=="object"?r.value.prev.link:void 0)??((f=o[n-1])==null?void 0:f.link)},next:l?void 0:{text:(typeof r.value.next=="string"?r.value.next:typeof r.value.next=="object"?r.value.next.text:void 0)??((g=o[n+1])==null?void 0:g.docFooterText)??((p=o[n+1])==null?void 0:p.text),link:(typeof r.value.next=="object"?r.value.next.link:void 0)??((m=o[n+1])==null?void 0:m.link)}}})}function hAt(t,e){const r=new Set;return t.filter(i=>{const s=e(i);return r.has(s)?!1:r.add(s)})}const um=ir({__name:"VPLink",props:{tag:null,href:null,noIcon:{type:Boolean},target:null,rel:null},setup(t){const e=t,r=ni(()=>e.tag??(e.href?"a":"span")),i=ni(()=>e.href&&TEt.test(e.href)||e.target==="_blank");return(s,o)=>(lt(),Er(Fy(r.value),{class:xo(["VPLink",{link:t.href,"vp-external-link-icon":i.value,"no-icon":t.noIcon}]),href:t.href?yt(nY)(t.href):void 0,target:t.target??(i.value?"_blank":void 0),rel:t.rel??(i.value?"noreferrer":void 0)},{default:Jt(()=>[Ft(s.$slots,"default")]),_:3},8,["class","href","target","rel"]))}}),uAt={class:"VPLastUpdated"},dAt=["datetime"],fAt=ir({__name:"VPDocFooterLastUpdated",setup(t){const{theme:e,page:r,lang:i}=Ci(),s=ni(()=>new Date(r.value.lastUpdated)),o=ni(()=>s.value.toISOString()),n=co("");return Py(()=>{yV(()=>{var a,l,c;
2n.value=new Intl.DateTimeFormat((l=(a=e.value.lastUpdated)==null?void 0:a.formatOptions)!=null&&l.forceLocale?i.value:void 0,((c=e.value.lastUpdated)==null?void 0:c.formatOptions)??{dateStyle:"short",timeStyle:"short"}).format(s.value)})}),(a,l)=>{var c;return lt(),Ut("p",uAt,[qS(No(((c=yt(e).lastUpdated)==null?void 0:c.text)||yt(e).lastUpdatedText||"Last updated")+": ",1),Kt("time",{datetime:o.value},No(n.value),9,dAt)])}}}),pAt=jr(fAt,[["__scopeId","data-v-8f0df88d"]]),gAt={key:0,class:"VPDocFooter"},mAt={key:0,class:"edit-info"},yAt={key:0,class:"edit-link"},vAt={key:1,class:"last-updated"},_At={key:1,class:"prev-next","aria-labelledby":"doc-footer-aria-label"},bAt={class:"pager"},wAt=["innerHTML"],EAt=["innerHTML"],AAt={class:"pager"},xAt=["innerHTML"],SAt=["innerHTML"],TAt=ir({__name:"VPDocFooter",setup(t){const{theme:e,page:r,frontmatter:i}=Ci(),s=lAt(),o=cAt(),n=ni(()=>e.value.editLink&&i.value.editLink!==!1),a=ni(()=>r.value.lastUpdated),l=ni(()=>n.value||a.value||o.value.prev||o.value.next);return(c,h)=>{var u,d,f,g;return l.value?(lt(),Ut("footer",gAt,[Ft(c.$slots,"doc-footer-before",{},void 0,!0),n.value||a.value?(lt(),Ut("div",mAt,[n.value?(lt(),Ut("div",yAt,[Ar(um,{class:"edit-link-button",href:yt(s).url,"no-icon":!0},{default:Jt(()=>[h[0]||(h[0]=Kt("span",{class:"vpi-square-pen edit-link-icon"},null,-1)),qS(" "+No(yt(s).text),1)]),_:1},8,["href"])])):Ke("",!0),a.value?(lt(),Ut("div",vAt,[Ar(pAt)])):Ke("",!0)])):Ke("",!0),(u=yt(o).prev)!=null&&u.link||(d=yt(o).next)!=null&&d.link?(lt(),Ut("nav",_At,[h[1]||(h[1]=Kt("span",{class:"visually-hidden",id:"doc-footer-aria-label"},"Pager",-1)),Kt("div",bAt,[(f=yt(o).prev)!=null&&f.link?(lt(),Er(um,{key:0,class:"pager-link prev",href:yt(o).prev.link},{default:Jt(()=>{var p;return[Kt("span",{class:"desc",innerHTML:((p=yt(e).docFooter)==null?void 0:p.prev)||"Previous page"},null,8,wAt),Kt("span",{class:"title",innerHTML:yt(o).prev.text},null,8,EAt)]}),_:1},8,["href"])):Ke("",!0)]),Kt("div",AAt,[(g=yt(o).next)!=null&&g.link?(lt(),Er(um,{key:0,class:"pager-link next",href:yt(o).next.link},{default:Jt(()=>{var p;return[Kt("span",{class:"desc",innerHTML:((p=yt(e).docFooter)==null?void 0:p.next)||"Next page"},null,8,xAt),Kt("span",{class:"title",innerHTML:yt(o).next.text},null,8,SAt)]}),_:1},8,["href"])):Ke("",!0)])])):Ke("",!0)])):Ke("",!0)}}}),RAt=jr(TAt,[["__scopeId","data-v-b26ea9c6"]]),CAt={class:"container"},MAt={class:"aside-container"},BAt={class:"aside-content"},OAt={class:"content"},IAt={class:"content-container"},DAt={class:"main"},PAt=ir({__name:"VPDoc",setup(t){const{theme:e}=Ci(),r=KU(),{hasSidebar:i,hasAside:s,leftAside:o}=t0(),n=ni(()=>r.path.replace(/[./]+/g,"_").replace(/_html$/,""));return(a,l)=>{const c=JS("Content");return lt(),Ut("div",{class:xo(["VPDoc",{"has-sidebar":yt(i),"has-aside":yt(s)}])},[Ft(a.$slots,"doc-top",{},void 0,!0),Kt("div",CAt,[yt(s)?(lt(),Ut("div",{key:0,class:xo(["aside",{"left-aside":yt(o)}])},[l[0]||(l[0]=Kt("div",{class:"aside-curtain"},null,-1)),Kt("div",MAt,[Kt("div",BAt,[Ar(aAt,null,{"aside-top":Jt(()=>[Ft(a.$slots,"aside-top",{},void 0,!0)]),"aside-bottom":Jt(()=>[Ft(a.$slots,"aside-bottom",{},void 0,!0)]),"aside-outline-before":Jt(()=>[Ft(a.$slots,"aside-outline-before",{},void 0,!0)]),"aside-outline-after":Jt(()=>[Ft(a.$slots,"aside-outline-after",{},void 0,!0)]),"aside-ads-before":Jt(()=>[Ft(a.$slots,"aside-ads-before",{},void 0,!0)]),"aside-ads-after":Jt(()=>[Ft(a.$slots,"aside-ads-after",{},void 0,!0)]),_:3})])])],2)):Ke("",!0),Kt("div",OAt,[Kt("div",IAt,[Ft(a.$slots,"doc-before",{},void 0,!0),Kt("main",DAt,[Ar(c,{class:xo(["vp-doc",[n.value,yt(e).externalLinkIcon&&"external-link-icon-enabled"]])},null,8,["class"])]),Ar(RAt,null,{"doc-footer-before":Jt(()=>[Ft(a.$slots,"doc-footer-before",{},void 0,!0)]),_:3}),Ft(a.$slots,"doc-after",{},void 0,!0)])])]),Ft(a.$slots,"doc-bottom",{},void 0,!0)],2)}}}),FAt=jr(PAt,[["__scopeId","data-v-e87fc0b3"]]),NAt=ir({__name:"VPButton",props:{tag:null,size:{default:"medium"},theme:{default:"brand"},text:null,href:null,target:null,rel:null},setup(t){const e=t,r=ni(()=>e.href&&TEt.test(e.href)),i=ni(()=>e.tag||(e.href?"a":"button"));return(s,o)=>(lt(),Er(Fy(i.value),{class:xo(["VPButton",[t.size,t.theme]]),href:t.href?yt(nY)(t.href):void 0,target:e.target??(r.value?"_blank":void 0),rel:e.rel??(r.value?"noreferrer":void 0)},{default:Jt(()=>[qS(No(t.text),1)]),_:1},8,["class","href","target","rel"]))}}),kAt=jr(NAt,[["__scopeId","data-v-fbd10fbf"]]),LAt=["src","alt"],UAt=ir({inheritAttrs:!1,__name:"VPImage",props:{image:null,alt:null},setup(t){return(e,r)=>{const i=JS("VPImage",!0);return t.image?(lt(),Ut(bn,{key:0},[typeof t.image=="string"||"src"in t.image?(lt(),Ut("img",Jw({key:0,class:"VPImage"},typeof t.image=="string"?e.$attrs:{...t.image,...e.$attrs},{src:yt(qQ)(typeof t.image=="string"?t.image:t.image.src),alt:t.alt??(typeof t.image=="string"?"":t.image.alt||"")}),null,16,LAt)):(lt(),Ut(bn,{key:1},[Ar(i,Jw({class:"dark",image:t.image.dark,alt:t.image.alt},e.$attrs),null,16,["image","alt"]),Ar(i,Jw({class:"light",image:t.image.light,alt:t.image.alt},e.$attrs),null,16,["image","alt"])],64))],64)):Ke("",!0)}}}),PG=jr(UAt,[["__scopeId","data-v-b17be7a3"]]),GAt={class:"container"},WAt={class:"main"},jAt={class:"heading"},XAt=["innerHTML"],zAt=["innerHTML"],VAt=["innerHTML"],YAt={key:0,class:"actions"},$At={key:0,class:"image"},HAt={class:"image-container"},KAt=ir({__name:"VPHero",props:{name:null,text:null,tagline:null,image:null,actions:null},setup(t){const e=bV("hero-image-slot-exists");return(r,i)=>(lt(),Ut("div",{class:xo(["VPHero",{"has-image":t.image||yt(e)}])},[Kt("div",GAt,[Kt("div",WAt,[Ft(r.$slots,"home-hero-info-before",{},void 0,!0),Ft(r.$slots,"home-hero-info",{},()=>[Kt("h1",jAt,[t.name?(lt(),Ut("span",{key:0,innerHTML:t.name,class:"name clip"},null,8,XAt)):Ke("",!0),t.text?(lt(),Ut("span",{key:1,innerHTML:t.text,class:"text"},null,8,zAt)):Ke("",!0)]),t.tagline?(lt(),Ut("p",{key:0,innerHTML:t.tagline,class:"tagline"},null,8,VAt)):Ke("",!0)],!0),Ft(r.$slots,"home-hero-info-after",{},void 0,!0),t.actions?(lt(),Ut("div",YAt,[(lt(!0),Ut(bn,null,Yh(t.actions,s=>(lt(),Ut("div",{key:s.link,class:"action"}
2,[Ar(kAt,{tag:"a",size:"medium",theme:s.theme,text:s.text,href:s.link,target:s.target,rel:s.rel},null,8,["theme","text","href","target","rel"])]))),128))])):Ke("",!0),Ft(r.$slots,"home-hero-actions-after",{},void 0,!0)]),t.image||yt(e)?(lt(),Ut("div",$At,[Kt("div",HAt,[i[0]||(i[0]=Kt("div",{class:"image-bg"},null,-1)),Ft(r.$slots,"home-hero-image",{},()=>[t.image?(lt(),Er(PG,{key:0,class:"image-src",image:t.image},null,8,["image"])):Ke("",!0)],!0)])])):Ke("",!0)])],2))}}),qAt=jr(KAt,[["__scopeId","data-v-8ce305d3"]]),ZAt=ir({__name:"VPHomeHero",setup(t){const{frontmatter:e}=Ci();return(r,i)=>yt(e).hero?(lt(),Er(qAt,{key:0,class:"VPHomeHero",name:yt(e).hero.name,text:yt(e).hero.text,tagline:yt(e).hero.tagline,image:yt(e).hero.image,actions:yt(e).hero.actions},{"home-hero-info-before":Jt(()=>[Ft(r.$slots,"home-hero-info-before")]),"home-hero-info":Jt(()=>[Ft(r.$slots,"home-hero-info")]),"home-hero-info-after":Jt(()=>[Ft(r.$slots,"home-hero-info-after")]),"home-hero-actions-after":Jt(()=>[Ft(r.$slots,"home-hero-actions-after")]),"home-hero-image":Jt(()=>[Ft(r.$slots,"home-hero-image")]),_:3},8,["name","text","tagline","image","actions"])):Ke("",!0)}}),JAt={class:"box"},QAt={key:0,class:"icon"},txt=["innerHTML"],ext=["innerHTML"],rxt=["innerHTML"],ixt={key:4,class:"link-text"},sxt={class:"link-text-value"},oxt=ir({__name:"VPFeature",props:{icon:null,title:null,details:null,link:null,linkText:null,rel:null,target:null},setup(t){return(e,r)=>(lt(),Er(um,{class:"VPFeature",href:t.link,rel:t.rel,target:t.target,"no-icon":!0,tag:t.link?"a":"div"},{default:Jt(()=>[Kt("article",JAt,[typeof t.icon=="object"&&t.icon.wrap?(lt(),Ut("div",QAt,[Ar(PG,{image:t.icon,alt:t.icon.alt,height:t.icon.height||48,width:t.icon.width||48},null,8,["image","alt","height","width"])])):typeof t.icon=="object"?(lt(),Er(PG,{key:1,image:t.icon,alt:t.icon.alt,height:t.icon.height||48,width:t.icon.width||48},null,8,["image","alt","height","width"])):t.icon?(lt(),Ut("div",{key:2,class:"icon",innerHTML:t.icon},null,8,txt)):Ke("",!0),Kt("h2",{class:"title",innerHTML:t.title},null,8,ext),t.details?(lt(),Ut("p",{key:3,class:"details",innerHTML:t.details},null,8,rxt)):Ke("",!0),t.linkText?(lt(),Ut("div",ixt,[Kt("p",sxt,[qS(No(t.linkText)+" ",1),r[0]||(r[0]=Kt("span",{class:"vpi-arrow-right link-text-icon"},null,-1))])])):Ke("",!0)])]),_:1},8,["href","rel","target","tag"]))}}),nxt=jr(oxt,[["__scopeId","data-v-7171e2c2"]]),axt={key:0,class:"VPFeatures"},lxt={class:"container"},cxt={class:"items"},hxt=ir({__name:"VPFeatures",props:{features:null},setup(t){const e=t,r=ni(()=>{const i=e.features.length;if(i){if(i===2)return"grid-2";if(i===3)return"grid-3";if(i%3===0)return"grid-6";if(i>3)return"grid-4"}else return});return(i,s)=>t.features?(lt(),Ut("div",axt,[Kt("div",lxt,[Kt("div",cxt,[(lt(!0),Ut(bn,null,Yh(t.features,o=>(lt(),Ut("div",{key:o.title,class:xo(["item",[r.value]])},[Ar(nxt,{icon:o.icon,title:o.title,details:o.details,link:o.link,"link-text":o.linkText,rel:o.rel,target:o.target},null,8,["icon","title","details","link","link-text","rel","target"])],2))),128))])])])):Ke("",!0)}}),uxt=jr(hxt,[["__scopeId","data-v-665a63b1"]]),dxt=ir({__name:"VPHomeFeatures",setup(t){const{frontmatter:e}=Ci();return(r,i)=>yt(e).features?(lt(),Er(uxt,{key:0,class:"VPHomeFeatures",features:yt(e).features},null,8,["features"])):Ke("",!0)}}),fxt=ir({__name:"VPHomeContent",setup(t){const{width:e}=wae({initialWidth:0,includeScrollbar:!1});return(r,i)=>(lt(),Ut("div",{class:"vp-doc container",style:REt(yt(e)?{"--vp-offset":`calc(50% - ${yt(e)/2}px)`}:{})},[Ft(r.$slots,"default",{},void 0,!0)],4))}}),pxt=jr(fxt,[["__scopeId","data-v-d792b75c"]]),gxt=ir({__name:"VPHome",setup(t){const{frontmatter:e,theme:r}=Ci();return(i,s)=>{const o=JS("Content");return lt(),Ut("div",{class:xo(["VPHome",{"external-link-icon-enabled":yt(r).externalLinkIcon}])},[Ft(i.$slots,"home-hero-before",{},void 0,!0),Ar(ZAt,null,{"home-hero-info-before":Jt(()=>[Ft(i.$slots,"home-hero-info-before",{},void 0,!0)]),"home-hero-info":Jt(()=>[Ft(i.$slots,"home-hero-info",{},void 0,!0)]),"home-hero-info-after":Jt(()=>[Ft(i.$slots,"home-hero-info-after",{},void 0,!0)]),"home-hero-actions-after":Jt(()=>[Ft(i.$slots,"home-hero-actions-after",{},void 0,!0)]),"home-hero-image":Jt(()=>[Ft(i.$slots,"home-hero-image",{},void 0,!0)]),_:3}),Ft(i.$slots,"home-hero-after",{},void 0,!0),Ft(i.$slots,"home-features-before",{},void 0,!0),Ar(dxt),Ft(i.$slots,"home-features-after",{},void 0,!0),yt(e).markdownStyles!==!1?(lt(),Er(pxt,{key:0},{default:Jt(()=>[Ar(o)]),_:1})):(lt(),Er(o,{key:1}))],2)}}}),mxt=jr(gxt,[["__scopeId","data-v-30fc7a4d"]]),yxt={},vxt={class:"VPPage"};function _xt(t,e){const r=JS("Content");return lt(),Ut("div",vxt,[Ft(t.$slots,"page-top"),Ar(r),Ft(t.$slots,"page-bottom")])}const bxt=jr(yxt,[["render",_xt]]),wxt=ir({__name:"VPContent",setup(t){const{page:e,frontmatter:r}=Ci(),{hasSidebar:i}=t0();return(s,o)=>(lt(),Ut("div",{class:xo(["VPContent",{"has-sidebar":yt(i),"is-home":yt(r).layout==="home"}]),id:"VPContent"},[yt(e).isNotFound?Ft(s.$slots,"not-found",{},()=>[Ar(U1t)],!0,0):yt(r).layout==="page"?(lt(),Er(bxt,{key:1},{"page-top":Jt(()=>[Ft(s.$slots,"page-top",{},void 0,!0)]),"page-bottom":Jt(()=>[Ft(s.$slots,"page-bottom",{},void 0,!0)]),_:3})):yt(r).layout==="home"?(lt(),Er(mxt,{key:2},{"home-hero-before":Jt(()=>[Ft(s.$slots,"home-hero-before",{},void 0,!0)]),"home-hero-info-before":Jt(()=>[Ft(s.$slots,"home-hero-info-before",{},void 0,!0)]),"home-hero-info":Jt(()=>[Ft(s.$slots,"home-hero-info",{},void 0,!0)]),"home-hero-info-after":Jt(()=>[Ft(s.$slots,"home-hero-info-after",{},void 0,!0)]),"home-hero-actions-after":Jt(()=>[Ft(s.$slots,"home-hero-actions-after",{},void 0,!0)]),"home-hero-image":Jt(()=>[Ft(s.$slots,"home-hero-image",{},void 0,!0)]),"home-hero-after":Jt(()=>[Ft(s.$slots,"home-hero-after",{},void 0,!0)]),"home-features-before":Jt(()=>[Ft(s.$slots,"home-features-before",{},void 0,!0)]),"home-features-after":Jt(()=>[Ft(s.$slots,"home-features-after",{},void 0,!0)]),_:3})):yt(r).layout&&yt(r).layout!=="doc"?(lt(),Er(Fy(yt(r).layout),{key:3})):(lt(),Er(FAt,{key:4},{"doc-top":Jt(()=>[Ft(s.$slots,"doc-top",{},void 0,!0)]),"doc-bottom":Jt(()=>[Ft(s.$slots,"doc-bottom",{},void 0,!0)]),"doc-footer-before":Jt(()=>[Ft(s.$slots,"doc-footer-before",{},void 0,!0)]),"doc-before":Jt(()=>[Ft(s.$slots,"doc-before",{},void 0,!0)]),"doc-after":Jt(()=>[Ft(s.$slots,"doc-after",{},void 0,!0)]),"aside-top":Jt(()=>[Ft(s.$slots,"aside-top",{},void 0,!0)]),"aside-outline-before":Jt(()=>[Ft(s.$slots,"aside-outline-before",{},void 0,!0)]),"aside-outline-after":Jt(()=>[Ft(s.$slots,"aside-outline-after",{},void 0,!0)]),"aside-ads-before":Jt(()=>[Ft(s.$slots,"aside-ads-before",{},void 0,!0)]),"aside-ads-after":Jt(()=>[Ft(s.$slots,"aside-ads-after",{},void 0,!0)]),"aside-bottom":Jt(()=>[Ft(s.$slots,"aside-bottom",{},void 0,!0)]),_:3}))],2))}}),Ext=jr(wxt,[["__scopeId","data-v-7a554675"]]),Axt={class:"container"},xxt=["innerHTML"],Sxt=["innerHTML"],Txt=ir({__name:"VPFooter",setup(t){const{theme:e,frontmatter:r}=Ci(),{hasSidebar:i}=t0();return(s,o)=>yt(e).footer&&yt(r).footer!==!1?(lt(),Ut("footer",{key:0,class:xo(["VPFooter",{"has-sidebar":yt(i)}])},[Kt("div",Axt,[yt(e).footer.message?(lt(),Ut("p",{key:0,class:"message",innerHTML:yt(e).footer.message},null,8,xxt)):Ke("",!0),yt(e).footer.copyright?(lt(),Ut("p",{key:1,class:"copyright",innerHTML:yt(e).footer.copyright},null,8,Sxt)):Ke("",!0)])],2)):Ke("",!0)}}),Rxt=jr(Txt,[["__scopeId","data-v-cc6a8507"]]);function Cxt(){const{theme:t,frontmatter:e}=Ci(),r=SEt([]),i=ni(()=>r.value.length>0);return _V(()=>{r.value=cY(e.value.outline??t.value.outline)}),{headers:r,hasLocalNav:i}
2}const Mxt={class:"menu-text"},Bxt={class:"header"},Oxt={class:"outline"},Ixt=ir({__name:"VPLocalNavOutlineDropdown",props:{headers:null,navHeight:null},setup(t){const e=t,{theme:r}=Ci(),i=co(!1),s=co(0),o=co(),n=co();function a(u){var d;(d=o.value)!=null&&d.contains(u.target)||(i.value=!1)}Dy(i,u=>{if(u){document.addEventListener("click",a);return}document.removeEventListener("click",a)}),Eae("Escape",()=>{i.value=!1}),_V(()=>{i.value=!1});function l(){i.value=!i.value,s.value=window.innerHeight+Math.min(window.scrollY-e.navHeight,0)}function c(u){u.target.classList.contains("outline-link")&&(n.value&&(n.value.style.transition="none"),CEt(()=>{i.value=!1}))}function h(){i.value=!1,window.scrollTo({top:0,left:0,behavior:"smooth"})}return(u,d)=>(lt(),Ut("div",{class:"VPLocalNavOutlineDropdown",style:REt({"--vp-vh":s.value+"px"}),ref_key:"main",ref:o},[t.headers.length>0?(lt(),Ut("button",{key:0,onClick:l,class:xo({open:i.value})},[Kt("span",Mxt,No(yt(get)(yt(r))),1),d[0]||(d[0]=Kt("span",{class:"vpi-chevron-right icon"},null,-1))],2)):(lt(),Ut("button",{key:1,onClick:h},No(yt(r).returnToTopLabel||"Return to top"),1)),Ar(KQ,{name:"flyout"},{default:Jt(()=>[i.value?(lt(),Ut("div",{key:0,ref_key:"items",ref:n,class:"items",onClick:c},[Kt("div",Bxt,[Kt("a",{class:"top-link",href:"#",onClick:h},No(yt(r).returnToTopLabel||"Return to top"),1)]),Kt("div",Oxt,[Ar(met,{headers:t.headers},null,8,["headers"])])],512)):Ke("",!0)]),_:1})],4))}}),Dxt=jr(Ixt,[["__scopeId","data-v-276f2739"]]),Pxt={class:"container"},Fxt=["aria-expanded"],Nxt={class:"menu-text"},kxt=ir({__name:"VPLocalNav",props:{open:{type:Boolean}},emits:["open-menu"],setup(t){const{theme:e,frontmatter:r}=Ci(),{hasSidebar:i}=t0(),{headers:s}=Cxt(),{y:o}=MEt(),n=co(0);Py(()=>{n.value=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--vp-nav-height"))}),_V(()=>{s.value=cY(r.value.outline??e.value.outline)});const a=ni(()=>s.value.length===0),l=ni(()=>a.value&&!i.value),c=ni(()=>({VPLocalNav:!0,"has-sidebar":i.value,empty:a.value,fixed:l.value}));return(h,u)=>yt(r).layout!=="home"&&(!l.value||yt(o)>=n.value)?(lt(),Ut("div",{key:0,class:xo(c.value)},[Kt("div",Pxt,[yt(i)?(lt(),Ut("button",{key:0,class:"menu","aria-expanded":t.open,"aria-controls":"VPSidebarNav",onClick:u[0]||(u[0]=d=>h.$emit("open-menu"))},[u[1]||(u[1]=Kt("span",{class:"vpi-align-left menu-icon"},null,-1)),Kt("span",Nxt,No(yt(e).sidebarMenuLabel||"Menu"),1)],8,Fxt)):Ke("",!0),Ar(Dxt,{headers:yt(s),navHeight:n.value},null,8,["headers","navHeight"])])],2)):Ke("",!0)}}),Lxt=jr(kxt,[["__scopeId","data-v-30290514"]]);function Uxt(){const t=co(!1);function e(){t.value=!0,window.addEventListener("resize",s)}function r(){t.value=!1,window.removeEventListener("resize",s)}function i(){t.value?r():e()}function s(){window.outerWidth>=768&&r()}const o=KU();return Dy(()=>o.path,r),{isScreenOpen:t,openScreen:e,closeScreen:r,toggleScreen:i}}const Gxt={},Wxt={class:"VPSwitch",type:"button",role:"switch"},jxt={class:"check"},Xxt={key:0,class:"icon"};function zxt(t,e){return lt(),Ut("button",Wxt,[Kt("span",jxt,[t.$slots.default?(lt(),Ut("span",Xxt,[Ft(t.$slots,"default",{},void 0,!0)])):Ke("",!0)])])}const Vxt=jr(Gxt,[["render",zxt],["__scopeId","data-v-1c1aaf17"]]),Yxt=ir({__name:"VPSwitchAppearance",setup(t){const{isDark:e,theme:r}=Ci(),i=bV("toggle-appearance",()=>{e.value=!e.value}),s=co("");return JQ(()=>{s.value=e.value?r.value.lightModeSwitchTitle||"Switch to light theme":r.value.darkModeSwitchTitle||"Switch to dark theme"}),(o,n)=>(lt(),Er(Vxt,{title:s.value,class:"VPSwitchAppearance","aria-checked":yt(e),onClick:yt(i)},{default:Jt(()=>[...n[0]||(n[0]=[Kt("span",{class:"vpi-sun sun"},null,-1),Kt("span",{class:"vpi-moon moon"},null,-1)])]),_:1},8,["title","aria-checked","onClick"]))}}),hY=jr(Yxt,[["__scopeId","data-v-1068e8cf"]]),$xt={key:0,class:"VPNavBarAppearance"},Hxt=ir({__name:"VPNavBarAppearance",setup(t){const{site:e}=Ci();return(r,i)=>yt(e).appearance&&yt(e).appearance!=="force-dark"&&yt(e).appearance!=="force-auto"?(lt(),Ut("div",$xt,[Ar(hY)])):Ke("",!0)}}),Kxt=jr(Hxt,[["__scopeId","data-v-8e66a1fc"]]),uY=co();let yet=!1,dY=0;function qxt(t){const e=co(!1);if(wV){!yet&&Zxt(),dY++;const r=Dy(uY,i=>{var s,o,n;i===t.el.value||(s=t.el.value)!=null&&s.contains(i)?(e.value=!0,(o=t.onF
2ocus)==null||o.call(t)):(e.value=!1,(n=t.onBlur)==null||n.call(t))});vV(()=>{r(),dY--,dY||Jxt()})}return Aae(e)}function Zxt(){document.addEventListener("focusin",vet),yet=!0,uY.value=document.activeElement}function Jxt(){document.removeEventListener("focusin",vet)}function vet(){uY.value=document.activeElement}const Qxt={class:"VPMenuLink"},tSt=["innerHTML"],eSt=ir({__name:"VPMenuLink",props:{item:null},setup(t){const{page:e}=Ci();return(r,i)=>(lt(),Ut("div",Qxt,[Ar(um,{class:xo({active:yt(ZS)(yt(e).relativePath,t.item.activeMatch||t.item.link,!!t.item.activeMatch)}),href:t.item.link,target:t.item.target,rel:t.item.rel,"no-icon":t.item.noIcon},{default:Jt(()=>[Kt("span",{innerHTML:t.item.text},null,8,tSt)]),_:1},8,["class","href","target","rel","no-icon"])]))}}),FG=jr(eSt,[["__scopeId","data-v-cb7a3302"]]),rSt={class:"VPMenuGroup"},iSt={key:0,class:"title"},sSt=ir({__name:"VPMenuGroup",props:{text:null,items:null},setup(t){return(e,r)=>(lt(),Ut("div",rSt,[t.text?(lt(),Ut("p",iSt,No(t.text),1)):Ke("",!0),(lt(!0),Ut(bn,null,Yh(t.items,i=>(lt(),Ut(bn,null,["link"in i?(lt(),Er(FG,{key:0,item:i},null,8,["item"])):Ke("",!0)],64))),256))]))}}),oSt=jr(sSt,[["__scopeId","data-v-d76fc915"]]),nSt={class:"VPMenu"},aSt={key:0,class:"items"},lSt=ir({__name:"VPMenu",props:{items:null},setup(t){return(e,r)=>(lt(),Ut("div",nSt,[t.items?(lt(),Ut("div",aSt,[(lt(!0),Ut(bn,null,Yh(t.items,i=>(lt(),Ut(bn,{key:JSON.stringify(i)},["link"in i?(lt(),Er(FG,{key:0,item:i},null,8,["item"])):"component"in i?(lt(),Er(Fy(i.component),Jw({key:1,ref_for:!0},i.props),null,16)):(lt(),Er(oSt,{key:2,text:i.text,items:i.items},null,8,["text","items"]))],64))),128))])):Ke("",!0),Ft(e.$slots,"default",{},void 0,!0)]))}}),cSt=jr(lSt,[["__scopeId","data-v-8192f3df"]]),hSt=["aria-expanded","aria-label"],uSt={key:0,class:"text"},dSt=["innerHTML"],fSt={key:1,class:"vpi-more-horizontal icon"},pSt={class:"menu"},gSt=ir({__name:"VPFlyout",props:{icon:null,button:null,label:null,items:null},setup(t){const e=co(!1),r=co();qxt({el:r,onBlur:i});function i(){e.value=!1}return(s,o)=>(lt(),Ut("div",{class:"VPFlyout",ref_key:"el",ref:r,onMouseenter:o[1]||(o[1]=n=>e.value=!0),onMouseleave:o[2]||(o[2]=n=>e.value=!1)},[Kt("button",{type:"button",class:"button","aria-haspopup":"true","aria-expanded":e.value,"aria-label":t.label,onClick:o[0]||(o[0]=n=>e.value=!e.value)},[t.button||t.icon?(lt(),Ut("span",uSt,[t.icon?(lt(),Ut("span",{key:0,class:xo([t.icon,"option-icon"])},null,2)):Ke("",!0),t.button?(lt(),Ut("span",{key:1,innerHTML:t.button},null,8,dSt)):Ke("",!0),o[3]||(o[3]=Kt("span",{class:"vpi-chevron-down text-icon"},null,-1))])):(lt(),Ut("span",fSt))],8,hSt),Kt("div",pSt,[Ar(cSt,{items:t.items},{default:Jt(()=>[Ft(s.$slots,"default",{},void 0,!0)]),_:3},8,["items"])])],544))}}),fY=jr(gSt,[["__scopeId","data-v-0355b447"]]),mSt=["href","aria-label","innerHTML"],ySt=ir({__name:"VPSocialLink",props:{icon:null,link:null,ariaLabel:null},setup(t){const e=t,r=co();Py(async()=>{var o;await CEt();const s=(o=r.value)==null?void 0:o.children[0];s instanceof HTMLElement&&s.className.startsWith("vpi-social-")&&(getComputedStyle(s).maskImage||getComputedStyle(s).webkitMaskImage)==="none"&&s.style.setProperty("--icon",`url('https://api.iconify.design/simple-icons/${e.icon}.svg')`)});const i=ni(()=>typeof e.icon=="object"?e.icon.svg:`<span class="vpi-social-${e.icon}"></span>`);return(s,o)=>(lt(),Ut("a",{ref_key:"el",ref:r,class:"VPSocialLink no-icon",href:t.link,"aria-label":t.ariaLabel??(typeof t.icon=="string"?t.icon:""),target:"_blank",rel:"noopener",innerHTML:i.value},null,8,mSt))}}),vSt=jr(ySt,[["__scopeId","data-v-23bfb711"]]),_St={class:"VPSocialLinks"},bSt=ir({__name:"VPSocialLinks",props:{links:null},setup(t){return(e,r)=>(lt(),Ut("div",_St,[(lt(!0),Ut(bn,null,Yh(t.links,({link:i,icon:s,ariaLabel:o})=>(lt(),Er(vSt,{key:i,icon:s,link:i,ariaLabel:o},null,8,["icon","link","ariaLabel"]))),128))]))}}),pY=jr(bSt,[["__scopeId","data-v-08f4ff64"]]),wSt={key:0,class:"group translations"},ESt={class:"trans-title"},ASt={key:1,class:"group"},xSt={class:"item appearance"},SSt={class:"label"},TSt={class:"appearance-action"},RSt={key:2,class:"group"},CSt={class:"item social-links"},MSt=ir({__name:"VPNavBarExtra",setup(t){const{site:e,theme:r}=Ci(),{localeLinks:i,currentLang:s}=CO({correspondingLink:!0}),o=ni(()=>
2i.value.length&&s.value.label||e.value.appearance||r.value.socialLinks);return(n,a)=>o.value?(lt(),Er(fY,{key:0,class:"VPNavBarExtra",label:"extra navigation"},{default:Jt(()=>[yt(i).length&&yt(s).label?(lt(),Ut("div",wSt,[Kt("p",ESt,No(yt(s).label),1),(lt(!0),Ut(bn,null,Yh(yt(i),l=>(lt(),Er(FG,{key:l.link,item:l},null,8,["item"]))),128))])):Ke("",!0),yt(e).appearance&&yt(e).appearance!=="force-dark"&&yt(e).appearance!=="force-auto"?(lt(),Ut("div",ASt,[Kt("div",xSt,[Kt("p",SSt,No(yt(r).darkModeSwitchLabel||"Appearance"),1),Kt("div",TSt,[Ar(hY)])])])):Ke("",!0),yt(r).socialLinks?(lt(),Ut("div",RSt,[Kt("div",CSt,[Ar(pY,{class:"social-links-list",links:yt(r).socialLinks},null,8,["links"])])])):Ke("",!0)]),_:1})):Ke("",!0)}}),BSt=jr(MSt,[["__scopeId","data-v-814164f8"]]),OSt=["aria-expanded"],ISt=ir({__name:"VPNavBarHamburger",props:{active:{type:Boolean}},emits:["click"],setup(t){return(e,r)=>(lt(),Ut("button",{type:"button",class:xo(["VPNavBarHamburger",{active:t.active}]),"aria-label":"mobile navigation","aria-expanded":t.active,"aria-controls":"VPNavScreen",onClick:r[0]||(r[0]=i=>e.$emit("click"))},[...r[1]||(r[1]=[Kt("span",{class:"container"},[Kt("span",{class:"top"}),Kt("span",{class:"middle"}),Kt("span",{class:"bottom"})],-1)])],10,OSt))}}),DSt=jr(ISt,[["__scopeId","data-v-e32aa638"]]),PSt=["innerHTML"],FSt=ir({__name:"VPNavBarMenuLink",props:{item:null},setup(t){const{page:e}=Ci();return(r,i)=>(lt(),Er(um,{class:xo({VPNavBarMenuLink:!0,active:yt(ZS)(yt(e).relativePath,t.item.activeMatch||t.item.link,!!t.item.activeMatch)}),href:t.item.link,target:t.item.target,rel:t.item.rel,"no-icon":t.item.noIcon,tabindex:"0"},{default:Jt(()=>[Kt("span",{innerHTML:t.item.text},null,8,PSt)]),_:1},8,["class","href","target","rel","no-icon"]))}}),NSt=jr(FSt,[["__scopeId","data-v-073ce319"]]),kSt=ir({__name:"VPNavBarMenuGroup",props:{item:null},setup(t){const e=t,{page:r}=Ci(),i=o=>"component"in o?!1:"link"in o?ZS(r.value.relativePath,o.link,!!e.item.activeMatch):o.items.some(i),s=ni(()=>i(e.item));return(o,n)=>(lt(),Er(fY,{class:xo({VPNavBarMenuGroup:!0,active:yt(ZS)(yt(r).relativePath,t.item.activeMatch,!!t.item.activeMatch)||s.value}),button:t.item.text,items:t.item.items},null,8,["class","button","items"]))}}),LSt={key:0,"aria-labelledby":"main-nav-aria-label",class:"VPNavBarMenu"},USt=ir({__name:"VPNavBarMenu",setup(t){const{theme:e}=Ci();return(r,i)=>yt(e).nav?(lt(),Ut("nav",LSt,[i[0]||(i[0]=Kt("span",{id:"main-nav-aria-label",class:"visually-hidden"}," Main Navigation ",-1)),(lt(!0),Ut(bn,null,Yh(yt(e).nav,s=>(lt(),Ut(bn,{key:JSON.stringify(s)},["link"in s?(lt(),Er(NSt,{key:0,item:s},null,8,["item"])):"component"in s?(lt(),Er(Fy(s.component),Jw({key:1,ref_for:!0},s.props),null,16)):(lt(),Er(kSt,{key:2,item:s},null,8,["item"]))],64))),128))])):Ke("",!0)}}),GSt=jr(USt,[["__scopeId","data-v-fa28baf9"]]);function WSt(t){const{localeIndex:e,theme:r}=Ci();function i(s){var g,p,m;const o=s.split("."),n=(g=r.value.search)==null?void 0:g.options,a=n&&typeof n=="object",l=a&&((m=(p=n.locales)==null?void 0:p[e.value])==null?void 0:m.translations)||null,c=a&&n.translations||null;let h=l,u=c,d=t;const f=o.pop();for(const v of o){let b=null;const y=d==null?void 0:d[v];y&&(b=d=y);const _=u==null?void 0:u[v];_&&(b=u=_);const w=h==null?void 0:h[v];w&&(b=h=w),y||(d=b),_||(u=b),w||(h=b)}return(h==null?void 0:h[f])??(u==null?void 0:u[f])??(d==null?void 0:d[f])??""}return i}const jSt=["aria-label"],XSt={class:"DocSearch-Button-Container"},zSt={class:"DocSearch-Button-Placeholder"},_et=ir({__name:"VPNavBarSearchButton",setup(t){const e=WSt({button:{buttonText:"Search",buttonAriaLabel:"Search"}});return(r,i)=>(lt(),Ut("button",{type:"button",class:"DocSearch DocSearch-Button","aria-label":yt(e)("button.buttonAriaLabel")},[Kt("span",XSt,[i[0]||(i[0]=Kt("span",{class:"vp-icon DocSearch-Search-Icon"},null,-1)),Kt("span",zSt,No(yt(e)("button.buttonText")),1)]),i[1]||(i[1]=Kt("span",{class:"DocSearch-Button-Keys"},[Kt("kbd",{class:"DocSearch-Button-Key"}),Kt("kbd",{class:"DocSearch-Button-Key"},"K")],-1))],8,jSt))}}),VSt={class:"VPNavBarSearch"},YSt={id:"local-search"},$St={key:1,id:"docsearch"},HSt=ir({__name:"VPNavBarSearch",setup(t){const e=()=>null,r=xae(()=>JB(()=>import("./VPAlgoliaSearchBox.BVtHE2fX.js"),__vite__mapDeps([0,1]))),{theme:i}=Ci(),s=co(!1),o=co(!1),n=()=>{const d="VPAlgoliaPreconnect";(window.requestIdleCallback||setTimeout)(()=>{var g;const f=document.createElement("link");
2f.id=d,f.rel="preconnect",f.href=`https://${(((g=i.value.search)==null?void 0:g.options)??i.value.algolia).appId}-dsn.algolia.net`,f.crossOrigin="",document.head.appendChild(f)})};Py(()=>{n();const d=g=>{(g.key.toLowerCase()==="k"&&(g.metaKey||g.ctrlKey)||!c(g)&&g.key==="/")&&(g.preventDefault(),a(),f())},f=()=>{window.removeEventListener("keydown",d)};window.addEventListener("keydown",d),vV(f)});function a(){s.value||(s.value=!0,setTimeout(l,16))}function l(){const d=new Event("keydown");d.key="k",d.metaKey=!0,window.dispatchEvent(d),setTimeout(()=>{document.querySelector(".DocSearch-Modal")||l()},16)}function c(d){const f=d.target,g=f.tagName;return f.isContentEditable||g==="INPUT"||g==="SELECT"||g==="TEXTAREA"}const h=co(!1),u="algolia";return(d,f)=>{var g;return lt(),Ut("div",VSt,[yt(u)==="local"?(lt(),Ut(bn,{key:0},[h.value?(lt(),Er(yt(e),{key:0,onClose:f[0]||(f[0]=p=>h.value=!1)})):Ke("",!0),Kt("div",YSt,[Ar(_et,{onClick:f[1]||(f[1]=p=>h.value=!0)})])],64)):yt(u)==="algolia"?(lt(),Ut(bn,{key:1},[s.value?(lt(),Er(yt(r),{key:0,algolia:((g=yt(i).search)==null?void 0:g.options)??yt(i).algolia,onVnodeBeforeMount:f[2]||(f[2]=p=>o.value=!0)},null,8,["algolia"])):Ke("",!0),o.value?Ke("",!0):(lt(),Ut("div",$St,[Ar(_et,{onClick:a})]))],64)):Ke("",!0)])}}}),KSt=ir({__name:"VPNavBarSocialLinks",setup(t){const{theme:e}=Ci();return(r,i)=>yt(e).socialLinks?(lt(),Er(pY,{key:0,class:"VPNavBarSocialLinks",links:yt(e).socialLinks},null,8,["links"])):Ke("",!0)}}),qSt=jr(KSt,[["__scopeId","data-v-fa2ae4c7"]]),ZSt=["href","rel","target"],JSt=["innerHTML"],QSt={key:2},tTt=ir({__name:"VPNavBarTitle",setup(t){const{site:e,theme:r}=Ci(),{hasSidebar:i}=t0(),{currentLang:s}=CO(),o=ni(()=>{var l;return typeof r.value.logoLink=="string"?r.value.logoLink:(l=r.value.logoLink)==null?void 0:l.link}),n=ni(()=>{var l;return typeof r.value.logoLink=="string"||(l=r.value.logoLink)==null?void 0:l.rel}),a=ni(()=>{var l;return typeof r.value.logoLink=="string"||(l=r.value.logoLink)==null?void 0:l.target});return(l,c)=>(lt(),Ut("div",{class:xo(["VPNavBarTitle",{"has-sidebar":yt(i)}])},[Kt("a",{class:"title",href:o.value??yt(nY)(yt(s).link),rel:n.value,target:a.value},[Ft(l.$slots,"nav-bar-title-before",{},void 0,!0),yt(r).logo?(lt(),Er(PG,{key:0,class:"logo",image:yt(r).logo},null,8,["image"])):Ke("",!0),yt(r).siteTitle?(lt(),Ut("span",{key:1,innerHTML:yt(r).siteTitle},null,8,JSt)):yt(r).siteTitle===void 0?(lt(),Ut("span",QSt,No(yt(e).title),1)):Ke("",!0),Ft(l.$slots,"nav-bar-title-after",{},void 0,!0)],8,ZSt)],2))}}),eTt=jr(tTt,[["__scopeId","data-v-dd0d29cd"]]),rTt={class:"items"},iTt={class:"title"},sTt=ir({__name:"VPNavBarTranslations",setup(t){const{theme:e}=Ci(),{localeLinks:r,currentLang:i}=CO({correspondingLink:!0});return(s,o)=>yt(r).length&&yt(i).label?(lt(),Er(fY,{key:0,class:"VPNavBarTranslations",icon:"vpi-languages",label:yt(e).langMenuLabel||"Change language"},{default:Jt(()=>[Kt("div",rTt,[Kt("p",iTt,No(yt(i).label),1),(lt(!0),Ut(bn,null,Yh(yt(r),n=>(lt(),Er(FG,{key:n.link,item:n},null,8,["item"]))),128))])]),_:1},8,["label"])):Ke("",!0)}}),oTt=jr(sTt,[["__scopeId","data-v-2dd0be64"]]),nTt={class:"wrapper"},aTt={class:"container"},lTt={class:"title"},cTt={class:"content"},hTt={class:"content-body"},uTt=ir({__name:"VPNavBar",props:{isScreenOpen:{type:Boolean}},emits:["toggle-screen"],setup(t){const e=t,{y:r}=MEt(),{hasSidebar:i}=t0(),{frontmatter:s}=Ci(),o=co({});return JQ(()=>{o.value={"has-sidebar":i.value,home:s.value.layout==="home",top:r.value===0,"screen-open":e.isScreenOpen}}),(n,a)=>(lt(),Ut("div",{class:xo(["VPNavBar",o.value])},[Kt("div",nTt,[Kt("div",aTt,[Kt("div",lTt,[Ar(eTt,null,{"nav-bar-title-before":Jt(()=>[Ft(n.$slots,"nav-bar-title-before",{},void 0,!0)]),"nav-bar-title-after":Jt(()=>[Ft(n.$slots,"nav-bar-title-after",{},void 0,!0)]),_:3})]),Kt("div",cTt,[Kt("div",hTt,[Ft(n.$slots,"nav-bar-content-before",{},void 0,!0),Ar(HSt,{class:"search"}),Ar(GSt,{class:"menu"}),Ar(oTt,{class:"translations"}),Ar(Kxt,{class:"appearance"}),Ar(qSt,{class:"social-links"}),Ar(BSt,{class:"extra"}),Ft(n.$slots,"nav-bar-content-after",{},void 0,!0),Ar(DSt,{class:"hamburger",active:t.isScreenOpen,onClick:a[0]||(a[0]=l=>n.$emit("toggle-screen"))},null,8,["active"])])])])]),a[1]||(a[1]=Kt("div",{class:"divider"},[Kt("div",{class:"divider-line"})],-1))],2))}}),dTt=jr(uTt,[["__scopeId","data-v-6c503bd8"]]),fTt={key:0,class:"VPNavScreenAppearance"},pTt={class:"text"},gTt=ir({__name:"VPNavScreenAppearance",setup(t){const{site:e,theme:r}=Ci();return(i,s)=>yt(e).appearance&&yt(e).appearance!=="force-dark"&&yt(e).appearance!=="force-auto"?(lt(),Ut("div",fTt,[Kt("p",pTt,No(yt(r).darkModeSwitchLabel||"Appearance"),1),Ar(hY)])):Ke("",!0)}}),mTt=jr(gTt,[["__scopeId","data-v-3ea71219"]]),yTt=["innerHTML"],vTt=ir({__name:"VPNavScreenMenuLink",props:{item:null},setup(t){const e=bV("close-screen");return(r,i)=>(lt(),Er(um,{class:"VPNavScreenMenuLink",href:t.item.link,target:t.item.target,rel:t.item.rel,"no-icon":t.item.noIcon,onClick:yt(e)},{default:Jt(()=>[Kt("span",{innerHTML:t.item.text},null,8,yTt)]),_:1},8,["href","target","rel","no-icon","onClick"]))}}),_Tt=jr(vTt,[["__scopeId","data-v-61da4deb"]]),bTt=["innerHTML"],wTt=ir({__name:"VPNavScreenMenuGroupLink",props:{item:null},setup(t){const e=bV("close-screen");return(r,i)=>(lt(),Er(um,{class:"VPNavScreenMenuGroupLink",href:t.item.link,target:t.item.target,rel:t.item.rel,"no-icon":t.item.noIcon,onClick:yt(e)},{default:Jt(()=>[Kt("span",{innerHTML:t.item.text},null,8,bTt)]),_:1},8,["href","target","rel","no-icon","onClick"]))}}),bet=jr(wTt,[["__scopeId","data-v-0dbc0c3d"]]),ETt={class:"VPNavScreenMenuGroupSection"},ATt={key:0,class:"title"},xTt=ir({__name:"VPNavScreenMenuGroupSection",props:{text:null,items:null},setup(t){return(e,r)=>(lt(),Ut("div",ETt,[t.text?(lt(),Ut("p",ATt,No(t.text),1)):Ke("",!0),(lt(!0),Ut(bn,null,Yh(t.items,i=>(lt(),Er(bet,{key:i.text,item:i},null,8,["item"]))),128))]))}}
2),STt=jr(xTt,[["__scopeId","data-v-74a6037f"]]),TTt=["aria-controls","aria-expanded"],RTt=["innerHTML"],CTt=["id"],MTt={key:0,class:"item"},BTt={key:1,class:"item"},OTt={key:2,class:"group"},ITt=ir({__name:"VPNavScreenMenuGroup",props:{text:null,items:null},setup(t){const e=t,r=co(!1),i=ni(()=>`NavScreenGroup-${e.text.replace(" ","-").toLowerCase()}`);function s(){r.value=!r.value}return(o,n)=>(lt(),Ut("div",{class:xo(["VPNavScreenMenuGroup",{open:r.value}])},[Kt("button",{class:"button","aria-controls":i.value,"aria-expanded":r.value,onClick:s},[Kt("span",{class:"button-text",innerHTML:t.text},null,8,RTt),n[0]||(n[0]=Kt("span",{class:"vpi-plus button-icon"},null,-1))],8,TTt),Kt("div",{id:i.value,class:"items"},[(lt(!0),Ut(bn,null,Yh(t.items,a=>(lt(),Ut(bn,{key:JSON.stringify(a)},["link"in a?(lt(),Ut("div",MTt,[Ar(bet,{item:a},null,8,["item"])])):"component"in a?(lt(),Ut("div",BTt,[(lt(),Er(Fy(a.component),Jw({ref_for:!0},a.props,{"screen-menu":""}),null,16))])):(lt(),Ut("div",OTt,[Ar(STt,{text:a.text,items:a.items},null,8,["text","items"])]))],64))),128))],8,CTt)],2))}}),DTt=jr(ITt,[["__scopeId","data-v-60406ed3"]]),PTt={key:0,class:"VPNavScreenMenu"},FTt=ir({__name:"VPNavScreenMenu",setup(t){const{theme:e}=Ci();return(r,i)=>yt(e).nav?(lt(),Ut("nav",PTt,[(lt(!0),Ut(bn,null,Yh(yt(e).nav,s=>(lt(),Ut(bn,{key:JSON.stringify(s)},["link"in s?(lt(),Er(_Tt,{key:0,item:s},null,8,["item"])):"component"in s?(lt(),Er(Fy(s.component),Jw({key:1,ref_for:!0},s.props,{"screen-menu":""}),null,16)):(lt(),Er(DTt,{key:2,text:s.text||"",items:s.items},null,8,["text","items"]))],64))),128))])):Ke("",!0)}}),NTt=ir({__name:"VPNavScreenSocialLinks",setup(t){const{theme:e}=Ci();return(r,i)=>yt(e).socialLinks?(lt(),Er(pY,{key:0,class:"VPNavScreenSocialLinks",links:yt(e).socialLinks},null,8,["links"])):Ke("",!0)}}),kTt={class:"list"},LTt=ir({__name:"VPNavScreenTranslations",setup(t){const{localeLinks:e,currentLang:r}=CO({correspondingLink:!0}),i=co(!1);function s(){i.value=!i.value}return(o,n)=>yt(e).length&&yt(r).label?(lt(),Ut("div",{key:0,class:xo(["VPNavScreenTranslations",{open:i.value}])},[Kt("button",{class:"title",onClick:s},[n[0]||(n[0]=Kt("span",{class:"vpi-languages icon lang"},null,-1)),qS(" "+No(yt(r).label)+" ",1),n[1]||(n[1]=Kt("span",{class:"vpi-chevron-down icon chevron"},null,-1))]),Kt("ul",kTt,[(lt(!0),Ut(bn,null,Yh(yt(e),a=>(lt(),Ut("li",{key:a.link,class:"item"},[Ar(um,{class:"link",href:a.link},{default:Jt(()=>[qS(No(a.text),1)]),_:2},1032,["href"])]))),128))])],2)):Ke("",!0)}}),UTt=jr(LTt,[["__scopeId","data-v-10ba78f9"]]),GTt={class:"container"},WTt=ir({__name:"VPNavScreen",props:{open:{type:Boolean}},setup(t){const e=co(null),r=BEt(wV?document.body:null);return(i,s)=>(lt(),Er(KQ,{name:"fade",onEnter:s[0]||(s[0]=o=>r.value=!0),onAfterLeave:s[1]||(s[1]=o=>r.value=!1)},{default:Jt(()=>[t.open?(lt(),Ut("div",{key:0,class:"VPNavScreen",ref_key:"screen",ref:e,id:"VPNavScreen"},[Kt("div",GTt,[Ft(i.$slots,"nav-screen-content-before",{},void 0,!0),Ar(FTt,{class:"menu"}),Ar(UTt,{class:"translations"}),Ar(mTt,{class:"appearance"}),Ar(NTt,{class:"social-links"}),Ft(i.$slots,"nav-screen-content-after",{},void 0,!0)])],512)):Ke("",!0)]),_:3}))}}),jTt=jr(WTt,[["__scopeId","data-v-308eeda0"]]),XTt={key:0,class:"VPNav"},zTt=ir({__name:"VPNav",setup(t){const{isScreenOpen:e,closeScreen:r,toggleScreen:i}=Uxt(),{frontmatter:s}=Ci(),o=ni(()=>s.value.navbar!==!1);return OEt("close-screen",r),yV(()=>{wV&&document.documentElement.classList.toggle("hide-nav",!o.value)}),(n,a)=>o.value?(lt(),Ut("header",XTt,[Ar(dTt,{"is-screen-open":yt(e),onToggleScreen:yt(i)},{"nav-bar-title-before":Jt(()=>[Ft(n.$slots,"nav-bar-title-before",{},void 0,!0)]),"nav-bar-title-after":Jt(()=>[Ft(n.$slots,"nav-bar-title-after",{},void 0,!0)]),"nav-bar-content-before":Jt(()=>[Ft(n.$slots,"nav-bar-content-before",{},void 0,!0)]),"nav-bar-content-after":Jt(()=>[Ft(n.$slots,"nav-bar-content-after",{},void 0,!0)]),_:3},8,["is-screen-open","onToggleScreen"]),Ar(jTt,{open:yt(e)},{"nav-screen-content-before":Jt(()=>[Ft(n.$slots,"nav-screen-content-before",{},void 0,!0)]),"nav-screen-content-after":Jt(()=>[Ft(n.$slots,"nav-screen-content-after",{},void 0,!0)]),_:3},8,["open"])])):Ke("",!0)}}),VTt=jr(zTt,[["__scopeId","data-v-1b8748ae"]]),YTt=["role","tabindex"],$Tt={key:1,class:"items"},HTt=ir({__name:"VPSidebarItem",props:{item:null,depth:null},setup(t){const e=t,{collapsed:r,collapsible:i,isLink:s,isActiveLink:o,hasActiveLink:n,hasChildren:a,toggle:l}=X1t(ni(()=>e.item)),c=ni(()=>a.value?"section":"div"),h=ni(()=>s.value?"a":"div"),u=ni(()=>a.value?e.depth+2===7?"p":`h${e.depth+2}`:"p"),d=ni(()=>s.value?void 0:"button"),f=ni(()=>[[`level-${e.depth}`],{collapsible:i.value},{collapsed:r.value},{"is-link":s.value},{"is-active":o.value},{"has-active":n.value}]);function g(m){"key"in m&&m.key!=="Enter"||!e.item.link&&l()}function p(){e.item.link&&l()}return(m,v)=>{const b=JS("VPSidebarItem",!0);return lt(),Er(Fy(c.value),{class:xo(["VPSidebarItem",f.value])},{default:Jt(()=>[t.item.text?(lt(),Ut("div",Jw({key:0,class:"item",role:d.value},Sae(t.item.items?{click:g,keydown:g}:{},!0),{tabindex:t.item.items&&0}),[v[1]||(v[1]=Kt("div",{class:"indicator"},null,-1)),t.item.link?(lt(),Er(um,{key:0,tag:h.value,class:"link",href:t.item.link,rel:t.item.rel,target:t.item.target},{default:Jt(()=>[(lt(),Er(Fy(u.value),{class:"text",innerHTML:t.item.text},null,8,["innerHTML"]))]),_:1},8,["tag","href","rel","target"])):(lt(),Er(Fy(u.value),{key:1,class:"text",innerHTML:t.item.text},null,8,["innerHTML"])),t.item.collapsed!=null&&t.item.items&&t.item.items.length?(lt(),Ut("div",{key:2,class:"caret",role:"button","aria-label":"toggle section",onClick:p,onKeydown:Tae(p,["enter"]),tabindex:"0"},[...v[0]||(v[0]=[Kt("span",{class:"vpi-chevron-right caret-icon"},null,-1)])],32)):Ke("",!0)],16,YTt)):Ke("",!0),t.item.items&&t.item.items.length?(lt(),Ut("div",$Tt,[t.depth<5?(lt(!0),Ut(bn,{key:0},Yh(t.item.items,y=>(lt(),Er(b,{key:y.text,item:y,depth:t.depth+1},null,8,["item","depth"]))),128)):Ke("",!0)])):Ke("",!0)]),_:1},8,["class"])}}}),KTt=jr(HTt,[["__scopeId","data-v-bbc8e978"]]),qTt=ir({__name:"VPSidebarGroup",props:{items:null},setup(t){const e=co(!0);let r=null;return Py(()=>{r=setTimeout(()=>{r=null,e.value=!1},300)}),IEt(()=>{r!=null&&(clearTimeout(r),r=null)}),(i,s)=>(lt(!0),Ut(bn,null,Yh(t.items,o=>(lt(),Ut("div",{key:o.text,class:xo(["group",{"no-transition":e.value}])},[Ar(KTt,{item:o,depth:0},null,8,["item"])],2))),128))}}),ZTt=jr(qTt,[["__scopeId","data-v-96ba0e50"]]),JTt={class:"nav",id:"VPSidebarNav","aria-labelledby":"sidebar-aria-label",tabindex:"-1"},QTt=ir({__name:"VPSidebar",props:{open:{type:Boolean}},setup(t){const{sidebarGroups:e,hasSidebar:r}=t0(),i=t,s=co(null),o=BEt(wV?document.body:null);Dy([i,s],()=>{var a;i.open?(o.value=!0,(a=s.value)==null||a.focus()):o.value=!1},{immediate:!0,flush:"post"});const n=co(0);return Dy(e,()=>{n.value+=1},{deep:!0}),(a,l)=>yt(r)?(lt(),Ut("aside",{key:0,class:xo(["VPSidebar",{open:t.open}]),ref_key:"navEl",ref:s,onClick:l[0]||(l[0]=Rae(()=>{},["stop"]))},[l[2]||(l[2]=Kt("div",{class:"curtain"},null,-1)),Kt("nav",JTt,[l[1]||(l[1]=Kt("span",{class:"visually-hidden",id:"sidebar-aria-label"}," Sidebar Navigation ",-1)),Ft(a.$slots,"sidebar-nav-before",{},void 0,!0),(lt(),Er(ZTt,{items:yt(e),key:n.value},null,8,["items"])),Ft(a.$slots,"sidebar-nav-after",{},void 0,!0)])],2)):Ke("",!0)}}),tRt=jr(QTt,[["__scopeId","data-v-2740b3c6"]]),eRt=ir({__name:"VPSkipLink",setup(t){const{theme:e}=Ci(),r=KU(),i=co();Dy(()=>r.path,()=>i.value.focus());function s({target:o}){const n=document.getElementById(decodeURIComponent(o.hash).slice(1));if(n){const a=()=>{n.removeAttribute("tabindex"),n.removeEventListener("blur",a)};n.setAttribute("tabindex","-1"),n.addEventListener("blur",a),n.focus(),window.scrollTo(0,0)}}return(o,n)=>(lt(),Ut(bn,null,[Kt("span",{ref_key:"backToTop",ref:i,tabindex:"-1"},null,512),Kt("a",{href:"#VPContent",class:"VPSkipLink visually-hidden",onClick:s},No(yt(e).skipToContentLabel||"Skip to content"),1)],64))}}),rRt=jr(eRt,[["__scopeId","data-v-32a01436"]]),iRt=ir({__name:"Layout",setup(t){const{isOpen:e,open:r,close:i}=t0(),s=KU();Dy(()=>s.path,i),j1t(e,i);const{frontmatter:o}=Ci(),n=Cae(),a=ni(()=>!!n["home-hero-image"]);return OEt("hero-image-slot-exists",a),(l,c)=>{const h=JS("Content");return yt(o).layout!==!1?(lt(),Ut("div",{key:0,class:xo(["Layout",yt(o).pageClass])},[Ft(l.$slots,"layout-top",{},void 0,!0),Ar(rRt),Ar(fet,{class:"backdrop",show:yt(e),onClick:yt(i)},null,8,["show","onClick"]),Ar(VTt,null,{"nav-bar-title-before":Jt(()=>[Ft(l.$slots,"nav-bar-title-before",{},void 0,!0)]),"nav-bar-title-after":Jt(()=>[Ft(l.$slots,"nav-bar-title-after",{},void 0,!0)]),"nav-bar-content-before":Jt(()=>[Ft(l.$slots,"nav-bar-content-before",{},void 0,!0)]),"nav-bar-content-after":Jt(()=>[Ft(l.$slots,"nav-bar-content-after",{},void 0,!0)]),"nav-screen-content-before":Jt(()=>[Ft(l.$slots,"nav-screen-content-before",{},void 0,!0)]),"nav-screen-content-after":Jt(()=>[Ft(l.$slots,"nav-screen-content-after",{},void 0,!0)]),_:3}),Ar(Lxt,{open:yt(e),onOpenMenu:yt(r)},null,8,["open","onOpenMenu"]),Ar(tRt,{open:yt(e)},{"sidebar-nav-before":Jt(()=>[Ft(l.$slots,"sidebar-nav-before",{},void 0,!0)]),"sidebar-nav-after":Jt(()=>[Ft(l.$slots,"sidebar-nav-after",{},void 0,!0)]),_:3},8,["open"]),Ar(Ext,null,{"page-top":Jt(()=>[Ft(l.$slots,"page-top",{},void 0,!0)]),"page-bottom":Jt(()=>[Ft(l.$slots,"page-bottom",{},void 0,!0)]),"not-found":Jt(()=>[Ft(l.$slots,"not-found",{},void 0,!0)]),"home-hero-before":Jt(()=>[Ft(l.$slots,"home-hero-before",{},void 0,!0)]),"home-hero-info-before":Jt(()=>[Ft(l.$slots,"home-hero-info-before",{},void 0,!0)]),"home-hero-info":Jt(()=>[Ft(l.$slots,"home-hero-info",{},void 0,!0)]),"home-hero-info-after":Jt(()=>[Ft(l.$slots,"home-hero-info-after",{},void 0,!0)]),"home-hero-actions-after":Jt(()=>[Ft(l.$slots,"home-hero-actions-after",{},void 0,!0)]),"home-hero-image":Jt(()=>[Ft(l.$slots,"home-hero-image",{},void 0,!0)]),"home-hero-after":Jt(()=>[Ft(l.$slots,"home-hero-after",{},void 0,!0)]),"home-features-before":Jt(()=>[Ft(l.$slots,"home-features-before",{},void 0,!0)]),"home-features-after":Jt(()=>[Ft(l.$slots,"home-features-after",{},void 0,!0)]),"doc-footer-before":Jt(()=>[Ft(l.$slots,"doc-footer-before",{},void 0,!0)]),"doc-before":Jt(()=>[Ft(l.$slots,"doc-before",{},void 0,!0)]),"doc-after":Jt(()=>[Ft(l.$slots,"doc-after",{},void 0,!0)]),"doc-top":Jt(()=>[Ft(l.$slots,"doc-top",{},void 0,!0)]),"doc-bottom":Jt(()=>[Ft(l.$slots,"doc-bottom",{},void 0,!0)]),"aside-top":Jt(()=>[Ft(l.$slots,"aside-top",{},void 0,!0)]),"aside-bottom":Jt(()=>[Ft(l.$slots,"aside-bottom",{},void 0,!0)]),"aside-outline-before":Jt(()=>[Ft(l.$slots,"aside-outline-before",{},void 0,!0)]),"aside-outline-after":Jt(()=>[Ft(l.$slots,"aside-outline-after",{},void 0,!0)]),"aside-ads-before":Jt(()=>[Ft(l.$slots,"aside-ads-before",{},void 0,!0)]),"aside-ads-after":Jt(()=>[Ft(l.$slots,"aside-ads-after",{},void 0,!0)]),_:3}),Ar(Rxt),Ft(l.$slots,"layout-bottom",{},void 0,!0)],2)):(lt(),Er(h,{key:1}))}}}
2),sRt=jr(iRt,[["__scopeId","data-v-70323d94"]]),wet={Layout:sRt,enhanceApp:({app:t})=>{t.component("Badge",hm)}};function oRt({library:t,transform:e}){const r=KU(),{isDark:i,site:s}=xEt();let o;const n=()=>setTimeout(()=>o.render(),20);Py(()=>{JB(async()=>{const{Page:a}=await import("./index.B-KTdNaC.js");return{Page:a}},[]).then(({Page:a})=>{o=new a({library:t,transform:e,isDark:i.value,path:r.path}),n()})}),Dy(()=>r.path,()=>n()),IEt(()=>{o.dispose()})}const nRt={__name:"Layout",props:Mae(["transform","library","Theme"],{transform:()=>({}),library:()=>({})}),setup(t){return oRt({transform:t.transform,library:t.library}),(e,r)=>(lt(),Er(yt(t.Theme).Layout))}};JEt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Sv=function(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t},KEt=function(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var r=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(r,i,s.get?s:{enumerable:!0,get:function(){return t[i]}})}),r};var gY={exports:{}},aRt=gY.exports,Eet;function lRt(){return Eet||(Eet=1,(function(t,e){(function(r,i){t.exports=i()})(aRt,function(){var r=function(){function i(f){return n.appendChild(f.dom),f}function s(f){for(var g=0;g<n.children.length;g++)n.children[g].style.display=g===f?"block":"none";o=f}var o=0,n=document.createElement("div");n.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",n.addEventListener("click",function(f){f.preventDefault(),s(++o%n.children.length)},!1);var a=(performance||Date).now(),l=a,c=0,h=i(new r.Panel("FPS","#0ff","#002")),u=i(new r.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var d=i(new r.Panel("MB","#f08","#201"));return s(0),{REVISION:16,dom:n,addPanel:i,showPanel:s,begin:function(){a=(performance||Date).now()},end:function(){c++;var f=(performance||Date).now();if(u.update(f-a,200),f>l+1e3&&(h.update(1e3*c/(f-l),100),l=f,c=0,d)){var g=performance.memory;d.update(g.usedJSHeapSize/1048576,g.jsHeapSizeLimit/1048576)}return f},update:function(){a=this.end()},domElement:n,setMode:s}};return r.Panel=function(i,s,o){var n=1/0,a=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,u=48*c,d=3*c,f=2*c,g=3*c,p=15*c,m=74*c,v=30*c,b=document.createElement("canvas");b.width=h,b.height=u,b.style.cssText="width:80px;height:48px";var y=b.getContext("2d");return y.font="bold "+9*c+"px Helvetica,Arial,sans-serif",y.textBaseline="top",y.fillStyle=o,y.fillRect(0,0,h,u),y.fillStyle=s,y.fillText(i,d,f),y.fillRect(g,p,m,v),y.fillStyle=o,y.globalAlpha=.9,y.fillRect(g,p,m,v),{dom:b,update:function(_,w){n=Math.min(n,_),a=Math.max(a,_),y.fillStyle=o,y.globalAlpha=1,y.fillRect(0,0,h,p),y.fillStyle=s,y.fillText(l(_)+" "+i+" ("+l(n)+"-"+l(a)+")",d,f),y.drawImage(b,g+c,p,m-c,v,g,p,m-c,v),y.fillRect(g+m-c,p,c,v),y.fillStyle=o,y.globalAlpha=.9,y.fillRect(g+m-c,p,c,l((1-_/w)*v))}}},r})})(gY)),gY.exports}var Aet=lRt();let mY,xet;mY=Sv(Aet),i1t=mE({__proto__:null,default:mY},[Aet]),xet="4.5.2";function NG(t,e){if(!t)throw new Error(e||"loader assertion failed.")}const kG=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser),Tet=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version);Tet&&parseFloat(Tet[1]);const LG=globalThis,aT=globalThis.process||{};function cRt(t){var r,i;if(typeof window<"u"&&((r=window.process)==null?void 0:r.type)==="renderer"||typeof process<"u"&&((i=process.versions)!=null&&i.electron))return!0;const e=typeof navigator<"u"&&navigator.userAgent;return!!(e&&e.indexOf("Electron")>=0)}function yY(){return!(typeof process=="object"&&String(process)==="[object process]"&&!(process!=null&&process.browser))||cRt()}const Ret="4.1.1";function vY(t,e){if(!t)throw new Error("Assertion failed")}function Cet(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return vY(Number.isFinite(e)&&e>=0),e}function hRt(t){const{logLevel:e,message:r}=t;t.logLevel=Cet(e);const i=t.args?Array.from(t.args):[];for(;i.length&&i.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&i.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break}typeof t.message=="function"&&(t.message=t.message());const s=typeof t.message;return vY(s==="string"||s==="object"),Object.assign(t,{args:i},t.opts)}const lT=()=>{};class uRt{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...r){return this._log("warn",0,e,r,{once:!0})}error(e,...r){return this._log("error",0,e,r)}log(e,r,...i){return this._log("log",e,r,i)}info(e,r,...i){return this._log("info",e,r,i)}once(e,r,...i){return this._log("once",e,r,i,{once:!0})}_log(e,r,i,s,o={}){const n=hRt({logLevel:r,message:i,args:this._buildArgs(r,i,s),opts:o});return this._createLogFunction(e,n,o)}
2_buildArgs(e,r,i){return[e,r,...i]}_createLogFunction(e,r,i){if(!this._shouldLog(r.logLevel))return lT;const s=this._getOnceTag(i.tag??r.tag??r.message);if((i.once||r.once)&&s!==void 0){if(this._onceCache.has(s))return lT;this._onceCache.add(s)}return this._emit(e,r)}_shouldLog(e){return this.getLevel()>=Cet(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}function dRt(t){try{const e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}class fRt{constructor(e,r,i="sessionStorage"){this.storage=dRt(i),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){const r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}}function pRt(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function gRt(t,e=8){const r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var UG;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(UG||(UG={}));const mRt=10;function Met(t){return typeof t!="string"?t:(t=t.toUpperCase(),UG[t]||UG.WHITE)}function yRt(t,e,r){return!yY&&typeof t=="string"&&(e&&(t=`\x1B[${Met(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${Met(r)+mRt}m${t}\x1B[49m`)),t}function vRt(t,e=["constructor"]){const r=Object.getPrototypeOf(t),i=Object.getOwnPropertyNames(r),s=t;for(const o of i){const n=s[o];typeof n=="function"&&(e.find(a=>o===a)||(s[o]=n.bind(t)))}}function MO(){var e,r,i;let t;if(yY()&&LG.performance)t=(r=(e=LG==null?void 0:LG.performance)==null?void 0:e.now)==null?void 0:r.call(e);else if("hrtime"in aT){const s=(i=aT==null?void 0:aT.hrtime)==null?void 0:i.call(aT);t=s[0]*1e3+s[1]/1e6}else t=Date.now();return t}const cT={debug:yY()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},_Y={enabled:!0,level:0};class bY extends uRt{constructor({id:e}={id:""}){super({level:0}),this.VERSION=Ret,this._startTs=MO(),this._deltaTs=MO(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new fRt(`__probe-${this.id}__`,{[this.id]:_Y}),this.timeStamp(`${this.id} started`),vRt(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((MO()-this._startTs).toPrecision(10))}getDelta(){return Number((MO()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,r){this._updateConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e,...r){return this._log("warn",0,e,r,{method:cT.warn,once:!0})}error(e,...r){return this._log("error",0,e,r,{method:cT.error})}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r,...i){return this._log("log",e,r,i,{method:cT.log,time:!0,once:!0})}log(e,r,...i){return this._log("log",e,r,i,{method:cT.debug})}info(e,r,...i){return this._log("info",e,r,i,{method:console.info})}once(e,r,...i){return this._log("once",e,r,i,{method:cT.debug||cT.info,once:!0})}table(e,r,i){return r?this._log("table",e,r,i&&[i]||[],{method:console.table||lT,tag:bRt(r)}):lT}time(e,r){return this._log("time",e,r,[],{method:console.time?console.time:console.info})}timeEnd(e,r){return this._log("time",e,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,r){return this._log("time",e,r,[],{method:console.timeStamp||lT})}group(e,r,i={collapsed:!1}){const s=(i.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,r,[],{method:s})}groupCollapsed(e,r,i={}){return this.group(e,r,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||lT})}withGroup(e,r,i){this.group(e,r)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,r){const i=r.method;vY(i),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=MO();const s=_Rt(this.id,r.message,r);return i.bind(console,s,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(_Y),this._storage.config[this.id]}_updateConfiguration(e){const r=this._storage.config[this.id]||{..._Y};this._storage.setConfiguration({[this.id]:{...r,...e}})}}bY.VERSION=Ret;function _Rt(t,e,r){if(typeof e=="string"){const i=r.time?gRt(pRt(r.total)):"";e=r.time?`${t}: ${i} ${e}`:`${t}: ${e}`,e=yRt(e,r.color,r.background)}return e}function bRt(t){for(const e in t)for(const r in t[e])return r||"untitled";return"empty"}const wY="4.5.2",wRt=wY[0]>="0"&&wY[0]<="9"?`v${wY}`:"";function ERt(){const t=new bY({id:"loaders.gl"});return globalThis.loaders||(globalThis.loaders={}),globalThis.loaders.log=t,globalThis.loaders.version=wRt,globalThis.probe||(globalThis.probe={}),globalThis.probe.loaders=t,t}const ARt=ERt(),xRt=t=>typeof t=="boolean",dm=t=>typeof t=="function",vE=t=>t!==null&&typeof t=="object",Bet=t=>vE(t)&&t.constructor==={}.constructor,Oet=t=>typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer,EY=t=>vE(t)&&typeof t.byteLength=="number"&&typeof t.slice=="function",SRt=t=>!!t&&dm(t[Symbol.iterator]),TRt=t=>!!t&&dm(t[Symbol.asyncIterator]),_E=t=>typeof Response<"u"&&t instanceof Response||vE(t)&&dm(t.arrayBuffer)&&dm(t.text)&&dm(t.json),bE=t=>typeof Blob<"u"&&t instanceof Blob,RRt=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||vE(t)&&dm(t.tee)&&dm(t.cancel)&&dm(t.getReader),CRt=t=>vE(t)&&dm(t.read)&&dm(t.pipe)&&xRt(t.readable),Iet=t=>RRt(t)||CRt(t);function MRt(t,e){return Det(t||{},e)}function Det(t,e,r=0){if(r>3)return e;const i={...t};for(const[s,o]of Object.entries(e))o&&typeof o=="object"&&!Array.isArray(o)?i[s]=Det(i[s]||{},e[s],r+1):i[s]=e[s];return i}function BRt(t){var e;globalThis.loaders||(globalThis.loaders={}),(e=globalThis.loaders).modules||(e.modules={}),Object.assign(globalThis.loaders.modules,t)}function ORt(t){var e,r;return((r=(e=globalThis.loaders)==null?void 0:e.modules)==null?void 0:r[t])||null}const IRt="latest";function DRt(){var t;return(t=globalThis._loadersgl_)!=null&&t.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.5.2"),globalThis._loadersgl_.version}const Pet=DRt();function e0(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}const qd=typeof process!="object"||String(process)!=="[object process]"||process.browser,AY=typeof importScripts=="function",PRt=typeof window<"u"&&typeof window.orientation<"u",Fet=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version);Fet&&parseFloat(Fet[1]);class FRt{constructor(e,r){W(this,"name");W(this,"workerThread");W(this,"isRunning",!0);W(this,"result");W(this,"_resolve",()=>{});W(this,"_reject",()=>{});this.name=e,this.workerThread=r,this.result=new Promise((i,s)=>{this._resolve=i,this._reject=s})}postMessage(e,r){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:r})}done(e){e0(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){e0(this.isRunning),this.isRunning=!1,this._reject(e)}}class xY{terminate(){}}const SY=new Map;function NRt(t){e0(t.source&&!t.url||!t.source&&t.url);
2let e=SY.get(t.source||t.url);return e||(t.url&&(e=kRt(t.url),SY.set(t.url,e)),t.source&&(e=Net(t.source),SY.set(t.source,e))),e0(e),e}function kRt(t){if(!t.startsWith("http"))return t;const e=LRt(t);return Net(e)}function Net(t){const e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function LRt(t){return`try { 3 importScripts('${t}'); 4} catch (error) { 5 console.error(error); 6 throw error; 7}`}function ket(t,e=!0,r){const i=r||new Set;if(t){if(Let(t))i.add(t);else if(Let(t.buffer))i.add(t.buffer);else if(!ArrayBuffer.isView(t)&&e&&typeof t=="object")for(const s in t)ket(t[s],e,i)}return r===void 0?Array.from(i):[]}function Let(t){return t?t instanceof ArrayBuffer||typeof MessagePort<"u"&&t instanceof MessagePort||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas:!1}const TY=()=>{};class RY{constructor(e){W(this,"name");W(this,"source");W(this,"url");W(this,"terminated",!1);W(this,"worker");W(this,"onMessage");W(this,"onError");W(this,"_loadableURL","");const{name:r,source:i,url:s}=e;e0(i||s),this.name=r,this.source=i,this.url=s,this.onMessage=TY,this.onError=o=>console.log(o),this.worker=qd?this._createBrowserWorker():this._createNodeWorker()}static isSupported(){return typeof Worker<"u"&&qd||typeof xY<"u"&&!qd}destroy(){this.onMessage=TY,this.onError=TY,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(e,r){r=r||ket(e),this.worker.postMessage(e,r)}_getErrorFromErrorEvent(e){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,e.message&&(r+=`${e.message} in `),e.lineno&&(r+=`:${e.lineno}:${e.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=NRt({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},e.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},e.onmessageerror=r=>console.error(r),e}_createNodeWorker(){let e;if(this.url){const r=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,i=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new xY(r,{eval:!1,type:i})}else if(this.source)e=new xY(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",r=>{this.onMessage(r)}),e.on("error",r=>{this.onError(r)}),e.on("exit",r=>{}),e}}class URt{constructor(e){W(this,"name","unnamed");W(this,"source");W(this,"url");W(this,"maxConcurrency",1);W(this,"maxMobileConcurrency",1);W(this,"onDebug",()=>{});W(this,"reuseWorkers",!0);W(this,"props",{});W(this,"jobQueue",[]);W(this,"idleQueue",[]);W(this,"count",0);W(this,"isDestroyed",!1);this.source=e.source,this.url=e.url,this.setProps(e)}static isSupported(){return RY.isSupported()}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,r=(s,o,n)=>s.done(n),i=(s,o)=>s.error(o)){const s=new Promise(o=>(this.jobQueue.push({name:e,onMessage:r,onError:i,onStart:o}),this));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:e,backlog:this.jobQueue.length});const i=new FRt(r.name,e);e.onMessage=s=>r.onMessage(i,s.type,s.payload),e.onError=s=>r.onError(i,s),r.onStart(i);try{await i.result}catch(s){console.error(`Worker exception: ${s}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!qd||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}
7_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;const e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new RY({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return PRt?this.maxMobileConcurrency:this.maxConcurrency}}const GRt={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},Vw=class Vw{constructor(e){W(this,"props");W(this,"workerPools",new Map);this.props={...GRt},this.setProps(e),this.workerPools=new Map}static isSupported(){return RY.isSupported()}static getWorkerFarm(e={}){return Vw._workerFarm=Vw._workerFarm||new Vw({}),Vw._workerFarm.setProps(e),Vw._workerFarm}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:r,source:i,url:s}=e;let o=this.workerPools.get(r);return o||(o=new URt({name:r,source:i,url:s}),o.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,o)),o}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};W(Vw,"_workerFarm");let GG=Vw;function WRt(t,e={}){var o;const r=e[t.id]||{},i=qd?t.workerFile||`${t.id}-worker.js`:`${t.id}-worker-node.js`;let s=r.workerUrl;if(!s&&t.id==="compression"&&(s=e.workerUrl),(e._workerType||((o=e==null?void 0:e.core)==null?void 0:o._workerType))==="test"&&(qd?s=`modules/${t.module}/dist/${i}`:s=`modules/${t.module}/src/workers/${t.id}-worker-node.ts`),!s){let n=t.version;n==="latest"&&(n=IRt);const a=n?`@${n}`:"";s=`https://unpkg.com/@loaders.gl/${t.module}${a}/dist/${i}`}return e0(s),s}function jRt(t,e=Pet){e0(t,"no worker provided");const r=t.version;return!(!e||!r)}const CY={};function XRt(t={}){var s,o;const e=t.useLocalLibraries??((s=t.core)==null?void 0:s.useLocalLibraries),r=t.CDN??((o=t.core)==null?void 0:o.CDN),i=t.modules;return{...e!==void 0?{useLocalLibraries:e}:{},...r!==void 0?{CDN:r}:{},...i!==void 0?{modules:i}:{}}}async function WG(t,e=null,r={},i=null){return e&&(t=zRt(t,e,r,i)),CY[t]=CY[t]||VRt(t),await CY[t]}function zRt(t,e,r={},i=null){if(r!=null&&r.core)throw new Error("loadLibrary: options.core must be pre-normalized");if(!r.useLocalLibraries&&t.startsWith("http"))return t;i=i||t;const s=r.modules||{};return s[i]?s[i]:qd?r.CDN?(e0(r.CDN.startsWith("http")),`${r.CDN}/${e}@${Pet}/dist/libs/${i}`):AY?`../src/libs/${i}`:`modules/${e}/src/libs/${i}`:`modules/${e}/dist/libs/${i}`}async function VRt(t){if(t.endsWith("wasm"))return await $Rt(t);if(!qd){const{requireFromFile:r}=globalThis.loaders||{};try{const i=await(r==null?void 0:r(t));return i||!t.includes("/dist/libs/")?i:await(r==null?void 0:r(t.replace("/dist/libs/","/src/libs/")))}catch(i){if(t.includes("/dist/libs/"))try{return await(r==null?void 0:r(t.replace("/dist/libs/","/src/libs/")))}catch{}return console.error(i),null}}if(AY)return importScripts(t);const e=await HRt(t);return YRt(e,t)}function YRt(t,e){if(!qd){const{requireFromString:i}=globalThis.loaders||{};return i==null?void 0:i(t,e)}if(AY)return eval.call(globalThis,t),null;const r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch{r.text=t}return document.body.appendChild(r),null}async function $Rt(t){const{readFileAsArrayBuffer:e}=globalThis.loaders||{};if(qd||!e||t.startsWith("http"))return await(await fetch(t)).arrayBuffer();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load ArrayBuffer from ${t}`)}}async function HRt(t){const{readFileAsText:e}=globalThis.loaders||{};if(qd||!e||t.startsWith("http"))return await(await fetch(t)).text();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load text from ${t}`)}}function KRt(t,e){var s,o;if(!GG.isSupported())return!1;
7const r=(e==null?void 0:e._nodeWorkers)??((s=e==null?void 0:e.core)==null?void 0:s._nodeWorkers);if(!qd&&!r)return!1;const i=(e==null?void 0:e.worker)??((o=e==null?void 0:e.core)==null?void 0:o.worker);return!!(t.worker&&i)}async function qRt(t,e,r,i,s){const o=t.id,n=WRt(t,r),a=GG.getWorkerFarm(r==null?void 0:r.core).getWorkerPool({name:o,url:n});r=JSON.parse(JSON.stringify(r||{})),r._workerLoaderId=t.id,i=JSON.parse(JSON.stringify(i||{}));const l=await a.startJob("process-on-worker",ZRt.bind(null,s));return l.postMessage("process",{input:e,options:r,context:i}),await(await l.result).result}async function ZRt(t,e,r,i){switch(r){case"done":e.done(i);break;case"error":e.error(new Error(i.error));break;case"process":const{id:s,input:o,options:n}=i;try{const a=await t(o,n);e.postMessage("done",{id:s,result:a})}catch(a){const l=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:s,error:l})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function JRt(t,e,r){if(r=r||t.byteLength,t.byteLength<r||e.byteLength<r)return!1;const i=new Uint8Array(t),s=new Uint8Array(e);for(let o=0;o<i.length;++o)if(i[o]!==s[o])return!1;return!0}function QRt(...t){return tCt(t)}function tCt(t){const e=t.map(o=>o instanceof ArrayBuffer?new Uint8Array(o):o),r=e.reduce((o,n)=>o+n.byteLength,0),i=new Uint8Array(r);let s=0;for(const o of e)i.set(o,s),s+=o.byteLength;return i.buffer}async function eCt(t){const e=[];for await(const r of t)e.push(rCt(r));return QRt(...e)}function rCt(t){if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t)){const{buffer:e,byteOffset:r,byteLength:i}=t;return Uet(e,r,i)}return Uet(t)}function Uet(t,e=0,r=t.byteLength-e){const i=new Uint8Array(t,e,r),s=new Uint8Array(i.length);return s.set(i),s.buffer}let iCt="";const Get={};function sCt(t){for(const e in Get)if(t.startsWith(e)){const r=Get[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${iCt}${t}`),t}function Wet(t){return t&&typeof t=="object"&&t.isBuffer}function MY(t){if(Wet(t)||t instanceof ArrayBuffer)return t;if(Oet(t))return BY(t);if(ArrayBuffer.isView(t)){const e=t.buffer;return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?e:e.slice(t.byteOffset,t.byteOffset+t.byteLength)}if(typeof t=="string"){const e=t;return new TextEncoder().encode(e).buffer}if(t&&typeof t=="object"&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}function jet(t){if(t instanceof ArrayBuffer)return t;if(Oet(t))return BY(t);const{buffer:e,byteOffset:r,byteLength:i}=t;return e instanceof ArrayBuffer&&r===0&&i===e.byteLength?e:BY(e,r,i)}function BY(t,e=0,r=t.byteLength-e){const i=new Uint8Array(t,e,r),s=new Uint8Array(i.length);return s.set(i),s.buffer}function oCt(t){return ArrayBuffer.isView(t)?t:new Uint8Array(t)}function Xet(t){const e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function zet(t){const e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}const nCt=(mEt=globalThis.loaders)==null?void 0:mEt.parseImageNode,OY=typeof Image<"u",IY=typeof ImageBitmap<"u",aCt=!!nCt,DY=kG?!0:aCt;function lCt(t){switch(t){case"auto":return IY||OY||DY;case"imagebitmap":return IY;case"image":return OY;case"data":return DY;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function cCt(){if(IY)return"imagebitmap";if(OY)return"image";if(DY)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function hCt(t){const e=uCt(t);if(!e)throw new Error("Not an image");return e}function Vet(t){switch(hCt(t)){case"data":return t;case"image":case"imagebitmap":const e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function uCt(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}const dCt=/^data:image\/svg\+xml/,fCt=/\.svg((\?|#).*)?$/;function PY(t){return t&&(dCt.test(t)||fCt.test(t))}function pCt(t,e){if(PY(e)){let r=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(r=unescape(encodeURIComponent(r)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(r)}`}return Yet(t,e)}function Yet(t,e){if(PY(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}
7async function $et(t,e,r){const i=pCt(t,r),s=self.URL||self.webkitURL,o=typeof i!="string"&&s.createObjectURL(i);try{return await gCt(o||i,e)}finally{o&&s.revokeObjectURL(o)}}async function gCt(t,e){const r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((i,s)=>{try{r.onload=()=>i(r),r.onerror=o=>{const n=o instanceof Error?o.message:"error";s(new Error(n))}}catch(o){s(o)}})}let Het=!0;async function mCt(t,e,r){let i;PY(r)?i=await $et(t,e,r):i=Yet(t,r);const s=e&&e.imagebitmap;return await yCt(i,s)}async function yCt(t,e=null){if((vCt(e)||!Het)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),Het=!1}return await createImageBitmap(t)}function vCt(t){if(!t)return!0;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function _Ct(t){return!ACt(t,"ftyp",4)||(t[8]&96)===0?null:bCt(t)}function bCt(t){switch(wCt(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function wCt(t,e,r){return String.fromCharCode(...t.slice(e,r))}function ECt(t){return[...t].map(e=>e.charCodeAt(0))}function ACt(t,e,r=0){const i=ECt(e);for(let s=0;s<i.length;++s)if(i[s]!==t[s+r])return!1;return!0}const fm=!1,BO=!0;function FY(t){const e=OO(t);return SCt(e)||CCt(e)||TCt(e)||RCt(e)||xCt(e)}function xCt(t){const e=new Uint8Array(t instanceof DataView?t.buffer:t),r=_Ct(e);return r?{mimeType:r.mimeType,width:0,height:0}:null}function SCt(t){const e=OO(t);return e.byteLength>=24&&e.getUint32(0,fm)===2303741511?{mimeType:"image/png",width:e.getUint32(16,fm),height:e.getUint32(20,fm)}:null}function TCt(t){const e=OO(t);return e.byteLength>=10&&e.getUint32(0,fm)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,BO),height:e.getUint16(8,BO)}:null}function RCt(t){const e=OO(t);return e.byteLength>=14&&e.getUint16(0,fm)===16973&&e.getUint32(2,BO)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,BO),height:e.getUint32(22,BO)}:null}function CCt(t){const e=OO(t);if(!(e.byteLength>=3&&e.getUint16(0,fm)===65496&&e.getUint8(2)===255))return null;const{tableMarkers:r,sofMarkers:i}=MCt();let s=2;for(;s+9<e.byteLength;){const o=e.getUint16(s,fm);if(i.has(o))return{mimeType:"image/jpeg",height:e.getUint16(s+5,fm),width:e.getUint16(s+7,fm)};if(!r.has(o))return null;s+=2,s+=e.getUint16(s,fm)}return null}function MCt(){const t=new Set([65499,65476,65484,65501,65534]);for(let e=65504;e<65520;++e)t.add(e);return{tableMarkers:t,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function OO(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}async function BCt(t,e){var s;const{mimeType:r}=FY(t)||{},i=(s=globalThis.loaders)==null?void 0:s.parseImageNode;return NG(i),await i(t,r)}async function OCt(t,e,r){e=e||{};const i=(e.image||{}).type||"auto",{url:s}=r||{},o=ICt(i);let n;switch(o){case"imagebitmap":n=await mCt(t,e,s);break;case"image":n=await $et(t,e,s);break;case"data":n=await BCt(t);break;default:NG(!1)}return i==="data"&&(n=Vet(n)),n}function ICt(t){switch(t){case"auto":case"data":return cCt();default:return lCt(t),t}}let Ket,qet,Zet,jG;Ket=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],qet=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],Zet={image:{type:"auto",decode:!0}},Hh={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:xet,mimeTypes:qet,extensions:Ket,parse:OCt,tests:[t=>!!FY(new DataView(t))],options:Zet},jG={};function DCt(t){if(jG[t]===void 0){const e=kG?FCt(t):PCt(t);jG[t]=e}return jG[t]}function PCt(t){var i,s;const e=["image/png","image/jpeg","image/gif"],r=((i=globalThis.loaders)==null?void 0:i.imageFormatsNode)||e;return!!((s=globalThis.loaders)!=null&&s.parseImageNode)&&r.includes(t)}function FCt(t){switch(t){case"image/avif":case"image/webp":return NCt(t);default:return!0}}function NCt(t){try{return document.createElement("canvas").toDataURL(t).indexOf(`data:${t}`)===0}catch{return!1}}
7class kCt extends Error{constructor(r,i){super(r);W(this,"reason");W(this,"url");W(this,"response");this.reason=i.reason,this.url=i.url,this.response=i.response}}const LCt=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,UCt=/^([-\w.]+\/[-\w.+]+)/;function Jet(t,e){return t.toLowerCase()===e.toLowerCase()}function GCt(t){const e=UCt.exec(t);return e?e[1]:t}function Qet(t){const e=LCt.exec(t);return e?e[1]:""}const trt=/\?.*/;function WCt(t){const e=t.match(trt);return e&&e[0]}function XG(t){return t.replace(trt,"")}function jCt(t){if(t.length<50)return t;const e=t.slice(t.length-15);return`${t.substr(0,32)}...${e}`}function zG(t){return _E(t)?t.url:bE(t)?("name"in t?t.name:"")||"":typeof t=="string"?t:""}function VG(t){if(_E(t)){const e=t.headers.get("content-type")||"",r=XG(t.url);return GCt(e)||Qet(r)}return bE(t)?t.type||"":typeof t=="string"?Qet(t):""}function XCt(t){return _E(t)?t.headers["content-length"]||-1:bE(t)?t.size:typeof t=="string"?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}async function ert(t){if(_E(t))return t;const e={},r=XCt(t);r>=0&&(e["content-length"]=String(r));const i=zG(t),s=VG(t);s&&(e["content-type"]=s);const o=await YCt(t);o&&(e["x-first-bytes"]=o),typeof t=="string"&&(t=new TextEncoder().encode(t));const n=new Response(t,{headers:e});return Object.defineProperty(n,"url",{value:i}),n}async function zCt(t){if(!t.ok)throw await VCt(t)}async function VCt(t){const e=jCt(t.url);let r=`Failed to fetch resource (${t.status}) ${t.statusText}: ${e}`;r=r.length>100?`${r.slice(0,100)}...`:r;const i={reason:t.statusText,url:t.url,response:t};try{const s=t.headers.get("Content-Type");i.reason=!t.bodyUsed&&(s!=null&&s.includes("application/json"))?await t.json():await t.text()}catch{}return new kCt(r,i)}async function YCt(t){if(typeof t=="string")return`data:,${t.slice(0,5)}`;if(t instanceof Blob){const e=t.slice(0,5);return await new Promise(r=>{const i=new FileReader;i.onload=s=>{var o;return r((o=s==null?void 0:s.target)==null?void 0:o.result)},i.readAsDataURL(e)})}if(t instanceof ArrayBuffer){const e=t.slice(0,5);return`data:base64,${$Ct(e)}`}return null}function $Ct(t){let e="";const r=new Uint8Array(t);for(let i=0;i<r.byteLength;i++)e+=String.fromCharCode(r[i]);return btoa(e)}function HCt(t){return!KCt(t)&&!qCt(t)}function KCt(t){return t.startsWith("http:")||t.startsWith("https:")}function qCt(t){return t.startsWith("data:")}async function rrt(t,e){var r,i;if(typeof t=="string"){const s=sCt(t);return HCt(s)&&((r=globalThis.loaders)!=null&&r.fetchNode)?(i=globalThis.loaders)==null?void 0:i.fetchNode(s,e):await fetch(s,e)}return await ert(t)}const YG=new bY({id:"loaders.gl"});class ZCt{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}class JCt{constructor(){W(this,"console");this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}}const NY={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new JCt,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:kG,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},QCt={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"
7core.fetch.keepalive",signal:"core.fetch.signal"},kY=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function irt(){globalThis.loaders=globalThis.loaders||{};const{loaders:t}=globalThis;return t._state||(t._state={}),t._state}function srt(){const t=irt();return t.globalOptions=t.globalOptions||{...NY,core:{...NY.core}},wE(t.globalOptions)}function tMt(t,e,r,i){return r=r||[],r=Array.isArray(r)?r:[r],eMt(t,r),wE(iMt(e,t,i))}function wE(t){const e=oMt(t);art(e);for(const r of kY)e.core&&e.core[r]!==void 0&&delete e[r];return e.core&&e.core._workerType!==void 0&&delete e._worker,e}function eMt(t,e){ort(t,null,NY,QCt,e);for(const r of e){const i=t&&t[r.id]||{},s=r.options&&r.options[r.id]||{},o=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};ort(i,r.id,s,o,e)}}function ort(t,e,r,i,s){const o=e||"Top level",n=e?`${e}.`:"";for(const a in t){const l=!e&&vE(t[a]),c=a==="baseUri"&&!e,h=a==="workerUrl"&&e;if(!(a in r)&&!c&&!h){if(a in i)YG.level>0&&YG.warn(`${o} loader option '${n}${a}' no longer supported, use '${i[a]}'`)();else if(!l&&YG.level>0){const u=rMt(a,s);YG.warn(`${o} loader option '${n}${a}' not recognized. ${u}`)()}}}}function rMt(t,e){const r=t.toLowerCase();let i="";for(const s of e)for(const o in s.options){if(t===o)return`Did you mean '${s.id}.${o}'?`;const n=o.toLowerCase();(r.startsWith(n)||n.startsWith(r))&&(i=i||`Did you mean '${s.id}.${o}'?`)}return i}function iMt(t,e,r){var n;const i=t.options||{},s={...i};i.core&&(s.core={...i.core}),art(s),((n=s.core)==null?void 0:n.log)===null&&(s.core={...s.core,log:new ZCt}),nrt(s,wE(srt()));const o=wE(e);return nrt(s,o),sMt(s,r),nMt(s),s}function nrt(t,e){for(const r in e)if(r in e){const i=e[r];Bet(i)&&Bet(t[r])?t[r]={...t[r],...e[r]}:t[r]=e[r]}}function sMt(t,e){var r;e&&(((r=t.core)==null?void 0:r.baseUrl)!==void 0||(t.core||(t.core={}),t.core.baseUrl=zet(XG(e))))}function oMt(t){const e={...t};return t.core&&(e.core={...t.core}),e}function art(t){t.baseUri!==void 0&&(t.core||(t.core={}),t.core.baseUrl===void 0&&(t.core.baseUrl=t.baseUri));for(const r of kY)if(t[r]!==void 0){const i=t.core=t.core||{};i[r]===void 0&&(i[r]=t[r])}const e=t._worker;e!==void 0&&(t.core||(t.core={}),t.core._workerType===void 0&&(t.core._workerType=e))}function nMt(t){const e=t.core;if(e)for(const r of kY)e[r]!==void 0&&(t[r]=e[r])}function LY(t){return t?(Array.isArray(t)&&(t=t[0]),Array.isArray(t==null?void 0:t.extensions)):!1}function lrt(t){NG(t,"null loader"),NG(LY(t),"invalid loader");let e;return Array.isArray(t)&&(e=t[1],t=t[0],t={...t,options:{...t.options,...e}}),(t!=null&&t.parseTextSync||t!=null&&t.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}const aMt=()=>{const t=irt();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};function lMt(){return aMt()}const cMt=/\.([^.]+)$/;async function hMt(t,e=[],r,i){if(!hrt(t))return null;const s=wE(r||{});if(s.core||(s.core={}),t instanceof Response&&crt(t)){const n=await t.clone().text(),a=$G(n,e,{...s,core:{...s.core,nothrow:!0}},i);if(a)return a}let o=$G(t,e,{...s,core:{...s.core,nothrow:!0}},i);if(o)return o;if(bE(t)&&(t=await t.slice(0,10).arrayBuffer(),o=$G(t,e,s,i)),!o&&t instanceof Response&&crt(t)){const n=await t.clone().text();o=$G(n,e,s,i)}if(!o&&!s.core.nothrow)throw new Error(urt(t));return o}function crt(t){const e=VG(t);return!!(e&&(e.startsWith("text/")||e==="application/json"||e.endsWith("+json")))}function $G(t,e=[],r,i){if(!hrt(t))return null;const s=wE(r||{});if(s.core||(s.core={}),e&&!Array.isArray(e))return lrt(e);let o=[];e&&(o=o.concat(e)),s.core.ignoreRegisteredLoaders||o.push(...lMt()),dMt(o);const n=uMt(t,o,s,i);if(!n&&!s.core.nothrow)throw new Error(urt(t));return n}function uMt(t,e,r,i){var c,h,u,d,f;const s=zG(t),o=VG(t),n=XG(s)||(i==null?void 0:i.url);let a=null,l="";return(c=r==null?void 0:r.core)!=null&&c.mimeType&&(a=UY(e,(h=r==null?void 0:r.core)==null?void 0:h.mimeType),l=`match forced by supplied MIME type ${(u=r==null?void 0:r.core)==null?void 0:u.mimeType}`),a=a||fMt(e,n),l=l||(a?`matched url ${n}`:""),a=a||UY(e,o),l=l||(a?`matched MIME type ${o}`:""),a=a||gMt(e,t),l=l||(a?`matched initial data ${frt(t)}`:""),(d=r==null?void 0:r.core)!=null&&d.fallbackMimeType&&(a=a||UY(e,(f=r==null?void 0:r.core)==null?void 0:f.fallbackMimeType),l=l||(a?`matched fallback MIME type ${o}`:"")),l&&ARt.log(1,`selectLoader selected ${a==null?void 0:a.name}: ${l}.`),a}function hrt(t){return!(t instanceof Response&&t.status===204)}function urt(t){const e=zG(t),r=VG(t);let i="No valid loader found (";i+=e?`${Xet(e)}, `:"no url provided, ",i+=`MIME type: ${r?`"${r}"`:"not provided"}, `;const s=t?frt(t):"";return i+=s?` first bytes: "${s}"`:"first bytes: not available",i+=")",i}function dMt(t){for(const e of t)lrt(e)}function fMt(t,e){const r=e&&cMt.exec(e),i=r&&r[1];return i?pMt(t,i):null}function pMt(t,e){e=e.toLowerCase();for(const r of t)for(const i of r.extensions)if(i.toLowerCase()===e)return r;return null}function UY(t,e){var r;for(const i of t)if((r=i.mimeTypes)!=null&&r.some(s=>Jet(e,s))||Jet(e,`application/x.${i.id}`))return i;return null}function gMt(t,e){if(!e)return null;for(const r of t)if(typeof e=="string"){if(mMt(e,r))return r}else if(ArrayBuffer.isView(e)){if(drt(e.buffer,e.byteOffset,r))return r}else if(e instanceof ArrayBuffer&&drt(e,0,r))return r;return null}function mMt(t,e){return e.testText?e.testText(t):(Array.isArray(e.tests)?e.tests:[e.tests]).some(r=>t.startsWith(r))}function drt(t,e,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(i=>yMt(t,e,r,i))}function yMt(t,e,r,i){if(EY(i))return JRt(i,t,i.byteLength);switch(typeof i){case"function":return i(jet(t));case"string":const s=GY(t,e,i.length);return i===s;default:return!1}}function frt(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?GY(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?GY(t,0,e):""}function GY(t,e,r){if(t.byteLength<e+r)return"";const i=new DataView(t);let s="";for(let o=0;o<r;o++)s+=String.fromCharCode(i.getUint8(e+o));return s}const vMt=256*1024;function*_Mt(t,e){const r=(e==null?void 0:e.chunkSize)||vMt;let i=0;const s=new TextEncoder;for(;i<t.length;){const o=Math.min(t.length-i,r),n=t.slice(i,i+o);i+=o,yield jet(s.encode(n))}}const bMt=256*1024;function*wMt(t,e={}){const{chunkSize:r=bMt}=e;let i=0;for(;i<t.byteLength;){const s=Math.min(t.byteLength-i,r),o=new ArrayBuffer(s),n=new Uint8Array(t,i,s);new Uint8Array(o).set(n),i+=s,yield o}}const EMt=1024*1024;async function*AMt(t,e){const r=(e==null?void 0:e.chunkSize)||EMt;let i=0;for(;i<t.size;){const s=i+r,o=await t.slice(i,s).arrayBuffer();i=s,yield o}}function prt(t,e){return kG?xMt(t,e):SMt(t)}async function*xMt(t,e){const r=t.getReader();let i;try{for(;;){const s=i||r.read();e!=null&&e._streamReadAhead&&(i=r.read());const{done:o,value:n}=await s;if(o)return;yield MY(n)}}catch{r.releaseLock()}}async function*SMt(t,e){for await(const r of t)yield MY(r)}function TMt(t,e){if(typeof t=="string")return _Mt(t,e);if(t instanceof ArrayBuffer)return wMt(t,e);if(bE(t))return AMt(t,e);if(Iet(t))return prt(t,e);if(_E(t)){const r=t.body;if(!r)throw new Error("Readable stream not available on Response");return prt(r,e)}throw new Error("makeIterator")}const grt="Cannot convert supplied data type";function RMt(t,e,r){if(e.text&&typeof t=="string")return t;if(Wet(t)&&(t=t.buffer),EY(t)){const i=oCt(t);return e.text&&!e.binary?new TextDecoder("utf8").decode(i):MY(i)}throw new Error(grt)}async function CMt(t,e,r){if(typeof t=="string"||EY(t))return RMt(t,e);if(bE(t)&&(t=await ert(t)),_E(t))return await zCt(t),e.binary?await t.arrayBuffer():await t.text();if(Iet(t)&&(t=TMt(t,r)),SRt(t)||TRt(t))return eCt(t);throw new Error(grt)}function mrt(t,e){var o;const r=srt(),i=t||r,s=i.fetch??((o=i.core)==null?void 0:o.fetch);return typeof s=="function"?s:vE(s)?n=>rrt(n,s):e!=null&&e.fetch?e==null?void 0:e.fetch:rrt}function MMt(t,e,r){if(r)return r;const i={fetch:mrt(e,t),...t};if(i.url){const s=XG(i.url);i.baseUrl=s,i.queryString=WCt(i.url),i.filename=Xet(s),i.baseUrl=zet(s)}return Array.isArray(i.loaders)||(i.loaders=null),i}function BMt(t,e){if(t&&!Array.isArray(t))return t;let r;if(t&&(r=Array.isArray(t)?t:[t]),e&&e.loaders){const i=Array.isArray(e.loaders)?e.loaders:[e.loaders];r=r?[...r,...i]:i}return r&&r.length?r:void 0}cO=async function(t,e,r,i){e&&!Array.isArray(e)&&!LY(e)&&(i=void 0,r=e,e=void 0),t=await t,r=r||{};const s=zG(t),o=BMt(e,i),n=await hMt(t,o,r);if(!n)return null;const a=tMt(r,n,o,s);return i=MMt({url:s,_parse:cO,loaders:o},a,i||null),await OMt(n,t,a,i)};async function OMt(t,e,r,i){if(jRt(t),r=MRt(t.options,r),_E(e)){const{ok:o,redirected:n,status:a,statusText:l,type:c,url:h}=e,u=Object.fromEntries(e.headers.entries());i.response={headers:u,ok:o,redirected:n,status:a,statusText:l,type:c,url:h}}e=await CMt(e,t,r);const s=t;if(s.parseTextSync&&typeof e=="string")return s.parseTextSync(e,r,i);if(KRt(t,r))return await qRt(t,e,r,i,cO);if(s.parseText&&typeof e=="string")return await s.parseText(e,r,i);if(s.parse)return await s.parse(e,r,i);throw e0(!s.parseSync),new Error(`${t.id} loader - no parser found and worker is disabled`)}var WY=function(t,e){return WY=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(r[s]=i[s])},WY(t,e)};function Jo(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");WY(t,e);function r(){this.constructor=t}
vendor: 4,280 bytes, line 7
7t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var fo=function(){return fo=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},fo.apply(this,arguments)};function IMt(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r}function Rr(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})}function hT(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,s,o,n=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return n.next=a(0),n.throw=a(1),n.return=a(2),typeof Symbol=="function"&&(n[Symbol.iterator]=function(){return this}),n;function a(c){return function(h){return l([c,h])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;n&&(n=0,c[0]&&(r=0)),r;)try{if(i=1,s&&(o=c[0]&2?s.return:c[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,c[1])).done)return o;switch(s=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,s=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){r.label=c[1];break}if(c[0]===6&&r.label<o[1]){r.label=o[1],o=c;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(c);break}o[2]&&r.ops.pop(),r.trys.pop();continue}c=e.call(t,r)}catch(h){c=[6,h],s=0}finally{i=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function r0(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function np(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),s,o=[],n;try{for(;(e===void 0||e-- >0)&&!(s=i.next()).done;)o.push(s.value)}catch(a){n={error:a}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return o}function EE(t,e,r){if(r||arguments.length===2)for(var i=0,s=e.length,o;i<s;i++)(o||!(i in e))&&(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return t.concat(o||Array.prototype.slice.call(e))}function Si(t){return this instanceof Si?(this.v=t,this):new Si(t)}function pm(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",n),s[Symbol.asyncIterator]=function(){return this},s;function n(f){return function(g){return Promise.resolve(g).then(f,u)}}function a(f,g){i[f]&&(s[f]=function(p){return new Promise(function(m,v){o.push([f,p,m,v])>1||l(f,p)})},g&&(s[f]=g(s[f])))}function l(f,g){try{c(i[f](g))}catch(p){d(o[0][3],p)}}function c(f){f.value instanceof Si?Promise.resolve(f.value.v).then(h,u):d(o[0][2],f)}function h(f){l("next",f)}function u(f){l("throw",f)}function d(f,g){f(g),o.shift(),o.length&&l(o[0][0],o[0][1])}}function HG(t){var e,r;return e={},i("next"),i("throw",function(s){throw s}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(s,o){e[s]=t[s]?function(n){return(r=!r)?{value:Si(t[s](n)),done:!1}:o?o(n):n}:o}}function uT(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof r0=="function"?r0(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(o){r[o]=t[o]&&function(n){return new Promise(function(a,l){n=t[o
7](n),s(a,l,n.done,n.value)})}}function s(o,n,a,l){Promise.resolve(l).then(function(c){o({value:c,done:a})},n)}}const DMt=new TextDecoder("utf-8"),jY=t=>DMt.decode(t),PMt=new TextEncoder,XY=t=>PMt.encode(t),FMt=t=>typeof t=="number",NMt=t=>typeof t=="boolean",Eh=t=>typeof t=="function",ap=t=>t!=null&&Object(t)===t,IO=t=>ap(t)&&Eh(t.then),KG=t=>ap(t)&&Eh(t[Symbol.iterator]),zY=t=>ap(t)&&Eh(t[Symbol.asyncIterator]),VY=t=>ap(t)&&ap(t.schema),yrt=t=>ap(t)&&"done"in t&&"value"in t,vrt=t=>ap(t)&&Eh(t.stat)&&FMt(t.fd),_rt=t=>ap(t)&&YY(t.body),brt=t=>"_getDOMStream"in t&&"_getNodeStream"in t,YY=t=>ap(t)&&Eh(t.cancel)&&Eh(t.getReader)&&!brt(t),wrt=t=>ap(t)&&Eh(t.read)&&Eh(t.pipe)&&NMt(t.readable)&&!brt(t),kMt=t=>ap(t)&&Eh(t.clear)&&Eh(t.bytes)&&Eh(t.position)&&Eh(t.setPosition)&&Eh(t.capacity)&&Eh(t.getBufferIdentifier)&&Eh(t.createLong),$Y=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function LMt(t){const e=t[0]?[t[0]]:[];let r,i,s,o;for(let n,a,l=0,c=0,h=t.length;++l<h;){if(n=e[c],a=t[l],!n||!a||n.buffer!==a.buffer||a.byteOffset<n.byteOffset){a&&(e[++c]=a);continue}if({byteOffset:r,byteLength:s}=n,{byteOffset:i,byteLength:o}=a,r+s<i||i+o<r){a&&(e[++c]=a);continue}e[c]=new Uint8Array(n.buffer,r,i-r+o)}return e}function Ert(t,e,r=0,i=e.byteLength){const s=t.byteLength,o=new Uint8Array(t.buffer,t.byteOffset,s),n=new Uint8Array(e.buffer,e.byteOffset,Math.min(i,s));return o.set(n,r),t}function gm(t,e){const r=LMt(t),i=r.reduce((h,u)=>h+u.byteLength,0);let s,o,n,a=0,l=-1;const c=Math.min(e||Number.POSITIVE_INFINITY,i);for(const h=r.length;++l<h;){if(s=r[l],o=s.subarray(0,Math.min(s.length,c-a)),c<=a+o.length){o.length<s.length?r[l]=s.subarray(o.length):o.length===s.length&&l++,n?Ert(n,o,a):n=o;break}Ert(n||(n=new Uint8Array(c)),o,a),a+=o.length}return[n||new Uint8Array(0),r.slice(l),i-(n?n.byteLength:0)]}function Co(t,e){let r=yrt(e)?e.value:e;return r instanceof t?t===Uint8Array?new t(r.buffer,r.byteOffset,r.byteLength):r:r?(typeof r=="string"&&(r=XY(r)),r instanceof ArrayBuffer?new t(r):r instanceof $Y?new t(r):kMt(r)?Co(t,r.bytes()):ArrayBuffer.isView(r)?r.byteLength<=0?new t(0):new t(r.buffer,r.byteOffset,r.byteLength/t.BYTES_PER_ELEMENT):t.from(r)):new t(0)}const DO=t=>Co(Int32Array,t),Art=t=>Co(BigInt64Array,t),Is=t=>Co(Uint8Array,t),HY=t=>(t.next(),t);function*UMt(t,e){const r=function*(s){yield s},i=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof $Y?r(e):KG(e)?e:r(e);return yield*HY((function*(s){let o=null;do o=s.next(yield Co(t,o));while(!o.done)})(i[Symbol.iterator]())),new t}const GMt=t=>UMt(Uint8Array,t);function xrt(t,e){return pm(this,arguments,function*(){if(IO(e))return yield Si(yield Si(yield*HG(uT(xrt(t,yield Si(e))))));const r=function(o){return pm(this,arguments,function*(){yield yield Si(yield Si(o))})},i=function(o){return pm(this,arguments,function*(){yield Si(yield*HG(uT(HY((function*(n){let a=null;do a=n.next(yield a==null?void 0:a.value);while(!a.done)})(o[Symbol.iterator]())))))})},s=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof $Y?r(e):KG(e)?i(e):zY(e)?e:r(e);return yield Si(yield*HG(uT(HY((function(o){return pm(this,arguments,function*(){let n=null;do n=yield Si(o.next(yield yield Si(Co(t,n))));while(!n.done)})})(s[Symbol.asyncIterator]()))))),yield Si(new t)})}const WMt=t=>xrt(Uint8Array,t);function jMt(t,e){let r=0;const i=t.length;if(i!==e.length)return!1;if(i>0)do if(t[r]!==e[r])return!1;while(++r<i);return!0}const Zd={fromIterable(t){return qG(XMt(t))},fromAsyncIterable(t){return qG(zMt(t))},fromDOMStream(t){return qG(VMt(t))},fromNodeStream(t){return qG($Mt(t))},toDOMStream(t,e){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(t,e){throw new Error('"toNodeStream" not available in this environment')}},qG=t=>(t.next(),t);function*XMt(t){let e,r=!1,i=[],s,o,n,a=0;function l(){return o==="peek"?gm(i,n)[0]:([s,i,a]=gm(i,n),s)}({cmd:o,size:n}=(yield null)||{cmd:"read",size:0});const c=GMt(t)[Symbol.iterator]();try{do if({done:e,value:s}=Number.isNaN(n-a)?c.next():c.next(n-a),!e&&s.byteLength>0&&(i.push(s),a+=s.byteLength),e||n<=a)do({cmd:o,size:n}=yield l());while(n<a);while(!e)}catch(h){(r=!0)&&typeof c.throw=="function"&&c.throw(h)}finally{r===!1&&typeof c.return=="function"&&c.return(null)}return null}function zMt(t){return pm(this,arguments,function*(){let e,r=!1,i=[],s,o,n,a=0;function l(){return o==="peek"?gm(i,n)[0]:([s,i,a]=gm(i,n),s)}({cmd:o,size:n}=(yield yield Si(null))||{cmd:"read",size:0});const c=WMt(t)[Symbol.asyncIterator]();try{do if({done:e,value:s}=Number.isNaN(n-a)?yield Si(c.next()):yield Si(c.next(n-a)),!e&&s.byteLength>0&&(i.push(s),a+=s.byteLength),e||n<=a)do({cmd:o,size:n}=yield yield Si(l()));while(n<a);while(!e)}catch(h){(r=!0)&&typeof c.throw=="function"&&(yield Si(c.throw(h)))}finally{r===!1&&typeof c.return=="function"&&(yield Si(c.return(new Uint8Array(0))))}return yield Si(null)})}
7function VMt(t){return pm(this,arguments,function*(){let e=!1,r=!1,i=[],s,o,n,a=0;function l(){return o==="peek"?gm(i,n)[0]:([s,i,a]=gm(i,n),s)}({cmd:o,size:n}=(yield yield Si(null))||{cmd:"read",size:0});const c=new YMt(t);try{do if({done:e,value:s}=Number.isNaN(n-a)?yield Si(c.read()):yield Si(c.read(n-a)),!e&&s.byteLength>0&&(i.push(Is(s)),a+=s.byteLength),e||n<=a)do({cmd:o,size:n}=yield yield Si(l()));while(n<a);while(!e)}catch(h){(r=!0)&&(yield Si(c.cancel(h)))}finally{r===!1?yield Si(c.cancel()):t.locked&&c.releaseLock()}return yield Si(null)})}class YMt{constructor(e){this.source=e,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return Rr(this,void 0,void 0,function*(){const{reader:r,source:i}=this;r&&(yield r.cancel(e).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(e){return Rr(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const r=yield this.reader.read();return!r.done&&(r.value=Is(r)),r})}}const KY=(t,e)=>{const r=s=>i([e,s]);let i;return[e,r,new Promise(s=>(i=s)&&t.once(e,r))]};function $Mt(t){return pm(this,arguments,function*(){const e=[];let r="error",i=!1,s=null,o,n,a=0,l=[],c;function h(){return o==="peek"?gm(l,n)[0]:([c,l,a]=gm(l,n),c)}if({cmd:o,size:n}=(yield yield Si(null))||{cmd:"read",size:0},t.isTTY)return yield yield Si(new Uint8Array(0)),yield Si(null);try{e[0]=KY(t,"end"),e[1]=KY(t,"error");do{if(e[2]=KY(t,"readable"),[r,s]=yield Si(Promise.race(e.map(d=>d[2]))),r==="error")break;if((i=r==="end")||(Number.isFinite(n-a)?(c=Is(t.read(n-a)),c.byteLength<n-a&&(c=Is(t.read()))):c=Is(t.read()),c.byteLength>0&&(l.push(c),a+=c.byteLength)),i||n<=a)do({cmd:o,size:n}=yield yield Si(h()));while(n<a)}while(!i)}finally{yield Si(u(e,r==="error"?s:null))}return yield Si(null);function u(d,f){return c=l=null,new Promise((g,p)=>{for(const[m,v]of d)t.off(m,v);try{const m=t.destroy;m&&m.call(t,f),f=void 0}catch(m){f=m||f}finally{f!=null?p(f):g()}})}})}var ja;(function(t){t[t.V1=0]="V1",t[t.V2=1]="V2",t[t.V3=2]="V3",t[t.V4=3]="V4",t[t.V5=4]="V5"})(ja||(ja={}));var lu;
7(function(t){t[t.Sparse=0]="Sparse",t[t.Dense=1]="Dense"})(lu||(lu={})),(function(t){t[t.HALF=0]="HALF",t[t.SINGLE=1]="SINGLE",t[t.DOUBLE=2]="DOUBLE"})(ll||(ll={})),(function(t){t[t.DAY=0]="DAY",t[t.MILLISECOND=1]="MILLISECOND"})(Jh||(Jh={})),(function(t){t[t.SECOND=0]="SECOND",t[t.MILLISECOND=1]="MILLISECOND",t[t.MICROSECOND=2]="MICROSECOND",t[t.NANOSECOND=3]="NANOSECOND"})(or||(or={})),(function(t){t[t.YEAR_MONTH=0]="YEAR_MONTH",t[t.DAY_TIME=1]="DAY_TIME",t[t.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})($d||($d={}));const qY=2,mm=4,i0=4,no=4,Nv=new Int32Array(2),Srt=new Float32Array(Nv.buffer),Trt=new Float64Array(Nv.buffer),ZG=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var ZY;(function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"})(ZY||(ZY={}));let dT=class s1t{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new s1t(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<<BigInt(32)))}readUint64(e){return BigInt.asUintN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<<BigInt(32)))}readFloat32(e){return Nv[0]=this.readInt32(e),Srt[0]}readFloat64(e){return Nv[ZG?0:1]=this.readInt32(e),Nv[ZG?1:0]=this.readInt32(e+4),Trt[0]}writeInt8(e,r){this.bytes_[e]=r}writeUint8(e,r){this.bytes_[e]=r}writeInt16(e,r){this.bytes_[e]=r,this.bytes_[e+1]=r>>8}writeUint16(e,r){this.bytes_[e]=r,this.bytes_[e+1]=r>>8}writeInt32(e,r){this.bytes_[e]=r,this.bytes_[e+1]=r>>8,this.bytes_[e+2]=r>>16,this.bytes_[e+3]=r>>24}writeUint32(e,r){this.bytes_[e]=r,this.bytes_[e+1]=r>>8,this.bytes_[e+2]=r>>16,this.bytes_[e+3]=r>>24}writeInt64(e,r){this.writeInt32(e,Number(BigInt.asIntN(32,r))),this.writeInt32(e+4,Number(BigInt.asIntN(32,r>>BigInt(32))))}writeUint64(e,r){this.writeUint32(e,Number(BigInt.asUintN(32,r))),this.writeUint32(e+4,Number(BigInt.asUintN(32,r>>BigInt(32))))}writeFloat32(e,r){Srt[0]=r,this.writeInt32(e,Nv[0])}writeFloat64(e,r){Trt[0]=r,this.writeInt32(e,Nv[ZG?0:1]),this.writeInt32(e+4,Nv[ZG?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+mm+i0)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let e="";for(let r=0;r<i0;r++)e+=String.fromCharCode(this.readInt8(this.position_+mm+r));return e}__offset(e,r){const i=e-this.readInt32(e);return r<this.readInt16(i)?this.readInt16(i+r):0}__union(e,r){return e.bb_pos=r+this.readInt32(r),e.bb=this,e}__string(e,r){e+=this.readInt32(e);const i=this.readInt32(e);e+=mm;const s=this.bytes_.subarray(e,e+i);return r===ZY.UTF8_BYTES?s:this.text_decoder_.decode(s)}__union_with_string(e,r){return typeof e=="string"?this.__string(r):this.__union(e,r)}__indirect(e){return e+this.readInt32(e)}__vector(e){return e+this.readInt32(e)+mm}__vector_len(e){return this.readInt32(e+this.readInt32(e))}__has_identifier(e){if(e.length!=i0)throw new Error("FlatBuffers: file identifier must be length "+i0);for(let r=0;r<i0;r++)if(e.charCodeAt(r)!=this.readInt8(this.position()+mm+r))return!1;return!0}createScalarList(e,r){const i=[];for(let s=0;s<r;++s){const o=e(s);o!==null&&i.push(o)}return i}createObjList(e,r){const i=[];for(let s=0;s<r;++s){const o=e(s);o!==null&&i.push(o.unpack())}return i}},Rrt=class o1t{constructor(e){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let r;e?r=e:r=1024,this.bb=dT.allocate(r),this.space=r}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(e){this.force_defaults=e}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(e,r){e>this.minalign&&(this.minalign=e);const i=~(this.bb.capacity()-this.space+r)+1&e-1;for(;this.space<i+e+r;){const s=this.bb.capacity();this.bb=o1t.growByteBuffer(this.bb),this.space+=this.bb.capacity()-s}this.pad(i)}pad(e){for(let r=0;r<e;r++)this.bb.writeInt8(--this.space,0)}writeInt8(e){this.bb.writeInt8(this.space-=1,e)}writeInt16(e){this.bb.writeInt16(this.space-=2,e)}writeInt32(e){this.bb.writeInt32(this.space-=4,e)}writeInt64(e){this.bb.writeInt64(this.space-=8,e)}writeFloat32(e){this.bb.writeFloat32(this.space-=4,e)}writeFloat64(e){this.bb.writeFloat64(this.space-=8,e)}addInt8(e){this.prep(1,0),this.writeInt8(e)}addInt16(e){this.prep(2,0),this.writeInt16(e)}addInt32(e){this.prep(4,0),this.writeInt32(e)}addInt64(e){this.prep(8,0),this.writeInt64(e)}addFloat32(e){this.prep(4,0),this.writeFloat32(e)}addFloat64(e){this.prep(8,0),this.writeFloat64(e)}addFieldInt8(e,r,i){(this.force_defaults||r!=i)&&(this.addInt8(r),this.slot(e))}addFieldInt16(e,r,i){(this.force_defaults||r!=i)&&(this.addInt16(r),this.slot(e))}addFieldInt32(e,r,i){(this.force_defaults||r!=i)&&(this.addInt32(r),this.slot(e))}addFieldInt64(e,r,i){(this.force_defaults||r!==i)&&(this.addInt64(r),this.slot(e))}addFieldFloat32(e,r,i){(this.force_defaults||r!=i)&&(this.addFloat32(r),this.slot(e))}addFieldFloat64(e,r,i){(this.force_defaults||r!=i)&&(this.addFloat64(r),this.slot(e))}addFieldOffset(e,r,i){(this.force_defaults||r!=i)&&(this.addOffset(r),this.slot(e))}addFieldStruct(e,r,i){r!=i&&(this.nested(r),this.slot(e))}nested(e){if(e!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(e){this.vtable!==null&&(this.vtable[e]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(e){const r=e.capacity();if(r&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const i=r<<1,s=dT.allocate(i);return s.setPosition(i-r),s.bytes().set(e.bytes(),i-r),s}addOffset(e){this.prep(mm,0),this.writeInt32(this.offset()-e+mm)}startObject(e){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=e;for(let r=0;r<e;r++)this.vtable[r]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const e=this.offset();let r=this.vtable_in_use-1;for(;r>=0&&this.vtable[r]==0;r--);const i=r+1;for(;r>=0;r--)this.addInt16(this.vtable[r]!=0?e-this.vtable[r]:0);const s=2;this.addInt16(e-this.object_start);const o=(i+s)*qY;this.addInt16(o);let n=0;const a=this.space;t:for(r=0;r<this.vtables.length;r++){const l=this.bb.capacity()-this.vtables[r];if(o==this.bb.readInt16(l)){for(let c=qY;c<o;c+=qY)if(this.bb.readInt16(a+c)!=this.bb.readInt16(l+c))continue t;n=this.vtables[r];break}}return n?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,n-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e}
7finish(e,r,i){const s=i?no:0;if(r){const o=r;if(this.prep(this.minalign,mm+i0+s),o.length!=i0)throw new TypeError("FlatBuffers: file identifier must be length "+i0);for(let n=i0-1;n>=0;n--)this.writeInt8(o.charCodeAt(n))}this.prep(this.minalign,mm+s),this.addOffset(e),s&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,r){this.finish(e,r,!0)}requiredField(e,r){const i=this.bb.capacity()-e,s=i-this.bb.readInt32(i);if(!(r<this.bb.readInt16(s)&&this.bb.readInt16(s+r)!=0))throw new TypeError("FlatBuffers: field "+r+" must be set")}startVector(e,r,i){this.notNested(),this.vector_num_elems=r,this.prep(mm,e*r),this.prep(i,e*r)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(e){if(!e)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(e))return this.string_maps.get(e);const r=this.createString(e);return this.string_maps.set(e,r),r}createString(e){if(e==null)return 0;let r;return e instanceof Uint8Array?r=e:r=this.text_encoder.encode(e),this.addInt8(0),this.startVector(1,r.length,1),this.bb.setPosition(this.space-=r.length),this.bb.bytes().set(r,this.space),this.endVector()}createByteVector(e){return e==null?0:(this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector())}createObjectOffset(e){return e===null?0:typeof e=="string"?this.createString(e):e.pack(this)}createObjectOffsetList(e){const r=[];for(let i=0;i<e.length;++i){const s=e[i];if(s!==null)r.push(this.createObjectOffset(s));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return r}createStructOffsetList(e,r){return r(this,e.length),this.createObjectOffsetList(e.slice().reverse()),this.endVector()}};var JG;(function(t){t[t.BUFFER=0]="BUFFER"})(JG||(JG={}));var QG;(function(t){t[t.LZ4_FRAME=0]="LZ4_FRAME",t[t.ZSTD=1]="ZSTD"})(QG||(QG={}));class kv{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsBodyCompression(e,r){return(r||new kv).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsBodyCompression(e,r){return e.setPosition(e.position()+no),(r||new kv).__init(e.readInt32(e.position())+e.position(),e)}codec(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt8(this.bb_pos+e):QG.LZ4_FRAME}method(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt8(this.bb_pos+e):JG.BUFFER}static startBodyCompression(e){e.startObject(2)}static addCodec(e,r){e.addFieldInt8(0,r,QG.LZ4_FRAME)}static addMethod(e,r){e.addFieldInt8(1,r,JG.BUFFER)}static endBodyCompression(e){return e.endObject()}static createBodyCompression(e,r,i){return kv.startBodyCompression(e),kv.addCodec(e,r),kv.addMethod(e,i),kv.endBodyCompression(e)}}class Crt{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(e,r,i){return e.prep(8,16),e.writeInt64(BigInt(i??0)),e.writeInt64(BigInt(r??0)),e.offset()}}let Mrt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,r){return t.prep(8,16),t.writeInt64(BigInt(r??0)),t.writeInt64(BigInt(e??0)),t.offset()}},s0=class aet{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsRecordBatch(e,r){return(r||new aet).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsRecordBatch(e,r){return e.setPosition(e.position()+no),(r||new aet).__init(e.readInt32(e.position())+e.position(),e)}length(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}nodes(e,r){const i=this.bb.__offset(this.bb_pos,6);return i?(r||new Mrt).__init(this.bb.__vector(this.bb_pos+i)+e*16,this.bb):null}nodesLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}buffers(e,r){const i=this.bb.__offset(this.bb_pos,8);return i?(r||new Crt).__init(this.bb.__vector(this.bb_pos+i)+e*16,this.bb):null}buffersLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}compression(e){const r=this.bb.__offset(this.bb_pos,10);return r?(e||new kv).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}static startRecordBatch(e){e.startObject(4)}static addLength(e,r){e.addFieldInt64(0,r,BigInt("0"))}static addNodes(e,r){e.addFieldOffset(1,r,0)}static startNodesVector(e,r){e.startVector(16,r,8)}static addBuffers(e,r){e.addFieldOffset(2,r,0)}static startBuffersVector(e,r){e.startVector(16,r,8)}static addCompression(e,r){e.addFieldOffset(3,r,0)}static endRecordBatch(e){return e.endObject()}},fT=class cet{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsDictionaryBatch(e,r){return(r||new cet).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDictionaryBatch(e,r){return e.setPosition(e.position()+no),(r||new cet).__init(e.readInt32(e.position())+e.position(),e)}id(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}data(e){const r=this.bb.__offset(this.bb_pos,6);return r?(e||new s0).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}isDelta(){const e=this.bb.__offset(this.bb_pos,8);return e?!!this.bb.readInt8(this.bb_pos+e):!1}
7static startDictionaryBatch(e){e.startObject(3)}static addId(e,r){e.addFieldInt64(0,r,BigInt("0"))}static addData(e,r){e.addFieldOffset(1,r,0)}static addIsDelta(e,r){e.addFieldInt8(2,+r,0)}static endDictionaryBatch(e){return e.endObject()}};var pT;(function(t){t[t.Little=0]="Little",t[t.Big=1]="Big"})(pT||(pT={}));var t4;(function(t){t[t.DenseArray=0]="DenseArray"})(t4||(t4={}));class nd{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsInt(e,r){return(r||new nd).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsInt(e,r){return e.setPosition(e.position()+no),(r||new nd).__init(e.readInt32(e.position())+e.position(),e)}bitWidth(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}isSigned(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}static startInt(e){e.startObject(2)}static addBitWidth(e,r){e.addFieldInt32(0,r,0)}static addIsSigned(e,r){e.addFieldInt8(1,+r,0)}static endInt(e){return e.endObject()}static createInt(e,r,i){return nd.startInt(e),nd.addBitWidth(e,r),nd.addIsSigned(e,i),nd.endInt(e)}}class o0{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsDictionaryEncoding(e,r){return(r||new o0).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDictionaryEncoding(e,r){return e.setPosition(e.position()+no),(r||new o0).__init(e.readInt32(e.position())+e.position(),e)}id(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}indexType(e){const r=this.bb.__offset(this.bb_pos,6);return r?(e||new nd).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}isOrdered(){const e=this.bb.__offset(this.bb_pos,8);return e?!!this.bb.readInt8(this.bb_pos+e):!1}dictionaryKind(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt16(this.bb_pos+e):t4.DenseArray}static startDictionaryEncoding(e){e.startObject(4)}static addId(e,r){e.addFieldInt64(0,r,BigInt("0"))}static addIndexType(e,r){e.addFieldOffset(1,r,0)}static addIsOrdered(e,r){e.addFieldInt8(2,+r,0)}static addDictionaryKind(e,r){e.addFieldInt16(3,r,t4.DenseArray)}static endDictionaryEncoding(e){return e.endObject()}}class fl{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsKeyValue(e,r){return(r||new fl).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsKeyValue(e,r){return e.setPosition(e.position()+no),(r||new fl).__init(e.readInt32(e.position())+e.position(),e)}key(e){const r=this.bb.__offset(this.bb_pos,4);return r?this.bb.__string(this.bb_pos+r,e):null}value(e){const r=this.bb.__offset(this.bb_pos,6);return r?this.bb.__string(this.bb_pos+r,e):null}static startKeyValue(e){e.startObject(2)}static addKey(e,r){e.addFieldOffset(0,r,0)}static addValue(e,r){e.addFieldOffset(1,r,0)}static endKeyValue(e){return e.endObject()}static createKeyValue(e,r,i){return fl.startKeyValue(e),fl.addKey(e,r),fl.addValue(e,i),fl.endKeyValue(e)}}let Brt=class xG{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsBinary(e,r){return(r||new xG).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsBinary(e,r){return e.setPosition(e.position()+no),(r||new xG).__init(e.readInt32(e.position())+e.position(),e)}static startBinary(e){e.startObject(0)}static endBinary(e){return e.endObject()}static createBinary(e){return xG.startBinary(e),xG.endBinary(e)}},Ort=class SG{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsBool(e,r){return(r||new SG).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsBool(e,r){return e.setPosition(e.position()+no),(r||new SG).__init(e.readInt32(e.position())+e.position(),e)}static startBool(e){e.startObject(0)}static endBool(e){return e.endObject()}static createBool(e){return SG.startBool(e),SG.endBool(e)}},e4=class AO{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsDate(e,r){return(r||new AO).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDate(e,r){return e.setPosition(e.position()+no),(r||new AO).__init(e.readInt32(e.position())+e.position(),e)}unit(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Jh.MILLISECOND}static startDate(e){e.startObject(1)}static addUnit(e,r){e.addFieldInt16(0,r,Jh.MILLISECOND)}static endDate(e){return e.endObject()}static createDate(e,r){return AO.startDate(e),AO.addUnit(e,r),AO.endDate(e)}},gT=class pE{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsDecimal(e,r){return(r||new pE).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDecimal(e,r){return e.setPosition(e.position()+no),(r||new pE).__init(e.readInt32(e.position())+e.position(),e)}precision(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}scale(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb_pos+e):0}bitWidth(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readInt32(this.bb_pos+e):128}static startDecimal(e){e.startObject(3)}static addPrecision(e,r){e.addFieldInt32(0,r,0)}static addScale(e,r){e.addFieldInt32(1,r,0)}static addBitWidth(e,r){e.addFieldInt32(2,r,128)}static endDecimal(e){return e.endObject()}static createDecimal(e,r,i,s){return pE.startDecimal(e),pE.addPrecision(e,r),pE.addScale(e,i),pE.addBitWidth(e,s),pE.endDecimal(e)}},r4=class xO{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsDuration(e,r){return(r||new xO).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDuration(e,r){return e.setPosition(e.position()+no),(r||new xO).__init(e.readInt32(e.position())+e.position(),e)}unit(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):or.MILLISECOND}static startDuration(e){e.startObject(1)}static addUnit(e,r){e.addFieldInt16(0,r,or.MILLISECOND)}static endDuration(e){return e.endObject()}static createDuration(e,r){return xO.startDuration(e),xO.addUnit(e,r),xO.endDuration(e)}},i4=class SO{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsFixedSizeBinary(e,r){return(r||new SO).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFixedSizeBinary(e,r){return e.setPosition(e.position()+no),(r||new SO).__init(e.readInt32(e.position())+e.position(),e)}byteWidth(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}static startFixedSizeBinary(e){e.startObject(1)}static addByteWidth(e,r){e.addFieldInt32(0,r,0)}static endFixedSizeBinary(e){return e.endObject()}static createFixedSizeBinary(e,r){return SO.startFixedSizeBinary(e),SO.addByteWidth(e,r),SO.endFixedSizeBinary(e)}},s4=class TO{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsFixedSizeList(e,r){return(r||new TO).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFixedSizeList(e,r){return e.setPosition(e.position()+no),(r||new TO).__init(e.readInt32(e.position())+e.position(),e)}listSize(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}static startFixedSizeList(e){e.startObject(1)}static addListSize(e,r){e.addFieldInt32(0,r,0)}static endFixedSizeList(e){return e.endObject()}static createFixedSizeList(e,r){return TO.startFixedSizeList(e),TO.addListSize(e,r),TO.endFixedSizeList(e)}};class ym{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsFloatingPoint(e,r){return(r||new ym).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFloatingPoint(e,r){return e.setPosition(e.position()+no),(r||new ym).__init(e.readInt32(e.position())+e.position(),e)}precision(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ll.HALF}static startFloatingPoint(e){e.startObject(1)}static addPrecision(e,r){e.addFieldInt16(0,r,ll.HALF)}static endFloatingPoint(e){return e.endObject()}static createFloatingPoint(e,r){return ym.startFloatingPoint(e),ym.addPrecision(e,r),ym.endFloatingPoint(e)}}class vm{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsInterval(e,r){return(r||new vm).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsInterval(e,r){return e.setPosition(e.position()+no),(r||new vm).__init(e.readInt32(e.position())+e.position(),e)}unit(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):$d.YEAR_MONTH}static startInterval(e){e.startObject(1)}static addUnit(e,r){e.addFieldInt16(0,r,$d.YEAR_MONTH)}static endInterval(e){return e.endObject()}static createInterval(e,r){return vm.startInterval(e),vm.addUnit(e,r),vm.endInterval(e)}}let Irt=class TG{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsLargeBinary(e,r){return(r||new TG).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsLargeBinary(e,r){return e.setPosition(e.position()+no),(r||new TG).__init(e.readInt32(e.position())+e.position(),e)}static startLargeBinary(e){e.startObject(0)}static endLargeBinary(e){return e.endObject()}static createLargeBinary(e){return TG.startLargeBinary(e),TG.endLargeBinary(e)}},Drt=class RG{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsLargeUtf8(e,r){return(r||new RG).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsLargeUtf8(e,r){return e.setPosition(e.position()+no),(r||new RG).__init(e.readInt32(e.position())+e.position(),e)}static startLargeUtf8(e){e.startObject(0)}static endLargeUtf8(e){return e.endObject()}static createLargeUtf8(e){return RG.startLargeUtf8(e),RG.endLargeUtf8(e)}},Prt=class CG{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsList(e,r){return(r||new CG).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsList(e,r){return e.setPosition(e.position()+no),(r||new CG).__init(e.readInt32(e.position())+e.position(),e)}static startList(e){e.startObject(0)}static endList(e){return e.endObject()}static createList(e){return CG.startList(e),CG.endList(e)}},o4=class RO{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsMap(e,r){return(r||new RO).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMap(e,r){return e.setPosition(e.position()+no),(r||new RO).__init(e.readInt32(e.position())+e.position(),e)}keysSorted(){const e=this.bb.__offset(this.bb_pos,4);return e?!!this.bb.readInt8(this.bb_pos+e):!1}
7static startMap(e){e.startObject(1)}static addKeysSorted(e,r){e.addFieldInt8(0,+r,0)}static endMap(e){return e.endObject()}static createMap(e,r){return RO.startMap(e),RO.addKeysSorted(e,r),RO.endMap(e)}},Frt=class MG{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsNull(e,r){return(r||new MG).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsNull(e,r){return e.setPosition(e.position()+no),(r||new MG).__init(e.readInt32(e.position())+e.position(),e)}static startNull(e){e.startObject(0)}static endNull(e){return e.endObject()}static createNull(e){return MG.startNull(e),MG.endNull(e)}};class AE{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsStruct_(e,r){return(r||new AE).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsStruct_(e,r){return e.setPosition(e.position()+no),(r||new AE).__init(e.readInt32(e.position())+e.position(),e)}static startStruct_(e){e.startObject(0)}static endStruct_(e){return e.endObject()}static createStruct_(e){return AE.startStruct_(e),AE.endStruct_(e)}}class Jd{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsTime(e,r){return(r||new Jd).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsTime(e,r){return e.setPosition(e.position()+no),(r||new Jd).__init(e.readInt32(e.position())+e.position(),e)}unit(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):or.MILLISECOND}bitWidth(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb_pos+e):32}static startTime(e){e.startObject(2)}static addUnit(e,r){e.addFieldInt16(0,r,or.MILLISECOND)}static addBitWidth(e,r){e.addFieldInt32(1,r,32)}static endTime(e){return e.endObject()}static createTime(e,r,i){return Jd.startTime(e),Jd.addUnit(e,r),Jd.addBitWidth(e,i),Jd.endTime(e)}}class Qd{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsTimestamp(e,r){return(r||new Qd).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsTimestamp(e,r){return e.setPosition(e.position()+no),(r||new Qd).__init(e.readInt32(e.position())+e.position(),e)}unit(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):or.SECOND}timezone(e){const r=this.bb.__offset(this.bb_pos,6);return r?this.bb.__string(this.bb_pos+r,e):null}static startTimestamp(e){e.startObject(2)}static addUnit(e,r){e.addFieldInt16(0,r,or.SECOND)}static addTimezone(e,r){e.addFieldOffset(1,r,0)}static endTimestamp(e){return e.endObject()}static createTimestamp(e,r,i){return Qd.startTimestamp(e),Qd.addUnit(e,r),Qd.addTimezone(e,i),Qd.endTimestamp(e)}}class cu{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsUnion(e,r){return(r||new cu).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUnion(e,r){return e.setPosition(e.position()+no),(r||new cu).__init(e.readInt32(e.position())+e.position(),e)}mode(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):lu.Sparse}typeIds(e){const r=this.bb.__offset(this.bb_pos,6);return r?this.bb.readInt32(this.bb.__vector(this.bb_pos+r)+e*4):0}typeIdsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}typeIdsArray(){const e=this.bb.__offset(this.bb_pos,6);return e?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+e),this.bb.__vector_len(this.bb_pos+e)):null}static startUnion(e){e.startObject(2)}static addMode(e,r){e.addFieldInt16(0,r,lu.Sparse)}static addTypeIds(e,r){e.addFieldOffset(1,r,0)}static createTypeIdsVector(e,r){e.startVector(4,r.length,4);for(let i=r.length-1;i>=0;i--)e.addInt32(r[i]);return e.endVector()}static startTypeIdsVector(e,r){e.startVector(4,r,4)}static endUnion(e){return e.endObject()}static createUnion(e,r,i){return cu.startUnion(e),cu.addMode(e,r),cu.addTypeIds(e,i),cu.endUnion(e)}}let Nrt=class BG{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsUtf8(e,r){return(r||new BG).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,r){return e.setPosition(e.position()+no),(r||new BG).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return BG.startUtf8(e),BG.endUtf8(e)}};var jo;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.FloatingPoint=3]="FloatingPoint",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct_=13]="Struct_",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.LargeList=21]="LargeList",t[t.RunEndEncoded=22]="RunEndEncoded"})(jo||(jo={}));let tf=class JV{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsField(e,r){return(r||new JV).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,r){return e.setPosition(e.position()+no),(r||new JV).__init(e.readInt32(e.position())+e.position(),e)}name(e){const r=this.bb.__offset(this.bb_pos,4);return r?this.bb.__string(this.bb_pos+r,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}
7typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):jo.NONE}type(e){const r=this.bb.__offset(this.bb_pos,10);return r?this.bb.__union(e,this.bb_pos+r):null}dictionary(e){const r=this.bb.__offset(this.bb_pos,12);return r?(e||new o0).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}children(e,r){const i=this.bb.__offset(this.bb_pos,14);return i?(r||new JV).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,r){const i=this.bb.__offset(this.bb_pos,16);return i?(r||new fl).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,r){e.addFieldOffset(0,r,0)}static addNullable(e,r){e.addFieldInt8(1,+r,0)}static addTypeType(e,r){e.addFieldInt8(2,r,jo.NONE)}static addType(e,r){e.addFieldOffset(3,r,0)}static addDictionary(e,r){e.addFieldOffset(4,r,0)}static addChildren(e,r){e.addFieldOffset(5,r,0)}static createChildrenVector(e,r){e.startVector(4,r.length,4);for(let i=r.length-1;i>=0;i--)e.addOffset(r[i]);return e.endVector()}static startChildrenVector(e,r){e.startVector(4,r,4)}static addCustomMetadata(e,r){e.addFieldOffset(6,r,0)}static createCustomMetadataVector(e,r){e.startVector(4,r.length,4);for(let i=r.length-1;i>=0;i--)e.addOffset(r[i]);return e.endVector()}static startCustomMetadataVector(e,r){e.startVector(4,r,4)}static endField(e){return e.endObject()}},_m=class Fv{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsSchema(e,r){return(r||new Fv).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,r){return e.setPosition(e.position()+no),(r||new Fv).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):pT.Little}fields(e,r){const i=this.bb.__offset(this.bb_pos,6);return i?(r||new tf).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,r){const i=this.bb.__offset(this.bb_pos,8);return i?(r||new fl).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const r=this.bb.__offset(this.bb_pos,10);return r?this.bb.readInt64(this.bb.__vector(this.bb_pos+r)+e*8):BigInt(0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,r){e.addFieldInt16(0,r,pT.Little)}static addFields(e,r){e.addFieldOffset(1,r,0)}static createFieldsVector(e,r){e.startVector(4,r.length,4);for(let i=r.length-1;i>=0;i--)e.addOffset(r[i]);return e.endVector()}static startFieldsVector(e,r){e.startVector(4,r,4)}static addCustomMetadata(e,r){e.addFieldOffset(2,r,0)}static createCustomMetadataVector(e,r){e.startVector(4,r.length,4);for(let i=r.length-1;i>=0;i--)e.addOffset(r[i]);return e.endVector()}static startCustomMetadataVector(e,r){e.startVector(4,r,4)}static addFeatures(e,r){e.addFieldOffset(3,r,0)}static createFeaturesVector(e,r){e.startVector(8,r.length,8);for(let i=r.length-1;i>=0;i--)e.addInt64(r[i]);return e.endVector()}static startFeaturesVector(e,r){e.startVector(8,r,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,r){e.finish(r)}static finishSizePrefixedSchemaBuffer(e,r){e.finish(r,void 0,!0)}static createSchema(e,r,i,s,o){return Fv.startSchema(e),Fv.addEndianness(e,r),Fv.addFields(e,i),Fv.addCustomMetadata(e,s),Fv.addFeatures(e,o),Fv.endSchema(e)}};var ao;(function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"})(ao||(ao={}));var ot;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth",t[t.DurationSecond=-27]="DurationSecond",t[t.DurationMillisecond=-28]="DurationMillisecond",t[t.DurationMicrosecond=-29]="DurationMicrosecond",t[t.DurationNanosecond=-30]="DurationNanosecond"})(ot||(ot={}));var n0;(function(t){t[t.OFFSET=0]="OFFSET",t[t.DATA=1]="DATA",t[t.VALIDITY=2]="VALIDITY",t[t.TYPE=3]="TYPE"})(n0||(n0={}));const HMt=void 0;function PO(t){if(t===null)return"null";if(t===HMt)return"undefined";switch(typeof t){case"number":return`${t}`;case"bigint":return`${t}`;case"string":return`"${t}"`}return typeof t[Symbol.toPrimitive]=="function"?t[Symbol.toPrimitive]("string"):ArrayBuffer.isView(t)?t instanceof BigInt64Array||t instanceof BigUint64Array?`[${[...t].map(e=>PO(e))}]`:`[${t}]`:ArrayBuffer.isView(t)?`[${t}]`:JSON.stringify(t,(e,r)=>typeof r=="bigint"?`${r}`:r)}function Qo(t){if(typeof t=="bigint"&&(t<Number.MIN_SAFE_INTEGER||t>Number.MAX_SAFE_INTEGER))throw new TypeError(`${t} is not safe to convert to a number.`);return Number(t)}function krt(t,e){return Qo(t/e)+Qo(t%e)/Qo(e)}const KMt=Symbol.for("isArrowBigNum");function lp(t,...e){return e.length===0?Object.setPrototypeOf(Co(this.TypedArray,t),this.constructor.prototype):Object.
7setPrototypeOf(new this.TypedArray(t,...e),this.constructor.prototype)}lp.prototype[KMt]=!0,lp.prototype.toJSON=function(){return`"${NO(this)}"`},lp.prototype.valueOf=function(t){return Lrt(this,t)},lp.prototype.toString=function(){return NO(this)},lp.prototype[Symbol.toPrimitive]=function(t="default"){switch(t){case"number":return Lrt(this);case"string":return NO(this);case"default":return JMt(this)}return NO(this)};function mT(...t){return lp.apply(this,t)}function yT(...t){return lp.apply(this,t)}function FO(...t){return lp.apply(this,t)}Object.setPrototypeOf(mT.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(yT.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(FO.prototype,Object.create(Uint32Array.prototype)),Object.assign(mT.prototype,lp.prototype,{constructor:mT,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(yT.prototype,lp.prototype,{constructor:yT,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(FO.prototype,lp.prototype,{constructor:FO,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const qMt=BigInt(4294967296)*BigInt(4294967296),ZMt=qMt-BigInt(1);function Lrt(t,e){const{buffer:r,byteOffset:i,byteLength:s,signed:o}=t,n=new BigUint64Array(r,i,s/8),a=o&&n.at(-1)&BigInt(1)<<BigInt(63);let l=BigInt(0),c=0;if(a){for(const h of n)l|=(h^ZMt)*(BigInt(1)<<BigInt(64*c++));l*=BigInt(-1),l-=BigInt(1)}else for(const h of n)l|=h*(BigInt(1)<<BigInt(64*c++));if(typeof e=="number"){const h=BigInt(Math.pow(10,e)),u=l/h,d=l%h;return Qo(u)+Qo(d)/Qo(h)}return Qo(l)}function NO(t){if(t.byteLength===8)return`${new t.BigIntArray(t.buffer,t.byteOffset,1)[0]}`;if(!t.signed)return JY(t);let e=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2);if(new Int16Array([e.at(-1)])[0]>=0)return JY(t);e=e.slice();let r=1;for(let i=0;i<e.length;i++){const s=e[i],o=~s+r;e[i]=o,r&=s===0?1:0}return`-${JY(e)}`}function JMt(t){return t.byteLength===8?new t.BigIntArray(t.buffer,t.byteOffset,1)[0]:NO(t)}function JY(t){let e="";const r=new Uint32Array(2);let i=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2);const s=new Uint32Array((i=new Uint16Array(i).reverse()).buffer);let o=-1;const n=i.length-1;do{for(r[0]=i[o=0];o<n;)i[o++]=r[1]=r[0]/10,r[0]=(r[0]-r[1]*10<<16)+i[o];i[o]=r[1]=r[0]/10,r[0]=r[0]-r[1]*10,e=`${r[0]}${e}`}while(s[0]||s[1]||s[2]||s[3]);return e??"0"}class QY{static new(e,r){switch(r){case!0:return new mT(e);case!1:return new yT(e)}switch(e.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new mT(e)}return e.byteLength===16?new FO(e):new yT(e)}static signed(e){return new mT(e)}static unsigned(e){return new yT(e)}static decimal(e){return new FO(e)}constructor(e,r){return QY.new(e,r)}}var Urt,Grt,Wrt,jrt,Xrt,zrt,Vrt,Yrt,$rt,Hrt,Krt,qrt,Zrt,Jrt,Qrt,tit,eit,rit,iit,sit,oit,nit;class ur{static isNull(e){return(e==null?void 0:e.typeId)===ot.Null}static isInt(e){return(e==null?void 0:e.typeId)===ot.Int}static isFloat(e){return(e==null?void 0:e.typeId)===ot.Float}static isBinary(e){return(e==null?void 0:e.typeId)===ot.Binary}static isLargeBinary(e){return(e==null?void 0:e.typeId)===ot.LargeBinary}static isUtf8(e){return(e==null?void 0:e.typeId)===ot.Utf8}static isLargeUtf8(e){return(e==null?void 0:e.typeId)===ot.LargeUtf8}static isBool(e){return(e==null?void 0:e.typeId)===ot.Bool}static isDecimal(e){return(e==null?void 0:e.typeId)===ot.Decimal}static isDate(e){return(e==null?void 0:e.typeId)===ot.Date}static isTime(e){return(e==null?void 0:e.typeId)===ot.Time}static isTimestamp(e){return(e==null?void 0:e.typeId)===ot.Timestamp}static isInterval(e){return(e==null?void 0:e.typeId)===ot.Interval}static isDuration(e){return(e==null?void 0:e.typeId)===ot.Duration}static isList(e){return(e==null?void 0:e.typeId)===ot.List}static isStruct(e){return(e==null?void 0:e.typeId)===ot.Struct}static isUnion(e){return(e==null?void 0:e.typeId)===ot.Union}static isFixedSizeBinary(e){return(e==null?void 0:e.typeId)===ot.FixedSizeBinary}static isFixedSizeList(e){return(e==null?void 0:e.typeId)===ot.FixedSizeList}static isMap(e){return(e==null?void 0:e.typeId)===ot.Map}static isDictionary(e){return(e==null?void 0:e.typeId)===ot.Dictionary}static isDenseUnion(e){return ur.isUnion(e)&&e.mode===lu.Dense}static isSparseUnion(e){return ur.isUnion(e)&&e.mode===lu.Sparse}constructor(e){this.typeId=e}}Urt=Symbol.toStringTag,ur[Urt]=(t=>(t.children=null,t.ArrayType=Array,t.OffsetArrayType=Int32Array,t[Symbol.toStringTag]="DataType"))(ur.prototype),Ly=class extends ur{constructor(){super(ot.Null)}toString(){return"Null"}},Grt=Symbol.toStringTag,Ly[Grt]=(t=>t[Symbol.toStringTag]="Null")(Ly.prototype),gh=class extends ur{constructor(t,e){super(ot.Int),this.isSigned=t,this.bitWidth=e}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}},Wrt=Symbol.toStringTag,gh[Wrt]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(gh.prototype),htt=class extends gh{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},ctt=class extends gh{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},QS=class extends gh{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},ltt=class extends gh{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},att=class extends gh{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},ntt=class extends gh{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},ott=class extends gh{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},stt=class extends gh{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}},Object.defineProperty(htt.prototype,"ArrayType",{value:Int8Array}),Object.defineProperty(ctt.prototype,"ArrayType",{value:Int16Array}),Object.defineProperty(QS.prototype,"ArrayType",{value:Int32Array}),Object.defineProperty(ltt.prototype,"ArrayType",{value:BigInt64Array}),Object.defineProperty(att.prototype,"ArrayType",{value:Uint8Array}),Object.defineProperty(ntt.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(ott.prototype,"ArrayType",{value:Uint32Array}),Object.defineProperty(stt.prototype,"ArrayType",{value:BigUint64Array}),Cv=class extends ur{constructor(t){super(ot.Float),this.precision=t}get ArrayType(){switch(this.precision){case ll.HALF:return Uint16Array;case ll.SINGLE:return Float32Array;case ll.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}},jrt=Symbol.toStringTag,Cv[jrt]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(Cv.prototype),itt=class extends Cv{constructor(){super(ll.HALF)}},ptt=class extends Cv{constructor(){super(ll.SINGLE)}},ftt=class extends Cv{constructor(){super(ll.DOUBLE)}},Object.defineProperty(itt.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(ptt.prototype,"ArrayType",{value:Float32Array}),Object.defineProperty(ftt.prototype,"ArrayType",{value:Float64Array}),eO=class extends ur{constructor(){super(ot.Binary)}toString(){return"Binary"}},Xrt=Symbol.toStringTag,eO[Xrt]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(eO.prototype);class n4 extends ur{constructor(){super(ot.LargeBinary)}toString(){return"LargeBinary"}}zrt=Symbol.toStringTag,n4[zrt]=(t=>(t.ArrayType=Uint8Array,t.OffsetArrayType=BigInt64Array,t[Symbol.toStringTag]="LargeBinary"))(n4.prototype),lO=class extends ur{constructor(){super(ot.Utf8)}toString(){return"Utf8"}},Vrt=Symbol.toStringTag,lO[Vrt]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(lO.prototype);class a4 extends ur{constructor(){super(ot.LargeUtf8)}toString(){return"LargeUtf8"}}Yrt=Symbol.toStringTag,a4[Yrt]=(t=>(t.ArrayType=Uint8Array,t.OffsetArrayType=BigInt64Array,t[Symbol.toStringTag]="LargeUtf8"))(a4.prototype),tO=class extends ur{constructor(){super(ot.Bool)}toString(){return"Bool"}},$rt=Symbol.toStringTag,tO[$rt]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(tO.prototype),aO=class extends ur{constructor(t,e,r=128){super(ot.Decimal),this.scale=t,this.precision=e,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}},Hrt=Symbol.toStringTag,aO[Hrt]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(aO.prototype),oE=class extends ur{constructor(t){super(ot.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${Jh[this.unit]}>`}get ArrayType(){return this.unit===Jh.DAY?Int32Array:BigInt64Array}},Krt=Symbol.toStringTag,oE[Krt]=(t=>(t.unit=null,t[Symbol.toStringTag]="Date"))(oE.prototype),$Et=class extends oE{constructor(){super(Jh.DAY)}},YEt=class extends oE{constructor(){super(Jh.MILLISECOND)}},Wy=class extends ur{constructor(t,e){super(ot.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${or[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}},qrt=Symbol.toStringTag,Wy[qrt]=(t=>(t.unit=null,t.bitWidth=null,t[Symbol.toStringTag]="Time"))(Wy.prototype),zEt=class extends Wy{constructor(){super(or.SECOND,32)}},VEt=class extends Wy{constructor(){super(or.MILLISECOND,32)}},XEt=class extends Wy{constructor(){super(or.MICROSECOND,64)}},jEt=class extends Wy{constructor(){super(or.NANOSECOND,64)}},Gy=class extends ur{constructor(t,e){super(ot.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${or[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}},Zrt=Symbol.toStringTag,Gy[Zrt]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=BigInt64Array,t[Symbol.toStringTag]="Timestamp"))(Gy.prototype),WEt=class extends Gy{constructor(t){super(or.SECOND,t)}},GEt=class extends Gy{constructor(t){super(or.MILLISECOND,t)}},UEt=class extends Gy{constructor(t){super(or.MICROSECOND,t)}},LEt=class extends Gy{constructor(t){super(or.NANOSECOND,t)}},sE=class extends ur{constructor(t){super(ot.Interval),this.unit=t}toString(){return`Interval<${$d[this.unit]}>`}},Jrt=Symbol.toStringTag,sE[Jrt]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(sE.prototype),kEt=class extends sE{constructor(){super($d.DAY_TIME)}},NEt=class extends sE{constructor(){super($d.YEAR_MONTH)}};class l4 extends ur{constructor(e){super(ot.Duration),this.unit=e}toString(){return`Duration<${or[this.unit]}>`}}Qrt=Symbol.toStringTag,l4[Qrt]=(t=>(t.unit=null,t.ArrayType=BigInt64Array,t[Symbol.toStringTag]="Duration"))(l4.prototype),oO=class extends ur{constructor(t){super(ot.List),this.children=[t]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}},tit=Symbol.toStringTag,oO[tit]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(oO.prototype),Uc=class extends ur{constructor(t){super(ot.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}},eit=Symbol.toStringTag,Uc[eit]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(Uc.prototype);class c4 extends ur{constructor(e,r,i){super(ot.Union),this.mode=e,this.children=i,this.typeIds=r=Int32Array.from(r),this.typeIdToChildIndex=r.reduce((s,o,n)=>(s[o]=n)&&s||s,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}rit=Symbol.toStringTag,c4[rit]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))(c4.prototype);class h4 extends ur{constructor(e){super(ot.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}iit=Symbol.toStringTag,h4[iit]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(h4.prototype),sO=class extends ur{constructor(t,e){super(ot.FixedSizeList),this.listSize=t,this.children=[e]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}},sit=Symbol.toStringTag,sO[sit]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(sO.prototype),nO=class extends ur{constructor(t,e=!1){var r,i,s;if(super(ot.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((r=t==null?void 0:t.type)===null||r===void 0)&&r.children)){const o=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");const n=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];n&&(n.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}},oit=Symbol.toStringTag,nO[oit]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))(nO.prototype);const QMt=(t=>()=>++t)(-1);class vT extends ur{constructor(e,r,i,s){super(ot.Dictionary),this.indices=r,this.dictionary=e,this.isOrdered=s||!1,this.id=i==null?QMt():Qo(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}nit=Symbol.toStringTag,vT[nit]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(vT.prototype);function a0(t){const e=t;switch(t.typeId){case ot.Decimal:return t.bitWidth/32;case ot.Interval:return 1+e.unit;case ot.FixedSizeList:return e.listSize;case ot.FixedSizeBinary:return e.byteWidth;default:return 1}}class Ui{visitMany(e,...r){return e.map((i,s)=>this.visit(i,...r.map(o=>o[s])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,r=!0){return t2t(this,e,r)}getVisitFnByTypeId(e,r=!0){return _T(this,e,r)}visitNull(e,...r){return null}visitBool(e,...r){return null}visitInt(e,...r){return null}visitFloat(e,...r){return null}visitUtf8(e,...r){return null}visitLargeUtf8(e,...r){return null}visitBinary(e,...r){return null}visitLargeBinary(e,...r){return null}visitFixedSizeBinary(e,...r){return null}visitDate(e,...r){return null}visitTimestamp(e,...r){return null}visitTime(e,...r){return null}visitDecimal(e,...r){return null}visitList(e,...r){return null}visitStruct(e,...r){return null}visitUnion(e,...r){return null}visitDictionary(e,...r){return null}visitInterval(e,...r){return null}visitDuration(e,...r){return null}visitFixedSizeList(e,...r){return null}visitMap(e,...r){return null}}function t2t(t,e,r=!0){return typeof e=="number"?_T(t,e,r):typeof e=="string"&&e in ot?_T(t,ot[e],r):e&&e instanceof ur?_T(t,ait(e),r):e!=null&&e.type&&e.type instanceof ur?_T(t,ait(e.type),r):_T(t,ot.NONE,r)}function _T(t,e,r=!0){let i=null;switch(e){case ot.Null:i=t.visitNull;break;case ot.Bool:i=t.visitBool;break;case ot.Int:i=t.visitInt;break;case ot.Int8:i=t.visitInt8||t.visitInt;break;case ot.Int16:i=t.visitInt16||t.visitInt;break;case ot.Int32:i=t.visitInt32||t.visitInt;break;case ot.Int64:i=t.visitInt64||t.visitInt;break;case ot.Uint8:i=t.visitUint8||t.visitInt;break;case ot.Uint16:i=t.visitUint16||t.visitInt;break;case ot.Uint32:i=t.visitUint32||t.visitInt;break;case ot.Uint64:i=t.visitUint64||t.visitInt;break;case ot.Float:i=t.visitFloat;break;case ot.Float16:i=t.visitFloat16||t.visitFloat;break;case ot.Float32:i=t.visitFloat32||t.visitFloat;break;case ot.Float64:i=t.visitFloat64||t.visitFloat;break;case ot.Utf8:i=t.visitUtf8;break;case ot.LargeUtf8:i=t.visitLargeUtf8;break;case ot.Binary:i=t.visitBinary;break;case ot.LargeBinary:i=t.visitLargeBinary;break;case ot.FixedSizeBinary:i=t.visitFixedSizeBinary;break;case ot.Date:i=t.visitDate;break;case ot.DateDay:i=t.visitDateDay||t.visitDate;break;case ot.DateMillisecond:i=t.visitDateMillisecond||t.visitDate;break;case ot.Timestamp:i=t.visitTimestamp;break;case ot.TimestampSecond:i=t.visitTimestampSecond||t.visitTimestamp;break;case ot.TimestampMillisecond:i=t.
7visitTimestampMillisecond||t.visitTimestamp;break;case ot.TimestampMicrosecond:i=t.visitTimestampMicrosecond||t.visitTimestamp;break;case ot.TimestampNanosecond:i=t.visitTimestampNanosecond||t.visitTimestamp;break;case ot.Time:i=t.visitTime;break;case ot.TimeSecond:i=t.visitTimeSecond||t.visitTime;break;case ot.TimeMillisecond:i=t.visitTimeMillisecond||t.visitTime;break;case ot.TimeMicrosecond:i=t.visitTimeMicrosecond||t.visitTime;break;case ot.TimeNanosecond:i=t.visitTimeNanosecond||t.visitTime;break;case ot.Decimal:i=t.visitDecimal;break;case ot.List:i=t.visitList;break;case ot.Struct:i=t.visitStruct;break;case ot.Union:i=t.visitUnion;break;case ot.DenseUnion:i=t.visitDenseUnion||t.visitUnion;break;case ot.SparseUnion:i=t.visitSparseUnion||t.visitUnion;break;case ot.Dictionary:i=t.visitDictionary;break;case ot.Interval:i=t.visitInterval;break;case ot.IntervalDayTime:i=t.visitIntervalDayTime||t.visitInterval;break;case ot.IntervalYearMonth:i=t.visitIntervalYearMonth||t.visitInterval;break;case ot.Duration:i=t.visitDuration;break;case ot.DurationSecond:i=t.visitDurationSecond||t.visitDuration;break;case ot.DurationMillisecond:i=t.visitDurationMillisecond||t.visitDuration;break;case ot.DurationMicrosecond:i=t.visitDurationMicrosecond||t.visitDuration;break;case ot.DurationNanosecond:i=t.visitDurationNanosecond||t.visitDuration;break;case ot.FixedSizeList:i=t.visitFixedSizeList;break;case ot.Map:i=t.visitMap;break}if(typeof i=="function")return i;if(!r)return()=>null;throw new Error(`Unrecognized type '${ot[e]}'`)}function ait(t){switch(t.typeId){case ot.Null:return ot.Null;case ot.Int:{const{bitWidth:e,isSigned:r}=t;switch(e){case 8:return r?ot.Int8:ot.Uint8;case 16:return r?ot.Int16:ot.Uint16;case 32:return r?ot.Int32:ot.Uint32;case 64:return r?ot.Int64:ot.Uint64}return ot.Int}case ot.Float:switch(t.precision){case ll.HALF:return ot.Float16;case ll.SINGLE:return ot.Float32;case ll.DOUBLE:return ot.Float64}return ot.Float;case ot.Binary:return ot.Binary;case ot.LargeBinary:return ot.LargeBinary;case ot.Utf8:return ot.Utf8;case ot.LargeUtf8:return ot.LargeUtf8;case ot.Bool:return ot.Bool;case ot.Decimal:return ot.Decimal;case ot.Time:switch(t.unit){case or.SECOND:return ot.TimeSecond;case or.MILLISECOND:return ot.TimeMillisecond;case or.MICROSECOND:return ot.TimeMicrosecond;case or.NANOSECOND:return ot.TimeNanosecond}return ot.Time;case ot.Timestamp:switch(t.unit){case or.SECOND:return ot.TimestampSecond;case or.MILLISECOND:return ot.TimestampMillisecond;case or.MICROSECOND:return ot.TimestampMicrosecond;case or.NANOSECOND:return ot.TimestampNanosecond}return ot.Timestamp;case ot.Date:switch(t.unit){case Jh.DAY:return ot.DateDay;case Jh.MILLISECOND:return ot.DateMillisecond}return ot.Date;case ot.Interval:switch(t.unit){case $d.DAY_TIME:return ot.IntervalDayTime;case $d.YEAR_MONTH:return ot.IntervalYearMonth}return ot.Interval;case ot.Duration:switch(t.unit){case or.SECOND:return ot.DurationSecond;case or.MILLISECOND:return ot.DurationMillisecond;case or.MICROSECOND:return ot.DurationMicrosecond;case or.NANOSECOND:return ot.DurationNanosecond}return ot.Duration;case ot.Map:return ot.Map;case ot.List:return ot.List;case ot.Struct:return ot.Struct;case ot.Union:switch(t.mode){case lu.Dense:return ot.DenseUnion;case lu.Sparse:return ot.SparseUnion}return ot.Union;case ot.FixedSizeBinary:return ot.FixedSizeBinary;case ot.FixedSizeList:return ot.FixedSizeList;case ot.Dictionary:return ot.Dictionary}throw new Error(`Unrecognized type '${ot[t.typeId]}'`)}Ui.prototype.visitInt8=null,Ui.prototype.visitInt16=null,Ui.prototype.visitInt32=null,Ui.prototype.visitInt64=null,Ui.prototype.visitUint8=null,Ui.prototype.visitUint16=null,Ui.prototype.visitUint32=null,Ui.prototype.visitUint64=null,Ui.prototype.visitFloat16=null,Ui.prototype.visitFloat32=null,Ui.prototype.visitFloat64=null,Ui.prototype.visitDateDay=null,Ui.prototype.visitDateMillisecond=null,Ui.prototype.visitTimestampSecond=null,Ui.prototype.visitTimestampMillisecond=null,Ui.prototype.visitTimestampMicrosecond=null,Ui.prototype.visitTimestampNanosecond=null,Ui.prototype.visitTimeSecond=null,Ui.prototype.visitTimeMillisecond=null,Ui.prototype.visitTimeMicrosecond=null,Ui.prototype.visitTimeNanosecond=null,Ui.prototype.visitDenseUnion=null,Ui.prototype.visitSparseUnion=null,Ui.prototype.visitIntervalDayTime=null,Ui.prototype.visitIntervalYearMonth=null,Ui.prototype.visitDuration=null,Ui.prototype.visitDurationSecond=null,Ui.prototype.visitDurationMillisecond=null,Ui.prototype.visitDurationMicrosecond=null,Ui.prototype.visitDurationNanosecond=null;const lit=new Float64Array(1),bT=new Uint32Array(lit.buffer);function cit(t){const e=(t&31744)>>10,r=(t&1023)/1024,i=Math.pow(-1,(t&32768)>>15);switch(e){case 31:return i*(r?Number.NaN:1/0);case 0:return i*(r?6103515625e-14*r:0)}return i*Math.pow(2,e-15)*(1+r)}function e2t(t){if(t!==t)return 32256;lit[0]=t;const e=(bT[1]&2147483648)>>16&65535;let r=bT[1]&2146435072,i=0;return r>=1089470464?bT[0]>0?r=31744:(r=(r&2080374784)>>16,i=(bT[1]&1048575)>>10):r<=1056964608?(i=1048576+(bT[1]&1048575),i=1048576+(i<<(r>>20)-998)>>21,r=0):(r=r-1056964608>>10,i=(bT[1]&1048575)+512>>10),e|r|i&65535}class Fr extends Ui{}
7function zr(t){return(e,r,i)=>{if(e.setValid(r,i!=null))return t(e,r,i)}}const r2t=(t,e,r)=>{t[e]=Math.floor(r/864e5)},hit=(t,e,r,i)=>{if(r+1<e.length){const s=Qo(e[r]),o=Qo(e[r+1]);t.set(i.subarray(0,o-s),s)}},i2t=({offset:t,values:e},r,i)=>{const s=t+r;i?e[s>>3]|=1<<s%8:e[s>>3]&=~(1<<s%8)},l0=({values:t},e,r)=>{t[e]=r},t$=({values:t},e,r)=>{t[e]=r},uit=({values:t},e,r)=>{t[e]=e2t(r)},s2t=(t,e,r)=>{switch(t.type.precision){case ll.HALF:return uit(t,e,r);case ll.SINGLE:case ll.DOUBLE:return t$(t,e,r)}},dit=({values:t},e,r)=>{r2t(t,e,r.valueOf())},fit=({values:t},e,r)=>{t[e]=BigInt(r)},o2t=({stride:t,values:e},r,i)=>{e.set(i.subarray(0,t),t*r)},pit=({values:t,valueOffsets:e},r,i)=>hit(t,e,r,i),git=({values:t,valueOffsets:e},r,i)=>hit(t,e,r,XY(i)),n2t=(t,e,r)=>{t.type.unit===Jh.DAY?dit(t,e,r):fit(t,e,r)},mit=({values:t},e,r)=>{t[e]=BigInt(r/1e3)},yit=({values:t},e,r)=>{t[e]=BigInt(r)},vit=({values:t},e,r)=>{t[e]=BigInt(r*1e3)},_it=({values:t},e,r)=>{t[e]=BigInt(r*1e6)},a2t=(t,e,r)=>{switch(t.type.unit){case or.SECOND:return mit(t,e,r);case or.MILLISECOND:return yit(t,e,r);case or.MICROSECOND:return vit(t,e,r);case or.NANOSECOND:return _it(t,e,r)}},bit=({values:t},e,r)=>{t[e]=r},wit=({values:t},e,r)=>{t[e]=r},Eit=({values:t},e,r)=>{t[e]=r},Ait=({values:t},e,r)=>{t[e]=r},l2t=(t,e,r)=>{switch(t.type.unit){case or.SECOND:return bit(t,e,r);case or.MILLISECOND:return wit(t,e,r);case or.MICROSECOND:return Eit(t,e,r);case or.NANOSECOND:return Ait(t,e,r)}},c2t=({values:t,stride:e},r,i)=>{t.set(i.subarray(0,e),e*r)},h2t=(t,e,r)=>{const i=t.children[0],s=t.valueOffsets,o=ef.getVisitFn(i);if(Array.isArray(r))for(let n=-1,a=s[e],l=s[e+1];a<l;)o(i,a++,r[++n]);else for(let n=-1,a=s[e],l=s[e+1];a<l;)o(i,a++,r.get(++n))},u2t=(t,e,r)=>{const i=t.children[0],{valueOffsets:s}=t,o=ef.getVisitFn(i);let{[e]:n,[e+1]:a}=s;const l=r instanceof Map?r.entries():Object.entries(r);for(const c of l)if(o(i,n,c),++n>=a)break},d2t=(t,e)=>(r,i,s,o)=>i&&r(i,t,e[o]),f2t=(t,e)=>(r,i,s,o)=>i&&r(i,t,e.get(o)),p2t=(t,e)=>(r,i,s,o)=>i&&r(i,t,e.get(s.name)),g2t=(t,e)=>(r,i,s,o)=>i&&r(i,t,e[s.name]),m2t=(t,e,r)=>{const i=t.type.children.map(o=>ef.getVisitFn(o.type)),s=r instanceof Map?p2t(e,r):r instanceof Ma?f2t(e,r):Array.isArray(r)?d2t(e,r):g2t(e,r);t.type.children.forEach((o,n)=>s(i[n],t.children[n],o,n))},y2t=(t,e,r)=>{t.type.mode===lu.Dense?xit(t,e,r):Sit(t,e,r)},xit=(t,e,r)=>{const i=t.type.typeIdToChildIndex[t.typeIds[e]],s=t.children[i];ef.visit(s,t.valueOffsets[e],r)},Sit=(t,e,r)=>{const i=t.type.typeIdToChildIndex[t.typeIds[e]],s=t.children[i];ef.visit(s,e,r)},v2t=(t,e,r)=>{var i;(i=t.dictionary)===null||i===void 0||i.set(t.values[e],r)},_2t=(t,e,r)=>{t.type.unit===$d.DAY_TIME?Tit(t,e,r):Rit(t,e,r)},Tit=({values:t},e,r)=>{t.set(r.subarray(0,2),2*e)},Rit=({values:t},e,r)=>{t[e]=r[0]*12+r[1]%12},Cit=({values:t},e,r)=>{t[e]=r},Mit=({values:t},e,r)=>{t[e]=r},Bit=({values:t},e,r)=>{t[e]=r},Oit=({values:t},e,r)=>{t[e]=r},b2t=(t,e,r)=>{switch(t.type.unit){case or.SECOND:return Cit(t,e,r);case or.MILLISECOND:return Mit(t,e,r);case or.MICROSECOND:return Bit(t,e,r);case or.NANOSECOND:return Oit(t,e,r)}},w2t=(t,e,r)=>{const{stride:i}=t,s=t.children[0],o=ef.getVisitFn(s);if(Array.isArray(r))for(let n=-1,a=e*i;++n<i;)o(s,a+n,r[n]);else for(let n=-1,a=e*i;++n<i;)o(s,a+n,r.get(n))};Fr.prototype.visitBool=zr(i2t),Fr.prototype.visitInt=zr(l0),Fr.prototype.visitInt8=zr(l0),Fr.prototype.visitInt16=zr(l0),Fr.prototype.visitInt32=zr(l0),Fr.prototype.visitInt64=zr(l0),Fr.prototype.visitUint8=zr(l0),Fr.prototype.visitUint16=zr(l0),Fr.prototype.visitUint32=zr(l0),Fr.prototype.visitUint64=zr(l0),Fr.prototype.visitFloat=zr(s2t),Fr.prototype.visitFloat16=zr(uit),Fr.prototype.visitFloat32=zr(t$),Fr.prototype.visitFloat64=zr(t$),Fr.prototype.visitUtf8=zr(git),Fr.prototype.visitLargeUtf8=zr(git),Fr.prototype.visitBinary=zr(pit),Fr.prototype.visitLargeBinary=zr(pit),Fr.prototype.visitFixedSizeBinary=zr(o2t),Fr.prototype.visitDate=zr(n2t),Fr.prototype.visitDateDay=zr(dit),Fr.prototype.visitDateMillisecond=zr(fit),Fr.prototype.visitTimestamp=zr(a2t),Fr.prototype.visitTimestampSecond=zr(mit),Fr.prototype.visitTimestampMillisecond=zr(yit),Fr.prototype.visitTimestampMicrosecond=zr(vit),Fr.prototype.visitTimestampNanosecond=zr(_it),Fr.prototype.visitTime=zr(l2t),Fr.prototype.visitTimeSecond=zr(bit),Fr.prototype.visitTimeMillisecond=zr(wit),Fr.prototype.visitTimeMicrosecond=zr(Eit),Fr.prototype.visitTimeNanosecond=zr(Ait),Fr.prototype.visitDecimal=zr(c2t),Fr.prototype.visitList=zr(h2t),Fr.prototype.visitStruct=zr(m2t),Fr.prototype.visitUnion=zr(y2t),Fr.prototype.visitDenseUnion=zr(xit),Fr.prototype.visitSparseUnion=zr(Sit),Fr.prototype.visitDictionary=zr(v2t),Fr.prototype.visitInterval=zr(_2t),Fr.prototype.visitIntervalDayTime=zr(Tit),Fr.prototype.visitIntervalYearMonth=zr(Rit),Fr.prototype.visitDuration=zr(b2t),Fr.prototype.visitDurationSecond=zr(Cit),Fr.prototype.visitDurationMillisecond=zr(Mit),Fr.prototype.visitDurationMicrosecond=zr(Bit),Fr.prototype.visitDurationNanosecond=zr(Oit),Fr.prototype.visitFixedSizeList=zr(w2t),Fr.prototype.visitMap=zr(u2t);const ef=new Fr,cp=Symbol.for("parent"),wT=Symbol.for("rowIndex");class e${constructor(e,r){return this[cp]=e,this[wT]=r,new Proxy(this,x2t)}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[wT],r=this[cp],i=r.type.children,s={};for(let o=-1,n=i.length;++o<n;)s[i[o].name]=hu.visit(r.children[o],e);return s}toString(){return`{${[...this].map(([e,r])=>`${PO(e)}: ${PO(r)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new E2t(this[cp],this[wT])}}class E2t{constructor(e,r){this.childIndex=0,this.children=e.children,this.rowIndex=r,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return e<this.numChildren?(this.childIndex=e+1,{done:!1,value:[this.childFields[e].name,hu.visit(this.children[e],this.rowIndex)]}):{done:!0,value:null}}}Object.defineProperties(e$.prototype,{[Symbol.toStringTag]:{enumerable:!1,
7configurable:!1,value:"Row"},[cp]:{writable:!0,enumerable:!1,configurable:!1,value:null},[wT]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});class A2t{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[cp].type.children.map(r=>r.name)}has(e,r){return e[cp].type.children.some(i=>i.name===r)}getOwnPropertyDescriptor(e,r){if(e[cp].type.children.some(i=>i.name===r))return{writable:!0,enumerable:!0,configurable:!0}}get(e,r){if(Reflect.has(e,r))return e[r];const i=e[cp].type.children.findIndex(s=>s.name===r);if(i!==-1){const s=hu.visit(e[cp].children[i],e[wT]);return Reflect.set(e,r,s),s}}set(e,r,i){const s=e[cp].type.children.findIndex(o=>o.name===r);return s!==-1?(ef.visit(e[cp].children[s],e[wT],i),Reflect.set(e,r,i)):Reflect.has(e,r)||typeof r=="symbol"?Reflect.set(e,r,i):!1}}const x2t=new A2t;class Cr extends Ui{}function Nr(t){return(e,r)=>e.getValid(r)?t(e,r):null}const S2t=(t,e)=>864e5*t[e],T2t=(t,e)=>null,Iit=(t,e,r)=>{if(r+1>=e.length)return null;const i=Qo(e[r]),s=Qo(e[r+1]);return t.subarray(i,s)},R2t=({offset:t,values:e},r)=>{const i=t+r;return(e[i>>3]&1<<i%8)!==0},Dit=({values:t},e)=>S2t(t,e),Pit=({values:t},e)=>Qo(t[e]),Lv=({stride:t,values:e},r)=>e[t*r],C2t=({stride:t,values:e},r)=>cit(e[t*r]),Fit=({values:t},e)=>t[e],M2t=({stride:t,values:e},r)=>e.subarray(t*r,t*(r+1)),Nit=({values:t,valueOffsets:e},r)=>Iit(t,e,r),kit=({values:t,valueOffsets:e},r)=>{const i=Iit(t,e,r);return i!==null?jY(i):null},B2t=({values:t},e)=>t[e],O2t=({type:t,values:e},r)=>t.precision!==ll.HALF?e[r]:cit(e[r]),I2t=(t,e)=>t.type.unit===Jh.DAY?Dit(t,e):Pit(t,e),Lit=({values:t},e)=>1e3*Qo(t[e]),Uit=({values:t},e)=>Qo(t[e]),Git=({values:t},e)=>krt(t[e],BigInt(1e3)),Wit=({values:t},e)=>krt(t[e],BigInt(1e6)),D2t=(t,e)=>{switch(t.type.unit){case or.SECOND:return Lit(t,e);case or.MILLISECOND:return Uit(t,e);case or.MICROSECOND:return Git(t,e);case or.NANOSECOND:return Wit(t,e)}},jit=({values:t},e)=>t[e],Xit=({values:t},e)=>t[e],zit=({values:t},e)=>t[e],Vit=({values:t},e)=>t[e],P2t=(t,e)=>{switch(t.type.unit){case or.SECOND:return jit(t,e);case or.MILLISECOND:return Xit(t,e);case or.MICROSECOND:return zit(t,e);case or.NANOSECOND:return Vit(t,e)}},F2t=({values:t,stride:e},r)=>QY.decimal(t.subarray(e*r,e*(r+1))),N2t=(t,e)=>{const{valueOffsets:r,stride:i,children:s}=t,{[e*i]:o,[e*i+1]:n}=r,a=s[0].slice(o,n-o);return new Ma([a])},k2t=(t,e)=>{const{valueOffsets:r,children:i}=t,{[e]:s,[e+1]:o}=r,n=i[0];return new i$(n.slice(s,o-s))},L2t=(t,e)=>new e$(t,e),U2t=(t,e)=>t.type.mode===lu.Dense?Yit(t,e):$it(t,e),Yit=(t,e)=>{const r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];return hu.visit(i,t.valueOffsets[e])},$it=(t,e)=>{const r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];return hu.visit(i,e)},G2t=(t,e)=>{var r;return(r=t.dictionary)===null||r===void 0?void 0:r.get(t.values[e])},W2t=(t,e)=>t.type.unit===$d.DAY_TIME?Hit(t,e):Kit(t,e),Hit=({values:t},e)=>t.subarray(2*e,2*(e+1)),Kit=({values:t},e)=>{const r=t[e],i=new Int32Array(2);return i[0]=Math.trunc(r/12),i[1]=Math.trunc(r%12),i},qit=({values:t},e)=>t[e],Zit=({values:t},e)=>t[e],Jit=({values:t},e)=>t[e],Qit=({values:t},e)=>t[e],j2t=(t,e)=>{switch(t.type.unit){case or.SECOND:return qit(t,e);case or.MILLISECOND:return Zit(t,e);case or.MICROSECOND:return Jit(t,e);case or.NANOSECOND:return Qit(t,e)}},X2t=(t,e)=>{const{stride:r,children:i}=t,s=i[0].slice(e*r,r);return new Ma([s])};Cr.prototype.visitNull=Nr(T2t),Cr.prototype.visitBool=Nr(R2t),Cr.prototype.visitInt=Nr(B2t),Cr.prototype.visitInt8=Nr(Lv),Cr.prototype.visitInt16=Nr(Lv),Cr.prototype.visitInt32=Nr(Lv),Cr.prototype.visitInt64=Nr(Fit),Cr.prototype.visitUint8=Nr(Lv),Cr.prototype.visitUint16=Nr(Lv),Cr.prototype.visitUint32=Nr(Lv),Cr.prototype.visitUint64=Nr(Fit),Cr.prototype.visitFloat=Nr(O2t),Cr.prototype.visitFloat16=Nr(C2t),Cr.prototype.visitFloat32=Nr(Lv),Cr.prototype.visitFloat64=Nr(Lv),Cr.prototype.visitUtf8=Nr(kit),Cr.prototype.visitLargeUtf8=Nr(kit),Cr.prototype.visitBinary=Nr(Nit),Cr.prototype.visitLargeBinary=Nr(Nit),Cr.prototype.visitFixedSizeBinary=Nr(M2t),Cr.prototype.visitDate=Nr(I2t),Cr.prototype.visitDateDay=Nr(Dit),Cr.prototype.visitDateMillisecond=Nr(Pit),Cr.prototype.visitTimestamp=Nr(D2t),Cr.prototype.visitTimestampSecond=Nr(Lit),Cr.prototype.visitTimestampMillisecond=Nr(Uit),Cr.prototype.visitTimestampMicrosecond=Nr(Git),Cr.prototype.visitTimestampNanosecond=Nr(Wit),Cr.prototype.visitTime=Nr(P2t),Cr.prototype.visitTimeSecond=Nr(jit),Cr.prototype.visitTimeMillisecond=Nr(Xit),Cr.prototype.visitTimeMicrosecond=Nr(zit),Cr.prototype.visitTimeNanosecond=Nr(Vit),Cr.prototype.visitDecimal=Nr(F2t),Cr.prototype.visitList=Nr(N2t),Cr.prototype.visitStruct=Nr(L2t),Cr.prototype.visitUnion=Nr(U2t),Cr.prototype.visitDenseUnion=Nr(Yit),Cr.prototype.visitSparseUnion=Nr($it),Cr.prototype.visitDictionary=Nr(G2t),Cr.prototype.visitInterval=Nr(W2t),Cr.prototype.visitIntervalDayTime=Nr(Hit),Cr.prototype.visitIntervalYearMonth=Nr(Kit),Cr.prototype.visitDuration=Nr(j2t),Cr.prototype.visitDurationSecond=Nr(qit),Cr.prototype.visitDurationMillisecond=Nr(Zit),Cr.prototype.visitDurationMicrosecond=Nr(Jit),Cr.prototype.visitDurationNanosecond=Nr(Qit),Cr.prototype.visitFixedSizeList=Nr(X2t),Cr.prototype.visitMap=Nr(k2t);const hu=new Cr,ET=Symbol.for("keys"),AT=Symbol.for("vals"),xT=Symbol.for("kKeysAsStrings"),r$=Symbol.for("_kKeysAsStrings");class i${constructor(e){return this[ET]=new Ma([e.children[0]]).memoize(),this[AT]=e.children[1],new Proxy(this,new V2t)}get[xT](){return this[r$]||(this[r$]=Array.from(this[ET].toArray(),String))}[Symbol.iterator](){return new z2t(this[ET],this[AT])}get size(){return this[ET].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[ET],r=this[AT],i={};for(let s=-1,o=e.length;++s<o;)i[e.get(s)]=hu.visit(r,s);return i}toString(){return`{${[...this].map(([e,r])=>`${PO(e)}: ${PO(r)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class z2t{constructor(e,r){this.keys=e,this.vals=r,this.keyIndex=0,this.numKe
7ys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),hu.visit(this.vals,e)]})}}class V2t{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[xT]}has(e,r){return e[xT].includes(r)}getOwnPropertyDescriptor(e,r){if(e[xT].indexOf(r)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,r){if(Reflect.has(e,r))return e[r];const i=e[xT].indexOf(r);if(i!==-1){const s=hu.visit(Reflect.get(e,AT),i);return Reflect.set(e,r,s),s}}set(e,r,i){const s=e[xT].indexOf(r);return s!==-1?(ef.visit(Reflect.get(e,AT),s,i),Reflect.set(e,r,i)):Reflect.has(e,r)?Reflect.set(e,r,i):!1}}Object.defineProperties(i$.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[ET]:{writable:!0,enumerable:!1,configurable:!1,value:null},[AT]:{writable:!0,enumerable:!1,configurable:!1,value:null},[r$]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let tst;function est(t,e,r,i){const{length:s=0}=t;let o=typeof e!="number"?0:e,n=typeof r!="number"?s:r;return o<0&&(o=(o%s+s)%s),n<0&&(n=(n%s+s)%s),n<o&&(tst=o,o=n,n=tst),n>s&&(n=s),i?i(t,o,n):[o,n]}const s$=(t,e)=>t<0?e+t:t,rst=t=>t!==t;function ST(t){if(typeof t!="object"||t===null)return rst(t)?rst:e=>e===t;if(t instanceof Date){const e=t.valueOf();return r=>r instanceof Date?r.valueOf()===e:!1}return ArrayBuffer.isView(t)?e=>e?jMt(t,e):!1:t instanceof Map?$2t(t):Array.isArray(t)?Y2t(t):t instanceof Ma?H2t(t):K2t(t,!0)}function Y2t(t){const e=[];for(let r=-1,i=t.length;++r<i;)e[r]=ST(t[r]);return u4(e)}function $2t(t){let e=-1;const r=[];for(const i of t.values())r[++e]=ST(i);return u4(r)}function H2t(t){const e=[];for(let r=-1,i=t.length;++r<i;)e[r]=ST(t.get(r));return u4(e)}function K2t(t,e=!1){const r=Object.keys(t);if(!e&&r.length===0)return()=>!1;const i=[];for(let s=-1,o=r.length;++s<o;)i[s]=ST(t[r[s]]);return u4(i,r)}function u4(t,e){return r=>{if(!r||typeof r!="object")return!1;switch(r.constructor){case Array:return q2t(t,r);case Map:return ist(t,r,r.keys());case i$:case e$:case Object:case void 0:return ist(t,r,e||Object.keys(r))}return r instanceof Ma?Z2t(t,r):!1}}function q2t(t,e){const r=t.length;if(e.length!==r)return!1;for(let i=-1;++i<r;)if(!t[i](e[i]))return!1;return!0}function Z2t(t,e){const r=t.length;if(e.length!==r)return!1;for(let i=-1;++i<r;)if(!t[i](e.get(i)))return!1;return!0}function ist(t,e,r){const i=r[Symbol.iterator](),s=e instanceof Map?e.keys():Object.keys(e)[Symbol.iterator](),o=e instanceof Map?e.values():Object.values(e)[Symbol.iterator]();let n=0;const a=t.length;let l=o.next(),c=i.next(),h=s.next();for(;n<a&&!c.done&&!h.done&&!l.done&&!(c.value!==h.value||!t[n](l.value));++n,c=i.next(),h=s.next(),l=o.next());return n===a&&c.done&&h.done&&l.done?!0:(i.return&&i.return(),s.return&&s.return(),o.return&&o.return(),!1)}function sst(t,e,r,i){return(r&1<<i)!==0}function J2t(t,e,r,i){return(r&1<<i)>>i}function ost(t,e,r){const i=r.byteLength+7&-8;if(t>0||r.byteLength<i){const s=new Uint8Array(i);return s.set(t%8===0?r.subarray(t>>3):o$(new n$(r,t,e,null,sst)).subarray(0,i)),s}return r}function o$(t){const e=[];let r=0,i=0,s=0;for(const n of t)n&&(s|=1<<i),++i===8&&(e[r++]=s,s=i=0);(r===0||i>0)&&(e[r++]=s);const o=new Uint8Array(e.length+7&-8);return o.set(e),o}class n${constructor(e,r,i,s,o){this.bytes=e,this.length=i,this.context=s,this.get=o,this.bit=r%8,this.byteIndex=r>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index<this.length?(this.bit===8&&(this.bit=0,this.byte=this.bytes[this.byteIndex++]),{value:this.get(this.context,this.index++,this.byte,this.bit++)}):{done:!0,value:null}}[Symbol.iterator](){return this}}function a$(t,e,r){if(r-e<=0)return 0;if(r-e<8){let o=0;for(const n of new n$(t,e,r-e,t,J2t))o+=n;return o}const i=r>>3<<3,s=e+(e%8===0?0:8-e%8);return a$(t,e,s)+a$(t,i,r)+Q2t(t,s>>3,i-s>>3)}function Q2t(t,e,r){let i=0,s=Math.trunc(e);const o=new DataView(t.buffer,t.byteOffset,t.byteLength),n=r===void 0?t.byteLength:s+r;for(;n-s>=4;)i+=l$(o.getUint32(s)),s+=4;for(;n-s>=2;)i+=l$(o.getUint16(s)),s+=2;for(;n-s>=1;)i+=l$(o.getUint8(s)),s+=1;return i}function l$(t){let e=Math.trunc(t);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const tBt=-1;class po{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:e}=this;return ur.isSparseUnion(e)?this.children.some(r=>r.nullable):ur.isDenseUnion(e)?this.children.some(r=>
vendor: 8,213 bytes, line 7
7r.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0;const{valueOffsets:r,values:i,nullBitmap:s,typeIds:o}=this;return r&&(e+=r.byteLength),i&&(e+=i.byteLength),s&&(e+=s.byteLength),o&&(e+=o.byteLength),this.children.reduce((n,a)=>n+a.byteLength,e)}get nullCount(){if(ur.isUnion(this.type))return this.children.reduce((i,s)=>i+s.nullCount,0);let e=this._nullCount,r;return e<=tBt&&(r=this.nullBitmap)&&(this._nullCount=e=r.length===0?0:this.length-a$(r,this.offset,this.offset+this.length)),e}constructor(e,r,i,s,o,n=[],a){this.type=e,this.children=n,this.dictionary=a,this.offset=Math.floor(Math.max(r||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(s||0,-1));let l;o instanceof po?(this.stride=o.stride,this.values=o.values,this.typeIds=o.typeIds,this.nullBitmap=o.nullBitmap,this.valueOffsets=o.valueOffsets):(this.stride=a0(e),o&&((l=o[0])&&(this.valueOffsets=l),(l=o[1])&&(this.values=l),(l=o[2])&&(this.nullBitmap=l),(l=o[3])&&(this.typeIds=l)))}getValid(e){const{type:r}=this;if(ur.isUnion(r)){const i=r,s=this.children[i.typeIdToChildIndex[this.typeIds[e]]],o=i.mode===lu.Dense?this.valueOffsets[e]:e;return s.getValid(o)}if(this.nullable&&this.nullCount>0){const i=this.offset+e;return(this.nullBitmap[i>>3]&1<<i%8)!==0}return!0}setValid(e,r){let i;const{type:s}=this;if(ur.isUnion(s)){const o=s,n=this.children[o.typeIdToChildIndex[this.typeIds[e]]],a=o.mode===lu.Dense?this.valueOffsets[e]:e;i=n.getValid(a),n.setValid(a,r)}else{let{nullBitmap:o}=this;const{offset:n,length:a}=this,l=n+e,c=1<<l%8,h=l>>3;(!o||o.byteLength<=h)&&(o=new Uint8Array((n+a+63&-64)>>3).fill(255),this.nullCount>0?(o.set(ost(n,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:o})):Object.assign(this,{nullBitmap:o,_nullCount:0}));const u=o[h];i=(u&c)!==0,o[h]=r?u|c:u&~c}return i!==!!r&&(this._nullCount=this.nullCount+(r?-1:1)),r}clone(e=this.type,r=this.offset,i=this.length,s=this._nullCount,o=this,n=this.children){return new po(e,r,i,s,o,n,this.dictionary)}slice(e,r){const{stride:i,typeId:s,children:o}=this,n=+(this._nullCount===0)-1,a=s===16?i:1,l=this._sliceBuffers(e,r,i,s);return this.clone(this.type,this.offset+e,r,n,l,o.length===0||this.valueOffsets?o:this._sliceChildren(o,a*e,a*r))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===ot.Null)return this.clone(this.type,0,e,0);const{length:r,nullCount:i}=this,s=new Uint8Array((e+63&-64)>>3).fill(255,0,r>>3);s[r>>3]=(1<<r-(r&-8))-1,i>0&&s.set(ost(this.offset,r,this.nullBitmap),0);const o=this.buffers;return o[n0.VALIDITY]=s,this.clone(this.type,0,e,i+(e-r),o)}_sliceBuffers(e,r,i,s){let o;const{buffers:n}=this;return(o=n[n0.TYPE])&&(n[n0.TYPE]=o.subarray(e,e+r)),(o=n[n0.OFFSET])&&(n[n0.OFFSET]=o.subarray(e,e+r+1))||(o=n[n0.DATA])&&(n[n0.DATA]=s===6?o:o.subarray(i*e,i*(e+r))),n}_sliceChildren(e,r,i){return e.map(s=>s.slice(r,i))}}po.prototype.children=Object.freeze([]);class kO extends Ui{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:r,["offset"]:i=0,["length"]:s=0}=e;return new po(r,i,s,s)}visitBool(e){const{["type"]:r,["offset"]:i=0}=e,s=Is(e.nullBitmap),o=Co(r.ArrayType,e.data),{["length"]:n=o.length>>3,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new po(r,i,n,a,[void 0,o,s])}visitInt(e){const{["type"]:r,["offset"]:i=0}=e,s=Is(e.nullBitmap),o=Co(r.ArrayType,e.data),{["length"]:n=o.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new po(r,i,n,a,[void 0,o,s])}visitFloat(e){const{["type"]:r,["offset"]:i=0}=e,s=Is(e.nullBitmap),o=Co(r.ArrayType,e.data),{["length"]:n=o.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new po(r,i,n,a,[void 0,o,s])}visitUtf8(e){const{["type"]:r,["offset"]:i=0}=e,s=Is(e.data),o=Is(e.nullBitmap),n=DO(e.valueOffsets),{["length"]:a=n.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new po(r,i,a,l,[n,s,o])}visitLargeUtf8(e){const{["type"]:r,["offset"]:i=0}=e,s=Is(e.data),o=Is(e.nullBitmap),n=Art(e.valueOffsets),{["length"]:a=n.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new po(r,i,a,l,[n,s,o])}visitBinary(e){const{["type"]:r,["offset"]:i=0}=e,s=Is(e.data),o=Is(e.nullBitmap),n=DO(e.valueOffsets),{["length"]:a=n.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new po(r,i,a,l,[n,s,o])}visitLargeBinary(e){const{["type"]:r,["offset"]:i=0}=e,s=Is(e.data),o=Is(e.nullBitmap),n=Art(e.valueOffsets),{["length"]:a=n.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new po(r,i,a,l,[n,s,o])}visitFixedSizeBinary(e){const{["type"]:r,["offset"]:i=0}=e,s=Is(e.nullBitmap),o=Co(r.ArrayType,e.data),{["length"]:n=o.length/a0(r),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new po(r,i,n,a,[void 0,o,s])}visitDate(e){const{["type"]:r,["offset"]:i=0}=e,s=Is(e.nullBitmap),o=Co(r.ArrayType,e.data),{["length"]:n=o.length/a0(r),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new po(r,i,n,a,[void 0,o,s])}visitTimestamp(e){const{["type"]:r,["offset"]:i=0}=e,s=Is(e.nullBitmap),o=Co(r.ArrayType,e.data),{["length"]:n=o.length/a0(r),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new po(r,i,n,a,[void 0,o,s])}visitTime(e){const{["type"]:r,["offset"]:i=0}=e,s=Is(e.nullBitmap),o=Co(r.ArrayType,e.data),{["length"]:n=o.length/a0(r),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new po(r,i,n,a,[void 0,o,s])}visitDecimal(e){const{["type"]:r,["offset"]:i=0}=e,s=Is(e.nullBitmap),o=Co(r.ArrayType,e.data),{["length"]:n=o.length/a0(r),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new po(r,i,n,a,[void 0,o,s])}visitList(e){const{["type"]:r,["offset"]:i=0,["child"]:s}=e,o=Is(e.nullBitmap),n=DO(e.valueOffsets),{["length"]:a=n.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new po(r,i,a,l,[n,void 0,o],[s])}visitStruct(e){const{["type"]:r,["offset"]:i=0,["children"]:s=[]}=e,o=Is(e.nullBitmap),{length:n=s.reduce((l,{length:c})=>Math.max(l,c),0),nullCount:a=e.nullBitmap?-1:0}=e;return new po(r,i,n,a,[void 0,void 0,o],s)}visitUnion(e){const{["type"]:r,["offset"]:i=0,["children"]:s=[]}=e,o=Co(r.ArrayType,e.typeIds),{["length"]:n=o.length,["nullCount"]:a=-1}=e;if(ur.isSparseUnion(r))return new po(r,i,n,a,[void 0,void 0,void 0,o],s);const l=DO(e.valueOffsets);return new po(r,i,n,a,[l,void 0,void 0,o],s)}visitDictionary(e){const{["type"]:r,["offset"]:i=0}=e,s=Is(e.nullBitmap),o=Co(r.indices.ArrayType,e.data),{["dictionary"]:n=new Ma([new kO().visit({type:r.dictionary})])}=e,{["length"]:a=o.length,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new po(r,i,a,l,[void 0,o,s],[],n)}visitInterval(e){const{["type"]:r,["offset"]:i=0}=e,s=Is(e.nullBitmap),o=Co(r.ArrayType,e.data),{["length"]:n=o.length/a0(r),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new po(r,i,n,a,[void 0,o,s])}visitDuration(e){const{["type"]:r,["offset"]:i=0}=e,s=Is(e.nullBitmap),o=Co(r.ArrayType,e.data),{["length"]:n=o.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new po(r,i,n,a,[void 0,o,s])}visitFixedSizeList(e){const{["type"]:r,["offset"]:i=0,["child"]:s=new kO().visit({type:r.valueType})}=e,o=Is(e.nullBitmap),{["length"]:n=s.length/a0(r),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new po(r,i,n,a,[void 0,void 0,o],[s])}visitMap(e){const{["type"]:r,["offset"]:i=0,["child"]:s=new kO().visit({type:r.childType})}=e,o=Is(e.nullBitmap),n=DO(e.valueOffsets),{["length"]:a=n.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new po(r,i,a,l,[n,void 0,o],[s])}}const eBt=new kO;function Gi(t){return eBt.visit(t)}class nst{constructor(e=0,r){this.numChunks=e,this.getChunkIterator=r,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){const e=this.chunkIterator.next();if(!e.done)return e;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}}function rBt(t){return t.some(e=>e.nullable)}function ast(t){return t.reduce((e,r)=>e+r.nullCount,0)}function lst(t){return t.reduce((e,r,i)=>(e[i+1]=e[i]+r.length,e),new Uint32Array(t.length+1))}function cst(t,e,r,i){const s=[];for(let o=-1,n=t.length;++o<n;){const a=t[o],l=e[o],{length:c}=a;if(l>=i)break;if(r>=l+c)continue;if(l>=r&&l+c<=i){s.push(a);continue}const h=Math.max(0,r-l),u=Math.min(i-l,c);s.push(a.slice(h,u-h))}return s.length===0&&s.push(t[0].slice(0,0)),s}function c$(t,e,r,i){let s=0,o=0,n=e.length-1;
7do{if(s>=n-1)return r<e[n]?i(t,s,r-e[s]):null;o=s+Math.trunc((n-s)*.5),r<e[o]?n=o:s=o}while(s<n)}function h$(t,e){return t.getValid(e)}function d4(t){function e(r,i,s){return t(r[i],s)}return function(r){const i=this.data;return c$(i,this._offsets,r,e)}}function hst(t){let e;function r(i,s,o){return t(i[s],o,e)}return function(i,s){const o=this.data;e=s;const n=c$(o,this._offsets,i,r);return e=void 0,n}}function ust(t){let e;function r(i,s,o){let n=o,a=0,l=0;for(let c=s-1,h=i.length;++c<h;){const u=i[c];if(~(a=t(u,e,n)))return l+a;n=0,l+=u.length}return-1}return function(i,s){e=i;const o=this.data,n=typeof s!="number"?r(o,0,0):c$(o,this._offsets,s,r);return e=void 0,n}}class Mr extends Ui{}function iBt(t,e){return e===null&&t.length>0?0:-1}function sBt(t,e){const{nullBitmap:r}=t;if(!r||t.nullCount<=0)return-1;let i=0;for(const s of new n$(r,t.offset+(e||0),t.length,r,sst)){if(!s)return i;++i}return-1}function Jr(t,e,r){if(e===void 0)return-1;if(e===null)switch(t.typeId){case ot.Union:break;case ot.Dictionary:break;default:return sBt(t,r)}const i=hu.getVisitFn(t),s=ST(e);for(let o=(r||0)-1,n=t.length;++o<n;)if(s(i(t,o)))return o;return-1}function dst(t,e,r){const i=hu.getVisitFn(t),s=ST(e);for(let o=(r||0)-1,n=t.length;++o<n;)if(s(i(t,o)))return o;return-1}Mr.prototype.visitNull=iBt,Mr.prototype.visitBool=Jr,Mr.prototype.visitInt=Jr,Mr.prototype.visitInt8=Jr,Mr.prototype.visitInt16=Jr,Mr.prototype.visitInt32=Jr,Mr.prototype.visitInt64=Jr,Mr.prototype.visitUint8=Jr,Mr.prototype.visitUint16=Jr,Mr.prototype.visitUint32=Jr,Mr.prototype.visitUint64=Jr,Mr.prototype.visitFloat=Jr,Mr.prototype.visitFloat16=Jr,Mr.prototype.visitFloat32=Jr,Mr.prototype.visitFloat64=Jr,Mr.prototype.visitUtf8=Jr,Mr.prototype.visitLargeUtf8=Jr,Mr.prototype.visitBinary=Jr,Mr.prototype.visitLargeBinary=Jr,Mr.prototype.visitFixedSizeBinary=Jr,Mr.prototype.visitDate=Jr,Mr.prototype.visitDateDay=Jr,Mr.prototype.visitDateMillisecond=Jr,Mr.prototype.visitTimestamp=Jr,Mr.prototype.visitTimestampSecond=Jr,Mr.prototype.visitTimestampMillisecond=Jr,Mr.prototype.visitTimestampMicrosecond=Jr,Mr.prototype.visitTimestampNanosecond=Jr,Mr.prototype.visitTime=Jr,Mr.prototype.visitTimeSecond=Jr,Mr.prototype.visitTimeMillisecond=Jr,Mr.prototype.visitTimeMicrosecond=Jr,Mr.prototype.visitTimeNanosecond=Jr,Mr.prototype.visitDecimal=Jr,Mr.prototype.visitList=Jr,Mr.prototype.visitStruct=Jr,Mr.prototype.visitUnion=Jr,Mr.prototype.visitDenseUnion=dst,Mr.prototype.visitSparseUnion=dst,Mr.prototype.visitDictionary=Jr,Mr.prototype.visitInterval=Jr,Mr.prototype.visitIntervalDayTime=Jr,Mr.prototype.visitIntervalYearMonth=Jr,Mr.prototype.visitDuration=Jr,Mr.prototype.visitDurationSecond=Jr,Mr.prototype.visitDurationMillisecond=Jr,Mr.prototype.visitDurationMicrosecond=Jr,Mr.prototype.visitDurationNanosecond=Jr,Mr.prototype.visitFixedSizeList=Jr,Mr.prototype.visitMap=Jr;const f4=new Mr;class Br extends Ui{}function kr(t){const{type:e}=t;if(t.nullCount===0&&t.stride===1&&(ur.isInt(e)&&e.bitWidth!==64||ur.isTime(e)&&e.bitWidth!==64||ur.isFloat(e)&&e.precision!==ll.HALF))return new nst(t.data.length,i=>{const s=t.data[i];return s.values.subarray(0,s.length)[Symbol.iterator]()});let r=0;return new nst(t.data.length,i=>{const s=t.data[i].length,o=t.slice(r,r+s);return r+=s,new oBt(o)})}class oBt{constructor(e){this.vector=e,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}}Br.prototype.visitNull=kr,Br.prototype.visitBool=kr,Br.prototype.visitInt=kr,Br.prototype.visitInt8=kr,Br.prototype.visitInt16=kr,Br.prototype.visitInt32=kr,Br.prototype.visitInt64=kr,Br.prototype.visitUint8=kr,Br.prototype.visitUint16=kr,Br.prototype.visitUint32=kr,Br.prototype.visitUint64=kr,Br.prototype.visitFloat=kr,Br.prototype.visitFloat16=kr,Br.prototype.visitFloat32=kr,Br.prototype.visitFloat64=kr,Br.prototype.visitUtf8=kr,Br.prototype.visitLargeUtf8=kr,Br.prototype.visitBinary=kr,Br.prototype.visitLargeBinary=kr,Br.prototype.visitFixedSizeBinary=kr,Br.prototype.visitDate=kr,Br.prototype.visitDateDay=kr,Br.prototype.visitDateMillisecond=kr,Br.prototype.visitTimestamp=kr,Br.prototype.visitTimestampSecond=kr,Br.prototype.visitTimestampMillisecond=kr,Br.prototype.visitTimestampMicrosecond=kr,Br.prototype.visitTimestampNanosecond=kr,Br.prototype.visitTime=kr,Br.prototype.visitTimeSecond=kr,Br.prototype.visitTimeMillisecond=kr,Br.prototype.visitTimeMicrosecond=kr,Br.prototype.visitTimeNanosecond=kr,Br.prototype.visitDecimal=kr,Br.prototype.visitList=kr,Br.prototype.visitStruct=kr,Br.prototype.visitUnion=kr,Br.prototype.visitDenseUnion=kr,Br.prototype.visitSparseUnion=kr,Br.prototype.visitDictionary=kr,Br.prototype.visitInterval=kr,Br.prototype.visitIntervalDayTime=kr,Br.prototype.visitIntervalYearMonth=kr,Br.prototype.visitDuration=kr,Br.prototype.visitDurationSecond=kr,Br.prototype.visitDurationMillisecond=kr,Br.prototype.visitDurationMicrosecond=kr,Br.prototype.visitDurationNanosecond=kr,Br.prototype.visitFixedSizeList=kr,Br.prototype.visitMap=kr;const u$=new Br;var fst;const pst={},gst={};let Ma=class nT{constructor(e){var r,i,s;const o=e[0]instanceof nT?e.flatMap(a=>a.data):e;if(o.length===0||o.some(a=>!(a instanceof po)))throw new TypeError("Vector constructor expects an Array of Data instances.");const n=(r=o[0])===null||r===void 0?void 0:r.type;switch(o.length){case 0:this._offsets=[0];break;case 1:{const{get:a,set:l,indexOf:c}=pst[n.typeId],h=o[0];this.isValid=u=>h$(h,u),this.get=u=>a(h,u),this.set=(u,d)=>l(h,u,d),this.indexOf=u=>c(h,u),this._offsets=[0,h.length];break}default:Object.setPrototypeOf(this,gst[n.typeId]),this._offsets=lst(o);break}this.data=o,this.type=n,this.stride=a0(n),this.numChildren=(s=(i=n.children)===null||i===void 0?void 0:i.length)!==null&&s!==void 0?s:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,r)=>e+r.byteLength,0)}get nullable(){return rBt(this.data)}get nullCount(){return ast(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${ot[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(s$(e,this.length))}set(e,r){}indexOf(e,r){return-1}includes(e,r){return this.indexOf(e,r)>-1}[Symbol.iterator](){return u$.visit(this)}concat(...e){return new nT(this.data.concat(e.flatMap(r=>r.data).flat(Number.POSITIVE_INFINITY)))}slice(e,r){return new nT(est(this,e,r,({data:i,_offsets:s},o,n)=>cst(i,s,o,n)))}toJSON(){return[...this]}toArray(){const{type:e,data:r,length:i,stride:s,ArrayType:o}=this;switch(e.typeId){case ot.Int:case ot.Float:case ot.Decimal:case ot.Time:case ot.Timestamp:switch(r.length){case 0:return new o;case 1:return r[0].values.subarray(0,i*s);default:return r.reduce((n,{values:a,length:l})=>(n.array.set(a.subarray(0,l*s),n.offset),n.offset+=l*s,n),{array:new o(i*s),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var r;return this.getChildAt((r=this.type.children)===null||r===void 0?void 0:r.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&e<this.numChildren?new nT(this.data.map(({children:r})=>r[e])):null}get isMemoized(){return ur.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(ur.isDictionary(this.type)){const e=new p4(this.data[0].dictionary),r=this.data.map(i=>
7{const s=i.clone();return s.dictionary=e,s});return new nT(r)}return new p4(this)}unmemoize(){if(ur.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),r=this.data.map(i=>{const s=i.clone();return s.dictionary=e,s});return new nT(r)}return this}};fst=Symbol.toStringTag,Ma[fst]=(t=>{t.type=ur.prototype,t.data=[],t.length=0,t.stride=1,t.numChildren=0,t._offsets=new Uint32Array([0]),t[Symbol.isConcatSpreadable]=!0;const e=Object.keys(ot).map(r=>ot[r]).filter(r=>typeof r=="number"&&r!==ot.NONE);for(const r of e){const i=hu.getVisitFnByTypeId(r),s=ef.getVisitFnByTypeId(r),o=f4.getVisitFnByTypeId(r);pst[r]={get:i,set:s,indexOf:o},gst[r]=Object.create(t,{isValid:{value:d4(h$)},get:{value:d4(hu.getVisitFnByTypeId(r))},set:{value:hst(ef.getVisitFnByTypeId(r))},indexOf:{value:ust(f4.getVisitFnByTypeId(r))}})}return"Vector"})(Ma.prototype);class p4 extends Ma{constructor(e){super(e.data);const r=this.get,i=this.set,s=this.slice,o=new Array(this.length);Object.defineProperty(this,"get",{value(n){const a=o[n];if(a!==void 0)return a;const l=r.call(this,n);return o[n]=l,l}}),Object.defineProperty(this,"set",{value(n,a){i.call(this,n,a),o[n]=a}}),Object.defineProperty(this,"slice",{value:(n,a)=>new p4(s.call(this,n,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Ma(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class d${constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,r,i,s){return e.prep(8,24),e.writeInt64(BigInt(s??0)),e.pad(4),e.writeInt32(i),e.writeInt64(BigInt(r??0)),e.offset()}}class ad{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsFooter(e,r){return(r||new ad).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,r){return e.setPosition(e.position()+no),(r||new ad).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ja.V1}schema(e){const r=this.bb.__offset(this.bb_pos,6);return r?(e||new _m).__init(this.bb.__indirect(this.bb_pos+r),this.bb):null}dictionaries(e,r){const i=this.bb.__offset(this.bb_pos,8);return i?(r||new d$).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,r){const i=this.bb.__offset(this.bb_pos,10);return i?(r||new d$).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,r){const i=this.bb.__offset(this.bb_pos,12);return i?(r||new fl).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,r){e.addFieldInt16(0,r,ja.V1)}static addSchema(e,r){e.addFieldOffset(1,r,0)}static addDictionaries(e,r){e.addFieldOffset(2,r,0)}static startDictionariesVector(e,r){e.startVector(24,r,8)}static addRecordBatches(e,r){e.addFieldOffset(3,r,0)}static startRecordBatchesVector(e,r){e.startVector(24,r,8)}static addCustomMetadata(e,r){e.addFieldOffset(4,r,0)}static createCustomMetadataVector(e,r){e.startVector(4,r.length,4);for(let i=r.length-1;i>=0;i--)e.addOffset(r[i]);return e.endVector()}static startCustomMetadataVector(e,r){e.startVector(4,r,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,r){e.finish(r)}static finishSizePrefixedFooterBuffer(e,r){e.finish(r,void 0,!0)}}class lo{constructor(e=[],r,i,s=ja.V5){this.fields=e||[],this.metadata=r||new Map,i||(i=f$(this.fields)),this.dictionaries=i,this.metadataVersion=s}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}
7toString(){return`Schema<{ ${this.fields.map((e,r)=>`${r}: ${e}`).join(", ")} }>`}select(e){const r=new Set(e),i=this.fields.filter(s=>r.has(s.name));return new lo(i,this.metadata)}selectAt(e){const r=e.map(i=>this.fields[i]).filter(Boolean);return new lo(r,this.metadata)}assign(...e){const r=e[0]instanceof lo?e[0]:Array.isArray(e[0])?new lo(e[0]):new lo(e),i=[...this.fields],s=g4(g4(new Map,this.metadata),r.metadata),o=r.fields.filter(a=>{const l=i.findIndex(c=>c.name===a.name);return~l?(i[l]=a.clone({metadata:g4(g4(new Map,i[l].metadata),a.metadata)}))&&!1:!0}),n=f$(o,new Map);return new lo([...i,...o],s,new Map([...this.dictionaries,...n]))}}lo.prototype.fields=null,lo.prototype.metadata=null,lo.prototype.dictionaries=null;class tn{static new(...e){let[r,i,s,o]=e;return e[0]&&typeof e[0]=="object"&&({name:r}=e[0],i===void 0&&(i=e[0].type),s===void 0&&(s=e[0].nullable),o===void 0&&(o=e[0].metadata)),new tn(`${r}`,i,s,o)}constructor(e,r,i=!1,s){this.name=e,this.type=r,this.nullable=i,this.metadata=s||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[r,i,s,o]=e;return!e[0]||typeof e[0]!="object"?[r=this.name,i=this.type,s=this.nullable,o=this.metadata]=e:{name:r=this.name,type:i=this.type,nullable:s=this.nullable,metadata:o=this.metadata}=e[0],tn.new(r,i,s,o)}}tn.prototype.type=null,tn.prototype.name=null,tn.prototype.nullable=null,tn.prototype.metadata=null;function g4(t,e){return new Map([...t||new Map,...e||new Map])}function f$(t,e=new Map){for(let r=-1,i=t.length;++r<i;){const s=t[r].type;if(ur.isDictionary(s)){if(!e.has(s.id))e.set(s.id,s.dictionary);else if(e.get(s.id)!==s.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}s.children&&s.children.length>0&&f$(s.children,e)}return e}var nBt=Rrt,aBt=dT;class p${static decode(e){e=new aBt(Is(e));const r=ad.getRootAsFooter(e),i=lo.decode(r.schema(),new Map,r.version());return new lBt(i,r)}static encode(e){const r=new nBt,i=lo.encode(r,e.schema);ad.startRecordBatchesVector(r,e.numRecordBatches);for(const n of[...e.recordBatches()].slice().reverse())TT.encode(r,n);const s=r.endVector();ad.startDictionariesVector(r,e.numDictionaries);for(const n of[...e.dictionaryBatches()].slice().reverse())TT.encode(r,n);const o=r.endVector();return ad.startFooter(r),ad.addSchema(r,i),ad.addVersion(r,ja.V5),ad.addRecordBatches(r,s),ad.addDictionaries(r,o),ad.finishFooterBuffer(r,ad.endFooter(r)),r.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,r=ja.V5,i,s){this.schema=e,this.version=r,i&&(this._recordBatches=i),s&&(this._dictionaryBatches=s)}*recordBatches(){for(let e,r=-1,i=this.numRecordBatches;++r<i;)(e=this.getRecordBatch(r))&&(yield e)}*dictionaryBatches(){for(let e,r=-1,i=this.numDictionaries;++r<i;)(e=this.getDictionaryBatch(r))&&(yield e)}getRecordBatch(e){return e>=0&&e<this.numRecordBatches&&this._recordBatches[e]||null}getDictionaryBatch(e){return e>=0&&e<this.numDictionaries&&this._dictionaryBatches[e]||null}}class lBt extends p${get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(e,r){super(e,r.version()),this._footer=r}getRecordBatch(e){if(e>=0&&e<this.numRecordBatches){const r=this._footer.recordBatches(e);if(r)return TT.decode(r)}return null}getDictionaryBatch(e){if(e>=0&&e<this.numDictionaries){const r=this._footer.dictionaries(e);if(r)return TT.decode(r)}return null}}class TT{static decode(e){return new TT(e.metaDataLength(),e.bodyLength(),e.offset())}static encode(e,r){const{metaDataLength:i}=r,s=BigInt(r.offset),o=BigInt(r.bodyLength);return d$.createBlock(e,s,i,o)}constructor(e,r,i){this.metaDataLength=e,this.offset=Qo(i),this.bodyLength=Qo(r)}}const pl=Object.freeze({done:!0,value:void 0});class mst{constructor(e){this._json=e}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class yst{tee(){return this._getDOMStream().tee()}pipe(e,r){return this._getNodeStream().pipe(e,r)}pipeTo(e,r){return this._getDOMStream().pipeTo(e,r)}pipeThrough(e,r){return this._getDOMStream().pipeThrough(e,r)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}}class cBt extends yst{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return Rr(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(pl);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return Zd.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return Zd.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return Rr(this,void 0,void 0,function*(){return yield this.abort(e),pl})}return(e){return Rr(this,void 0,void 0,function*(){return yield this.close(),pl})}read(e){return Rr(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Rr(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((r,i)=>{this.resolvers.push({resolve:r,reject:i})}):Promise.resolve(pl)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class hBt extends cBt{write(e){if((e=Is(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?jY(this.toUint8Array(!0)):this.toUint8Array(!1).then(jY)}toUint8Array(e=!1){return e?gm(this._values)[0]:Rr(this,void 0,void 0,function*(){var r,i,s,o;const n=[];let a=0;try{for(var l=!0,c=uT(this),h;h=yield c.next(),r=h.done,!r;l=!0){o=h.value,l=!1;const u=o;n.push(u),a+=u.byteLength}}catch(u){i={error:u}}finally{try{!l&&!r&&(s=c.return)&&(yield s.call(c))}finally{if(i)throw i.error}}return gm(n,a)[0]})}}class m4{constructor(e){e&&(this.source=new uBt(Zd.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class RT{constructor(e){e instanceof RT?this.source=e.source:e instanceof hBt?this.source=new xE(Zd.fromAsyncIterable(e)):wrt(e)?this.source=new xE(Zd.fromNodeStream(e)):YY(e)?this.source=new xE(Zd.fromDOMStream(e)):_rt(e)?this.source=new xE(Zd.fromDOMStream(e.body)):KG(e)?this.source=new xE(Zd.fromIterable(e)):IO(e)?this.source=new xE(Zd.fromAsyncIterable(e)):zY(e)&&(this.source=new xE(Zd.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class uBt{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,r="read"){return this.source.next({cmd:r,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||pl)}return(e){return Object.create(this.source.return&&this.source.return(e)||pl)}}class xE{constructor(e){this.source=e,this._closedPromise=new Promise(r=>this._closedPromiseResolve=r)}cancel(e){return Rr(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return Rr(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Rr(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return Rr(this,arguments,void 0,function*(r,i="read"){return yield this.source.next({cmd:i,size:r})})}throw(e){return Rr(this,void 0,void 0,function*(){const r=this.source.throw&&(yield this.source.throw(e))||pl;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(r)})}return(e){return Rr(this,void 0,void 0,function*(){const r=this.source.return&&
7(yield this.source.return(e))||pl;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(r)})}}class vst extends m4{constructor(e,r){super(),this.position=0,this.buffer=Is(e),this.size=r===void 0?this.buffer.byteLength:r}readInt32(e){const{buffer:r,byteOffset:i}=this.readAt(e,4);return new DataView(r,i).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e<this.size}read(e){const{buffer:r,size:i,position:s}=this;return r&&s<i?(typeof e!="number"&&(e=Number.POSITIVE_INFINITY),this.position=Math.min(i,s+Math.min(i-s,e)),r.subarray(s,this.position)):null}readAt(e,r){const i=this.buffer,s=Math.min(this.size,e+r);return i?i.subarray(e,s):new Uint8Array(r)}close(){this.buffer&&(this.buffer=null)}throw(e){return this.close(),{done:!0,value:e}}return(e){return this.close(),{done:!0,value:e}}}class y4 extends RT{constructor(e,r){super(),this.position=0,this._handle=e,typeof r=="number"?this.size=r:this._pending=Rr(this,void 0,void 0,function*(){this.size=(yield e.stat()).size,delete this._pending})}readInt32(e){return Rr(this,void 0,void 0,function*(){const{buffer:r,byteOffset:i}=yield this.readAt(e,4);return new DataView(r,i).getInt32(0,!0)})}seek(e){return Rr(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(e,this.size),e<this.size})}read(e){return Rr(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:r,size:i,position:s}=this;if(r&&s<i){typeof e!="number"&&(e=Number.POSITIVE_INFINITY);let o=s,n=0,a=0;const l=Math.min(i,o+Math.min(i-o,e)),c=new Uint8Array(Math.max(0,(this.position=l)-o));for(;(o+=a)<l&&(n+=a)<c.byteLength;)({bytesRead:a}=yield r.read(c,n,c.byteLength-n,o));return c}return null})}readAt(e,r){return Rr(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:i,size:s}=this;if(i&&e+r<s){const o=Math.min(s,e+r),n=new Uint8Array(o-e);return(yield i.read(n,0,r,e)).buffer}return new Uint8Array(r)})}close(){return Rr(this,void 0,void 0,function*(){const e=this._handle;this._handle=null,e&&(yield e.close())})}throw(e){return Rr(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:e}})}return(e){return Rr(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:e}})}}const dBt=65536;function CT(t){return t<0&&(t=4294967295+t+1),`0x${t.toString(16)}`}const MT=8,g$=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class _st{constructor(e){this.buffer=e}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(e){const r=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let s=r[3]*i[3];this.buffer[0]=s&65535;let o=s>>>16;return s=r[2]*i[3],o+=s,s=r[3]*i[2]>>>0,o+=s,this.buffer[0]+=o<<16,this.buffer[1]=o>>>0<s?dBt:0,this.buffer[1]+=o>>>16,this.buffer[1]+=r[1]*i[3]+r[2]*i[2]+r[3]*i[1],this.buffer[1]+=r[0]*i[3]+r[1]*i[2]+r[2]*i[1]+r[3]*i[0]<<16,this}_plus(e){const r=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],r<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=r}lessThan(e){return this.buffer[1]<e.buffer[1]||this.buffer[1]===e.buffer[1]&&this.buffer[0]<e.buffer[0]}equals(e){return this.buffer[1]===e.buffer[1]&&this.buffer[0]==e.buffer[0]}greaterThan(e){return e.lessThan(this)}hex(){return`${CT(this.buffer[1])} ${CT(this.buffer[0])}`}}class go extends _st{times(e){return this._times(e),this}plus(e){return this._plus(e),this}static from(e,r=new Uint32Array(2)){return go.fromString(typeof e=="string"?e:e.toString(),r)}static fromNumber(e,r=new Uint32Array(2)){return go.fromString(e.toString(),r)}static fromString(e,r=new Uint32Array(2)){const i=e.length,s=new go(r);for(let o=0;o<i;){const n=MT<i-o?MT:i-o,a=new go(new Uint32Array([Number.parseInt(e.slice(o,o+n),10),0])),l=new go(new Uint32Array([g$[n],0]));s.times(l),s.plus(a),o+=n}return s}static convertArray(e){const r=new Uint32Array(e.length*2);for(let i=-1,s=e.length;++i<s;)go.from(e[i],new Uint32Array(r.buffer,r.byteOffset+2*i*4,2));return r}static multiply(e,r){return new go(new Uint32Array(e.buffer)).times(r)}static add(e,r){return new go(new Uint32Array(e.buffer)).plus(r)}}class rf extends _st{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(e){return this._times(e),this}plus(e){return this._plus(e),this}lessThan(e){const r=this.buffer[1]<<0,i=e.buffer[1]<<0;return r<i||r===i&&this.buffer[0]<e.buffer[0]}static from(e,r=new Uint32Array(2)){return rf.fromString(typeof e=="string"?e:e.toString(),r)}static fromNumber(e,r=new Uint32Array(2)){return rf.fromString(e.toString(),r)}static fromString(e,r=new Uint32Array(2)){const i=e.startsWith("-"),s=e.length,o=new rf(r);for(let n=i?1:0;n<s;){const a=MT<s-n?MT:s-n,l=new rf(new Uint32Array([Number.parseInt(e.slice(n,n+a),10),0])),c=new rf(new Uint32Array([g$[a],0]));o.times(c),o.plus(l),n+=a}return i?o.negate():o}
vendor: 10,254 bytes, line 7
7static convertArray(e){const r=new Uint32Array(e.length*2);for(let i=-1,s=e.length;++i<s;)rf.from(e[i],new Uint32Array(r.buffer,r.byteOffset+2*i*4,2));return r}static multiply(e,r){return new rf(new Uint32Array(e.buffer)).times(r)}static add(e,r){return new rf(new Uint32Array(e.buffer)).plus(r)}}class bm{constructor(e){this.buffer=e}high(){return new rf(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new rf(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(e){const r=new go(new Uint32Array([this.buffer[3],0])),i=new go(new Uint32Array([this.buffer[2],0])),s=new go(new Uint32Array([this.buffer[1],0])),o=new go(new Uint32Array([this.buffer[0],0])),n=new go(new Uint32Array([e.buffer[3],0])),a=new go(new Uint32Array([e.buffer[2],0])),l=new go(new Uint32Array([e.buffer[1],0])),c=new go(new Uint32Array([e.buffer[0],0]));let h=go.multiply(o,c);this.buffer[0]=h.low();const u=new go(new Uint32Array([h.high(),0]));return h=go.multiply(s,c),u.plus(h),h=go.multiply(o,l),u.plus(h),this.buffer[1]=u.low(),this.buffer[3]=u.lessThan(h)?1:0,this.buffer[2]=u.high(),new go(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(go.multiply(i,c)).plus(go.multiply(s,l)).plus(go.multiply(o,a)),this.buffer[3]+=go.multiply(r,c).plus(go.multiply(i,l)).plus(go.multiply(s,a)).plus(go.multiply(o,n)).low(),this}plus(e){const r=new Uint32Array(4);return r[3]=this.buffer[3]+e.buffer[3]>>>0,r[2]=this.buffer[2]+e.buffer[2]>>>0,r[1]=this.buffer[1]+e.buffer[1]>>>0,r[0]=this.buffer[0]+e.buffer[0]>>>0,r[0]<this.buffer[0]>>>0&&++r[1],r[1]<this.buffer[1]>>>0&&++r[2],r[2]<this.buffer[2]>>>0&&++r[3],this.buffer[3]=r[3],this.buffer[2]=r[2],this.buffer[1]=r[1],this.buffer[0]=r[0],this}hex(){return`${CT(this.buffer[3])} ${CT(this.buffer[2])} ${CT(this.buffer[1])} ${CT(this.buffer[0])}`}static multiply(e,r){return new bm(new Uint32Array(e.buffer)).times(r)}static add(e,r){return new bm(new Uint32Array(e.buffer)).plus(r)}static from(e,r=new Uint32Array(4)){return bm.fromString(typeof e=="string"?e:e.toString(),r)}static fromNumber(e,r=new Uint32Array(4)){return bm.fromString(e.toString(),r)}static fromString(e,r=new Uint32Array(4)){const i=e.startsWith("-"),s=e.length,o=new bm(r);for(let n=i?1:0;n<s;){const a=MT<s-n?MT:s-n,l=new bm(new Uint32Array([Number.parseInt(e.slice(n,n+a),10),0,0,0])),c=new bm(new Uint32Array([g$[a],0,0,0]));o.times(c),o.plus(l),n+=a}return i?o.negate():o}static convertArray(e){const r=new Uint32Array(e.length*4);for(let i=-1,s=e.length;++i<s;)bm.from(e[i],new Uint32Array(r.buffer,r.byteOffset+16*i,4));return r}}class bst extends Ui{constructor(e,r,i,s,o=ja.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=e,this.nodes=r,this.buffers=i,this.dictionaries=s,this.metadataVersion=o}visit(e){return super.visit(e instanceof tn?e.type:e)}visitNull(e,{length:r}=this.nextFieldNode()){return Gi({type:e,length:r})}visitBool(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),data:this.readData(e)})}visitInt(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),data:this.readData(e)})}visitFloat(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),data:this.readData(e)})}visitUtf8(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitLargeUtf8(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitBinary(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitLargeBinary(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitFixedSizeBinary(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),data:this.readData(e)})}visitDate(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),data:this.readData(e)})}visitTimestamp(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),data:this.readData(e)})}visitTime(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),data:this.readData(e)})}visitDecimal(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),data:this.readData(e)})}visitList(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),valueOffsets:this.readOffsets(e),child:this.visit(e.children[0])})}visitStruct(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),children:this.visitMany(e.children)})}visitUnion(e,{length:r,nullCount:i}=this.nextFieldNode()){return this.metadataVersion<ja.V5&&this.readNullBitmap(e,i),e.mode===lu.Sparse?this.visitSparseUnion(e,{length:r,nullCount:i}):this.visitDenseUnion(e,{length:r,nullCount:i})}visitDenseUnion(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,typeIds:this.readTypeIds(e),valueOffsets:this.readOffsets(e),children:this.visitMany(e.children)})}visitSparseUnion(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,typeIds:this.readTypeIds(e),children:this.visitMany(e.children)})}visitDictionary(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),data:this.readData(e.indices),dictionary:this.readDictionary(e)})}visitInterval(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),data:this.readData(e)})}visitDuration(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),data:this.readData(e)})}visitFixedSizeList(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),child:this.visit(e.children[0])})}visitMap(e,{length:r,nullCount:i}=this.nextFieldNode()){return Gi({type:e,length:r,nullCount:i,nullBitmap:this.readNullBitmap(e,i),valueOffsets:this.readOffsets(e),child:this.visit(e.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(e,r,i=this.nextBufferRange()){return r>0&&this.readData(e,i)||new Uint8Array(0)}readOffsets(e,r){return this.readData(e,r)}readTypeIds(e,r){return this.readData(e,r)}readData(e,{length:r,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+r)}readDictionary(e){return this.dictionaries.get(e.id)}}class fBt extends bst{constructor(e,r,i,s,o){super(new Uint8Array(0),r,i,s,o),this.sources=e}readNullBitmap(e,r,{offset:i}=this.nextBufferRange()){return r<=0?new Uint8Array(0):o$(this.sources[i])}readOffsets(e,{offset:r}=this.nextBufferRange()){return Co(Uint8Array,Co(e.OffsetArrayType,this.sources[r]))}readTypeIds(e,{offset:r}=this.nextBufferRange()){return Co(Uint8Array,Co(e.ArrayType,this.sources[r]))}readData(e,{offset:r}=this.nextBufferRange()){const{sources:i}=this;return ur.isTimestamp(e)||(ur.isInt(e)||ur.isTime(e))&&e.bitWidth===64||ur.isDuration(e)||ur.isDate(e)&&e.unit===Jh.MILLISECOND?Co(Uint8Array,rf.convertArray(i[r])):ur.isDecimal(e)?Co(Uint8Array,bm.convertArray(i[r])):ur.isBinary(e)||ur.isLargeBinary(e)||ur.isFixedSizeBinary(e)?pBt(i[r]):ur.isBool(e)?o$(i[r]):ur.isUtf8(e)||ur.isLargeUtf8(e)?XY(i[r].join("")):Co(Uint8Array,Co(e.ArrayType,i[r].map(s=>+s)))}}function pBt(t){const e=t.join(""),r=new Uint8Array(e.length/2);for(let i=0;i<e.length;i+=2)r[i>>1]=Number.parseInt(e.slice(i,i+2),16);return r}class Or extends Ui{compareSchemas(e,r){return e===r||r instanceof e.constructor&&this.compareManyFields(e.fields,r.fields)}compareManyFields(e,r){return e===r||Array.isArray(e)&&Array.isArray(r)&&e.length===r.length&&e.every((i,s)=>this.compareFields(i,r[s]))}compareFields(e,r){return e===r||r instanceof e.constructor&&e.name===r.name&&e.nullable===r.nullable&&this.visit(e.type,r.type)}}function Ah(t,e){return e instanceof t.constructor}function SE(t,e){return t===e||Ah(t,e)}function c0(t,e){return t===e||Ah(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function v4(t,e){return t===e||Ah(t,e)&&t.precision===e.precision}function gBt(t,e){return t===e||Ah(t,e)&&t.byteWidth===e.byteWidth}function m$(t,e){return t===e||Ah(t,e)&&t.unit===e.unit}function LO(t,e){return t===e||Ah(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function UO(t,e){return t===e||Ah(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function mBt(t,e){return t===e||Ah(t,e)&&t.children.length===e.children.length&&Uv.compareManyFields(t.children,e.children)}function yBt(t,e){return t===e||Ah(t,e)&&t.children.length===e.children.length&&Uv.compareManyFields(t.children,e.children)}function y$(t,e){return t===e||Ah(t,e)&&t.mode===e.mode&&t.typeIds.every((r,i)=>r===e.typeIds[i])&&Uv.compareManyFields(t.children,e.children)}function vBt(t,e){return t===e||Ah(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&Uv.visit(t.indices,e.indices)&&Uv.visit(t.dictionary,e.dictionary)}function v$(t,e){return t===e||Ah(t,e)&&t.unit===e.unit}function GO(t,e){return t===e||Ah(t,e)&&t.unit===e.unit}function _Bt(t,e){return t===e||Ah(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&Uv.compareManyFields(t.children,e.children)}
7function bBt(t,e){return t===e||Ah(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&Uv.compareManyFields(t.children,e.children)}Or.prototype.visitNull=SE,Or.prototype.visitBool=SE,Or.prototype.visitInt=c0,Or.prototype.visitInt8=c0,Or.prototype.visitInt16=c0,Or.prototype.visitInt32=c0,Or.prototype.visitInt64=c0,Or.prototype.visitUint8=c0,Or.prototype.visitUint16=c0,Or.prototype.visitUint32=c0,Or.prototype.visitUint64=c0,Or.prototype.visitFloat=v4,Or.prototype.visitFloat16=v4,Or.prototype.visitFloat32=v4,Or.prototype.visitFloat64=v4,Or.prototype.visitUtf8=SE,Or.prototype.visitLargeUtf8=SE,Or.prototype.visitBinary=SE,Or.prototype.visitLargeBinary=SE,Or.prototype.visitFixedSizeBinary=gBt,Or.prototype.visitDate=m$,Or.prototype.visitDateDay=m$,Or.prototype.visitDateMillisecond=m$,Or.prototype.visitTimestamp=LO,Or.prototype.visitTimestampSecond=LO,Or.prototype.visitTimestampMillisecond=LO,Or.prototype.visitTimestampMicrosecond=LO,Or.prototype.visitTimestampNanosecond=LO,Or.prototype.visitTime=UO,Or.prototype.visitTimeSecond=UO,Or.prototype.visitTimeMillisecond=UO,Or.prototype.visitTimeMicrosecond=UO,Or.prototype.visitTimeNanosecond=UO,Or.prototype.visitDecimal=SE,Or.prototype.visitList=mBt,Or.prototype.visitStruct=yBt,Or.prototype.visitUnion=y$,Or.prototype.visitDenseUnion=y$,Or.prototype.visitSparseUnion=y$,Or.prototype.visitDictionary=vBt,Or.prototype.visitInterval=v$,Or.prototype.visitIntervalDayTime=v$,Or.prototype.visitIntervalYearMonth=v$,Or.prototype.visitDuration=GO,Or.prototype.visitDurationSecond=GO,Or.prototype.visitDurationMillisecond=GO,Or.prototype.visitDurationMicrosecond=GO,Or.prototype.visitDurationNanosecond=GO,Or.prototype.visitFixedSizeList=_Bt,Or.prototype.visitMap=bBt;const Uv=new Or;function wBt(t,e){return Uv.compareSchemas(t,e)}function _$(t,e){return EBt(t,e.map(r=>r.data.concat()))}function EBt(t,e){const r=[...t.fields],i=[],s={numBatches:e.reduce((u,d)=>Math.max(u,d.length),0)};let o=0,n=0,a=-1;const l=e.length;let c,h=[];for(;s.numBatches-- >0;){for(n=Number.POSITIVE_INFINITY,a=-1;++a<l;)h[a]=c=e[a].shift(),n=Math.min(n,c?c.length:n);Number.isFinite(n)&&(h=ABt(r,n,h,e,s),n>0&&(i[o++]=Gi({type:new Uc(r),length:n,nullCount:0,children:h.slice()})))}return[t=t.assign(r),i.map(u=>new hp(t,u))]}function ABt(t,e,r,i,s){var o;const n=(e+63&-64)>>3;for(let a=-1,l=i.length;++a<l;){const c=r[a],h=c==null?void 0:c.length;if(h>=e)h===e?r[a]=c:(r[a]=c.slice(0,e),s.numBatches=Math.max(s.numBatches,i[a].unshift(c.slice(e,h-e))));else{const u=t[a];t[a]=u.clone({nullable:!0}),r[a]=(o=c==null?void 0:c._changeLengthAndBackfillNullBitmap(e))!==null&&o!==void 0?o:Gi({type:u.type,length:e,nullCount:e,nullBitmap:new Uint8Array(n)})}}return r}var wst;Yd=class{constructor(...t){var e,r;if(t.length===0)return this.batches=[],this.schema=new lo([]),this._offsets=[0],this;let i,s;t[0]instanceof lo&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());const o=a=>{if(a){if(a instanceof hp)return[a];if(a instanceof Yd)return a.batches;if(a instanceof po){if(a.type instanceof Uc)return[new hp(new lo(a.type.children),a)]}else{if(Array.isArray(a))return a.flatMap(l=>o(l));if(typeof a[Symbol.iterator]=="function")return[...a].flatMap(l=>o(l));if(typeof a=="object"){const l=Object.keys(a),c=l.map(d=>new Ma([a[d]])),h=i??new lo(l.map((d,f)=>new tn(String(d),c[f].type,c[f].nullable))),[,u]=_$(h,c);return u.length===0?[new hp(a)]:u}}}return[]},n=t.flatMap(a=>o(a));if(i=(r=i??((e=n[0])===null||e===void 0?void 0:e.schema))!==null&&r!==void 0?r:new lo([]),!(i instanceof lo))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const a of n){if(!(a instanceof hp))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!wBt(i,a.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=n,this._offsets=s??lst(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,e)=>t+e.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=ast(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(s$(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?u$.visit(new Ma(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ 8 ${this.toArray().join(`, 9 `)} 10]`}concat(...t){const e=this.schema,r=this.data.concat(t.flatMap(({data:i})=>i));return new Yd(e,r.map(i=>new hp(e,i)))}slice(t,e){const r=this.schema;[t,e]=est({length:this.numRows},t,e);const i=cst(this.data,this._offsets,t,e);return new Yd(r,i.map(s=>new hp(r,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){const e=this.data.map(r=>r.children[t]);if(e.length===0){const{type:r}=this.schema.fields[t],i=Gi({type:r,length:0,nullCount:0});
vendor: 4,418 bytes, line 10
10e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new Ma(e)}return null}setChild(t,e){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),e)}setChildAt(t,e){let r=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new Ma([Gi({type:new Ly,length:this.numRows})]));const s=r.fields.slice(),o=s[t].clone({type:e.type}),n=this.schema.fields.map((a,l)=>this.getChildAt(l));[s[t],n[t]]=[o,e],[r,i]=_$(r,n)}return new Yd(r,i)}select(t){const e=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(t.map(r=>e.get(r)).filter(r=>r>-1))}selectAt(t){const e=this.schema.selectAt(t),r=this.batches.map(i=>i.selectAt(t));return new Yd(e,r)}assign(t){const e=this.schema.fields,[r,i]=t.schema.fields.reduce((n,a,l)=>{const[c,h]=n,u=e.findIndex(d=>d.name===a.name);return~u?h[u]=l:c.push(l),n},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((n,a)=>[a,i[a]]).map(([n,a])=>a===void 0?this.getChildAt(n):t.getChildAt(a)),...r.map(n=>t.getChildAt(n))].filter(Boolean);return new Yd(..._$(s,o))}},wst=Symbol.toStringTag,Yd[wst]=(t=>(t.schema=null,t.batches=[],t._offsets=new Uint32Array([0]),t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,t.isValid=d4(h$),t.get=d4(hu.getVisitFn(ot.Struct)),t.set=hst(ef.getVisitFn(ot.Struct)),t.indexOf=ust(f4.getVisitFn(ot.Struct)),"Table"))(Yd.prototype);var Est;let hp=class OG{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof lo))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Gi({nullCount:0,type:new Uc(this.schema.fields),children:this.schema.fields.map(r=>Gi({type:r.type,nullCount:0}))})]=e,!(this.data instanceof po))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Ast(this.schema,this.data.children);break}case 1:{const[r]=e,{fields:i,children:s,length:o}=Object.keys(r).reduce((l,c,h)=>(l.children[h]=r[c],l.length=Math.max(l.length,r[c].length),l.fields[h]=tn.new({name:c,type:r[c].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),n=new lo(i),a=Gi({type:new Uc(i),length:o,children:s,nullCount:0});[this.schema,this.data]=Ast(n,a.children,o);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=xst(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return hu.visit(this.data,e)}at(e){return this.get(s$(e,this.numRows))}set(e,r){return ef.visit(this.data,e,r)}indexOf(e,r){return f4.visit(this.data,e,r)}[Symbol.iterator](){return u$.visit(new Ma([this.data]))}toArray(){return[...this]}concat(...e){return new Yd(this.schema,[this,...e])}slice(e,r){const[i]=new Ma([this.data]).slice(e,r).data;return new OG(this.schema,i)}getChild(e){var r;return this.getChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&e<this.schema.fields.length?new Ma([this.data.children[e]]):null}setChild(e,r){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(s=>s.name===e),r)}setChildAt(e,r){let i=this.schema,s=this.data;if(e>-1&&e<this.numCols){r||(r=new Ma([Gi({type:new Ly,length:this.numRows})]));const o=i.fields.slice(),n=s.children.slice(),a=o[e].clone({type:r.type});[o[e],n[e]]=[a,r.data[0]],i=new lo(o,new Map(this.schema.metadata)),s=Gi({type:new Uc(o),children:n})}return new OG(i,s)}select(e){const r=this.schema.select(e),i=new Uc(r.fields),s=[];for(const o of e){const n=this.schema.fields.findIndex(a=>a.name===o);~n&&(s[n]=this.data.children[n])}return new OG(r,Gi({type:i,length:this.numRows,children:s}))}selectAt(e){const r=this.schema.selectAt(e),i=e.map(o=>this.data.children[o]).filter(Boolean),s=Gi({type:new Uc(r.fields),length:this.numRows,children:i});return new OG(r,s)}};Est=Symbol.toStringTag,hp[Est]=(t=>(t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(hp.prototype);function Ast(t,e,r=e.reduce((i,s)=>Math.max(i,s.length),0)){var i;const s=[...t.fields],o=[...e],n=(r+63&-64)>>3;for(const[a,l]of t.fields.entries()){const c=e[a];(!c||c.length!==r)&&(s[a]=l.clone({nullable:!0}
10),o[a]=(i=c==null?void 0:c._changeLengthAndBackfillNullBitmap(r))!==null&&i!==void 0?i:Gi({type:l.type,length:r,nullCount:r,nullBitmap:new Uint8Array(n)}))}return[t.assign(s),Gi({type:new Uc(s),length:r,children:o})]}function xst(t,e,r=new Map){var i,s;if(((i=t==null?void 0:t.length)!==null&&i!==void 0?i:0)>0&&(t==null?void 0:t.length)===(e==null?void 0:e.length))for(let o=-1,n=t.length;++o<n;){const{type:a}=t[o],l=e[o];for(const c of[l,...((s=l==null?void 0:l.dictionary)===null||s===void 0?void 0:s.data)||[]])xst(a.children,c==null?void 0:c.children,r);if(ur.isDictionary(a)){const{id:c}=a;if(!r.has(c))l!=null&&l.dictionary&&r.set(c,l.dictionary);else if(r.get(c)!==l.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return r}class Sst extends hp{constructor(e){const r=e.fields.map(s=>Gi({type:s.type})),i=Gi({type:new Uc(e.fields),nullCount:0,children:r});super(e,i)}}let Gv=class Jy{constructor(){this.bb=null,this.bb_pos=0}__init(e,r){return this.bb_pos=e,this.bb=r,this}static getRootAsMessage(e,r){return(r||new Jy).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,r){return e.setPosition(e.position()+no),(r||new Jy).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ja.V1}headerType(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):ao.NONE}header(e){const r=this.bb.__offset(this.bb_pos,8);return r?this.bb.__union(e,this.bb_pos+r):null}bodyLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,r){const i=this.bb.__offset(this.bb_pos,12);return i?(r||new fl).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,r){e.addFieldInt16(0,r,ja.V1)}static addHeaderType(e,r){e.addFieldInt8(1,r,ao.NONE)}static addHeader(e,r){e.addFieldOffset(2,r,0)}static addBodyLength(e,r){e.addFieldInt64(3,r,BigInt("0"))}static addCustomMetadata(e,r){e.addFieldOffset(4,r,0)}static createCustomMetadataVector(e,r){e.startVector(4,r.length,4);for(let i=r.length-1;i>=0;i--)e.addOffset(r[i]);return e.endVector()}static startCustomMetadataVector(e,r){e.startVector(4,r,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,r){e.finish(r)}static finishSizePrefixedMessageBuffer(e,r){e.finish(r,void 0,!0)}static createMessage(e,r,i,s,o,n){return Jy.startMessage(e),Jy.addVersion(e,r),Jy.addHeaderType(e,i),Jy.addHeader(e,s),Jy.addBodyLength(e,o),Jy.addCustomMetadata(e,n),Jy.endMessage(e)}};class xBt extends Ui{visit(e,r){return e==null||r==null?void 0:super.visit(e,r)}visitNull(e,r){return Frt.startNull(r),Frt.endNull(r)}visitInt(e,r){return nd.startInt(r),nd.addBitWidth(r,e.bitWidth),nd.addIsSigned(r,e.isSigned),nd.endInt(r)}visitFloat(e,r){return ym.startFloatingPoint(r),ym.addPrecision(r,e.precision),ym.endFloatingPoint(r)}visitBinary(e,r){return Brt.startBinary(r),Brt.endBinary(r)}visitLargeBinary(e,r){return Irt.startLargeBinary(r),Irt.endLargeBinary(r)}visitBool(e,r){return Ort.startBool(r),Ort.endBool(r)}visitUtf8(e,r){return Nrt.startUtf8(r),Nrt.endUtf8(r)}visitLargeUtf8(e,r){return Drt.startLargeUtf8(r),Drt.endLargeUtf8(r)}visitDecimal(e,r){return gT.startDecimal(r),gT.addScale(r,e.scale),gT.addPrecision(r,e.precision),gT.addBitWidth(r,e.bitWidth),gT.endDecimal(r)}visitDate(e,r){return e4.startDate(r),e4.addUnit(r,e.unit),e4.endDate(r)}visitTime(e,r){return Jd.startTime(r),Jd.addUnit(r,e.unit),Jd.addBitWidth(r,e.bitWidth),Jd.endTime(r)}visitTimestamp(e,r){const i=e.timezone&&r.createString(e.timezone)||void 0;return Qd.startTimestamp(r),Qd.addUnit(r,e.unit),i!==void 0&&Qd.addTimezone(r,i),Qd.endTimestamp(r)}visitInterval(e,r){return vm.startInterval(r),vm.addUnit(r,e.unit),vm.endInterval(r)}visitDuration(e,r){return r4.startDuration(r),r4.addUnit(r,e.unit),r4.endDuration(r)}visitList(e,r){return Prt.startList(r),Prt.endList(r)}visitStruct(e,r){return AE.startStruct_(r),AE.endStruct_(r)}visitUnion(e,r){cu.startTypeIdsVector(r,e.typeIds.length);const i=cu.createTypeIdsVector(r,e.typeIds);return cu.startUnion(r),cu.addMode(r,e.mode),cu.addTypeIds(r,i),cu.endUnion(r)}visitDictionary(e,r){const i=this.visit(e.indices,r);return o0.startDictionaryEncoding(r),o0.addId(r,BigInt(e.id)),o0.addIsOrdered(r,e.isOrdered),i!==void 0&&o0.addIndexType(r,i),o0.endDictionaryEncoding(r)}visitFixedSizeBinary(e,r){return i4.startFixedSizeBinary(r),i4.addByteWidth(r,e.byteWidth),i4.endFixedSizeBinary(r)}visitFixedSizeList(e,r){return s4.startFixedSizeList(r),s4.addListSize(r,e.listSize),s4.endFixedSizeList(r)}visitMap(e,r){return o4.startMap(r),o4.addKeysSorted(r,e.keysSorted),o4.endMap(r)}}
10const b$=new xBt;function SBt(t,e=new Map){return new lo(RBt(t,e),_4(t.metadata),e)}function Tst(t){return new dp(t.count,Cst(t.columns),Mst(t.columns))}function TBt(t){return new h0(Tst(t.data),t.id,t.isDelta)}function RBt(t,e){return(t.fields||[]).filter(Boolean).map(r=>tn.fromJSON(r,e))}function Rst(t,e){return(t.children||[]).filter(Boolean).map(r=>tn.fromJSON(r,e))}function Cst(t){return(t||[]).reduce((e,r)=>[...e,new BT(r.count,CBt(r.VALIDITY)),...Cst(r.children)],[])}function Mst(t,e=[]){for(let r=-1,i=(t||[]).length;++r<i;){const s=t[r];s.VALIDITY&&e.push(new u0(e.length,s.VALIDITY.length)),s.TYPE_ID&&e.push(new u0(e.length,s.TYPE_ID.length)),s.OFFSET&&e.push(new u0(e.length,s.OFFSET.length)),s.DATA&&e.push(new u0(e.length,s.DATA.length)),e=Mst(s.children,e)}return e}function CBt(t){return(t||[]).reduce((e,r)=>e+ +(r===0),0)}function MBt(t,e){let r,i,s,o,n,a;return!e||!(o=t.dictionary)?(n=Ost(t,Rst(t,e)),s=new tn(t.name,n,t.nullable,_4(t.metadata))):e.has(r=o.id)?(i=(i=o.indexType)?Bst(i):new QS,a=new vT(e.get(r),i,r,o.isOrdered),s=new tn(t.name,a,t.nullable,_4(t.metadata))):(i=(i=o.indexType)?Bst(i):new QS,e.set(r,n=Ost(t,Rst(t,e))),a=new vT(n,i,r,o.isOrdered),s=new tn(t.name,a,t.nullable,_4(t.metadata))),s||null}function _4(t=[]){return new Map(t.map(({key:e,value:r})=>[e,r]))}function Bst(t){return new gh(t.isSigned,t.bitWidth)}function Ost(t,e){const r=t.type.name;switch(r){case"NONE":return new Ly;case"null":return new Ly;case"binary":return new eO;case"largebinary":return new n4;case"utf8":return new lO;case"largeutf8":return new a4;case"bool":return new tO;case"list":return new oO((e||[])[0]);case"struct":return new Uc(e||[]);case"struct_":return new Uc(e||[])}switch(r){case"int":{const i=t.type;return new gh(i.isSigned,i.bitWidth)}case"floatingpoint":{const i=t.type;return new Cv(ll[i.precision])}case"decimal":{const i=t.type;return new aO(i.scale,i.precision,i.bitWidth)}case"date":{const i=t.type;return new oE(Jh[i.unit])}case"time":{const i=t.type;return new Wy(or[i.unit],i.bitWidth)}case"timestamp":{const i=t.type;return new Gy(or[i.unit],i.timezone)}case"interval":{const i=t.type;return new sE($d[i.unit])}case"duration":{const i=t.type;return new l4(or[i.unit])}case"union":{const i=t.type,[s,...o]=(i.mode+"").toLowerCase(),n=s.toUpperCase()+o.join("");return new c4(lu[n],i.typeIds||[],e||[])}case"fixedsizebinary":{const i=t.type;return new h4(i.byteWidth)}case"fixedsizelist":{const i=t.type;return new sO(i.listSize,(e||[])[0])}case"map":{const i=t.type;return new nO((e||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${r}"`)}var BBt=Rrt,OBt=dT;class up{static fromJSON(e,r){const i=new up(0,ja.V5,r);return i._createHeader=IBt(e,r),i}static decode(e){e=new OBt(Is(e));const r=Gv.getRootAsMessage(e),i=r.bodyLength(),s=r.version(),o=r.headerType(),n=new up(i,s,o);return n._createHeader=DBt(r,o),n}static encode(e){const r=new BBt;let i=-1;return e.isSchema()?i=lo.encode(r,e.header()):e.isRecordBatch()?i=dp.encode(r,e.header()):e.isDictionaryBatch()&&(i=h0.encode(r,e.header())),Gv.startMessage(r),Gv.addVersion(r,ja.V5),Gv.addHeader(r,i),Gv.addHeaderType(r,e.headerType),Gv.addBodyLength(r,BigInt(e.bodyLength)),Gv.finishMessageBuffer(r,Gv.endMessage(r)),r.asUint8Array()}static from(e,r=0){if(e instanceof lo)return new up(0,ja.V5,ao.Schema,e);if(e instanceof dp)return new up(r,ja.V5,ao.RecordBatch,e);if(e instanceof h0)return new up(r,ja.V5,ao.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===ao.Schema}isRecordBatch(){return this.headerType===ao.RecordBatch}isDictionaryBatch(){return this.headerType===ao.DictionaryBatch}constructor(e,r,i,s){this._version=r,this._headerType=i,this.body=new Uint8Array(0),s&&(this._createHeader=()=>s),this._bodyLength=Qo(e)}}class dp{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,r,i){this._nodes=r,this._buffers=i,this._length=Qo(e)}}class h0{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,r,i=!1){this._data=e,this._isDelta=i,this._id=Qo(r)}}class u0{constructor(e,r){this.offset=Qo(e),this.length=Qo(r)}}class BT{constructor(e,r){this.length=Qo(e),this.nullCount=Qo(r)}}function IBt(t,e){return(()=>{switch(e){case ao.Schema:return lo.fromJSON(t);case ao.RecordBatch:return dp.fromJSON(t);case ao.DictionaryBatch:return h0.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${ao[e]}, type: ${e} }`)})}function DBt(t,e){return(()=>{switch(e){case ao.Schema:return lo.decode(t.header(new _m),new Map,t.version());case ao.RecordBatch:return dp.decode(t.header(new s0),t.version());case ao.DictionaryBatch:return h0.decode(t.header(new fT),t.version())}throw new Error(`Unrecognized Message type: { name: ${ao[e]}, type: ${e} }`)})}tn.encode=zBt,tn.decode=jBt,tn.fromJSON=MBt,lo.encode=XBt,lo.decode=PBt,lo.fromJSON=SBt,dp.encode=VBt,dp.decode=FBt,dp.fromJSON=Tst,h0.encode=YBt,h0.decode=NBt,h0.fromJSON=TBt,BT.encode=$Bt,BT.decode=LBt,u0.encode=HBt,u0.decode=kBt;function PBt(t,e=new Map,r=ja.V5){const i=WBt(t,e);return new lo(i,b4(t),e,r)}function FBt(t,e=ja.V5){if(t.compression()!==null)throw new Error("Record batch compression not implemented");return new dp(t.length(),UBt(t),GBt(t,e))}function NBt(t,e=ja.V5){return new h0(dp.decode(t.data(),e),t.id(),t.isDelta())}function kBt(t){return new u0(t.offset(),t.length())}function LBt(t){return new BT(t.length(),t.nullCount())}function UBt(t){const e=[];for(let r,i=-1,s=-1,o=t.nodesLength();++i<o;)(r=t.nodes(i))&&(e[++s]=BT.decode(r));return e}function GBt(t,e){const r=[];for(let i,s=-1,o=-1,n=t.buffersLength();++s<n;)(i=t.buffers(s))&&(e<ja.V4&&(i.bb_pos+=8*(s+1)),r[++o]=u0.decode(i));return r}function WBt(t,e){const r=[];for(let i,s=-1,o=-1,n=t.fieldsLength();++s<n;)(i=t.fields(s))&&(r[++o]=tn.decode(i,e));return r}function Ist(t,e){const r=[];for(let i,s=-1,o=-1,n=t.childrenLength();++s<n;)(i=t.children(s))&&(r[++o]=tn.decode(i,e));return r}function jBt(t,e){let r,i,s,o,n,a;return!e||!(a=t.dictionary())?(s=Pst(t,Ist(t,e)),i=new tn(t.name(),s,t.nullable(),b4(t))):e.has(r=Qo(a.id()))?(o=(o=a.indexType())?Dst(o):new QS,n=new vT(e.get(r),o,r,a.isOrdered()),i=new tn(t.name(),n,t.nullable(),b4(t))):(o=(o=a.indexType())?Dst(o):new QS,e.set(r,s=Pst(t,Ist(t,e))),n=new vT(s,o,r,a.isOrdered()),i=new tn(t.name(),n,t.nullable(),b4(t))),i||null}function b4(t){const e=new Map;if(t)for(let r,i,s=-1,o=Math.trunc(t.customMetadataLength());++s<o;)(r=t.customMetadata(s))&&(i=r.key())!=null&&e.set(i,r.value());return e}function Dst(t){return new gh(t.isSigned(),t.bitWidth())}function Pst(t,e){const r=t.typeType();switch(r){case jo.NONE:return new Ly;case jo.Null:return new Ly;case jo.Binary:return new eO;case jo.LargeBinary:return new n4;case jo.Utf8:return new lO;case jo.LargeUtf8:return new a4;case jo.Bool:return new tO;case jo.List:return new oO((e||[])[0]);case jo.Struct_:return new Uc(e||[])}switch(r){case jo.Int:{const i=t.type(new nd);return new gh(i.isSigned(),i.bitWidth())}case jo.FloatingPoint:{const i=t.type(new ym);return new Cv(i.precision())}
10case jo.Decimal:{const i=t.type(new gT);return new aO(i.scale(),i.precision(),i.bitWidth())}case jo.Date:{const i=t.type(new e4);return new oE(i.unit())}case jo.Time:{const i=t.type(new Jd);return new Wy(i.unit(),i.bitWidth())}case jo.Timestamp:{const i=t.type(new Qd);return new Gy(i.unit(),i.timezone())}case jo.Interval:{const i=t.type(new vm);return new sE(i.unit())}case jo.Duration:{const i=t.type(new r4);return new l4(i.unit())}case jo.Union:{const i=t.type(new cu);return new c4(i.mode(),i.typeIdsArray()||[],e||[])}case jo.FixedSizeBinary:{const i=t.type(new i4);return new h4(i.byteWidth())}case jo.FixedSizeList:{const i=t.type(new s4);return new sO(i.listSize(),(e||[])[0])}case jo.Map:{const i=t.type(new o4);return new nO((e||[])[0],i.keysSorted())}}throw new Error(`Unrecognized type: "${jo[r]}" (${r})`)}function XBt(t,e){const r=e.fields.map(o=>tn.encode(t,o));_m.startFieldsVector(t,r.length);const i=_m.createFieldsVector(t,r),s=e.metadata&&e.metadata.size>0?_m.createCustomMetadataVector(t,[...e.metadata].map(([o,n])=>{const a=t.createString(`${o}`),l=t.createString(`${n}`);return fl.startKeyValue(t),fl.addKey(t,a),fl.addValue(t,l),fl.endKeyValue(t)})):-1;return _m.startSchema(t),_m.addFields(t,i),_m.addEndianness(t,KBt?pT.Little:pT.Big),s!==-1&&_m.addCustomMetadata(t,s),_m.endSchema(t)}function zBt(t,e){let r=-1,i=-1,s=-1;const o=e.type;let n=e.typeId;ur.isDictionary(o)?(n=o.dictionary.typeId,s=b$.visit(o,t),i=b$.visit(o.dictionary,t)):i=b$.visit(o,t);const a=(o.children||[]).map(h=>tn.encode(t,h)),l=tf.createChildrenVector(t,a),c=e.metadata&&e.metadata.size>0?tf.createCustomMetadataVector(t,[...e.metadata].map(([h,u])=>{const d=t.createString(`${h}`),f=t.createString(`${u}`);return fl.startKeyValue(t),fl.addKey(t,d),fl.addValue(t,f),fl.endKeyValue(t)})):-1;return e.name&&(r=t.createString(e.name)),tf.startField(t),tf.addType(t,i),tf.addTypeType(t,n),tf.addChildren(t,l),tf.addNullable(t,!!e.nullable),r!==-1&&tf.addName(t,r),s!==-1&&tf.addDictionary(t,s),c!==-1&&tf.addCustomMetadata(t,c),tf.endField(t)}function VBt(t,e){const r=e.nodes||[],i=e.buffers||[];s0.startNodesVector(t,r.length);for(const n of r.slice().reverse())BT.encode(t,n);const s=t.endVector();s0.startBuffersVector(t,i.length);for(const n of i.slice().reverse())u0.encode(t,n);const o=t.endVector();return s0.startRecordBatch(t),s0.addLength(t,BigInt(e.length)),s0.addNodes(t,s),s0.addBuffers(t,o),s0.endRecordBatch(t)}function YBt(t,e){const r=dp.encode(t,e.data);return fT.startDictionaryBatch(t),fT.addId(t,BigInt(e.id)),fT.addIsDelta(t,e.isDelta),fT.addData(t,r),fT.endDictionaryBatch(t)}function $Bt(t,e){return Mrt.createFieldNode(t,BigInt(e.length),BigInt(e.nullCount))}function HBt(t,e){return Crt.createBuffer(t,BigInt(e.offset),BigInt(e.length))}const KBt=(()=>{const t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),new Int16Array(t)[0]===256})(),w$=t=>`Expected ${ao[t]} Message in stream, but was null or length 0.`,E$=t=>`Header pointer of flatbuffer-encoded ${ao[t]} Message is null or length 0.`,Fst=(t,e)=>`Expected to read ${t} metadata bytes, but only read ${e}.`,Nst=(t,e)=>`Expected to read ${t} bytes for message body, but only read ${e}.`;class kst{constructor(e){this.source=e instanceof m4?e:new m4(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?pl:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let r;if((r=this.next()).done)return null;if(e!=null&&r.value.headerType!==e)throw new Error(w$(e));return r.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);const r=Is(this.source.read(e));if(r.byteLength<e)throw new Error(Nst(e,r.byteLength));return r.byteOffset%8===0&&r.byteOffset+r.byteLength<=r.buffer.byteLength?r:r.slice()}readSchema(e=!1){const r=ao.Schema,i=this.readMessage(r),s=i==null?void 0:i.header();if(e&&!s)throw new Error(E$(r));return s}readMetadataLength(){const e=this.source.read(w4),r=e&&new dT(e),i=(r==null?void 0:r.readInt32(0))||0;return{done:i===0,value:i}}readMetadata(e){const r=this.source.read(e);if(!r)return pl;if(r.byteLength<e)throw new Error(Fst(e,r.byteLength));return{done:!1,value:up.decode(r)}}}class qBt{constructor(e,r){this.source=e instanceof RT?e:vrt(e)?new y4(e,r):new RT(e)}[Symbol.asyncIterator](){return this}next(){return Rr(this,void 0,void 0,function*(){let e;return(e=yield this.readMetadataLength()).done||e.value===-1&&(e=yield this.readMetadataLength()).done||(e=yield this.readMetadata(e.value)).done?pl:e})}throw(e){return Rr(this,void 0,void 0,function*(){return yield this.source.throw(e)})}return(e){return Rr(this,void 0,void 0,function*(){return yield this.source.return(e)})}readMessage(e){return Rr(this,void 0,void 0,function*(){let r;if((r=yield this.next()).done)return null;if(e!=null&&r.value.headerType!==e)throw new Error(w$(e));return r.value})}readMessageBody(e){return Rr(this,void 0,void 0,function*(){if(e<=0)return new Uint8Array(0);const r=Is(yield this.source.read(e));if(r.byteLength<e)throw new Error(Nst(e,r.byteLength));return r.byteOffset%8===0&&r.byteOffset+r.byteLength<=r.buffer.byteLength?r:r.slice()})}readSchema(){return Rr(this,arguments,void 0,function*(e=!1){const r=ao.Schema,i=yield this.readMessage(r),s=i==null?void 0:i.header();if(e&&!s)throw new Error(E$(r));return s})}readMetadataLength(){return Rr(this,void 0,void 0,function*(){const e=yield this.source.read(w4),r=e&&new dT(e),i=(r==null?void 0:r.readInt32(0))||0;return{done:i===0,value:i}})}readMetadata(e){return Rr(this,void 0,void 0,function*(){const r=yield this.source.read(e);if(!r)return pl;if(r.byteLength<e)throw new Error(Fst(e,r.byteLength));return{done:!1,value:up.decode(r)}})}}class ZBt extends kst{constructor(e){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=e instanceof mst?e:new mst(e)}next(){const{_json:e}=this;if(!this._schema)return this._schema=!0,{done:!1,value:up.fromJSON(e.schema,ao.Schema)};if(this._dictionaryIndex<e.dictionaries.length){const r=e.dictionaries[this._dictionaryIndex++];return this._body=r.data.columns,{done:!1,value:up.fromJSON(r,ao.DictionaryBatch)}}if(this._batchIndex<e.batches.length){const r=e.batches[this._batchIndex++];return this._body=r.columns,{done:!1,value:up.fromJSON(r,ao.RecordBatch)}}return this._body=[],pl}readMessageBody(e){return r(this._body);function r(i){return(i||[]).reduce((s,o)=>[...s,...o.VALIDITY&&[o.VALIDITY]||[],...o.TYPE_ID&&[o.TYPE_ID]||[],...o.OFFSET&&[o.OFFSET]||[],...o.DATA&&[o.DATA]||[],...r(o.children)],[])}}readMessage(e){let r;if((r=this.next()).done)return null;if(e!=null&&r.value.headerType!==e)throw new Error(w$(e));return r.value}readSchema(){const e=ao.Schema,r=this.readMessage(e),i=r==null?void 0:r.header();if(!r||!i)throw new Error(E$(e));return i}}const w4=4,A$="ARROW1",E4=new Uint8Array(A$.length);for(let t=0;t<A$.length;t+=1)E4[t]=A$.codePointAt(t);function x$(t,e=0){for(let r=-1,i=E4.length;++r<i;)if(E4[r]!==t[e+r])return!1;return!0}const WO=E4.length,Lst=WO+w4,JBt=WO*2+w4;Uy=class extends yst{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){const e=this._impl.open(t);return IO(e)?e.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Zd.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Zd.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof Uy?t:VY(t)?rOt(t):vrt(t)?oOt(t):IO(t)?Rr(this,void 0,void 0,function*(){return yield Uy.from(yield t)}):_rt(t)||YY(t)||wrt(t)||zY(t)?sOt(new RT(t)):iOt(new m4(t))}static readAll(t){return t instanceof Uy?t.isSync()?Xst(t):zst(t):VY(t)||ArrayBuffer.isView(t)||KG(t)||yrt(t)?Xst(t):zst(t)}};class A4 extends Uy{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return pm(this,arguments,function*(){yield Si(yield*HG(uT(this[Symbol.iterator]())))})}}class x4 extends Uy{constructor(e){super(e),this._impl=e}readAll(){return Rr(this,void 0,void 0,function*(){var e,r,i,s;const o=new Array;try{for(var n=!0,a=uT(this),l;l=yield a.next(),e=l.done,!e;n=!0){s=l.value,n=!1;const c=s;o.push(c)}}catch(c){r={error:c}}finally{try{!n&&!e&&(i=a.return)&&(yield i.call(a))}finally{if(r)throw r.error}}return o}
10)}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class Ust extends A4{constructor(e){super(e),this._impl=e}}class QBt extends x4{constructor(e){super(e),this._impl=e}}class Gst{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,r){const i=this._loadVectors(e,r,this.schema.fields),s=Gi({type:new Uc(this.schema.fields),length:e.length,children:i});return new hp(this.schema,s)}_loadDictionaryBatch(e,r){const{id:i,isDelta:s}=e,{dictionaries:o,schema:n}=this,a=o.get(i),l=n.dictionaries.get(i),c=this._loadVectors(e.data,r,[l]);return(a&&s?a.concat(new Ma(c)):new Ma(c)).memoize()}_loadVectors(e,r,i){return new bst(r,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}}class S4 extends Gst{constructor(e,r){super(r),this._reader=VY(e)?new ZBt(this._handle=e):new kst(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=jst(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):pl}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):pl}next(){if(this.closed)return pl;let e;const{_reader:r}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),s=r.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,s)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),s=r.readMessageBody(e.bodyLength),o=this._loadDictionaryBatch(i,s);this.dictionaries.set(i.id,o)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Sst(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}}class T4 extends Gst{constructor(e,r){super(r),this._reader=new qBt(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Rr(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return Rr(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=jst(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return Rr(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):pl})}return(e){return Rr(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):pl})}next(){return Rr(this,void 0,void 0,function*(){if(this.closed)return pl;let e;const{_reader:r}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),s=yield r.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,s)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),s=yield r.readMessageBody(e.bodyLength),o=this._loadDictionaryBatch(i,s);this.dictionaries.set(i.id,o)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Sst(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return Rr(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}}class Wst extends S4{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,r){super(e instanceof vst?e:new vst(e),r)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const r of this._footer.dictionaryBatches())r&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var r;if(this.closed)return null;this._footer||this.open();const i=(r=this._footer)===null||r===void 0?void 0:r.getRecordBatch(e);if(i&&this._handle.seek(i.offset)){const s=this._reader.readMessage(ao.RecordBatch);if(s!=null&&s.isRecordBatch()){const o=s.header(),n=this._reader.readMessageBody(s.bodyLength);return this._loadRecordBatch(o,n)}}return null}_readDictionaryBatch(e){var r;const i=(r=this._footer)===null||r===void 0?void 0:r.getDictionaryBatch(e);if(i&&this._handle.seek(i.offset)){const s=this._reader.readMessage(ao.DictionaryBatch);if(s!=null&&s.isDictionaryBatch()){const o=s.header(),n=this._reader.readMessageBody(s.bodyLength),a=this._loadDictionaryBatch(o,n);this.dictionaries.set(o.id,a)}}}_readFooter(){const{_handle:e}=this,r=e.size-Lst,i=e.readInt32(r),s=e.readAt(r-i,i);return p$.decode(s)}_readNextMessageAndValidate(e){var r;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){const i=(r=this._footer)===null||r===void 0?void 0:r.getRecordBatch(this._recordBatchIndex);if(i&&this._handle.seek(i.offset))return this._reader.readMessage(e)}return null}}class tOt extends T4{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,...r){const i=typeof r[0]!="number"?r.shift():void 0,s=r[0]instanceof Map?r.shift():void 0;super(e instanceof y4?e:new y4(e,i),s)}isFile(){return!0}isAsync(){return!0}open(e){const r=Object.create(null,{open:{get:()=>super.open}});return Rr(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield r.open.call(this,e)})}readRecordBatch(e){return Rr(this,void 0,void 0,function*(){var r;if(this.closed)return null;this._footer||(yield this.open());const i=(r=this._footer)===null||r===void 0?void 0:r.getRecordBatch(e);if(i&&(yield this._handle.seek(i.offset))){const s=yield this._reader.readMessage(ao.RecordBatch);if(s!=null&&s.isRecordBatch()){const o=s.header(),n=yield this._reader.readMessageBody(s.bodyLength);return this._loadRecordBatch(o,n)}}return null})}_readDictionaryBatch(e){return Rr(this,void 0,void 0,function*(){var r;const i=(r=this._footer)===null||r===void 0?void 0:r.getDictionaryBatch(e);if(i&&(yield this._handle.seek(i.offset))){const s=yield this._reader.readMessage(ao.DictionaryBatch);if(s!=null&&s.isDictionaryBatch()){const o=s.header(),n=yield this._reader.readMessageBody(s.bodyLength),a=this._loadDictionaryBatch(o,n);this.dictionaries.set(o.id,a)}}})}_readFooter(){return Rr(this,void 0,void 0,function*(){const{_handle:e}=this;e._pending&&(yield e._pending);const r=e.size-Lst,i=yield e.readInt32(r),s=yield e.readAt(r-i,i);return p$.decode(s)})}_readNextMessageAndValidate(e){return Rr(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){const r=this._footer.getRecordBatch(this._recordBatchIndex);if(r&&(yield this._handle.seek(r.offset)))return yield this._reader.readMessage(e)}return null})}}class eOt extends S4{constructor(e,r){super(e,r)}_loadVectors(e,r,i){return new fBt(r,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}}function jst(t,e){return e&&typeof e.autoDestroy=="boolean"?e.autoDestroy:t.autoDestroy}function*Xst(t){const e=Uy.from(t);try{if(!e.open({autoDestroy:!1}
10).closed)do yield e;while(!e.reset().open().closed)}finally{e.cancel()}}function zst(t){return pm(this,arguments,function*(){const e=yield Si(Uy.from(t));try{if(!(yield Si(e.open({autoDestroy:!1}))).closed)do yield yield Si(e);while(!(yield Si(e.reset().open())).closed)}finally{yield Si(e.cancel())}})}function rOt(t){return new A4(new eOt(t))}function iOt(t){const e=t.peek(WO+7&-8);return e&&e.byteLength>=4?x$(e)?new Ust(new Wst(t.read())):new A4(new S4(t)):new A4(new S4((function*(){})()))}function sOt(t){return Rr(this,void 0,void 0,function*(){const e=yield t.peek(WO+7&-8);return e&&e.byteLength>=4?x$(e)?new Ust(new Wst(yield t.read())):new x4(new T4(t)):new x4(new T4((function(){return pm(this,arguments,function*(){})})()))})}function oOt(t){return Rr(this,void 0,void 0,function*(){const{size:e}=yield t.stat(),r=new y4(t,e);return e>=JBt&&x$(yield r.readAt(0,WO+7&-8))?new QBt(new tOt(r)):new x4(new T4(r))})}utt=function(t){const e=Uy.from(t);return IO(e)?e.then(r=>utt(r)):e.isAsync()?e.readAll().then(r=>new Yd(r)):new Yd(e.readAll())},nu=async function(t,e,r,i){var l;let s,o;!Array.isArray(e)&&!LY(e)?(s=[],o=e):(s=e,o=r);const n=mrt(o);let a=t;return typeof t=="string"&&(a=await n(t)),bE(t)&&(a=await n(t)),typeof t=="string"&&((l=wE(o||{}).core)!=null&&l.baseUrl||(o={...o,core:{...o==null?void 0:o.core,baseUrl:t}})),Array.isArray(s)?await cO(a,s,o):await cO(a,s,o)};let OT=class QV{constructor(e,r,i,s,o="div"){this.parent=e,this.object=r,this.property=i,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(o),this.domElement.classList.add("controller"),this.domElement.classList.add(s),this.$name=document.createElement("div"),this.$name.classList.add("name"),QV.nextNameID=QV.nextNameID||0,this.$name.id=`lil-gui-name-${++QV.nextNameID}`,this.$widget=document.createElement("div"),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",n=>n.stopPropagation()),this.domElement.addEventListener("keyup",n=>n.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(i)}name(e){return this._name=e,this.$name.textContent=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const r=this.parent.add(this.object,this.property,e);return r.name(this._name),this.destroy(),r}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.getValue()!==e&&(this.object[this.property]=e,this._callOnChange(),this.updateDisplay()),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}};
10class nOt extends OT{constructor(e,r,i){super(e,r,i,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function S$(t){let e,r;return(e=t.match(/(#|0x)?([a-f0-9]{6})/i))?r=e[2]:(e=t.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?r=parseInt(e[1]).toString(16).padStart(2,0)+parseInt(e[2]).toString(16).padStart(2,0)+parseInt(e[3]).toString(16).padStart(2,0):(e=t.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(r=e[1]+e[1]+e[2]+e[2]+e[3]+e[3]),r?"#"+r:!1}const aOt={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:S$,toHexString:S$},jO={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},lOt={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,r=1){const i=jO.fromHexString(t);e[0]=(i>>16&255)/255*r,e[1]=(i>>8&255)/255*r,e[2]=(i&255)/255*r},toHexString([t,e,r],i=1){i=255/i;const s=t*i<<16^e*i<<8^r*i<<0;return jO.toHexString(s)}},cOt={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,r=1){const i=jO.fromHexString(t);e.r=(i>>16&255)/255*r,e.g=(i>>8&255)/255*r,e.b=(i&255)/255*r},toHexString({r:t,g:e,b:r},i=1){i=255/i;const s=t*i<<16^e*i<<8^r*i<<0;return jO.toHexString(s)}},hOt=[aOt,jO,lOt,cOt];function uOt(t){return hOt.find(e=>e.match(t))}class dOt extends OT{constructor(e,r,i,s){super(e,r,i,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=uOt(this.initialValue),this._rgbScale=s,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const o=S$(this.$text.value);o&&this._setValueFromHexString(o)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const r=this._format.fromHexString(e);this.setValue(r)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class T$ extends OT{constructor(e,r,i){super(e,r,i,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",s=>{s.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class fOt extends OT{constructor(e,r,i,s,o,n){super(e,r,i,"number"),this._initInput(),this.min(s),this.max(o);const a=n!==void 0;this.step(a?n:this._getImplicitStep(),a),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,r=!0){return this._step=e,this._stepExplicit=r,this}updateDisplay(){const e=this.getValue();
10if(this._hasSlider){let r=(e-this._min)/(this._max-this._min);r=Math.max(0,Math.min(r,1)),this.$fill.style.width=r*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const e=()=>{let v=parseFloat(this.$input.value);isNaN(v)||(this._stepExplicit&&(v=this._snap(v)),this.setValue(this._clamp(v)))},r=v=>{const b=parseFloat(this.$input.value);isNaN(b)||(this._snapClampSetValue(b+v),this.$input.value=this.getValue())},i=v=>{v.key==="Enter"&&this.$input.blur(),v.code==="ArrowUp"&&(v.preventDefault(),r(this._step*this._arrowKeyMultiplier(v))),v.code==="ArrowDown"&&(v.preventDefault(),r(this._step*this._arrowKeyMultiplier(v)*-1))},s=v=>{this._inputFocused&&(v.preventDefault(),r(this._step*this._normalizeMouseWheel(v)))};let o=!1,n,a,l,c,h;const u=5,d=v=>{n=v.clientX,a=l=v.clientY,o=!0,c=this.getValue(),h=0,window.addEventListener("mousemove",f),window.addEventListener("mouseup",g)},f=v=>{if(o){const b=v.clientX-n,y=v.clientY-a;Math.abs(y)>u?(v.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(b)>u&&g()}if(!o){const b=v.clientY-l;h-=b*this._step*this._arrowKeyMultiplier(v),c+h>this._max?h=this._max-c:c+h<this._min&&(h=this._min-c),this._snapClampSetValue(c+h)}l=v.clientY},g=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",g)},p=()=>{this._inputFocused=!0},m=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",e),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",s,{passive:!1}),this.$input.addEventListener("mousedown",d),this.$input.addEventListener("focus",p),this.$input.addEventListener("blur",m)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(v,b,y,_,w)=>(v-b)/(y-b)*(w-_)+_,r=v=>{const b=this.$slider.getBoundingClientRect();let y=e(v,b.left,b.right,this._min,this._max);this._snapClampSetValue(y)},i=v=>{this._setDraggingStyle(!0),r(v.clientX),window.addEventListener("mousemove",s),window.addEventListener("mouseup",o)},s=v=>{r(v.clientX)},o=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",o)};let n=!1,a,l;const c=v=>{v.preventDefault(),this._setDraggingStyle(!0),r(v.touches[0].clientX),n=!1},h=v=>{v.touches.length>1||(this._hasScrollBar?(a=v.touches[0].clientX,l=v.touches[0].clientY,n=!0):c(v),window.addEventListener("touchmove",u,{passive:!1}),window.addEventListener("touchend",d))},u=v=>{if(n){const b=v.touches[0].clientX-a,y=v.touches[0].clientY-l;Math.abs(b)>Math.abs(y)?c(v):(window.removeEventListener("touchmove",u),window.removeEventListener("touchend",d))}else v.preventDefault(),r(v.touches[0].clientX)},d=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",u),window.removeEventListener("touchend",d)},f=this._callOnFinishChange.bind(this),g=400;let p;const m=v=>{if(Math.abs(v.deltaX)<Math.abs(v.deltaY)&&this._hasScrollBar)return;v.preventDefault();const b=this._normalizeMouseWheel(v)*this._step;this._snapClampSetValue(this.getValue()+b),this.$input.value=this.getValue(),clearTimeout(p),p=setTimeout(f,g)};this.$slider.addEventListener("mousedown",i),this.$slider.addEventListener("touchstart",h,{passive:!1}),this.$slider.addEventListener("wheel",m,{passive:!1})}_setDraggingStyle(e,r="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle(`lil-gui-${r}`,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}
vendor: 4,215 bytes, lines 10-69
10_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:r,deltaY:i}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(r=0,i=-e.wheelDelta/120,i*=this._stepExplicit?1:10),r+-i}_arrowKeyMultiplier(e){let r=this._stepExplicit?1:10;return e.shiftKey?r*=10:e.altKey&&(r/=10),r}_snap(e){const r=Math.round(e/this._step)*this._step;return parseFloat(r.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class pOt extends OT{constructor(e,r,i,s){super(e,r,i,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.options(s)}options(e){return this._values=Array.isArray(e)?e:Object.values(e),this._names=Array.isArray(e)?e:Object.keys(e),this.$select.replaceChildren(),this._names.forEach(r=>{const i=document.createElement("option");i.textContent=r,this.$select.appendChild(i)}),this.updateDisplay(),this}updateDisplay(){const e=this.getValue(),r=this._values.indexOf(e);return this.$select.selectedIndex=r,this.$display.textContent=r===-1?e:this._names[r],this}}class gOt extends OT{constructor(e,r,i){super(e,r,i,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("spellcheck","false"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",s=>{s.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}const mOt=`.lil-gui { 11 font-family: var(--font-family); 12 font-size: var(--font-size); 13 line-height: 1; 14 font-weight: normal; 15 font-style: normal; 16 text-align: left; 17 color: var(--text-color); 18 user-select: none; 19 -webkit-user-select: none; 20 touch-action: manipulation; 21 --background-color: #1f1f1f; 22 --text-color: #ebebeb; 23 --title-background-color: #111111; 24 --title-text-color: #ebebeb; 25 --widget-color: #424242; 26 --hover-color: #4f4f4f; 27 --focus-color: #595959; 28 --number-color: #2cc9ff; 29 --string-color: #a2db3c; 30 --font-size: 11px; 31 --input-font-size: 11px; 32 --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; 33 --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace; 34 --padding: 4px; 35 --spacing: 4px; 36 --widget-height: 20px; 37 --title-height: calc(var(--widget-height) + var(--spacing) * 1.25); 38 --name-width: 45%; 39 --slider-knob-width: 2px; 40 --slider-input-width: 27%; 41 --color-input-width: 27%; 42 --slider-input-min-width: 45px; 43 --color-input-min-width: 45px; 44 --folder-indent: 7px; 45 --widget-padding: 0 0 0 3px; 46 --widget-border-radius: 2px; 47 --checkbox-size: calc(0.75 * var(--widget-height)); 48 --scrollbar-width: 5px; 49} 50.lil-gui, .lil-gui * { 51 box-sizing: border-box; 52 margin: 0; 53 padding: 0; 54} 55.lil-gui.root { 56 width: var(--width, 245px); 57 display: flex; 58 flex-direction: column; 59 background: var(--background-color); 60} 61.lil-gui.root > .title { 62 background: var(--title-background-color); 63 color: var(--title-text-color); 64} 65.lil-gui.root > .children { 66 overflow-x: hidden; 67 overflow-y: auto; 68} 69.lil-gui.root > .children::-webkit-scrollbar {
70 width: var(--scrollbar-width); 71 height: var(--scrollbar-width); 72 background: var(--background-color); 73} 74.lil-gui.root > .children::-webkit-scrollbar-thumb { 75 border-radius: var(--scrollbar-width); 76 background: var(--focus-color); 77} 78@media (pointer: coarse) { 79 .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui { 80 --widget-height: 28px; 81 --padding: 6px; 82 --spacing: 6px; 83 --font-size: 13px; 84 --input-font-size: 16px; 85 --folder-indent: 10px; 86 --scrollbar-width: 7px; 87 --slider-input-min-width: 50px; 88 --color-input-min-width: 65px; 89 } 90} 91.lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui { 92 --widget-height: 28px; 93 --padding: 6px; 94 --spacing: 6px; 95 --font-size: 13px; 96 --input-font-size: 16px; 97 --folder-indent: 10px; 98 --scrollbar-width: 7px; 99 --slider-input-min-width: 50px; 100 --color-input-min-width: 65px; 101} 102.lil-gui.autoPlace { 103 max-height: 100%; 104 position: fixed; 105 top: 0; 106 right: 15px; 107 z-index: 1001; 108} 109 110.lil-gui .controller { 111 display: flex; 112 align-items: center; 113 padding: 0 var(--padding); 114 margin: var(--spacing) 0; 115} 116.lil-gui .controller.disabled { 117 opacity: 0.5; 118} 119.lil-gui .controller.disabled, .lil-gui .controller.disabled * { 120 pointer-events: none !important; 121} 122.lil-gui .controller > .name { 123 min-width: var(--name-width); 124 flex-shrink: 0; 125 white-space: pre; 126 padding-right: var(--spacing); 127 line-height: var(--widget-height); 128} 129.lil-gui .controller .widget { 130 position: relative; 131 display: flex; 132 align-items: center; 133 width: 100%; 134 min-height: var(--widget-height); 135} 136.lil-gui .controller.string input { 137 color: var(--string-color); 138} 139.lil-gui .controller.boolean { 140 cursor: pointer; 141} 142.lil-gui .controller.color .display { 143 width: 100%; 144 height: var(--widget-height); 145 border-radius: var(--widget-border-radius); 146 position: relative; 147} 148@media (hover: hover) { 149 .lil-gui .controller.color .display:hover:before { 150 content: " "; 151 display: block; 152 position: absolute; 153 border-radius: var(--widget-border-radius); 154 border: 1px solid #fff9; 155 top: 0; 156 right: 0; 157 bottom: 0; 158 left: 0; 159 } 160} 161.lil-gui .controller.color input[type=color] { 162 opacity: 0; 163 width: 100%; 164 height: 100%; 165 cursor: pointer; 166} 167.lil-gui .controller.color input[type=text] { 168 margin-left: var(--spacing); 169 font-family: var(--font-family-mono); 170 min-width: var(--color-input-min-width); 171 width: var(--color-input-width); 172 flex-shrink: 0; 173} 174.lil-gui .controller.option select { 175 opacity: 0; 176 position: absolute; 177 width: 100%; 178 max-width: 100%; 179} 180.lil-gui .controller.option .display { 181 position: relative; 182 pointer-events: none; 183 border-radius: var(--widget-border-radius); 184 height: var(--widget-height); 185 line-height: var(--widget-height); 186 max-width: 100%; 187 overflow: hidden; 188 word-break: break-all; 189 padding-left: 0.55em; 190 padding-right: 1.75em; 191 background: var(--widget-color); 192} 193@media (hover: hover) { 194 .lil-gui .controller.option .display.focus { 195 background: var(--focus-color); 196 } 197} 198.lil-gui .controller.option .display.active { 199 background: var(--focus-color); 200} 201.lil-gui .controller.option .display:after { 202 font-family: "lil-gui"; 203 content: "\u2195"; 204 position: absolute; 205 top: 0; 206 right: 0; 207 bottom: 0; 208 padding-right: 0.375em; 209} 210.lil-gui .controller.option .widget, 211.lil-gui .controller.option select { 212 cursor: pointer; 213} 214@media (hover: hover) { 215 .lil-gui .controller.option .widget:hover .display { 216 background: var(--hover-color); 217 } 218} 219.lil-gui .controller.number input { 220 color: var(--number-color); 221} 222.lil-gui .controller.number.hasSlider input { 223 margin-left: var(--spacing); 224 width: var(--slider-input-width); 225 min-width: var(--slider-input-min-width); 226 flex-shrink: 0; 227} 228.lil-gui .controller.number .slider { 229 width: 100%; 230 height: var(--widget-height); 231 background: var(--widget-color); 232 border-radius: var(--widget-border-radius); 233 padding-right: var(--slider-knob-width); 234 overflow: hidden; 235 cursor: ew-resize; 236 touch-action: pan-y; 237} 238@media (hover: hover) { 239 .lil-gui .controller.number .slider:hover { 240 background: var(--hover-color); 241 } 242} 243.lil-gui .controller.number .slider.active { 244 background: var(--focus-color); 245} 246.lil-gui .controller.number .slider.active .fill { 247 opacity: 0.95; 248} 249.lil-gui .controller.number .fill { 250 height: 100%; 251 border-right: var(--slider-knob-width) solid var(--number-color); 252 box-sizing: content-box; 253} 254 255.lil-gui-dragging .lil-gui { 256 --hover-color: var(--widget-color); 257} 258.lil-gui-dragging * { 259 cursor: ew-resize !important; 260} 261
262.lil-gui-dragging.lil-gui-vertical * { 263 cursor: ns-resize !important; 264} 265 266.lil-gui .title { 267 height: var(--title-height); 268 line-height: calc(var(--title-height) - 4px); 269 font-weight: 600; 270 padding: 0 var(--padding); 271 -webkit-tap-highlight-color: transparent; 272 cursor: pointer; 273 outline: none; 274 text-decoration-skip: objects; 275} 276.lil-gui .title:before { 277 font-family: "lil-gui"; 278 content: "\u25BE"; 279 padding-right: 2px; 280 display: inline-block; 281} 282.lil-gui .title:active { 283 background: var(--title-background-color); 284 opacity: 0.75; 285} 286@media (hover: hover) { 287 body:not(.lil-gui-dragging) .lil-gui .title:hover { 288 background: var(--title-background-color); 289 opacity: 0.85; 290 } 291 .lil-gui .title:focus { 292 text-decoration: underline var(--focus-color); 293 } 294} 295.lil-gui.root > .title:focus { 296 text-decoration: none !important; 297} 298.lil-gui.closed > .title:before { 299 content: "\u25B8"; 300} 301.lil-gui.closed > .children { 302 transform: translateY(-7px); 303 opacity: 0; 304} 305.lil-gui.closed:not(.transition) > .children { 306 display: none; 307} 308.lil-gui.transition > .children { 309 transition-duration: 300ms; 310 transition-property: height, opacity, transform; 311 transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1); 312 overflow: hidden; 313 pointer-events: none; 314} 315.lil-gui .children:empty:before { 316 content: "Empty"; 317 padding: 0 var(--padding); 318 margin: var(--spacing) 0; 319 display: block; 320 height: var(--widget-height); 321 font-style: italic; 322 line-height: var(--widget-height); 323 opacity: 0.5; 324} 325.lil-gui.root > .children > .lil-gui > .title { 326 border: 0 solid var(--widget-color); 327 border-width: 1px 0; 328 transition: border-color 300ms; 329} 330.lil-gui.root > .children > .lil-gui.closed > .title { 331 border-bottom-color: transparent; 332} 333.lil-gui + .controller { 334 border-top: 1px solid var(--widget-color); 335 margin-top: 0; 336 padding-top: var(--spacing); 337} 338.lil-gui .lil-gui .lil-gui > .title { 339 border: none; 340} 341.lil-gui .lil-gui .lil-gui > .children { 342 border: none; 343 margin-left: var(--folder-indent); 344 border-left: 2px solid var(--widget-color); 345} 346.lil-gui .lil-gui .controller { 347 border: none; 348} 349 350.lil-gui label, .lil-gui input, .lil-gui button { 351 -webkit-tap-highlight-color: transparent; 352} 353.lil-gui input { 354 border: 0; 355 outline: none; 356 font-family: var(--font-family); 357 font-size: var(--input-font-size); 358 border-radius: var(--widget-border-radius); 359 height: var(--widget-height); 360 background: var(--widget-color); 361 color: var(--text-color); 362 width: 100%; 363} 364@media (hover: hover) { 365 .lil-gui input:hover { 366 background: var(--hover-color); 367 } 368 .lil-gui input:active { 369 background: var(--focus-color); 370 } 371} 372.lil-gui input:disabled { 373 opacity: 1; 374} 375.lil-gui input[type=text], 376.lil-gui input[type=number] { 377 padding: var(--widget-padding); 378 -moz-appearance: textfield; 379} 380.lil-gui input[type=text]:focus, 381.lil-gui input[type=number]:focus { 382 background: var(--focus-color); 383} 384.lil-gui input[type=checkbox] { 385 appearance: none; 386 width: var(--checkbox-size); 387 height: var(--checkbox-size); 388 border-radius: var(--widget-border-radius); 389 text-align: center; 390 cursor: pointer; 391} 392.lil-gui input[type=checkbox]:checked:before { 393 font-family: "lil-gui"; 394 content: "\u2713"; 395 font-size: var(--checkbox-size); 396 line-height: var(--checkbox-size); 397} 398@media (hover: hover) { 399 .lil-gui input[type=checkbox]:focus { 400 box-shadow: inset 0 0 0 1px var(--focus-color); 401 } 402} 403.lil-gui button { 404 outline: none; 405 cursor: pointer; 406 font-family: var(--font-family); 407 font-size: var(--font-size); 408 color: var(--text-color); 409 width: 100%; 410 height: var(--widget-height); 411 text-transform: none; 412 background: var(--widget-color); 413 border-radius: var(--widget-border-radius); 414 border: none; 415} 416@media (hover: hover) { 417 .lil-gui button:hover { 418 background: var(--hover-color); 419 } 420 .lil-gui button:focus { 421 box-shadow: inset 0 0 0 1px var(--focus-color); 422 } 423} 424.lil-gui button:active { 425 background: var(--focus-color); 426} 427 428@font-face { 429 font-family: "lil-gui"; 430 src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y
4307HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff"); 431}`;function yOt(t){const e=document.createElement("style");e.innerHTML=t;const r=document.querySelector("head link[rel=stylesheet], head style");r?document.head.insertBefore(e,r):document.head.appendChild(e)}let Vst=!1;ZV=class{constructor({parent:t,autoPlace:e=t===void 0,container:r,width:i,title:s="Controls",closeFolders:o=!1,injectStyles:n=!0,touchStyles:a=!0}={}){if(this.parent=t,this.root=t?t.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",l=>{(l.code==="Enter"||l.code==="Space")&&(l.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(s),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),a&&this.domElement.classList.add("allow-touch-styles"),!Vst&&n&&(yOt(mOt),Vst=!0),r?r.appendChild(this.domElement):e&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),i&&this.domElement.style.setProperty("--width",i+"px"),this._closeFolders=o}add(t,e,r,i,s){if(Object(r)===r)return new pOt(this,t,e,r);const o=t[e];switch(typeof o){case"number":return new fOt(this,t,e,r,i,s);case"boolean":return new nOt(this,t,e);case"string":return new gOt(this,t,e);case"function":return new T$(this,t,e)}console.error(`gui.add failed 432 property:`,e,` 433 object:`,t,` 434 value:`,o)}addColor(t,e,r=1){return new dOt(this,t,e,r)}addFolder(t){const e=new ZV({parent:this,title:t});return this.root._closeFolders&&e.close(),e}load(t,e=!0){return t.controllers&&this.controllers.forEach(r=>{r instanceof T$||r._name in t.controllers&&r.load(t.controllers[r._name])}),e&&t.folders&&this.folders.forEach(r=>{r._title in t.folders&&r.load(t.folders[r._title])}),this}save(t=!0){const e={controllers:{},folders:{}};return this.controllers.forEach(r=>{if(!(r instanceof T$)){if(r._name in e.controllers)throw new Error(`Cannot save GUI with duplicate property "${r._name}"`);e.controllers[r._name]=r.save()}}),t&&this.folders.forEach(r=>{if(r._title in e.folders)throw new Error(`Cannot save GUI with duplicate folder "${r._title}"`);e.folders[r._title]=r.save()}),e}open(t=!0){return this._setClosed(!t),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(t){this._closed!==t&&(this._closed=t,this._callOnOpenClose(this))}show(t=!0){return this._hidden=!t,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(t=!0){return this._setClosed(!t),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const e=this.$children.clientHeight;this.$children.style.height=e+"px",this.domElement.classList.add("transition");const r=s=>{s.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",r))};this.$children.addEventListener("transitionend",r);const i=t?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!t),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(t){return this._title=t,this.$title.textContent=t,this}reset(t=!0){return(t?this.controllersRecursive():this.controllers).forEac
434h(e=>e.reset()),this}onChange(t){return this._onChange=t,this}_callOnChange(t){this.parent&&this.parent._callOnChange(t),this._onChange!==void 0&&this._onChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}onFinishChange(t){return this._onFinishChange=t,this}_callOnFinishChange(t){this.parent&&this.parent._callOnFinishChange(t),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}onOpenClose(t){return this._onOpenClose=t,this}_callOnOpenClose(t){this.parent&&this.parent._callOnOpenClose(t),this._onOpenClose!==void 0&&this._onOpenClose.call(this,t)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(t=>t.destroy())}controllersRecursive(){let t=Array.from(this.controllers);return this.folders.forEach(e=>{t=t.concat(e.controllersRecursive())}),t}foldersRecursive(){let t=Array.from(this.folders);return this.folders.forEach(e=>{t=t.concat(e.foldersRecursive())}),t}};function vOt(t,e,r,i,s){Yst(t,e,r||0,i||t.length-1,s||_Ot)}function Yst(t,e,r,i,s){for(;i>r;){if(i-r>600){var o=i-r+1,n=e-r+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(n-o/2<0?-1:1),h=Math.max(r,Math.floor(e-n*l/o+c)),u=Math.min(i,Math.floor(e+(o-n)*l/o+c));Yst(t,e,h,u,s)}var d=t[e],f=r,g=i;for(XO(t,r,e),s(t[i],d)>0&&XO(t,r,i);f<g;){for(XO(t,f,g),f++,g--;s(t[f],d)<0;)f++;for(;s(t[g],d)>0;)g--}s(t[r],d)===0?XO(t,r,g):(g++,XO(t,g,i)),g<=e&&(r=g+1),e<=g&&(i=g-1)}}function XO(t,e,r){var i=t[e];t[e]=t[r],t[r]=i}function _Ot(t,e){return t<e?-1:t>e?1:0}let TE=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const r=[];if(!C4(t,e))return r;const i=this.toBBox,s=[];for(;e;){for(let o=0;o<e.children.length;o++){const n=e.children[o],a=e.leaf?i(n):n;C4(t,a)&&(e.leaf?r.push(n):C$(t,a)?this._all(n,r):s.push(n))}e=s.pop()}return r}collides(t){let e=this.data;if(!C4(t,e))return!1;const r=[];for(;e;){for(let i=0;i<e.children.length;i++){const s=e.children[i],o=e.leaf?this.toBBox(s):s;
vendor: 4,889 bytes, line 434
434if(C4(t,o)){if(e.leaf||C$(t,o))return!0;r.push(s)}}e=r.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let r=0;r<t.length;r++)this.insert(t[r]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const r=this.data;this.data=e,e=r}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=DT([]),this}remove(t,e){if(!t)return this;let r=this.data;const i=this.toBBox(t),s=[],o=[];let n,a,l;for(;r||s.length;){if(r||(r=s.pop(),a=s[s.length-1],n=o.pop(),l=!0),r.leaf){const c=bOt(t,r.children,e);if(c!==-1)return r.children.splice(c,1),s.push(r),this._condense(s),this}!l&&!r.leaf&&C$(r,i)?(s.push(r),o.push(n),n=0,a=r,r=r.children[0]):a?(n++,r=a.children[n],l=!1):r=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const r=[];for(;t;)t.leaf?e.push(...t.children):r.push(...t.children),t=r.pop();return e}_build(t,e,r,i){const s=r-e+1;let o=this._maxEntries,n;if(s<=o)return n=DT(t.slice(e,r+1)),IT(n,this.toBBox),n;i||(i=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,i-1))),n=DT([]),n.leaf=!1,n.height=i;const a=Math.ceil(s/o),l=a*Math.ceil(Math.sqrt(o));$st(t,e,r,l,this.compareMinX);for(let c=e;c<=r;c+=l){const h=Math.min(c+l-1,r);$st(t,c,h,a,this.compareMinY);for(let u=c;u<=h;u+=a){const d=Math.min(u+a-1,h);n.children.push(this._build(t,u,d,i-1))}}return IT(n,this.toBBox),n}_chooseSubtree(t,e,r,i){for(;i.push(e),!(e.leaf||i.length-1===r);){let s=1/0,o=1/0,n;for(let a=0;a<e.children.length;a++){const l=e.children[a],c=R$(l),h=AOt(t,l)-c;h<o?(o=h,s=c<s?c:s,n=l):h===o&&c<s&&(s=c,n=l)}e=n||e.children[0]}return e}_insert(t,e,r){const i=r?t:this.toBBox(t),s=[],o=this._chooseSubtree(i,this.data,e,s);for(o.children.push(t),VO(o,i);e>=0&&s[e].children.length>this._maxEntries;)this._split(s,e),e--;this._adjustParentBBoxes(i,s,e)}_split(t,e){const r=t[e],i=r.children.length,s=this._minEntries;this._chooseSplitAxis(r,s,i);const o=this._chooseSplitIndex(r,s,i),n=DT(r.children.splice(o,r.children.length-o));n.height=r.height,n.leaf=r.leaf,IT(r,this.toBBox),IT(n,this.toBBox),e?t[e-1].children.push(n):this._splitRoot(r,n)}_splitRoot(t,e){this.data=DT([t,e]),this.data.height=t.height+1,this.data.leaf=!1,IT(this.data,this.toBBox)}_chooseSplitIndex(t,e,r){let i,s=1/0,o=1/0;for(let n=e;n<=r-e;n++){const a=zO(t,0,n,this.toBBox),l=zO(t,n,r,this.toBBox),c=xOt(a,l),h=R$(a)+R$(l);c<s?(s=c,i=n,o=h<o?h:o):c===s&&h<o&&(o=h,i=n)}return i||r-e}_chooseSplitAxis(t,e,r){const i=t.leaf?this.compareMinX:wOt,s=t.leaf?this.compareMinY:EOt,o=this._allDistMargin(t,e,r,i),n=this._allDistMargin(t,e,r,s);o<n&&t.children.sort(i)}_allDistMargin(t,e,r,i){t.children.sort(i);const s=this.toBBox,o=zO(t,0,e,s),n=zO(t,r-e,r,s);let a=R4(o)+R4(n);for(let l=e;l<r-e;l++){const c=t.children[l];VO(o,t.leaf?s(c):c),a+=R4(o)}for(let l=r-e-1;l>=e;l--){const c=t.children[l];VO(n,t.leaf?s(c):c),a+=R4(n)}return a}_adjustParentBBoxes(t,e,r){for(let i=r;i>=0;i--)VO(e[i],t)}_condense(t){for(let e=t.length-1,r;e>=0;e--)t[e].children.length===0?e>0?(r=t[e-1].children,r.splice(r.indexOf(t[e]),1)):this.clear():IT(t[e],this.toBBox)}};function bOt(t,e,r){if(!r)return e.indexOf(t);for(let i=0;i<e.length;i++)if(r(t,e[i]))return i;return-1}function IT(t,e){zO(t,0,t.children.length,e,t)}function zO(t,e,r,i,s){s||(s=DT(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let o=e;o<r;o++){const n=t.children[o];VO(s,t.leaf?i(n):n)}return s}function VO(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function wOt(t,e){return t.minX-e.minX}function EOt(t,e){return t.minY-e.minY}function R$(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function R4(t){return t.maxX-t.minX+(t.maxY-t.minY)}function AOt(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function xOt(t,e){const r=Math.max(t.minX,e.minX),i=Math.max(t.minY,e.minY),s=Math.min(t.maxX,e.maxX),o=Math.min(t.maxY,e.maxY);return Math.max(0,s-r)*Math.max(0,o-i)}function C$(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function C4(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function DT(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function $st(t,e,r,i,s){const o=[e,r];for(;o.length;){if(r=o.pop(),e=o.pop(),r-e<=i)continue;const n=e+Math.ceil((r-e)/i/2)*i;vOt(t,n,e,r,s),o.push(e,n,n,r)}}me=function(t){return t==null},Na=function(t){return typeof t=="string"};var Hst=function(t,e,r){return t<e?e:t>
434r?r:t};lc=function(t){return typeof t=="number"};let PT,Xl;ytt=function(t){return t===void 0},PT=1e-6,Xl=typeof Float32Array<"u"?Float32Array:Array,Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),Bt=function(){var t=new Xl(9);return Xl!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t};function Kst(t){var e=new Xl(9);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function fp(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function SOt(t,e,r,i,s,o,n,a,l){var c=new Xl(9);return c[0]=t,c[1]=e,c[2]=r,c[3]=i,c[4]=s,c[5]=o,c[6]=n,c[7]=a,c[8]=l,c}function Yc(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function _i(t,e){var r=e[0],i=e[1],s=e[2],o=e[3],n=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=h*n-a*c,d=-h*o+a*l,f=c*o-n*l,g=r*u+i*d+s*f;return g?(g=1/g,t[0]=u*g,t[1]=(-h*i+s*c)*g,t[2]=(a*i-s*n)*g,t[3]=d*g,t[4]=(h*r-s*l)*g,t[5]=(-a*r+s*o)*g,t[6]=f*g,t[7]=(-c*r+i*l)*g,t[8]=(n*r-i*o)*g,t):null}us=function(t,e,r){var i=e[0],s=e[1],o=e[2],n=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=r[0],f=r[1],g=r[2],p=r[3],m=r[4],v=r[5],b=r[6],y=r[7],_=r[8];return t[0]=d*i+f*n+g*c,t[1]=d*s+f*a+g*h,t[2]=d*o+f*l+g*u,t[3]=p*i+m*n+v*c,t[4]=p*s+m*a+v*h,t[5]=p*o+m*l+v*u,t[6]=b*i+y*n+_*c,t[7]=b*s+y*a+_*h,t[8]=b*o+y*l+_*u,t};function bi(t,e,r){var i=e[0],s=e[1],o=e[2],n=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=r[0],f=r[1];return t[0]=i,t[1]=s,t[2]=o,t[3]=n,t[4]=a,t[5]=l,t[6]=d*i+f*n+c,t[7]=d*s+f*a+h,t[8]=d*o+f*l+u,t}function Mo(t,e,r){var i=e[0],s=e[1],o=e[2],n=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=Math.sin(r),f=Math.cos(r);return t[0]=f*i+d*n,t[1]=f*s+d*a,t[2]=f*o+d*l,t[3]=f*n-d*i,t[4]=f*a-d*s,t[5]=f*l-d*o,t[6]=c,t[7]=h,t[8]=u,t}function xh(t,e,r){var i=r[0],s=r[1];return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=s*e[3],t[4]=s*e[4],t[5]=s*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}eG=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e[0],t[7]=e[1],t[8]=1,t},TV=function(t,e){var r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=0,t[3]=-r,t[4]=i,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t};function qst(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=e[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function ld(t,e,r){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/r,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t}function cc(){var t=new Xl(16);return Xl!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function TOt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function ROt(t,e,r,i,s,o,n,a,l,c,h,u,d,f,g,p){var m=new Xl(16);return m[0]=t,m[1]=e,m[2]=r,m[3]=i,m[4]=s,m[5]=o,m[6]=n,m[7]=a,m[8]=l,m[9]=c,m[10]=h,m[11]=u,m[12]=d,m[13]=f,m[14]=g,m[15]=p,m}function COt(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function M$(t,e){if(t===e){var r=e[1],i=e[2],s=e[3],o=e[6],n=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=o,t[11]=e[14],t[12]=s,t[13]=n,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function M4(t,e){var r=e[0],i=e[1],s=e[2],o=e[3],n=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],f=e[11],g=e[12],p=e[13],m=e[14],v=e[15],b=r*a-i*n,y=r*l-s*n,_=r*c-o*n,w=i*l-s*a,E=i*c-o*a,A=s*c-o*l,x=h*p-u*g,S=h*m-d*g,T=h*v-f*g,R=u*m-d*p,B=u*v-f*p,O=d*v-f*m,C=b*O-y*B+_*R+w*T-E*S+A*x;return C?(C=1/C,t[0]=(a*O-l*B+c*R)*C,t[1]=(s*B-i*O-o*R)*C,t[2]=(p*A-m*E+v*w)*C,t[3]=(d*E-u*A-f*w)*C,t[4]=(l*T-n*O-c*S)*C,t[5]=(r*O-s*T+o*S)*C,t[6]=(m*_-g*A-v*y)*C,t[7]=(h*A-d*_+f*y)*C,t[8]=(n*B-a*T+c*x)*C,t[9]=(i*T-r*B-o*x)*C,t[10]=(g*E-p*_+v*b)*C,t[11]=(u*_-h*E-f*b)*C,t[12]=(a*S-n*R-l*x)*C,t[13]=(r*R-i*S+s*x)*C,t[14]=(p*y-g*w-m*b)*C,t[15]=(h*w-u*y+d*b)*C,t):null}function B$(t,e,r){var i=e[0],s=e[1],o=e[2],n=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=e[9],f=e[10],g=e[11],p=e[12],m=e[13],v=e[14],b=e[15],y=r[0],_=r[1],w=r[2],E=r[3];return t[0]=y*i+_*a+w*u+E*p,t[1]=y*s+_*l+w*d+E*m,t[2]=y*o+_*c+w*f+E*v,t[3]=y*n+_*h+w*g+E*b,y=r[4],_=r[5],w=r[6],E=r[7],t[4]=y*i+_*a+w*u+E*p,t[5]=y*s+_*l+w*d+E*m,t[6]=y*o+_*c+w*f+E*v,t[7]=y*n+_*h+w*g+E*b,y=r[8],_=r[9],w=r[10],E=r[11],t[8]=y*i+_*a+w*u+E*p,t[9]=y*s+_*l+w*d+E*m,t[10]=y*o+_*c+w*f+E*v,t[11]=y*n+_*h+w*g+E*b,y=r[12],_=r[13],w=r[14],E=r[15],t[12]=y*i+_*a+w*u+E*p,t[13]=y*s+_*l+w*d+E*m,t[14]=y*o+_*c+w*f+E*v,t[15]=y*n+_*h+w*g+E*b,t}function O$(t,e,r){var i=r[0],s=r[1],o=r[2],n,a,l,c,h,u,d,f,g,p,m,v;return e===t?(t[12]=e[0]*i+e[4]*s+e[8]*o+e[12],t[13]=e[1]*i+e[5]*s+e[9]*o+e[13],t[14]=e[2]*i+e[6]*s+e[10]*o+e[14],t[15]=e[3]*i+e[7]*s+e[11]*o+e[15]):(n=e[0],a=e[1],l=e[2],c=e[3],h=e[4],u=e[5],d=e[6],f=e[7],g=e[8],p=e[9],m=e[10],v=e[11],t[0]=n,t[1]=a,t[2]=l,t[3]=c,t[4]=h,t[5]=u,t[6]=d,t[7]=f,t[8]=g,t[9]=p,t[10]=m,t[11]=v,t[12]=n*i+h*s+g*o+e[12],t[13]=a*i+u*s+p*o+e[13],t[14]=l*i+d*s+m*o+e[14],t[15]=c*i+f*s+v*o+e[15]),t}function I$(t,e,r){var i=r[0],s=r[1],o=r[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function YO(t,e,r){var i=Math.sin(r),s=Math.cos(r),o=e[4],n=e[5],a=e[6],l=e[7],c=e[8],h=e[9],u=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*s+c*i,t[5]=n*s+h*i,t[6]=a*s+u*i,t[7]=l*s+d*i,t[8]=c*s-o*i,t[9]=h*s-n*i,t[10]=u*s-a*i,t[11]=d*s-l*i,t}function $O(t,e,r){var i=Math.sin(r),s=Math.cos(r),o=e[0],n=e[1],a=e[2],l=e[3],c=e[8],h=e[9],u=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*s-c*i,t[1]=n*s-h*i,t[2]=a*s-u*i,t[3]=l*s-d*i,t[8]=o*i+c*s,t[9]=n*i+h*s,t[10]=a*i+u*s,t[11]=l*i+d*s,t}function HO(t,e,r){var i=Math.sin(r),s=Math.cos(r),o=e[0],n=e[1],a=e[2],l=e[3],c=e[4],h=e[5],u=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*s+c*i,t[1]=n*s+h*i,t[2]=a*s+u*i,t[3]=l*s+d*i,t[4]=c*s-o*i,t[5]=h*s-n*i,t[6]=u*s-a*i,t[7]=d*s-l*i,t}function MOt(t,e,r,i){var s=e[0],o=e[1],n=e[2],a=e[3],l=s+s,c=o+o,h=n+n,u=s*l,d=s*c,f=s*h,g=
434o*c,p=o*h,m=n*h,v=a*l,b=a*c,y=a*h,_=i[0],w=i[1],E=i[2];return t[0]=(1-(g+m))*_,t[1]=(d+y)*_,t[2]=(f-b)*_,t[3]=0,t[4]=(d-y)*w,t[5]=(1-(u+m))*w,t[6]=(p+v)*w,t[7]=0,t[8]=(f+b)*E,t[9]=(p-v)*E,t[10]=(1-(u+g))*E,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function BOt(t,e,r,i,s){var o=1/Math.tan(e/2),n;return t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,s!=null&&s!==1/0?(n=1/(i-s),t[10]=(s+i)*n,t[14]=2*s*i*n):(t[10]=-1,t[14]=-2*i),t}var OOt=BOt;function IOt(t,e,r,i,s,o,n){var a=1/(e-r),l=1/(i-s),c=1/(o-n);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+r)*a,t[13]=(s+i)*l,t[14]=(n+o)*c,t[15]=1,t}var DOt=IOt;function POt(t,e,r,i){var s,o,n,a,l,c,h,u,d,f,g=e[0],p=e[1],m=e[2],v=i[0],b=i[1],y=i[2],_=r[0],w=r[1],E=r[2];return Math.abs(g-_)<PT&&Math.abs(p-w)<PT&&Math.abs(m-E)<PT?COt(t):(h=g-_,u=p-w,d=m-E,f=1/Math.hypot(h,u,d),h*=f,u*=f,d*=f,s=b*d-y*u,o=y*h-v*d,n=v*u-b*h,f=Math.hypot(s,o,n),f?(f=1/f,s*=f,o*=f,n*=f):(s=0,o=0,n=0),a=u*n-d*o,l=d*s-h*n,c=h*o-u*s,f=Math.hypot(a,l,c),f?(f=1/f,a*=f,l*=f,c*=f):(a=0,l=0,c=0),t[0]=s,t[1]=a,t[2]=h,t[3]=0,t[4]=o,t[5]=l,t[6]=u,t[7]=0,t[8]=n,t[9]=c,t[10]=d,t[11]=0,t[12]=-(s*g+o*p+n*m),t[13]=-(a*g+l*p+c*m),t[14]=-(h*g+u*p+d*m),t[15]=1,t)}function Xa(){var t=new Xl(3);return Xl!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Zst(t){var e=t[0],r=t[1],i=t[2];return Math.hypot(e,r,i)}function Wv(t,e,r){var i=new Xl(3);return i[0]=t,i[1]=e,i[2]=r,i}function d0(t,e,r,i){return t[0]=e,t[1]=r,t[2]=i,t}function KO(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function FOt(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function qO(t,e){var r=e[0],i=e[1],s=e[2],o=r*r+i*i+s*s;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function FT(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Jst(t,e,r){var i=e[0],s=e[1],o=e[2],n=r[0],a=r[1],l=r[2];return t[0]=s*l-o*a,t[1]=o*n-i*l,t[2]=i*a-s*n,t}function sf(t,e,r){var i=e[0],s=e[1],o=e[2],n=r[3]*i+r[7]*s+r[11]*o+r[15];return n=n||1,t[0]=(r[0]*i+r[4]*s+r[8]*o+r[12])/n,t[1]=(r[1]*i+r[5]*s+r[9]*o+r[13])/n,t[2]=(r[2]*i+r[6]*s+r[10]*o+r[14])/n,t}(function(){var t=Xa();return function(e,r,i,s,o,n){var a,l;for(r||(r=3),i||(i=0),s?l=Math.min(s*r+i,e.length):l=e.length,a=i;a<l;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],o(t,t,n),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}})();function f0(){var t=new Xl(4);return Xl!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function NT(t,e,r,i){var s=new Xl(4);return s[0]=t,s[1]=e,s[2]=r,s[3]=i,s}function jv(t,e,r){var i=e[0],s=e[1],o=e[2],n=e[3];return t[0]=r[0]*i+r[4]*s+r[8]*o+r[12]*n,t[1]=r[1]*i+r[5]*s+r[9]*o+r[13]*n,t[2]=r[2]*i+r[6]*s+r[10]*o+r[14]*n,t[3]=r[3]*i+r[7]*s+r[11]*o+r[15]*n,t}(function(){var t=f0();return function(e,r,i,s,o,n){var a,l;for(r||(r=4),i||(i=0),s?l=Math.min(s*r+i,e.length):l=e.length,a=i;a<l;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],o(t,t,n),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}})(),it=function(){var t=new Xl(2);return Xl!=Float32Array&&(t[0]=0,t[1]=0),t},Ta=function(t){var e=new Xl(2);return e[0]=t[0],e[1]=t[1],e},Be=function(t,e){var r=new Xl(2);return r[0]=t,r[1]=e,r},di=function(t,e){return t[0]=e[0],t[1]=e[1],t},Jn=function(t,e,r){return t[0]=e,t[1]=r,t},Aa=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t};function NOt(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}$y=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t},Ea=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},lG=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t},Hy=function(t,e){var r=e[0]-t[0],i=e[1]-t[1];return Math.hypot(r,i)};function D$(t,e){var r=e[0]-t[0],i=e[1]-t[1];return r*r+i*i}rm=function(t){var e=t[0],r=t[1];return Math.hypot(e,r)},aE=function(t,e){var r=e[0],i=e[1],s=r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t},Yy=function(t,e){return t[0]*e[0]+t[1]*e[1]};function ta(t,e,r,i){var s=e[0],o=e[1];return t[0]=s+i*(r[0]-s),t[1]=o+i*(r[1]-o),t}Qt=function(t,e,r){var i=e[0],s=e[1];return t[0]=r[0]*i+r[3]*s+r[6],t[1]=r[1]*i+r[4]*s+r[7],t},hO=function(t,e){return t[0]===e[0]&&t[1]===e[1]},sd=function(t,e){var r=t[0],i=t[1],s=e[0],o=e[1];return Math.abs(r-s)<=PT*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-o)<=PT*Math.max(1,Math.abs(i),Math.abs(o))};let P$,za;P$=rm,ru=NOt,za=Hy,(function(){var t=it();return function(e,r,i,s,o,n){var a,l;for(r||(r=2),i||(i=0),s?l=Math.min(s*r+i,e.length):l=e.length,a=i;a<l;a+=r)t[0]=e[a],t[1]=e[a+1],o(t,t,n),e[a]=t[0],e[a+1]=t[1];return e}})();function kOt(t,e){if(e==="off")return[].concat(t);var r=typeof e=="number"&&e>=1?Math.pow(10,e):1;return t.map(function(i){var s=i.slice(1).map(Number).map(function(o){return e?Math.round(o*r)/r:Math.round(o)});return[i[0]].concat(s)})}Bv=function(t,e){return e===void 0&&(e="off"),kOt(t,e).map(function(r){return r[0]+r.slice(1).join(" ")}).join("")};var Qst={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function LOt(t,e,r){if(t[r].length>7){t[r].shift();for(var i=t[r],s=r;i.length;)e[r]="A",t.splice(s+=1,0,["C"].concat(i.splice(0,6)));t.splice(r,1)}}var ZO={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function tot(t){return Array.isArray(t)&&t.every(function(e){var r=e[0].toLowerCase();return ZO[r]===e.length-1&&"achlmqstvz".includes(r)})}function eot(t){return tot(t)&&t.every(function(e){var r=e[0];return r===r.toUpperCase()})}function rot(t){return eot(t)&&t.every(function(e){var r=e[0];return"ACLMQZ".includes(r)})}function iot(t){for(var e=t.pathValue[t.segmentStart],r=e.toLowerCase(),i=t.data;i.length>=ZO[r]&&(r==="m"&&i.length>2?(t.segments.push([e].concat(i.splice(0,2))),r="l",e=e==="m"?"l":"L"):t.segments.push([e].concat(i.splice(0,ZO[r]))),!!ZO[r]););}function UOt(t){var e=t.index,r=t.pathValue,i=r.charCodeAt(e);if(i===48){t.param=0,t.index+=1;return}if(i===49){t.param=1,t.index+=1;return}
434t.err='[path-util]: invalid Arc flag "'.concat(r[e],'", expecting 0 or 1 at index ').concat(e)}function GOt(t){return t>=48&&t<=57||t===43||t===45||t===46}function kT(t){return t>=48&&t<=57}function WOt(t){var e=t.max,r=t.pathValue,i=t.index,s=i,o=!1,n=!1,a=!1,l=!1,c;if(s>=e){t.err="[path-util]: Invalid path value at index ".concat(s,', "pathValue" is missing param');return}if(c=r.charCodeAt(s),(c===43||c===45)&&(s+=1,c=r.charCodeAt(s)),!kT(c)&&c!==46){t.err="[path-util]: Invalid path value at index ".concat(s,', "').concat(r[s],'" is not a number');return}if(c!==46){if(o=c===48,s+=1,c=r.charCodeAt(s),o&&s<e&&c&&kT(c)){t.err="[path-util]: Invalid path value at index ".concat(i,', "').concat(r[i],'" illegal number');return}for(;s<e&&kT(r.charCodeAt(s));)s+=1,n=!0;c=r.charCodeAt(s)}if(c===46){for(l=!0,s+=1;kT(r.charCodeAt(s));)s+=1,a=!0;c=r.charCodeAt(s)}if(c===101||c===69){if(l&&!n&&!a){t.err="[path-util]: Invalid path value at index ".concat(s,', "').concat(r[s],'" invalid float exponent');return}if(s+=1,c=r.charCodeAt(s),(c===43||c===45)&&(s+=1),s<e&&kT(r.charCodeAt(s)))for(;s<e&&kT(r.charCodeAt(s));)s+=1;else{t.err="[path-util]: Invalid path value at index ".concat(s,', "').concat(r[s],'" invalid integer exponent');return}}t.index=s,t.param=+t.pathValue.slice(i,s)}function jOt(t){var e=[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];return t===10||t===13||t===8232||t===8233||t===32||t===9||t===11||t===12||t===160||t>=5760&&e.includes(t)}function B4(t){for(var e=t.pathValue,r=t.max;t.index<r&&jOt(e.charCodeAt(t.index));)t.index+=1}function XOt(t){switch(t|32){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}function zOt(t){return(t|32)===97}function VOt(t){var e=t.max,r=t.pathValue,i=t.index,s=r.charCodeAt(i),o=ZO[r[i].toLowerCase()];if(t.segmentStart=i,!XOt(s)){t.err='[path-util]: Invalid path value "'.concat(r[i],'" is not a path command');return}if(t.index+=1,B4(t),t.data=[],!o){iot(t);return}for(;;){for(var n=o;n>0;n-=1){if(zOt(s)&&(n===3||n===4)?UOt(t):WOt(t),t.err.length)return;t.data.push(t.param),B4(t),t.index<e&&r.charCodeAt(t.index)===44&&(t.index+=1,B4(t))}if(t.index>=t.max||!GOt(r.charCodeAt(t.index)))break}iot(t)}var YOt=(function(){function t(e){this.pathValue=e,this.segments=[],this.max=e.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}return t})();function $Ot(t){if(tot(t))return[].concat(t);var e=new YOt(t);for(B4(e);e.index<e.max&&!e.err.length;)VOt(e);return e.err?e.err:e.segments}ep=function(t){if(eot(t))return[].concat(t);var e=$Ot(t),r=0,i=0,s=0,o=0;return e.map(function(n){var a=n.slice(1).map(Number),l=n[0],c=l.toUpperCase();if(l==="M")return r=a[0],i=a[1],s=r,o=i,["M",r,i];var h;if(l!==c)switch(c){case"A":h=[c,a[0],a[1],a[2],a[3],a[4],a[5]+r,a[6]+i];break;case"V":h=[c,a[0]+i];break;case"H":h=[c,a[0]+r];break;default:{var u=a.map(function(f,g){return f+(g%2?i:r)});h=[c].concat(u)}}else h=[c].concat(a);var d=h.length;switch(c){case"Z":r=s,i=o;break;case"H":r=h[1];break;case"V":i=h[1];break;default:r=h[d-2],i=h[d-1],c==="M"&&(s=r,o=i)}return h})};function HOt(t,e){var r=t[0],i=e.x1,s=e.y1,o=e.x2,n=e.y2,a=t.slice(1).map(Number),l=t;if("TQ".includes(r)||(e.qx=null,e.qy=null),r==="H")l=["L",t[1],s];else if(r==="V")l=["L",i,t[1]];else if(r==="S"){var c=i*2-o,h=s*2-n;e.x1=c,e.y1=h,l=["C",c,h].concat(a)}else if(r==="T"){var u=i*2-e.qx,d=s*2-e.qy;e.qx=u,e.qy=d,l=["Q",u,d].concat(a)}else if(r==="Q"){var f=a[0],g=a[1];e.qx=f,e.qy=g}return l}function O4(t){if(rot(t))return[].concat(t);for(var e=ep(t),r=fo({},Qst),i=0;i<e.length;i+=1){e[i]=HOt(e[i],r);var s=e[i],o=s.length;r.x1=+s[o-2],r.y1=+s[o-1],r.x2=+s[o-4]||r.x1,r.y2=+s[o-3]||r.y1}return e}function KOt(t){return rot(t)&&t.every(function(e){var r=e[0];return"MC".includes(r)})}function I4(t,e,r){var i=t*Math.cos(r)-e*Math.sin(r),s=t*Math.sin(r)+e*Math.cos(r);return{x:i,y:s}}function sot(t,e,r,i,s,o,n,a,l,c){var h=t,u=e,d=r,f=i,g=a,p=l,m=Math.PI*120/180,v=Math.PI/180*(+s||0),b=[],y,_,w,E,A;if(c)_=c[0],w=c[1],E=c[2],A=c[3];else{y=I4(h,u,-v),h=y.x,u=y.y,y=I4(g,p,-v),g=y.x,p=y.y;var x=(h-g)/2,S=(u-p)/2,T=x*x/(d*d)+S*S/(f*f);T>1&&(T=Math.sqrt(T),d*=T,f*=T);var R=d*d,B=f*f,O=(o===n?-1:1)*Math.sqrt(Math.abs((R*B-R*S*S-B*x*x)/(R*S*S+B*x*x)));E=O*d*S/f+(h+g)/2,A=O*-f*x/d+(u+p)/2,_=Math.asin(((u-A)/f*Math.pow(10,9)>>0)/Math.pow(10,9)),w=Math.asin(((p-A)/f*Math.pow(10,9)>>0)/Math.pow(10,9)),_=h<E?Math.PI-_:_,w=g<E?Math.PI-w:w,_<0&&(_=Math.PI*2+_),w<0&&(w=Math.PI*2+w),n&&_>w&&(_-=Math.PI*2),!n&&w>_&&(w-=Math.PI*2)}var C=w-_;if(Math.abs(C)>m){var F=w,U=g,H=p;w=_+m*(n&&w>_?1:-1),g=E+d*Math.cos(w),p=A+f*Math.sin(w),b=sot(g,p,d,f,s,0,n,U,H,[w,F,E,A])}C=w-_;var N=Math.cos(_),G=Math.sin(_),Y=Math.cos(w),q=Math.sin(w),L=Math.tan(C/4),J=4/3*d*L,tt
434=4/3*f*L,bt=[h,u],ct=[h+J*G,u-tt*N],Xt=[g+J*q,p-tt*Y],It=[g,p];if(ct[0]=2*bt[0]-ct[0],ct[1]=2*bt[1]-ct[1],c)return ct.concat(Xt,It,b);b=ct.concat(Xt,It,b);for(var zt=[],Ht=0,Lt=b.length;Ht<Lt;Ht+=1)zt[Ht]=Ht%2?I4(b[Ht-1],b[Ht],v).y:I4(b[Ht],b[Ht+1],v).x;return zt}function qOt(t,e,r,i,s,o){var n=.3333333333333333,a=2/3;return[n*t+a*r,n*e+a*i,n*s+a*r,n*o+a*i,s,o]}function Xv(t,e,r){var i=t[0],s=t[1],o=e[0],n=e[1];return[i+(o-i)*r,s+(n-s)*r]}var oot=function(t,e,r,i){var s=.5,o=Xv([t,e],[r,i],s);return EE(EE([],o,!0),[r,i,r,i],!1)};function ZOt(t,e){var r=t[0],i=t.slice(1).map(Number),s=i[0],o=i[1],n,a=e.x1,l=e.y1,c=e.x,h=e.y;switch("TQ".includes(r)||(e.qx=null,e.qy=null),r){case"M":return e.x=s,e.y=o,t;case"A":return n=[a,l].concat(i),["C"].concat(sot(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9]));case"Q":return e.qx=s,e.qy=o,n=[a,l].concat(i),["C"].concat(qOt(n[0],n[1],n[2],n[3],n[4],n[5]));case"L":return["C"].concat(oot(a,l,s,o));case"Z":return a===c&&l===h?["C",a,l,c,h,c,h]:["C"].concat(oot(a,l,c,h))}return t}function F$(t,e){if(e===void 0&&(e=!1),KOt(t)){var r=[].concat(t);return e?[r,[]]:r}for(var i=O4(t),s=fo({},Qst),o=[],n="",a=i.length,l,c,h=[],u=0;u<a;u+=1){i[u]&&(n=i[u][0]),o[u]=n;var d=ZOt(i[u],s);i[u]=d,LOt(i,o,u),a=i.length,n==="Z"&&h.push(u),l=i[u],c=l.length,s.x1=+l[c-2],s.y1=+l[c-1],s.x2=+l[c-4]||s.x1,s.y2=+l[c-3]||s.y1}return e?[i,h]:i}function JOt(t){return t.map(function(e){return Array.isArray(e)?[].concat(e):e})}function QOt(t){var e=t.slice(1).map(function(r,i,s){return i?s[i-1].slice(-2).concat(r.slice(1)):t[0].slice(1).concat(r.slice(1))}).map(function(r){return r.map(function(i,s){return r[r.length-s-2*(1-s%2)]})}).reverse();return[["M"].concat(e[0].slice(0,2))].concat(e.map(function(r){return["C"].concat(r.slice(2))}))}qn=function(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))};function N$(t,e,r,i,s){var o=qn([t,e],[r,i]),n={x:0,y:0};if(typeof s=="number")if(s<=0)n={x:t,y:e};else if(s>=o)n={x:r,y:i};else{var a=Xv([t,e],[r,i],s/o),l=a[0],c=a[1];n={x:l,y:c}}return{length:o,point:n,min:{x:Math.min(t,r),y:Math.min(e,i)},max:{x:Math.max(t,r),y:Math.max(e,i)}}}function not(t,e){var r=t.x,i=t.y,s=e.x,o=e.y,n=r*s+i*o,a=Math.sqrt((Math.pow(r,2)+Math.pow(i,2))*(Math.pow(s,2)+Math.pow(o,2))),l=r*o-i*s<0?-1:1,c=l*Math.acos(n/a);return c}function tIt(t,e,r,i,s,o,n,a,l,c){var h=Math.abs,u=Math.sin,d=Math.cos,f=Math.sqrt,g=Math.PI,p=h(r),m=h(i),v=(s%360+360)%360,b=v*(g/180);if(t===a&&e===l)return{x:t,y:e};if(p===0||m===0)return N$(t,e,a,l,c).point;var y=(t-a)/2,_=(e-l)/2,w={x:d(b)*y+u(b)*_,y:-u(b)*y+d(b)*_},E=Math.pow(w.x,2)/Math.pow(p,2)+Math.pow(w.y,2)/Math.pow(m,2);E>1&&(p*=f(E),m*=f(E));var A=Math.pow(p,2)*Math.pow(m,2)-Math.pow(p,2)*Math.pow(w.y,2)-Math.pow(m,2)*Math.pow(w.x,2),x=Math.pow(p,2)*Math.pow(w.y,2)+Math.pow(m,2)*Math.pow(w.x,2),S=A/x;S=S<0?0:S;var T=(o!==n?1:-1)*f(S),R={x:T*(p*w.y/m),y:T*(-(m*w.x)/p)},B={x:d(b)*R.x-u(b)*R.y+(t+a)/2,y:u(b)*R.x+d(b)*R.y+(e+l)/2},O={x:(w.x-R.x)/p,y:(w.y-R.y)/m},C=not({x:1,y:0},O),F={x:(-w.x-R.x)/p,y:(-w.y-R.y)/m},U=not(O,F);!n&&U>0?U-=2*g:n&&U<0&&(U+=2*g),U%=2*g;var H=C+U*c,N=p*d(H),G=m*u(H),Y={x:d(b)*N-u(b)*G+B.x,y:u(b)*N+d(b)*G+B.y};return Y}function eIt(t,e,r,i,s,o,n,a,l,c,h){var u,d=h.bbox,f=d===void 0?!0:d,g=h.length,p=g===void 0?!0:g,m=h.sampleSize,v=m===void 0?30:m,b=typeof c=="number",y=t,_=e,w=0,E=[y,_,w],A=[y,_],x=0,S={x:0,y:0},T=[{x:y,y:_}];b&&c<=0&&(S={x:y,y:_});for(var R=0;R<=v;R+=1){if(x=R/v,u=tIt(t,e,r,i,s,o,n,a,l,x),y=u.x,_=u.y,f&&T.push({x:y,y:_}),p&&(w+=qn(A,[y,_])),A=[y,_],b&&w>=c&&c>E[2]){var B=(w-c)/(w-E[2]);S={x:A[0]*(1-B)+E[0]*B,y:A[1]*(1-B)+E[1]*B}}E=[y,_,w]}return b&&c>=w&&(S={x:a,y:l}),{length:w,point:S,min:{x:Math.min.apply(null,T.map(function(O){return O.x})),y:Math.min.apply(null,T.map(function(O){return O.y}))},max:{x:Math.max.apply(null,T.map(function(O){return O.x})),y:Math.max.apply(null,T.map(function(O){return O.y}))}}}function rIt(t,e,r,i,s,o,n,a,l){var c=1-l;return{x:Math.pow(c,3)*t+3*Math.pow(c,2)*l*r+3*c*Math.pow(l,2)*s+Math.pow(l,3)*n,y:Math.pow(c,3)*e+3*Math.pow(c,2)*l*i+3*c*Math.pow(l,2)*o+Math.pow(l,3)*a}}function aot(t,e,r,i,s,o,n,a,l,c){var h,u=c.bbox,d=u===void 0?!0:u,f=c.length,g=f===void 0?!0:f,p=c.sampleSize,m=p===void 0?10:p,v=typeof l=="number",b=t,y=e,_=0,w=[b,y,_],E=[b,y],A=0,x={x:0,y:0},S=[{x:b,y}];v&&l<=0&&(x={x:b,y});for(var T=0;T<=m;T+=1){if(A=T/m,h=rIt(t,e,r,i,s,o,n,a,A),b=h.x,y=h.y,d&&S.push({x:b,y}),g&&(_+=qn(E,[b,y])),E=[b,y],v&&_>=l&&l>w[2]){var R=(_-l)/(_-w[2]);x={x:E[0]*(1-R)+w[0]*R,y:E[1]*(1-R)+w[1]*R}}w=[b,y,_]}return v&&l>=_&&(x={x:n,y:a}),{length:_,point:x,min:{x:Math.min.apply(null,S.map(function(B){return B.x})),y:Math.min.apply(null,S.map(function(B){return B.y}))},max:{x:Math.max.apply(null,S.map(function(B){return B.x})),y:Math.max.apply(null,S.map(function(B){return B.y}))}}}function iIt(t,e,r,i,s,o,n){var a=1-n;return{x:Math.pow(a,2)*t+2*a*n*r+Math.pow(n,2)*s,y:Math.pow(a,2)*e+2*a*n*i+Math.pow(n,2)*o}}function sIt(t,e,r,i,s,o,n,a){var l,c=a.bbox,h=c===void 0?!0:c,u=a.length,d=u===void 0?!0:u,f=a.sampleSize,g=f===void 0?10:f,p=typeof n=="number",m=t,v=e,b=0,y=[m,v,b],_=[m,v],w=0,E={x:0,y:0},A=[{x:m,y:v}];p&&n<=0&&(E={x:m,y:v});for(var x=0;x<=g;x+=1){if(w=x/g,l=iIt(t,e,r,i,s,o,w),m=l.x,v=l.y,h&&A.push({x:m,y:v}),d&&(b+=qn(_,[m,v])),_=[m,v],p&&b>=n&&n>y[2]){var S=(b-n)/(b-y[2]);E={x:_[0]*(1-S)+y[0]*S,y:_[1]*(1-S)+y[1]*S}}y=[m,v,b]}return p&&n>=b&&(E={x:s,y:o}),{length:b,point:E,min:{x:Math.min.apply(null,A.map(function(T){return T.x})),y:Math.min.apply(null,A.map(function(T){return T.y}))},max:{x:Math.max.apply(null,A.map(function(T){return T.x})),y:Math.max.apply(null,A.map(function(T){return T.y}))}}}function oIt(t,e,r){for(var i,s,o,n,a,l,c=O4(t),h,u=[],d,f=0,g=0,p=0,m=0,v,b=[],y=[],_=0,w={x:0,y:0},E=w,A=w,x=0,S=0,T=c.length;S<T;S+=1)v=c[S],d=v[0],h=d==="M",u=h?u:[f,g].concat(v.slice(1)),h?(p=v[1],m=v[2],w={x:p,y:m},E=w,_=0):d==="L"?(i=N$(u[0],u[1],u[2],u[3],0-x),_=i.length,w=i.min,E=i.max,i.point):d==="A"?(s=eIt(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],0-x,r||{}),_=s.length,w=s.min,E=s.max,s.point):d==="C"?(o=aot(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],0-x,r||{}),_=o.length,w=o.min,E=o.max,o.point):d==="Q"?(n=sIt(u[0],u[1],u[2],u[3],u[4],u[5],0-x,r||{}),_=n.length,w=n.min,E=n.max,n.point):d==="Z"&&(u=[f,g,p,m],a=N$(u[0],u[1],u[2],u[3],0-x),_=a.length,w=a.min,E=a.max,a.point),y.push(E),b.push(w),x+=_,l=d!=="Z"?v.slice(-2):[p,m],f=l[0],g=l[1];return{length:x,point:A,min:{x:Math.min.apply(null,b.map(function(R){return R.x})),y:Math.min.apply(null,b.map(function(R){return R.y}))},max:{x:Math.max.apply(null,y.map(function(R){return R.x})),y:Math.max.apply(null,y.map(function(R){return R.y}))}}}qEt=function(t,e){return oIt(t,void 0,fo(fo({},e),{bbox:!1,length:!0})).length};function nIt(t){var e=t.length,r=e-1;return t.map(function(i,s){return t.map(function(o,n){var a=s+n,l;return n===0||t[a]&&t[a][0]==="M"?(l=t[a],["M"].concat(l.slice(-2))):(a>=e&&(a-=r),t[a])})})}function aIt(t,e){var r=t.length-1,i=[],s=0,o=0,n=nIt(t);
434return n.forEach(function(a,l){t.slice(1).forEach(function(c,h){o+=qn(t[(l+h)%r].slice(-2),e[h%r].slice(-2))}),i[l]=o,o=0}),s=i.indexOf(Math.min.apply(null,i)),n[s]}function lIt(t,e,r,i,s,o,n,a){return 3*((a-e)*(r+s)-(n-t)*(i+o)+i*(t-s)-r*(e-o)+a*(s+t/3)-n*(o+e/3))/20}function cIt(t){var e=0,r=0,i=0;return F$(t).map(function(s){var o;switch(s[0]){case"M":return e=s[1],r=s[2],0;default:var n=s.slice(1),a=n[0],l=n[1],c=n[2],h=n[3],u=n[4],d=n[5];return i=lIt(e,r,a,l,c,h,u,d),o=s.slice(-2),e=o[0],r=o[1],i}}).reduce(function(s,o){return s+o},0)}function lot(t){return cIt(t)>=0}function hIt(t,e){e===void 0&&(e=.5);var r=t.slice(0,2),i=t.slice(2,4),s=t.slice(4,6),o=t.slice(6,8),n=Xv(r,i,e),a=Xv(i,s,e),l=Xv(s,o,e),c=Xv(n,a,e),h=Xv(a,l,e),u=Xv(c,h,e);return[["C"].concat(n,c,u),["C"].concat(h,l,o)]}function cot(t){return t.map(function(e,r,i){var s=r&&i[r-1].slice(-2).concat(e.slice(1)),o=r?aot(s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],{bbox:!1}).length:0,n;return r?n=o?hIt(s):[e,e]:n=[e],{s:e,ss:n,l:o}})}function hot(t,e,r){var i=cot(t),s=cot(e),o=i.length,n=s.length,a=i.filter(function(m){return m.l}).length,l=s.filter(function(m){return m.l}).length,c=i.filter(function(m){return m.l}).reduce(function(m,v){var b=v.l;return m+b},0)/a||0,h=s.filter(function(m){return m.l}).reduce(function(m,v){var b=v.l;return m+b},0)/l||0,u=r||Math.max(o,n),d=[c,h],f=[u-o,u-n],g=0,p=[i,s].map(function(m,v){return m.l===u?m.map(function(b){return b.s}):m.map(function(b,y){return g=y&&f[v]&&b.l>=d[v],f[v]-=g?1:0,g?b.ss:[b.s]}).flat()});return p[0].length===p[1].length?p:hot(p[0],p[1],u)}var uIt=1e-6;function k$(t){return Math.abs(t)<uIt?0:t<0?-1:1}function dIt(t,e,r){return(r[0]-t[0])*(e[1]-t[1])===(e[0]-t[0])*(r[1]-t[1])&&Math.min(t[0],e[0])<=r[0]&&r[0]<=Math.max(t[0],e[0])&&Math.min(t[1],e[1])<=r[1]&&r[1]<=Math.max(t[1],e[1])}function uot(t,e,r){var i=!1,s=t.length;if(s<=2)return!1;for(var o=0;o<s;o++){var n=t[o],a=t[(o+1)%s];if(dIt(n,a,[e,r]))return!0;k$(n[1]-r)>0!=k$(a[1]-r)>0&&k$(e-(r-n[1])*(n[0]-a[0])/(n[1]-a[1])-n[0])<0&&(i=!i)}return i}var dot=function(t,e,r){return t>=e&&t<=r};function fIt(t,e,r,i){var s=.001,o={x:r.x-t.x,y:r.y-t.y},n={x:e.x-t.x,y:e.y-t.y},a={x:i.x-r.x,y:i.y-r.y},l=n.x*a.y-n.y*a.x,c=l*l,h=n.x*n.x+n.y*n.y,u=a.x*a.x+a.y*a.y,d=null;if(c>s*h*u){var f=(o.x*a.y-o.y*a.x)/l,g=(o.x*n.y-o.y*n.x)/l;dot(f,0,1)&&dot(g,0,1)&&(d={x:t.x+f*n.x,y:t.y+f*n.y})}return d}function fot(t){for(var e=[],r=t.length,i=0;i<r-1;i++){var s=t[i],o=t[i+1];e.push({from:{x:s[0],y:s[1]},to:{x:o[0],y:o[1]}})}if(e.length>1){var n=t[0],a=t[r-1];e.push({from:{x:a[0],y:a[1]},to:{x:n[0],y:n[1]}})}return e}function pIt(t,e){var r=!1;return t.forEach(function(i){if(fIt(i.from,i.to,e.from,e.to))return r=!0,!1}),r}function pot(t){var e=t.map(function(i){return i[0]}),r=t.map(function(i){return i[1]});return{minX:Math.min.apply(null,e),maxX:Math.max.apply(null,e),minY:Math.min.apply(null,r),maxY:Math.max.apply(null,r)}}function gIt(t,e){return!(e.minX>t.maxX||e.maxX<t.minX||e.minY>t.maxY||e.maxY<t.minY)}ZEt=function(t,e){if(t.length<2||e.length<2)return!1;var r=pot(t),i=pot(e);if(!gIt(r,i))return!1;var s=!1;if(e.forEach(function(l){if(uot(t,l[0],l[1]))return s=!0,!1}),s||(t.forEach(function(l){if(uot(e,l[0],l[1]))return s=!0,!1}),s))return!0;var o=fot(t),n=fot(e),a=!1;return n.forEach(function(l){if(pIt(o,l))return a=!0,!1}),a};var got={exports:{}},mot;function mIt(){return mot||(mot=1,(function(t){var e=Object.prototype.hasOwnProperty,r="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function s(l,c,h){this.fn=l,this.context=c,this.once=h||!1}function o(l,c,h,u,d){if(typeof h!="function")throw new TypeError("The listener must be a function");var f=new s(h,u||l,d),g=r?r+c:c;return l._events[g]?l._events[g].fn?l._events[g]=[l._events[g],f]:l._events[g].push(f):(l._events[g]=f,l._eventsCount++),l}function n(l,c){--l._eventsCount===0?l._events=new i:delete l._events[c]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],c,h;if(this._eventsCount===0)return l;for(h in c=this._events)e.call(c,h)&&l.push(r?h.slice(1):h);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=r?r+l:l,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var u=0,d=h.length,f=new Array(d);
vendor: 4,197 bytes, line 434
434u<d;u++)f[u]=h[u].fn;return f},a.prototype.listenerCount=function(l){var c=r?r+l:l,h=this._events[c];return h?h.fn?1:h.length:0},a.prototype.emit=function(l,c,h,u,d,f){var g=r?r+l:l;if(!this._events[g])return!1;var p=this._events[g],m=arguments.length,v,b;if(p.fn){switch(p.once&&this.removeListener(l,p.fn,void 0,!0),m){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,c),!0;case 3:return p.fn.call(p.context,c,h),!0;case 4:return p.fn.call(p.context,c,h,u),!0;case 5:return p.fn.call(p.context,c,h,u,d),!0;case 6:return p.fn.call(p.context,c,h,u,d,f),!0}for(b=1,v=new Array(m-1);b<m;b++)v[b-1]=arguments[b];p.fn.apply(p.context,v)}else{var y=p.length,_;for(b=0;b<y;b++)switch(p[b].once&&this.removeListener(l,p[b].fn,void 0,!0),m){case 1:p[b].fn.call(p[b].context);break;case 2:p[b].fn.call(p[b].context,c);break;case 3:p[b].fn.call(p[b].context,c,h);break;case 4:p[b].fn.call(p[b].context,c,h,u);break;default:if(!v)for(_=1,v=new Array(m-1);_<m;_++)v[_-1]=arguments[_];p[b].fn.apply(p[b].context,v)}}return!0},a.prototype.on=function(l,c,h){return o(this,l,c,h,!1)},a.prototype.once=function(l,c,h){return o(this,l,c,h,!0)},a.prototype.removeListener=function(l,c,h,u){var d=r?r+l:l;if(!this._events[d])return this;if(!c)return n(this,d),this;var f=this._events[d];if(f.fn)f.fn===c&&(!u||f.once)&&(!h||f.context===h)&&n(this,d);else{for(var g=0,p=[],m=f.length;g<m;g++)(f[g].fn!==c||u&&!f[g].once||h&&f[g].context!==h)&&p.push(f[g]);p.length?this._events[d]=p.length===1?p[0]:p:n(this,d)}return this},a.prototype.removeAllListeners=function(l){var c;return l?(c=r?r+l:l,this._events[c]&&n(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,t.exports=a})(got)),got.exports}var yIt=mIt();Uo=Sv(yIt);var Z;(function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMA
434SK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELET
434E_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.ALWAYS=519]="ALWAYS",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.GEQUAL=518]="GEQUAL",t[t.NOTEQUAL=517]="NOTEQUAL
vendor: 17,522 bytes, line 434
434",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.
434VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.UNSIGNED_INT_24_8_WEBGL=34042]="UNSIGNED_INT_24_8_WEBGL",t[t.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",t[t.RGBA32F_EXT=34836]="RGBA32F_EXT",t[t.RGB32F_EXT=34837]="RGB32F_EXT",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT",t[t.UNSIGNED_NORMALIZED_EXT=35863]="UNSIGNED_NORMALIZED_EXT",t[t.MIN_EXT=32775]="MIN_EXT",t[t.MAX_EXT=32776]="MAX_EXT",t[t.SRGB_EXT=35904]="SRGB_EXT",t[t.SRGB_ALPHA_EXT=35906]="SRGB_ALPHA_EXT",t[t.SRGB8_ALPHA8_EXT=35907]="SRGB8_ALPHA8_EXT",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT_OES=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT_OES",t[t.COLOR_ATTACHMENT0_WEBGL=36064]="COLOR_ATTACHMENT0_WEBGL",t[t.COLOR_ATTACHMENT1_WEBGL=36065]="COLOR_ATTACHMENT1_WEBGL",t[t.COLOR_ATTACHMENT2_WEBGL=36066]="COLOR_ATTACHMENT2_WEBGL",t[t.COLOR_ATTACHMENT3_WEBGL=36067]="COLOR_ATTACHMENT3_WEBGL",t[t.COLOR_ATTACHMENT4_WEBGL=36068]="COLOR_ATTACHMENT4_WEBGL",t[t.COLOR_ATTACHMENT5_WEBGL=36069]="COLOR_ATTACHMENT5_WEBGL",t[t.COLOR_ATTACHMENT6_WEBGL=36070]="COLOR_ATTACHMENT6_WEBGL",t[t.COLOR_ATTACHMENT7_WEBGL=36071]="COLOR_ATTACHMENT7_WEBGL",t[t.COLOR_ATTACHMENT8_WEBGL=36072]="COLOR_ATTACHMENT8_WEBGL",t[t.COLOR_ATTACHMENT9_WEBGL=36073]="COLOR_ATTACHMENT9_WEBGL",t[t.COLOR_ATTACHMENT10_WEBGL=36074]="COLOR_ATTACHMENT10_WEBGL",t[t.COLOR_ATTACHMENT11_WEBGL=36075]="COLOR_ATTACHMENT11_WEBGL",t[t.COLOR_ATTACHMENT12_WEBGL=36076]="COLOR_ATTACHMENT12_WEBGL",t[t.COLOR_ATTACHMENT13_WEBGL=36077]="COLOR_ATTACHMENT13_WEBGL",t[t.COLOR_ATTACHMENT14_WEBGL=36078]="COLOR_ATTACHMENT14_WEBGL",t[t.COLOR_ATTACHMENT15_WEBGL=36079]="COLOR_ATTACHMENT15_WEBGL",t[t.DRAW_BUFFER0_WEBGL=34853]="DRAW_BUFFER0_WEBGL",t[t.DRAW_BUFFER1_WEBGL=34854]="DRAW_BUFFER1_WEBGL",t[t.DRAW_BUFFER2_WEBGL=34855]="DRAW_BUFFER2_WEBGL",t[t.DRAW_BUFFER3_WEBGL=34856]="DRAW_BUFFER3_WEBGL",t[t.DRAW_BUFFER4_WEBGL=34857]="DRAW_BUFFER4_WEBGL",t[t.DRAW_BUFFER5_WEBGL=34858]="DRAW_BUFFER5_WEBGL",t[t.DRAW_BUFFER6_WEBGL=34859]="DRAW_BUFFER6_WEBGL",t[t.DRAW_BUFFER7_WEBGL=34860]="DRAW_BUFFER7_WEBGL",t[t.DRAW_BUFFER8_WEBGL=34861]="DRAW_BUFFER8_WEBGL",t[t.DRAW_BUFFER9_WEBGL=34862]="DRAW_BUFFER9_WEBGL",t[t.DRAW_BUFFER10_WEBGL=34863]="DRAW_BUFFER10_WEBGL",t[t.DRAW_BUFFER11_WEBGL=34864]="DRAW_BUFFER11_WEBGL",t[t.DRAW_BUFFER12_WEBGL=34865]="DRAW_BUFFER12_WEBGL",t[t.DRAW_BUFFER13_WEBGL=34866]="DRAW_BUFFER13_WEBGL",t[t.DRAW_BUFFER14_WEBGL=34867]="DRAW_BUFFER14_WEBGL",t[t.DRAW_BUFFER15_WEBGL=34868]="DRAW_BUFFER15_WEBGL",t[t.MAX_COLOR_ATTACHMENTS_WEBGL=36063]="MAX_COLOR_ATTACHMENTS_WEBGL",t[t.MAX_DRAW_BUFFERS_WEBGL=34852]="MAX_DRAW_BUFFERS_WEBGL",t[t.VERTEX_ARRAY_BINDING_OES=34229]="VERTEX_ARRAY_BINDING_OES",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT"})(Z||(Z={}));var Wi;(function(t){t[t.Buffer=0]="Buffer",t[t.Texture=1]="Texture",t[t.RenderTarget=2]="RenderTarget",t[t.Sampler=3]="Sampler",t[t.Program=4]="Program",t[t.Bindings=5]="Bindings",t[t.InputLayout=6]="InputLayout",t[t.RenderPipeline=7]="RenderPipeline",t[t.ComputePipeline=8]="ComputePipeline",t[t.Readback=9]="Readback",t[t.QueryPool=10]="QueryPool",t[t.RenderBundle=11]="RenderBundle"})(Wi||(Wi={})),(function(t){t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS"})(qe||(qe={}));var JO;(function(t){t[t.CCW=2305]="CCW",t[t.CW=2304]="CW"})(JO||(JO={}));var pp;(function(t){t[t.NONE=0]="NONE",t[t.FRONT=1]="FRONT",t[t.BACK=2]="BACK",t[t.FRONT_AND_BACK=3]="FRONT_AND_BACK"})(pp||(pp={})),(function(t){t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC=768]="SRC",t[t.ONE_MINUS_SRC=769]="ONE_MINUS_SRC",t[t.DST=774]="DST",t[t.ONE_MINUS_DST=775]="ONE_MINUS_DST",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.CONST=32769]="CONST",t[t.ONE_MINUS_CONSTANT=32770]="ONE_MINUS_CONSTANT",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"})(kt||(kt={})),(function(t){t[t.ADD=32774]="ADD",t[t.SUBSTRACT=32778]="SUBSTRACT",t[t.REVERSE_SUBSTRACT=32779]="REVERSE_SUBSTRACT",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX"})(hr||(hr={})),(function(t){t[t.CLAMP_TO_EDGE=0]="CLAMP_TO_EDGE",t[t.REPEAT=1]="REPEAT",t[t.MIRRORED_REPEAT=2]="MIRRORED_REPEAT"})(Zn||(Zn={})),(function(t){t[t.POINT=0]="POINT",t[t.BILINEAR=1]="BILINEAR"})(io||(io={})),(function(t){t[t.NO_MIP=0]="NO_MIP",t[t.NEAREST=1]="NEAREST",t[t.LINEAR=2]="LINEAR"})(xn||(xn={})),(function(t){t[t.POINTS=0]="POINTS",t[t.TRIANGLES=1]="TRIANGLES",t[t.TRIANGLE_STRIP=2]="TRIANGLE_STRIP",t[t.LINES=3]="LINES",t[t.LINE_STRIP=4]="LINE_STRIP"})(Go||(Go={})),(function(t){t[t.MAP_READ=1]="MAP_READ",t[t.MAP_WRITE=2]="MAP_WRITE",t[t.COPY_SRC=4]="COPY_SRC",t[t.COPY_DST=8]="COPY_DST",t[t.INDEX=16]="INDEX",t[t.VERTEX=32]="VERTEX",t[t.UNIFORM=64]="UNIFORM",t[t.STORAGE=128]="STORAGE",t[t.INDIRECT=256]="INDIRECT",t[t.QUERY_RESOLVE=512]="QUERY_RESOLVE"})(dt||(dt={})),(function(t){t[t.STATIC=1]="STATIC",t[t.DYNAMIC=2]="DYNAMIC"})(Et||(Et={})),(function(t){t[t.VERTEX=1]="VERTEX",t[t.INSTANCE=2]="INSTANCE"})(ne||(ne={}));var yot;(function(t){t.LOADED="loaded"})(yot||(yot={}));var ei;(function(t){t[t.TEXTURE_2D=0]="TEXTURE_2D",t[t.TEXTURE_2D_ARRAY=1]="TEXTURE_2D_ARRAY",t[t.TEXTURE_3D=2]="TEXTURE_3D",t[t.TEXTURE_CUBE_MAP=3]="TEXTURE_CUBE_MAP"})(ei||(ei={})),(function(t){t[t.SAMPLED=1]="SAMPLED",t[t.RENDER_TARGET=2]="RENDER_TARGET",t[t.STORAGE=4]="STORAGE"})(xr||(xr={})),(function(t){t[t.NONE=0]="NONE",t[t.RED=1]="RED",t[t.GREEN=2]="GREEN",t[t.BLUE=4]="BLUE",t[t.ALPHA=8]="ALPHA",t[t.RGB=7]="RGB",t[t.ALL=15]="ALL"})(Di||(Di={})),(function(t){t[t.KEEP=7680]="KEEP",t[t.ZERO=0]="ZERO",t[t.REPLACE=7681]="REPLACE",t[t.INVERT=5386]="INVERT",t[t.INCREMENT_CLAMP=7682]="INCREMENT_CLAMP",t[t.DECREMENT_CLAMP=7683]="DECREMENT_CLAMP",t[t.INCREMENT_WRAP=34055]="INCREMENT_WRAP",t[t.DECREMENT_WRAP=34056]="DECREMENT_WRAP"})(ce||(ce={})),Stt=function(t,e,r,i){var s=ei.TEXTURE_2D,o=1,n=xr.SAMPLED;return{dimension:s,format:t,width:e,height:r,depthOrArrayLayers:o,mipLevelCount:i,usage:n}};var en;(function(t){t[t.Float=0]="Float",t[t.UnfilterableFloat=1]="UnfilterableFloat",t[t.Uint=2]="Uint",t[t.Sint=3]="Sint",t[t.Depth=4]="Depth"})(en||(en={}));var QO;(function(t){t[t.LOWER_LEFT=0]="LOWER_LEFT",t[t.UPPER_LEFT=1]="UPPER_LEFT"})(QO||(QO={}));var Sh;(function(t){t[t.NEGATIVE_ONE=0]="NEGATIVE_ONE",t[t.ZERO=1]="ZERO"})(Sh||(Sh={}));var D4;(function(t){t[t.OcclusionConservative=0]="OcclusionConservative"})(D4||(D4={}));var St;(function(t){t[t.U8=1]="U8",t[t.U16=2]="U16",t[t.U32=3]="U32",t[t.S8=4]="S8",t[t.S16=5]="S16",t[t.S32=6]="S32",t[t.F16=7]="F16",t[t.F32=8]="F32",t[t.BC1=65]="BC1",t[t.BC2=66]="BC2",t[t.BC3=67]="BC3",t[t.BC4_UNORM=68]="BC4_UNORM",t[t.BC4_SNORM=69]="BC4_SNORM",t[t.BC5_UNORM=70]="BC5_UNORM",t[t.BC5_SNORM=71]="BC5_SNORM",t[t.U16_PACKED_5551=97]="U16_PACKED_5551",t[t.U16_PACKED_565=98]="U16_PACKED_565",t[t.D24=129]="D24",t[t.D32F=130]="D32F",t[t.D24S8=131]="D24S8",t[t.D32FS8=132]="D32FS8"})(St||(St={}));var xe;(function(t){t[t.R=1]="R",t[t.RG=2]="RG",t[t.RGB=3]="RGB",t[t.RGBA=4]="RGBA",t[t.A=5]="A"})(xe||(xe={}));var se;(function(t){t[t.None=0]="None",t[t.Normalized=1]="Normalized",t[t.sRGB=2]="sRGB",t[t.Depth=4]="Depth",t[t.Stencil=8]="Stencil",t[t.RenderTarget=16]="RenderTarget",t[t.Luminance=32]="Luminance"})(se||(se={}));function Le(t,e,r){return t<<16|e<<8|r}(function(t){t[t.ALPHA=Le(St.U8,xe.A,se.None)]="ALPHA",t[t.U8_LUMINANCE=Le(St.U8,xe.A,se.Luminance)]="U8_LUMINANCE",t[t.F16_LUMINANCE=Le(St.F16,xe.A,se.Luminance)]="F16_LUMINANCE",t[t.F32_LUMINANCE=Le(St.F32,xe.A,se.Luminance)]="F32_LUMINANCE",t[t.F16_R=Le(St.F16,xe.R,se.None)]="F16_R",t[t.F16_RG=Le(St.F16,xe.RG,se.None)]="F16_RG",t[t.F16_RGB=Le(St.F16,xe.RGB,se.None)]="F16_RGB",t[t.F16_RGBA=Le(St.F16,xe.RGBA,se.None)]="F16_RGBA",t[t.F32_R=Le(St.F32,xe.R,se.None)]="F32_R",t[t.F32_RG=Le(St.F32,xe.RG,se.None)]="F32_RG",t[t.F32_RGB=Le(St.F32,xe.RGB,se.None)]="F32_RGB",t[t.F32_RGBA=Le(St.F32,xe.RGBA,se.None)]="F32_RGBA",t[t.U8_R=Le(St.U8,xe.R,se.None)]="U8_R",t[t.U8_R_NORM=Le(St.U8,xe.R,se.Normalized)]="U8_R_NORM",t[t.U8_RG=Le(St.U8,xe.RG,se.None)]="U8_RG",t[t.U8_RG_NORM=Le(St.U8,xe.RG,se.Normalized)]="U8_RG_NORM",t[t.U8_RGB=Le(St.U8,xe.RGB,se.None)]="U8_RGB",t[t.U8_RGB_NORM=Le(St.U8,xe.RGB,se.Normalized)]="U8_RGB_NORM",t[t.U8_RGB_SRGB=Le(St.U8,xe.RGB,se.sRGB|se.Normalized)]="U8_RGB_SRGB",t[t.U8_RGBA=Le(St.U8,xe.RGBA,se.None)]="U8_RGBA",t[t.U8_RGBA_NORM=Le(St.U8,xe.RGBA,se.Normalized)]="U8_RGBA_NORM",t[t.U8_RGBA_SRGB=Le(St.U8,xe.RGBA,se.sRGB|se.Normalized)]="U8_RGBA_SRGB",t[t.U16_R=Le(St.U16,xe.R,se.None)]="U16_R",t[t.U16_R_NORM=Le(St.U16,xe.R,se.Normalized)]="U16_R_NORM",t[t.U16_RG_NORM=Le(St.U16,xe.RG,se.Normalized)]="U16_RG_NORM",t[t.U16_RGBA_NORM=Le(St.U16,xe.RGBA,se.Normalized)]="U16_RGBA_NORM",t[t.U16_RGBA=Le(St.U16,xe.RGBA,se.None)]="U16_RGBA",t[t.U16_RGB=Le(St.U16,xe.RGB,se.None)]="U16_RGB",t[t.U16_RG=Le(St.U16,xe.RG,se.None)]="U16_RG",t[t.U32_R=Le(St.U32,xe.R,se.None)]="U32_R",t[t.U32_RG=Le(St.U32,xe.RG,se.None)]="U32_RG",t[t.U32_RGB=Le(St.U32,xe.RGB,se.None)]="U32_RGB",t[t.U32_RGBA=Le(St.U32,xe.RGBA,se.None)]="U32_RGBA",t[t.S8_R=Le(St.S8,xe.R,se.None)]="S8_R",t[t.S8_R_NORM=Le(St.S8,xe.R,se.Normalized)]="S8_R_NORM",t[t.S8_RG_NORM=Le(St.S8,xe.RG,se.Normalized)]="S8_RG_NORM",t[t.S8_RGB_NORM=Le(St.S8,xe.RGB,se.Normalized)]="S8_RGB_NORM",t[t.S8_RGBA_NORM=Le(St.S8,xe.RGBA,se.Normalized)]="S8_RGBA_NORM",t[t.S16_R=Le(St.S16,xe.R,se.None)]="S16_R",t[t.S16_RG=Le(St.S16,xe.RG,se.None)]="S16_RG",t[t.S16_RG_NORM=Le(St.S16,xe.RG,se.Normalized)]="S16_RG_NORM",t[t.S16_RGB_NORM=Le(St.S16,xe.RGB,se.Normalized)]="S16_RGB_NORM",t[t.S16_RGBA=Le(St.S16,xe.RGBA,se.None)]="S16_RGBA",t[t.S16_RGBA_NORM=Le(St.S16,xe.RGBA,se.Normalized)]="S16_RGBA_NORM",t[t.S32_R=Le(St.S32,xe.R,se.None)]="S32_R",t[t.S32_RG=Le(St.S32,xe.RG,se.None)]="S32_RG",t[t.S32_RGB=Le(St.S32,xe.RGB,se.None)]="S32_RGB",t[t.S32_RGBA=Le(St.S32,xe.RGBA,se.None)]="S32_RGBA",t[t.U16_RGBA_5551=Le(St.U16_PACKED_5551,xe.RGBA,se.Normalized)]="U16_RGBA_5551",t[t.U16_RGB_565=Le(St.U16_PACKED_565,xe.RGB,se.Normalized)]="U16_RGB_565",t[t.BC1=Le(St.BC1,xe.RGBA,se.Normalized)]="BC1",t[t.BC1_SRGB=Le(St.BC1,xe.RGBA,se.Normalized|se.sRGB)]="BC1_SRGB",t[t.BC2=Le(St.BC2,xe.RGBA,se.Normalized)]="BC2",t[t.BC2_SRGB=Le(St.BC2,xe.RGBA,se.Normalized|se.sRGB)]="BC2_SRGB",t[t.BC3=Le(St.BC3,xe.RGBA,se.Normalized)]="BC3",t[t.BC3_SRGB=Le(St.BC3,xe.RGBA,se.Normalized|se.sRGB)]="BC3_SRGB",t[t.BC4_UNORM=Le(St.BC4_UNORM,xe.R,se.Normalized)]="BC4_UNORM",t[t.BC4_SNORM=Le(St.BC4_SNORM,xe.R,se.Normalized)]="BC4_SNORM",t[t.BC5_UNORM=Le(St.BC5_UNORM,xe.RG,se.Normalized)]="BC5_UNORM",t[t.BC5_SNORM=Le(St.BC5_SNORM,xe.RG,se.Normalized)]="BC5_SNORM",t[t.D24=Le(St.D24,xe.R,se.Depth)]="D24",t[t.D24_S8=Le(St.D24S8,xe.RG,se.Depth|se.Stencil)]="D24_S8",t[t.D32F=Le(St.D32F,xe.R,se.Depth)]="D32F",t[t.D32F_S8=Le(St.D32FS8,xe.RG,se.Depth|se.Stencil)]="D32F_S8",t[t.U8_RGB_RT=Le(St.U8,xe.RGB,se.RenderTarget|se.Normalized)]="U8_RGB_RT",t[t.U8_RGBA_RT=Le(St.U8,xe.RGBA,se.RenderTarget|se.Normalized)]="U8_RGBA_RT",t[t.U8_RGBA_RT_SRGB=Le(St.U8,xe.RGBA,se.RenderTarget|se.Normalized|se.sRGB)]="U8_RGBA_RT_SRGB"})(I||(I={}));function L$(t){return t>>>8&255}function wm(t){return t>>>16&255}function LT(t){return t&255}function vot(t){switch(t){case St.F32:case St.U32:case St.S32:return 4;case St.U16:case St.S16:case St.F16:return 2;case St.U8:case St.S8:return 1;default:throw new Error("whoops")}}function _ot(t){return vot(wm(t))}function vIt(t){var e=vot(wm(t)),r=L$(t);return e*r}function bot(t){var e=LT(t);if(e&se.Depth)return en.Depth;if(e&se.Normalized)return en.Float;var r=wm(t);if(r===St.F16||r===St.F32)return en.Float;if(r===St.U8||r===St.U16||r===St.U32)return en.Uint;if(r===St.S8||r===St.S16||r===St.S32)return en.Sint;throw new Error("whoops")}function Ir(t,e){if(e===void 0&&(e=""),!t)throw new Error("Assert fail: ".concat(e))}function RE(t){if(t!=null)return t;throw new Error("Missing object")}function wot(t,e){return t.r===e.r&&t.g===e.g&&t.b===e.b&&t.a===e.a}function Eot(t,e){t.r=e.r,t.g=e.g,t.b=e.b,t.a=e.a}function Aot(t){var e=t.r,r=t.g,i=t.b,s=t.a;return{r:e,g:r,b:i,a:s}}function P4(t,e,r,i){return i===void 0&&(i=1),{r:t,g:e,b:r,a:i}}kn=P4(0,0,0,0),P4(0,0,0,1),op=P4(1,1,1,0),P4(1,1,1,1);
434function F4(t){return!!(t&&(t&t-1)===0)}function zv(t,e){return t??e}function _It(t){return t===void 0?null:t}function N4(t,e){var r=e-1;return t+r&~r}function bIt(t,e){for(var r=new Array(t),i=0;i<t;i++)r[i]=e();return r}function wIt(t,e){e===void 0&&(e=1);var r=t.split(` 435`);return r.map(function(i,s){return"".concat(EIt(""+(e+s),4," ")," ").concat(i)}).join(` 436`)}function EIt(t,e,r){for(;t.length<e;)t="".concat(r).concat(t);return t}function xot(t,e){t.blendDstFactor=e.blendDstFactor,t.blendSrcFactor=e.blendSrcFactor,t.blendMode=e.blendMode}function k4(t,e){return t===void 0&&(t={}),t.compare=e.compare,t.depthFailOp=e.depthFailOp,t.passOp=e.passOp,t.failOp=e.failOp,t.mask=e.mask,t}function Sot(t,e){return t===void 0&&(t={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),xot(t.rgbBlendState,e.rgbBlendState),xot(t.alphaBlendState,e.alphaBlendState),t.channelWriteMask=e.channelWriteMask,t}function Tot(t,e){t.length!==e.length&&(t.length=e.length);for(var r=0;r<e.length;r++)t[r]=Sot(t[r],e[r])}function AIt(t,e){e.attachmentsState!==void 0&&Tot(t.attachmentsState,e.attachmentsState),t.blendConstant&&e.blendConstant&&Eot(t.blendConstant,e.blendConstant),t.depthCompare=zv(e.depthCompare,t.depthCompare),t.depthWrite=zv(e.depthWrite,t.depthWrite),t.stencilWrite=zv(e.stencilWrite,t.stencilWrite),t.stencilFront&&e.stencilFront&&k4(t.stencilFront,e.stencilFront),t.stencilBack&&e.stencilBack&&k4(t.stencilBack,e.stencilBack),t.cullMode=zv(e.cullMode,t.cullMode),t.frontFace=zv(e.frontFace,t.frontFace),t.polygonOffset=zv(e.polygonOffset,t.polygonOffset),t.polygonOffsetFactor=zv(e.polygonOffsetFactor,t.polygonOffsetFactor),t.polygonOffsetUnits=zv(e.polygonOffsetUnits,t.polygonOffsetUnits)}function UT(t){var e=Object.assign({},t);return e.attachmentsState=[],Tot(e.attachmentsState,t.attachmentsState),e.blendConstant=e.blendConstant&&Aot(e.blendConstant),e.stencilFront=k4(void 0,t.stencilFront),e.stencilBack=k4(void 0,t.stencilBack),e}var Rot={blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ZERO},GT={attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:Rot,alphaBlendState:Rot}],blendConstant:Aot(kn),depthWrite:!0,depthCompare:qe.LEQUAL,stencilWrite:!1,stencilFront:{compare:qe.ALWAYS,passOp:ce.KEEP,depthFailOp:ce.KEEP,failOp:ce.KEEP},stencilBack:{compare:qe.ALWAYS,passOp:ce.KEEP,depthFailOp:ce.KEEP,failOp:ce.KEEP},cullMode:pp.NONE,frontFace:JO.CCW,polygonOffset:!1,polygonOffsetFactor:0,polygonOffsetUnits:0};function xIt(t,e){t===void 0&&(t=null),e===void 0&&(e=GT);var r=UT(e);return t!==null&&AIt(r,t),r}xIt({depthCompare:qe.ALWAYS,depthWrite:!1},GT);var Cot={texture:null,sampler:null,formatKind:en.Float,dimension:ei.TEXTURE_2D};function Vv(t,e,r){if(t.length!==e.length)return!1;for(var i=0;i<t.length;i++)if(!r(t[i],e[i]))return!1;return!0}function WT(t,e){for(var r=Array(t.length),i=0;i<t.length;i++)r[i]=e(t[i]);return r}function SIt(t,e){return t.texture===e.texture&&t.binding===e.binding}function Mot(t,e){return t.buffer===e.buffer&&t.size===e.size&&t.binding===e.binding&&t.offset===e.offset}function TIt(t,e){return t===null?e===null:e===null?!1:t.sampler===e.sampler&&t.texture===e.texture&&t.dimension===e.dimension&&t.formatKind===e.formatKind&&t.comparison===e.comparison}function L4(t,e){return t.samplerBindings=t.samplerBindings||[],t.uniformBufferBindings=t.uniformBufferBindings||[],t.storageBufferBindings=t.storageBufferBindings||[],t.storageTextureBindings=t.storageTextureBindings||[],e.samplerBindings=e.samplerBindings||[],e.uniformBufferBindings=e.uniformBufferBindings||[],e.storageBufferBindings=e.storageBufferBindings||[],e.storageTextureBindings=e.storageTextureBindings||[],!(t.samplerBindings.length!==e.samplerBindings.length||!Vv(t.samplerBindings,e.samplerBindings,TIt)||!Vv(t.uniformBufferBindings,e.uniformBufferBindings,Mot)||!Vv(t.storageBufferBindings,e.storageBufferBindings,Mot)||!Vv(t.storageTextureBindings,e.storageTextureBindings,SIt))}function Bot(t,e){return t.blendMode==e.blendMode&&t.blendSrcFactor===e.blendSrcFactor&&t.blendDstFactor===e.blendDstFactor}function RIt(t,e){return!(!Bot(t.rgbBlendState,e.rgbBlendState)||!Bot(t.alphaBlendState,e.alphaBlendState)||t.channelWriteMask!==e.channelWriteMask)}function U4(t,e){return t.compare==e.compare&&t.depthFailOp===e.depthFailOp&&t.failOp===e.failOp&&t.passOp===e.passOp&&t.mask===e.mask}function CIt(t,e){return!Vv(t.attachmentsState,e.attachmentsState,RIt)||t.blendConstant&&e.blendConstant&&!wot(t.blendConstant,e.blendConstant)||t.stencilFront&&e.stencilFront&&!U4
436(t.stencilFront,e.stencilFront)||t.stencilBack&&e.stencilBack&&!U4(t.stencilBack,e.stencilBack)?!1:t.depthCompare===e.depthCompare&&t.depthWrite===e.depthWrite&&t.stencilWrite===e.stencilWrite&&t.cullMode===e.cullMode&&t.frontFace===e.frontFace&&t.polygonOffset===e.polygonOffset&&t.polygonOffsetFactor===e.polygonOffsetFactor&&t.polygonOffsetUnits===e.polygonOffsetUnits}function Oot(t,e){return t.id===e.id}function MIt(t,e){return t===e}function G4(t,e){return!(t.topology!==e.topology||t.inputLayout!==e.inputLayout||t.sampleCount!==e.sampleCount||t.megaStateDescriptor&&e.megaStateDescriptor&&!CIt(t.megaStateDescriptor,e.megaStateDescriptor)||!Oot(t.program,e.program)||!Vv(t.colorAttachmentFormats,e.colorAttachmentFormats,MIt)||t.depthStencilAttachmentFormat!==e.depthStencilAttachmentFormat)}function BIt(t,e){return t.offset===e.offset&&t.shaderLocation===e.shaderLocation&&t.format===e.format&&t.divisor===e.divisor}function OIt(t,e){return me(t)?me(e):me(e)?!1:t.arrayStride===e.arrayStride&&t.stepMode===e.stepMode&&Vv(t.attributes,e.attributes,BIt)}function W4(t,e){return!(t.indexBufferFormat!==e.indexBufferFormat||!Vv(t.vertexBufferDescriptors,e.vertexBufferDescriptors,OIt)||!Oot(t.program,e.program))}function j4(t,e){return t.addressModeU===e.addressModeU&&t.addressModeV===e.addressModeV&&t.minFilter===e.minFilter&&t.magFilter===e.magFilter&&t.mipmapFilter===e.mipmapFilter&&t.lodMinClamp===e.lodMinClamp&&t.lodMaxClamp===e.lodMaxClamp&&t.maxAnisotropy===e.maxAnisotropy&&t.compareFunction===e.compareFunction}function IIt(t){var e=t.sampler,r=t.texture,i=t.dimension,s=t.formatKind,o=t.comparison;return{sampler:e,texture:r,dimension:i,formatKind:s,comparison:o}}function Iot(t){var e=t.buffer,r=t.size,i=t.binding,s=t.offset;return{binding:i,buffer:e,offset:s,size:r}}function DIt(t){var e=t.binding,r=t.texture;return{binding:e,texture:r}}function X4(t){var e=t.samplerBindings&&WT(t.samplerBindings,IIt),r=t.uniformBufferBindings&&WT(t.uniformBufferBindings,Iot),i=t.storageBufferBindings&&WT(t.storageBufferBindings,Iot),s=t.storageTextureBindings&&WT(t.storageTextureBindings,DIt);return{samplerBindings:e,uniformBufferBindings:r,storageBufferBindings:i,storageTextureBindings:s,pipeline:t.pipeline}}function z4(t){var e=t.inputLayout,r=t.program,i=t.topology,s=t.megaStateDescriptor&&UT(t.megaStateDescriptor),o=t.colorAttachmentFormats.slice(),n=t.depthStencilAttachmentFormat,a=t.sampleCount;return{inputLayout:e,megaStateDescriptor:s,program:r,topology:i,colorAttachmentFormats:o,depthStencilAttachmentFormat:n,sampleCount:a}}function PIt(t){var e=t.shaderLocation,r=t.format,i=t.offset,s=t.divisor;return{shaderLocation:e,format:r,offset:i,divisor:s}}function FIt(t){if(me(t))return t;var e=t.arrayStride,r=t.stepMode,i=WT(t.attributes,PIt);return{arrayStride:e,stepMode:r,attributes:i}}function V4(t){var e=WT(t.vertexBufferDescriptors,FIt),r=t.indexBufferFormat,i=t.program;return{vertexBufferDescriptors:e,indexBufferFormat:r,program:i}}var wi,NIt=/([^[]*)(\[[0-9]+\])?/;function kIt(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};var e=t.match(NIt);if(!e||e.length<2)throw new Error("Failed to parse GLSL uniform name ".concat(t));return{name:e[1],length:Number(e[2])||1,isArray:!!e[2]}}function Th(){var t=null;return function(e,r,i){var s=t!==i;return s&&(e.uniform1i(r,i),t=i),s}}function rn(t,e,r,i){var s=null,o=null;return function(n,a,l){var c=e(l,r),h=c.length,u=!1;if(s===null)s=new Float32Array(h),o=h,u=!0;else{Ir(o===h,"Uniform length cannot change.");for(var d=0;d<h;++d)if(c[d]!==s[d]){u=!0;break}}return u&&(i(n,t,a,c),s.set(c)),u}}function $c(t,e,r,i){t[e](r,i)}function p0(t,e,r,i){t[e](r,!1,i)}var LIt={},UIt={},GIt={},Dot=[0];function U$(t,e,r,i){e===1&&typeof t=="boolean"&&(t=t?1:0),Number.isFinite(t)&&(Dot[0]=t,t=Dot);var s=t.length;if(t instanceof r)return t;var o=i[s];o||(o=new r(s),i[s]=o);for(var n=0;n<s;n++)o[n]=t[n];return o}function cd(t,e){return U$(t,e,Float32Array,LIt)}function Yv(t,e){return U$(t,e,Int32Array,UIt)}function Y4(t,e){return U$(t,e,Uint32Array,GIt)}var WIt=(wi={},wi[Z.FLOAT]=rn.bind(null,"uniform1fv",cd,1,$c),wi[Z.FLOAT_VEC2]=rn.bind(null,"uniform2fv",cd,2,$c),wi[Z.FLOAT_VEC3]=rn.bind(null,"uniform3fv",cd,3,$c),wi[Z.FLOAT_VEC4]=rn.bind(null,"uniform4fv",cd,4,$c),wi[Z.INT]=rn.bind(null,"uniform1iv",Yv,1,$c),wi[Z.INT_VEC2]=rn.bind(null,"uniform2iv",Yv,2,$c),wi[Z.INT_VEC3]=rn.bind(null,"uniform3iv",Yv,3,$c),wi[Z.INT_VEC4]=rn.bind(null,"uniform4iv",Yv,4,$c),wi[Z.BOOL]=rn.bind(null,"uniform1iv",Yv,1,$c),wi[Z.BOOL_VEC2]=rn.bind(null,"uniform2iv",Yv,2,$c),wi[Z.BOOL_VEC3]=rn.bind(null,"uniform3iv",Yv,3,$c),wi[Z.BOOL_VEC4]=rn.bind(null,"uniform4iv",Yv,4,$c),wi[Z.FLOAT_MAT2]=rn.bind(null,"uniformMatrix2fv",cd,4,p0),wi[Z.FLOAT_MAT3]=rn.bind(null,"uniformMatrix3fv",cd,9,p0),wi[Z.FLOAT_MAT4]=rn.bind(null,"uniformMatrix4fv",cd,16,p0),wi[Z.UNSIGNED_INT]=rn.bind(null,"uniform1uiv",Y4,1,$c),wi[Z.UNSIGNED_INT_VEC2]=rn.bind(null,"uniform2uiv",Y4,2,$c),wi[Z.UNSIGNED_INT_VEC3]=rn.bind(null,"uniform3uiv",Y4,3,$c),wi[Z.UNSIGNED_INT_VEC4]=rn.bind(null,"uniform4uiv",Y4,4,$c),wi[Z.FLOAT_MAT2x3]=rn.bind(null,"uniformMatrix2x3fv",cd,6,p0),wi[Z.FLOAT_MAT2x4]=rn.bind(null,"uniformMatrix2x4fv",cd,8,p0),wi[Z.FLOAT_MAT3x2]=rn.bind(null,"uniformMatrix3x2fv",cd,6,p0),wi[Z.FLOAT_MAT3x4]=rn.bind(null,"uniformMatrix3x4fv",cd,12,p0),wi[Z.FLOAT_MAT4x2]=rn.bind(null,"uniformMatrix4x2fv",cd,8,p0),wi[Z.FLOAT_MAT4x3]=rn.bind(null,"uniformMatrix4x3fv",cd,12,p0),wi[Z.SAMPLER_2D]=Th,wi[Z.SAMPLER_CUBE]=Th,wi[Z.SAMPLER_3D]=Th,wi[Z.SAMPLER_2D_SHADOW]=Th,wi[Z.SAMPLER_2D_ARRAY]=Th,wi[Z.SAMPLER_2D_ARRAY_SHADOW]=Th,wi[Z.SAMPLER_CUBE_SHADOW]=Th,wi[Z.INT_SAMPLER_2D]=Th,wi[Z.INT_SAMPLER_3D]=Th,wi[Z.INT_SAMPLER_CUBE]=Th,wi[Z.INT_SAMPLER_2D_ARRAY]=Th,wi[Z.UNSIGNED_INT_SAMPLER_2D]=Th,wi[Z.UNSIGNED_INT_SAMPLER_3D]=Th,wi[Z.UNSIGNED_INT_SAMPLER_CUBE]=Th,wi[Z.UNSIGNED_INT_SAMPLER_2D_ARRAY]=Th,wi);function Pot(t,e,r){var i=WIt[r.type];if(!i)throw new Error("Unknown GLSL uniform type ".concat(r.type));return i().bind(null,t,e)}var jIt={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array
436]":5121,"[object ArrayBuffer]":5121};function XIt(t){return Object.prototype.toString.call(t)in jIt}function tI(t,e){return"#define ".concat(t," ").concat(e)}function zIt(t){var e={};return t.replace(/^\s*#define\s*(\S*)\s*(\S*)\s*$/gm,function(r,i,s){var o=Number(s);return e[i]=isNaN(o)?s:o,""}),e}function VIt(t,e){var r=[];return t.replace(/^\s*layout\(location\s*=\s*(\S*)\)\s*in\s+\S+\s*(.*);$/gm,function(i,s,o){var n=Number(s);return r.push({location:isNaN(n)?e[s]:n,name:o}),""}),r}function Fot(t){if(t===void 0)return null;var e=/binding\s*=\s*(\d+)/.exec(t);if(e!==null){var r=parseInt(e[1],10);if(!Number.isNaN(r))return r}return null}function Not(t){var e="",r=t;return[r,e]}function $4(t,e,r,i,s){var o;i===void 0&&(i=null),s===void 0&&(s=!0);var n=t.glslVersion==="#version 100",a=e==="frag"&&((o=r.match(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm))===null||o===void 0?void 0:o.length)>1,l=r.replace(`\r 437`,` 438`).split(` 439`).map(function(E){return E.replace(/[/][/].*$/,"")}).filter(function(E){var A=!E||/^\s+$/.test(E);return!A}),c="";i!==null&&(c=Object.keys(i).map(function(E){return tI(E,i[E])}).join(` 440`));var h=l.find(function(E){return E.startsWith("precision")})||"precision mediump float;",u=s?l.filter(function(E){return!E.startsWith("precision")}).join(` 441`):l.join(` 442`),d="";if(t.viewportOrigin===QO.UPPER_LEFT&&(d+="".concat(tI("VIEWPORT_ORIGIN_TL","1"),` 443`)),t.clipSpaceNearZ===Sh.ZERO&&(d+="".concat(tI("CLIPSPACE_NEAR_ZERO","1"),` 444`)),t.explicitBindingLocations){var f=0,g=0,p=0;u=u.replace(/^\s*(layout\((.*)\))?\s*uniform(.+{)$/gm,function(E,A,x,S){var T=x?"".concat(x,", "):"";return"layout(".concat(T,"set = ").concat(f,", binding = ").concat(g++,") uniform ").concat(S)}),f++,g=0,Ir(t.separateSamplerTextures),u=u.replace(/^\s*(layout\((.*)\))?\s*uniform sampler(\w+) (.*);/gm,function(E,A,x,S,T){var R=Fot(x);R===null&&(R=g++);var B=np(Not(S),2),O=B[0],C=B[1];return e==="frag"?` 445layout(set = `.concat(f,", binding = ").concat(R*2+0,") uniform texture").concat(O," T_").concat(T,`; 446layout(set = `).concat(f,", binding = ").concat(R*2+1,") uniform sampler").concat(C," S_").concat(T,";").trim():""}),u=u.replace(e==="frag"?/^\s*\b(varying|in)\b/gm:/^\s*\b(varying|out)\b/gm,function(E,A){return"layout(location = ".concat(p++,") ").concat(A)}),d+="".concat(tI("gl_VertexID","gl_VertexIndex"),` 447`),d+="".concat(tI("gl_InstanceID","gl_InstanceIndex"),` 448`),h=h.replace(/^precision (.*) sampler(.*);$/gm,"")}else{var m=0;u=u.replace(/^\s*(layout\((.*)\))?\s*uniform sampler(\w+) (.*);/gm,function(E,A,x,S,T){var R=Fot(x);return R===null&&(R=m++),"uniform sampler".concat(S," ").concat(T,"; // BINDING=").concat(R)})}if(u=u.replace(/\bPU_SAMPLER_(\w+)\((.*?)\)/g,function(E,A,x){return"SAMPLER_".concat(A,"(P_").concat(x,")")}),u=u.replace(/\bPF_SAMPLER_(\w+)\((.*?)\)/g,function(E,A,x){return"PP_SAMPLER_".concat(A,"(P_").concat(x,")")}),u=u.replace(/\bPU_TEXTURE\((.*?)\)/g,function(E,A){return"TEXTURE(P_".concat(A,")")}),t.separateSamplerTextures)u=u.replace(/\bPD_SAMPLER_(\w+)\((.*?)\)/g,function(E,A,x){var S=np(Not(A),2),T=S[0],R=S[1];return"texture".concat(T," T_P_").concat(x,", sampler").concat(R," S_P_").concat(x)}),u=u.replace(/\bPP_SAMPLER_(\w+)\((.*?)\)/g,function(E,A,x){return"T_".concat(x,", S_").concat(x)}),u=u.replace(/\bSAMPLER_(\w+)\((.*?)\)/g,function(E,A,x){return"sampler".concat(A,"(T_").concat(x,", S_").concat(x,")")}),u=u.replace(/\bTEXTURE\((.*?)\)/g,function(E,A){return"T_".concat(A)});else{var v=[];u=u.replace(/\bPD_SAMPLER_(\w+)\((.*?)\)/g,function(E,A,x){return"sampler".concat(A," P_").concat(x)}),u=u.replace(/\bPP_SAMPLER_(\w+)\((.*?)\)/g,function(E,A,x){return x}),u=u.replace(/\bSAMPLER_(\w+)\((.*?)\)/g,function(E,A,x){return v.push([x,A]),x}),n&&v.forEach(function(E){var A=np(E,2),x=A[0],S=A[1];u=u.replace(new RegExp("texture\\(".concat(x),"g"),function(){return"texture".concat(S,"(").concat(x)})}),u=u.replace(/\bTEXTURE\((.*?)\)/g,function(E,A){return A})}var b="".concat(n?"":t.glslVersion,` 449`).concat(n&&a?`#extension GL_EXT_draw_buffers : require 450`:"",` 451`).concat(n&&e==="frag"?`#extension GL_OES_standard_derivatives : enable 452`:"").concat(s?h:"",` 453`).concat(d||"").concat(c?c+` 454`:"",` 455`).concat(u,` 456`).trim();if(t.explicitBindingLocations&&e==="frag"&&(b=b.replace(/^\b(out)\b/g,function(E,A){return"layout(location = 0) ".concat(A)})),n){if(e==="frag"&&(b=b.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,function(E,A,x){return"varying ".concat(A," ").concat(x,`; 457`)})),e==="vert"&&(b=b.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,function(E,A,x){return"varying ".concat(A," ").concat(x,`; 458`)}
458),b=b.replace(/^\s*layout\(location\s*=\s*\S*\)\s*in\s+(\S+)\s*(.*);$/gm,function(E,A,x){return"attribute ".concat(A," ").concat(x,`; 459`)})),b=b.replace(/\s*uniform\s*.*\s*{((?:\s*.*\s*)*?)};/g,function(E,A){return A.trim().replace(/^.*$/gm,function(x){var S=x.trim();return S.startsWith("#")?S:x?"uniform ".concat(S):""})}),e==="frag")if(a){var y=[];b=b.replace(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm,function(E,A){return y.push(A),"vec4 ".concat(A,`; 460`)});var _=b.lastIndexOf("}");b=b.substring(0,_)+` 461 `.concat(y.map(function(E,A){return"gl_FragData[".concat(A,"] = ").concat(E,`; 462 `)}).join(` 463`))+b.substring(_)}else{var w;if(b=b.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,function(E,A,x){return w=x,"".concat(A," ").concat(x,`; 464`)}),w){var _=b.lastIndexOf("}");b=b.substring(0,_)+` 465 gl_FragColor = vec4(`.concat(w,`); 466`)+b.substring(_)}}b=b.replace(/^\s*layout\((.*)\)/gm,"")}return b}var of=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=t.call(this)||this;return o.id=i,o.device=s,o.device.resourceCreationTracker!==null&&o.device.resourceCreationTracker.trackResourceCreated(o),o}return e.prototype.destroy=function(){this.device.resourceCreationTracker!==null&&this.device.resourceCreationTracker.trackResourceDestroyed(this)},e})(Uo),YIt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n=t.call(this,{id:i,device:s})||this;n.type=Wi.Bindings;var a=o.uniformBufferBindings,l=o.samplerBindings;return n.uniformBufferBindings=a||[],n.samplerBindings=l||[],n.bindingLayouts=n.createBindingLayouts(),n}return e.prototype.createBindingLayouts=function(){var r=0,i=0,s=[],o=this.uniformBufferBindings.length,n=this.samplerBindings.length;return s.push({firstUniformBuffer:r,numUniformBuffers:o,firstSampler:i,numSamplers:n}),r+=o,i+=n,{numUniformBuffers:r,numSamplers:i,bindingLayoutTables:s}},e})(of),eI;function Me(t){return eI!==void 0?eI:typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?(eI=!0,!0):(eI=!!(t&&t._version===2),eI)}function kot(t){var e=wm(t);switch(e){case St.BC1:case St.BC2:case St.BC3:case St.BC4_UNORM:case St.BC4_SNORM:case St.BC5_UNORM:case St.BC5_SNORM:return!0;default:return!1}}function Lot(t){var e=LT(t);if(e&se.Normalized)return!1;var r=wm(t);return r===St.S8||r===St.S16||r===St.S32||r===St.U8||r===St.U16||r===St.U32}function $It(t){switch(t){case Et.STATIC:return Z.STATIC_DRAW;case Et.DYNAMIC:return Z.DYNAMIC_DRAW}}function Uot(t){if(t&dt.INDEX)return Z.ELEMENT_ARRAY_BUFFER;if(t&dt.VERTEX)return Z.ARRAY_BUFFER;if(t&dt.UNIFORM)return Z.UNIFORM_BUFFER}function HIt(t){switch(t){case Go.TRIANGLES:return Z.TRIANGLES;case Go.POINTS:return Z.POINTS;case Go.TRIANGLE_STRIP:return Z.TRIANGLE_STRIP;case Go.LINES:return Z.LINES;case Go.LINE_STRIP:return Z.LINE_STRIP;default:throw new Error("Unknown primitive topology mode")}}function KIt(t){switch(t){case St.U8:return Z.UNSIGNED_BYTE;case St.U16:return Z.UNSIGNED_SHORT;case St.U32:return Z.UNSIGNED_INT;case St.S8:return Z.BYTE;case St.S16:return Z.SHORT;case St.S32:return Z.INT;case St.F16:return Z.HALF_FLOAT;case St.F32:return Z.FLOAT;default:throw new Error("whoops")}}function qIt(t){switch(t){case xe.R:return 1;case xe.RG:return 2;case xe.RGB:return 3;case xe.RGBA:return 4;default:return 1}}function ZIt(t){var e=wm(t),r=L$(t),i=LT(t),s=KIt(e),o=qIt(r),n=!!(i&se.Normalized);return{size:o,type:s,normalized:n}}function JIt(t){switch(t){case I.U8_R:return Z.UNSIGNED_BYTE;case I.U16_R:return Z.UNSIGNED_SHORT;case I.U32_R:return Z.UNSIGNED_INT;default:throw new Error("whoops")}}function rI(t){switch(t){case Zn.CLAMP_TO_EDGE:return Z.CLAMP_TO_EDGE;case Zn.REPEAT:return Z.REPEAT;case Zn.MIRRORED_REPEAT:return Z.MIRRORED_REPEAT;default:throw new Error("whoops")}}function H4(t,e){if(e===xn.LINEAR&&t===io.BILINEAR)return Z.LINEAR_MIPMAP_LINEAR;if(e===xn.LINEAR&&t===io.POINT)return Z.NEAREST_MIPMAP_LINEAR;if(e===xn.NEAREST&&t===io.BILINEAR)return Z.LINEAR_MIPMAP_NEAREST;if(e===xn.NEAREST&&t===io.POINT)return Z.NEAREST_MIPMAP_NEAREST;if(e===xn.NO_MIP&&t===io.BILINEAR)return Z.LINEAR;if(e===xn.NO_MIP&&t===io.POINT)return Z.NEAREST;throw new Error("Unknown texture filter mode")}function jT(t,e){e===void 0&&(e=0);var r=t;return r.gl_buffer_pages[e/r.pageByteSize|0]}function XT(t){var e=t;return e.gl_texture}function G$(t){var e=t;return e.gl_sampler}function iI(t,e){t.name=e,t.__SPECTOR_Metadata={name:e}}function Got(t,e){for(var r=[];;){var i=e.exec(t);if(!i)break;r.push(i)}return r}function $v(t){return t.blendMode==hr.ADD&&t.blendSrcFactor==kt.ONE&&t.blendDstFactor===kt.ZERO}function QIt(t){switch(t){case D4.OcclusionConservative:return Z.ANY_SAMPLES_PASSED_CONSERVATIVE;default:throw new Error("whoops")}}function tDt(t){if(t===ei.TEXTURE_2D)return Z.TEXTURE_2D;if(t===ei.TEXTURE_2D_ARRAY)return Z.TEXTURE_2D_ARRAY;if(t===ei.TEXTURE_CUBE_MAP)return Z.TEXTURE_CUBE_MAP;if(t===ei.TEXTURE_3D)return Z.TEXTURE_3D;throw new Error("whoops")}function W$(t,e,r,i){return!(t%r!==0||e%i!==0)}var eDt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n=t.call(this,{id:i,device:s})||this;n.type=Wi.Buffer;var a=o.viewOrSize,l=o.usage,c=o.hint,h=c===void 0?Et.STATIC:c,u=s.uniformBufferMaxPageByteSize,d=s.gl,f=l&dt.UNIFORM;f||(Me(d)?d.bindVertexArray(null):s.OES_vertex_array_object.bindVertexArrayOES(null));var g=lc(a)?N4(a,4):N4(a.byteLength,4);n.gl_buffer_pages=[];var p;if(f){for(var m=g;m>0;)n.gl_buffer_pages.push(n.createBufferPage(Math.min(m,u),l,h)),m-=u;p=u}else n.gl_buffer_pages.push(n.createBufferPage(g,l,h)),p=g;return n.pageByteSize=p,n.byteSize=g,n.usage=l,n.gl_target=Uot(l),lc(a)||n.setSubData(0,new Uint8Array(a.buffer)),f||(Me(d)?d.bindVertexArray(n.device.currentBoundVAO):s.OES_vertex_array_object.bindVertexArrayOES(n.device.currentBoundVAO)),n}return e.prototype.setSubData=function(r,i,s,o){s===void 0&&(s=0),o===void 0&&(o=i.byteLength-s);for(var n=this.device.gl,a=this.pageByteSize,l=r+o,c=r,h=r%a;c<l;){var u=Me(n)?n.COPY_WRITE_BUFFER:this.gl_target,d=jT(this,c);if(d.ubo)return;n.bindBuffer(u,d),Me(n)?n.bufferSubData(u,h,i,s,Math.min(l-c,a)):n.bufferSubData(u,h,i),c+=a,h=0,s+=a,this.device.debugGroupStatisticsBufferUpload()}},e.prototype.destroy=function(){t.prototype.destroy.call(this);for(var r=0;r<this.gl_buffer_pages.length;r++)this.gl_buffer_pages[r].ubo||this.device.gl.deleteBuffer(this.gl_buffer_pages[r]);this.gl_buffer_pages=[]},e.prototype.createBufferPage=function(r,i,s){var o=this.device.gl,n=i&dt.UNIFORM;if(!Me(o)&&n)return{ubo:!0};var a=this.device.ensureResourceExists(o.createBuffer()),l=Uot(i),c=$It(s);return o.bindBuffer(l,a),o.bufferData(l,r,c),a},e})(of),rDt=(function(t){Jo(e,t);function e(r){var i,s,o,n,a=r.id,l=r.device,c=r.descriptor,h,u=t.call(this,{id:a,device:l})||this;u.type=Wi.InputLayout;var d=c.vertexBufferDescriptors,f=c.indexBufferFormat,g=c.program;Ir(f===I.U16_R||f===I.U32_R||f===null);var p=f!==null?JIt(f):null,m=f!==null?_ot(f):null,v=u.device.gl,b=u.device.ensureResourceExists(Me(v)?v.createVertexArray():l.OES_vertex_array_object.createVertexArrayOES());Me(v)?v.bindVertexArray(b):l.OES_vertex_array_object.bindVertexArrayOES(b),v.bindBuffer(v.ARRAY_BUFFER,jT(u.device.fallbackVertexBuffer));try{for(var y=r0(c.vertexBufferDescriptors),_=y.next();!_.done;_=y.next()){var w=_.value,E=w.stepMode,A=w.attributes;try{for(var x=(o=void 0,r0(A)),S=x.next();!S.done;S=x.next()){var T=S.value,R=T.shaderLocation,B=T.format,O=T.divisor,C=O===void 0?1:O,F=Me(v)?R:(h=g.attributes[R])===null||h===void 0?void 0:h.location,U=ZIt(B);if(T.vertexFormat=U,!me(F)){Lot(B);var H=U.size,N=U.type,G=U.normalized;v.vertexAttribPointer(F,H,N,G,0,0),E===ne.INSTANCE&&(Me(v)?v.vertexAttribDivisor(F,C):l.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(F,C)),v.enableVertexAttribArray(F)}}}catch(Y){o={error:Y}}finally{try{S&&!S.done&&(n=x.return)&&n.call(x)}finally{if(o)throw o.error}}}}catch(Y){i={error:Y}}finally{try{_&&!_.done&&(s=y.return)&&s.call(y)}finally{if(i)throw i.error}}return Me(v)?v.bindVertexArray(null):l.OES_vertex_array_object.bindVertexArrayOES(null),u.vertexBufferDescriptors=d,u.vao=b,u.indexBufferFormat=f,u.indexBufferType=p,u.indexBufferCompByteSize=m,u.program=g,u}return e.prototype.destroy=function(){t.prototype.destroy.call(this),this.device.currentBoundVAO===this.vao&&(Me(this.device.gl)?(this.device.gl.bindVertexArray(null),this.device.gl.deleteVertexArray(this.vao)):(this.device.OES_vertex_array_object.bindVertexArrayOES(null),this.device.OES_vertex_array_object.deleteVertexArrayOES(this.vao)),this.device.currentBoundVAO=null)},e})(of),j$=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n=r.fake,a=t.call(this,{id:i,device:s})||this;a.type=Wi.Texture,o=fo({dimension:ei.TEXTURE_2D,depthOrArrayLayers:1,mipLevelCount:1},o);var l=a.device.gl,c,h,u=a.clampmipLevelCount(o);if(a.immutable=o.usage===xr.RENDER_TARGET,a.pixelStore=o.pixelStore,a.format=o.format,a.dimension=o.dimension,a.formatKind=bot(o.format),a.width=o.width,a.height=o.height,a.depthOrArrayLayers=o.depthOrArrayLayers,a.mipmaps=u>=1,!n){h=a.device.ensureResourceExists(l.createTexture());var d=a.device.translateTextureType(o.format),f=a.device.translateTextureInternalFormat(o.format);if(a.device.setActiveTexture(l.TEXTURE0),a.device.currentTextures[0]=null,a.preprocessImage(),o.dimension===ei.TEXTURE_2D){if(c=
466Z.TEXTURE_2D,l.bindTexture(c,h),a.immutable)if(Me(l))l.texStorage2D(c,u,f,o.width,o.height);else{var g=(f===Z.DEPTH_COMPONENT||a.isNPOT(),0);(a.format===I.D32F||a.format===I.D24_S8)&&!Me(l)&&!s.WEBGL_depth_texture||(l.texImage2D(c,g,f,o.width,o.height,0,f,d,null),a.mipmaps&&(a.mipmaps=!1,l.texParameteri(Z.TEXTURE_2D,Z.TEXTURE_MIN_FILTER,Z.LINEAR),l.texParameteri(Z.TEXTURE_2D,Z.TEXTURE_WRAP_S,Z.CLAMP_TO_EDGE),l.texParameteri(Z.TEXTURE_2D,Z.TEXTURE_WRAP_T,Z.CLAMP_TO_EDGE)))}Ir(o.depthOrArrayLayers===1)}else if(o.dimension===ei.TEXTURE_2D_ARRAY)c=Z.TEXTURE_2D_ARRAY,l.bindTexture(c,h),a.immutable&&Me(l)&&l.texStorage3D(c,u,f,o.width,o.height,o.depthOrArrayLayers);else if(o.dimension===ei.TEXTURE_3D)c=Z.TEXTURE_3D,l.bindTexture(c,h),a.immutable&&Me(l)&&l.texStorage3D(c,u,f,o.width,o.height,o.depthOrArrayLayers);else if(o.dimension===ei.TEXTURE_CUBE_MAP)c=Z.TEXTURE_CUBE_MAP,l.bindTexture(c,h),a.immutable&&Me(l)&&l.texStorage2D(c,u,f,o.width,o.height),Ir(o.depthOrArrayLayers===6);else throw new Error("whoops")}return a.gl_texture=h,a.gl_target=c,a.mipLevelCount=u,a}return e.prototype.setImageData=function(r,i){i===void 0&&(i=0);var s=this.device.gl;kot(this.format);var o=this.gl_target===Z.TEXTURE_3D||this.gl_target===Z.TEXTURE_2D_ARRAY,n=this.gl_target===Z.TEXTURE_CUBE_MAP,a=XIt(r[0]);this.device.setActiveTexture(s.TEXTURE0),this.device.currentTextures[0]=null;var l=r[0],c,h;a?(c=this.width,h=this.height):(c=l.width,h=l.height,this.width=c,this.height=h),s.bindTexture(this.gl_target,this.gl_texture);var u=this.device.translateTextureFormat(this.format),d=Me(s)?this.device.translateInternalTextureFormat(this.format):u,f=this.device.translateTextureType(this.format);this.preprocessImage();for(var g=0;g<this.depthOrArrayLayers;g++){var p=r[g],m=this.gl_target;n&&(m=Z.TEXTURE_CUBE_MAP_POSITIVE_X+g%6),this.immutable?s.texSubImage2D(m,i,0,0,c,h,u,f,p):Me(s)?o?s.texImage3D(m,i,d,c,h,this.depthOrArrayLayers,0,u,f,p):s.texImage2D(m,i,d,c,h,0,u,f,p):a?s.texImage2D(m,i,u,c,h,0,u,f,p):s.texImage2D(m,i,u,u,f,p)}this.mipmaps&&this.generateMipmap(o)},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.device.gl.deleteTexture(XT(this))},e.prototype.clampmipLevelCount=function(r){if(r.dimension===ei.TEXTURE_2D_ARRAY&&r.depthOrArrayLayers>1){var i=wm(r.format);if(i===St.BC1)for(var s=r.width,o=r.height,n=0;n<r.mipLevelCount;n++){if(s<=2||o<=2)return n-1;s=Math.max(s/2|0,1),o=Math.max(o/2|0,1)}}return r.mipLevelCount},e.prototype.preprocessImage=function(){var r=this.device.gl;this.pixelStore&&(this.pixelStore.unpackFlipY&&r.pixelStorei(Z.UNPACK_FLIP_Y_WEBGL,!0),this.pixelStore.packAlignment&&r.pixelStorei(Z.PACK_ALIGNMENT,this.pixelStore.packAlignment),this.pixelStore.unpackAlignment&&r.pixelStorei(Z.UNPACK_ALIGNMENT,this.pixelStore.unpackAlignment))},e.prototype.generateMipmap=function(r){r===void 0&&(r=!1);var i=this.device.gl;return!Me(i)&&this.isNPOT()?this:(this.gl_texture&&this.gl_target&&(i.bindTexture(this.gl_target,this.gl_texture),r?(i.texParameteri(this.gl_target,Z.TEXTURE_BASE_LEVEL,0),i.texParameteri(this.gl_target,Z.TEXTURE_MAX_LEVEL,Math.log2(this.width)),i.texParameteri(this.gl_target,Z.TEXTURE_MIN_FILTER,Z.LINEAR_MIPMAP_LINEAR),i.texParameteri(this.gl_target,Z.TEXTURE_MAG_FILTER,Z.LINEAR)):i.texParameteri(Z.TEXTURE_2D,Z.TEXTURE_MIN_FILTER,Z.NEAREST_MIPMAP_LINEAR),i.generateMipmap(this.gl_target),i.bindTexture(this.gl_target,null)),this)},e.prototype.isNPOT=function(){var r=this.device.gl;return Me(r)?!1:!F4(this.width)||!F4(this.height)},e})(of),iDt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n=t.call(this,{id:i,device:s})||this;n.type=Wi.RenderTarget,n.gl_renderbuffer=null,n.texture=null;var a=n.device.gl,l=o.format,c=o.width,h=o.height,u=o.sampleCount,d=u===void 0?1:u,f=o.texture,g=!1;if((l===I.D32F||l===I.D24_S8)&&f&&!Me(a)&&!s.WEBGL_depth_texture&&(f.destroy(),n.texture=null,g=!0),!g&&f)n.texture=f;else{n.gl_renderbuffer=n.device.ensureResourceExists(a.createRenderbuffer()),a.bindRenderbuffer(a.RENDERBUFFER,n.gl_renderbuffer);var p=n.device.translateTextureInternalFormat(l,!0);Me(a)&&d>1?a.renderbufferStorageMultisample(Z.RENDERBUFFER,d,p,c,h):a.renderbufferStorage(Z.RENDERBUFFER,p,c,h)}return n.format=l,n.width=c,n.height=h,n.sampleCount=d,n}return e.prototype.destroy=function(){t.prototype.destroy.call(this),this.gl_renderbuffer!==null&&this.device.gl.deleteRenderbuffer(this.gl_renderbuffer),this.texture&&this.texture.destroy()},e})(of),uu;(function(t){t[t.NeedsCompile=0]="NeedsCompile",t[t.Compiling=1]="Compiling",t[t.NeedsBind=2]="NeedsBind",t[t.ReadyToUse=3]="ReadyToUse"})(uu||(uu={}));var sDt=(function(t){Jo(e,t);
466function e(r,i){var s=r.id,o=r.device,n=r.descriptor,a=t.call(this,{id:s,device:o})||this;a.rawVertexGLSL=i,a.type=Wi.Program,a.uniformSetters={},a.attributes=[];var l=a.device.gl;return a.descriptor=n,a.gl_program=a.device.ensureResourceExists(l.createProgram()),a.gl_shader_vert=null,a.gl_shader_frag=null,a.compileState=uu.NeedsCompile,a.tryCompileProgram(),a}return e.prototype.destroy=function(){t.prototype.destroy.call(this),this.device.gl.deleteProgram(this.gl_program),this.device.gl.deleteShader(this.gl_shader_vert),this.device.gl.deleteShader(this.gl_shader_frag)},e.prototype.tryCompileProgram=function(){Ir(this.compileState===uu.NeedsCompile);var r=this.descriptor,i=r.vertex,s=r.fragment,o=this.device.gl;i!=null&&i.glsl&&(s!=null&&s.glsl)&&(this.gl_shader_vert=this.compileShader(i.postprocess?i.postprocess(i.glsl):i.glsl,o.VERTEX_SHADER),this.gl_shader_frag=this.compileShader(s.postprocess?s.postprocess(s.glsl):s.glsl,o.FRAGMENT_SHADER),o.attachShader(this.gl_program,this.gl_shader_vert),o.attachShader(this.gl_program,this.gl_shader_frag),o.linkProgram(this.gl_program),this.compileState=uu.Compiling,Me(o)||(this.readUniformLocationsFromLinkedProgram(),this.readAttributesFromLinkedProgram()))},e.prototype.readAttributesFromLinkedProgram=function(){for(var r,i=this.device.gl,s=i.getProgramParameter(this.gl_program,i.ACTIVE_ATTRIBUTES),o=zIt(this.descriptor.vertex.glsl),n=VIt(this.rawVertexGLSL,o),a=function(h){var u=i.getActiveAttrib(l.gl_program,h),d=u.name,f=u.type,g=u.size,p=i.getAttribLocation(l.gl_program,d),m=(r=n.find(function(v){return v.name===d}))===null||r===void 0?void 0:r.location;p>=0&&!me(m)&&(l.attributes[m]={name:d,location:p,type:f,size:g})},l=this,c=0;c<s;c++)a(c)},e.prototype.readUniformLocationsFromLinkedProgram=function(){for(var r=this.device.gl,i=r.getProgramParameter(this.gl_program,r.ACTIVE_UNIFORMS),s=0;s<i;s++){var o=r.getActiveUniform(this.gl_program,s),n=kIt(o.name).name,a=r.getUniformLocation(this.gl_program,n);if(this.uniformSetters[n]=Pot(r,a,o),o&&o.size>1)for(var l=0;l<o.size;l++)a=r.getUniformLocation(this.gl_program,"".concat(n,"[").concat(l,"]")),this.uniformSetters["".concat(n,"[").concat(l,"]")]=Pot(r,a,o)}},e.prototype.compileShader=function(r,i){var s=this.device.gl,o=this.device.ensureResourceExists(s.createShader(i));return s.shaderSource(o,r),s.compileShader(o),o},e.prototype.setUniformsLegacy=function(r){r===void 0&&(r={});var i=this.device.gl;if(!Me(i)){var s=!1;for(var o in r){s||(i.useProgram(this.gl_program),s=!0);var n=r[o],a=this.uniformSetters[o];if(a){var l=n;l instanceof j$&&(l=l.textureIndex),a(l)}}}return this},e})(of),oDt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n=t.call(this,{id:i,device:s})||this;n.type=Wi.QueryPool;var a=n.device.gl;if(Me(a)){var l=o.elemCount,c=o.type;n.gl_query=bIt(l,function(){return n.device.ensureResourceExists(a.createQuery())}),n.gl_query_type=QIt(c)}return n}return e.prototype.queryResultOcclusion=function(r){var i=this.device.gl;if(Me(i)){var s=this.gl_query[r];return i.getQueryParameter(s,i.QUERY_RESULT_AVAILABLE)?!!i.getQueryParameter(s,i.QUERY_RESULT):null}return null},e.prototype.destroy=function(){t.prototype.destroy.call(this);var r=this.device.gl;if(Me(r))for(var i=0;i<this.gl_query.length;i++)r.deleteQuery(this.gl_query[i])},e})(of),nDt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=t.call(this,{id:i,device:s})||this;return o.type=Wi.Readback,o.gl_pbo=null,o.gl_sync=null,o}return e.prototype.clientWaitAsync=function(r,i,s){i===void 0&&(i=0),s===void 0&&(s=10);var o=this.device.gl;return new Promise(function(n,a){function l(){var c=o.clientWaitSync(r,i,0);if(c==o.WAIT_FAILED){a();return}if(c==o.TIMEOUT_EXPIRED){setTimeout(l,Hst(s,0,o.MAX_CLIENT_WAIT_TIMEOUT_WEBGL));return}n()}l()})},e.prototype.getBufferSubDataAsync=function(r,i,s,o,n,a){return Rr(this,void 0,void 0,function(){var l;return hT(this,function(c){switch(c.label){case 0:return l=this.device.gl,Me(l)?(this.gl_sync=l.fenceSync(l.SYNC_GPU_COMMANDS_COMPLETE,0),l.flush(),[4,this.clientWaitAsync(this.gl_sync,0,10)]):[3,2];case 1:return c.sent(),l.bindBuffer(r,i),l.getBufferSubData(r,s,o,n,a),l.bindBuffer(r,null),[2,o];case 2:return[2]}})})},e.prototype.readTexture=function(r,i,s,o,n,a,l,c){return l===void 0&&(l=0),c===void 0&&(c=a.byteLength||0),Rr(this,void 0,void 0,function(){var h,u,d,f,g;return hT(this,function(p){return h=this.device.gl,u=r,d=this.device.translateTextureFormat(u.format),f=this.device.translateTextureType(u.format),g=vIt(u.format),Me(h)?(this.gl_pbo=this.device.ensureResourceExists(h.createBuffer()),h.bindBuffer(h.PIXEL_PACK_BUFFER,this.gl_pbo),h.bufferData(h.PIXEL_PACK_BUFFER,c,h.STREAM_READ),h.bindBuffer(h.PIXEL_PACK_BUFFER,null),h.bindFramebuffer(Z.READ_FRAMEBUFFER,this.device.readbackFramebuffer),h.framebufferTexture2D(Z.READ_FRAMEBUFFER,Z.COLOR_ATTACHMENT0,Z.TEXTURE_2D,u.gl_texture,0),h.bindBuffer(h.PIXEL_PACK_BUFFER,this.gl_pbo),h.readPixels(i,s,o,n,d,f,l*g),h.bindBuffer(h.PIXEL_PACK_BUFFER,null),[2,this.getBufferSubDataAsync(h.PIXEL_PACK_BUFFER,this.gl_pbo,0,a,l,0)]):[2,this.readTextureSync(r,i,s,o,n,a,l,c)]})})},e.prototype.readTextureSync=function(r,i,s,o,n,a,l,c){c===void 0&&(c=a.byteLength||0);var h=this.device.gl,u=r,d=this.device.translateTextureType(u.format);return h.bindFramebuffer(Z.FRAMEBUFFER,this.device.readbackFramebuffer),h.framebufferTexture2D(Z.FRAMEBUFFER,Z.COLOR_ATTACHMENT0,Z.TEXTURE_2D,u.gl_texture,0),h.pixelStorei(h.PACK_ALIGNMENT,4),h.readPixels(i,s,o,n,h.RGBA,d,a),a},e.prototype.readBuffer=function(r,i,s,o,n){return Rr(this,void 0,void 0,function(){var a;return hT(this,function(l){return a=this.device.gl,Me(a)?[2,this.getBufferSubDataAsync(a.ARRAY_BUFFER,jT(r,i),i,s,o,n)]:[2,Promise.reject()]})})},e.prototype.destroy=function(){t.prototype.destroy.call(this),Me(this.device.gl)&&(this.gl_sync!==null&&this.device.gl.deleteSync(this.gl_sync),this.gl_pbo!==null&&this.device.gl.deleteBuffer(this.gl_pbo))},e})(of),aDt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n,a,l=t.call(this,{id:i,device:s})||this;return l.type=Wi.RenderPipeline,l.drawMode=HIt((n=o.topology)!==null&&n!==void 0?n:Go.TRIANGLES),l.program=o.program,l.inputLayout=o.inputLayout,l.megaState=fo(fo({},UT(GT)),o.megaStateDescriptor),l.colorAttachmentFormats=o.colorAttachmentFormats.slice(),l.depthStencilAttachmentFormat=o.depthStencilAttachmentFormat,l.sampleC
466ount=(a=o.sampleCount)!==null&&a!==void 0?a:1,l}return e})(of),lDt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n=t.call(this,{id:i,device:s})||this;return n.type=Wi.ComputePipeline,n.descriptor=o,n}return e})(of),cDt=(function(){function t(){this.liveObjects=new Set,this.creationStacks=new Map,this.deletionStacks=new Map}return t.prototype.trackResourceCreated=function(e){this.creationStacks.set(e,new Error().stack),this.liveObjects.add(e)},t.prototype.trackResourceDestroyed=function(e){this.deletionStacks.has(e)&&console.warn("Object double freed:",e,` 467 468Creation stack: `,this.creationStacks.get(e),` 469 470Deletion stack: `,this.deletionStacks.get(e),` 471 472This stack: `,new Error().stack),this.deletionStacks.set(e,new Error().stack),this.liveObjects.delete(e)},t.prototype.checkForLeaks=function(){var e,r;try{for(var i=r0(this.liveObjects.values()),s=i.next();!s.done;s=i.next()){var o=s.value;console.warn("Object leaked:",o,"Creation stack:",this.creationStacks.get(o))}}catch(n){e={error:n}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}},t.prototype.setResourceLeakCheck=function(e,r){r?this.liveObjects.add(e):this.liveObjects.delete(e)},t})(),hDt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n,a,l=t.call(this,{id:i,device:s})||this;l.type=Wi.Sampler;var c=l.device.gl;if(Me(c)){var h=l.device.ensureResourceExists(c.createSampler());c.samplerParameteri(h,Z.TEXTURE_WRAP_S,rI(o.addressModeU)),c.samplerParameteri(h,Z.TEXTURE_WRAP_T,rI(o.addressModeV)),c.samplerParameteri(h,Z.TEXTURE_WRAP_R,rI((n=o.addressModeW)!==null&&n!==void 0?n:o.addressModeU)),c.samplerParameteri(h,Z.TEXTURE_MIN_FILTER,H4(o.minFilter,o.mipmapFilter)),c.samplerParameteri(h,Z.TEXTURE_MAG_FILTER,H4(o.magFilter,xn.NO_MIP)),o.lodMinClamp!==void 0&&c.samplerParameterf(h,Z.TEXTURE_MIN_LOD,o.lodMinClamp),o.lodMaxClamp!==void 0&&c.samplerParameterf(h,Z.TEXTURE_MAX_LOD,o.lodMaxClamp),o.compareFunction!==void 0&&(c.samplerParameteri(h,c.TEXTURE_COMPARE_MODE,c.COMPARE_REF_TO_TEXTURE),c.samplerParameteri(h,c.TEXTURE_COMPARE_FUNC,o.compareFunction));var u=(a=o.maxAnisotropy)!==null&&a!==void 0?a:1;u>1&&l.device.EXT_texture_filter_anisotropic!==null&&(Ir(o.minFilter===io.BILINEAR&&o.magFilter===io.BILINEAR&&o.mipmapFilter===xn.LINEAR),c.samplerParameterf(h,l.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u)),l.gl_sampler=h}else l.descriptor=o;return l}return e.prototype.setTextureParameters=function(r,i,s){var o,n=this.device.gl,a=this.descriptor;this.isNPOT(i,s)?n.texParameteri(Z.TEXTURE_2D,Z.TEXTURE_MIN_FILTER,Z.LINEAR):n.texParameteri(r,Z.TEXTURE_MIN_FILTER,H4(a.minFilter,a.mipmapFilter)),n.texParameteri(Z.TEXTURE_2D,Z.TEXTURE_WRAP_S,rI(a.addressModeU)),n.texParameteri(Z.TEXTURE_2D,Z.TEXTURE_WRAP_T,rI(a.addressModeV)),n.texParameteri(r,Z.TEXTURE_MAG_FILTER,H4(a.magFilter,xn.NO_MIP));var l=(o=a.maxAnisotropy)!==null&&o!==void 0?o:1;l>1&&this.device.EXT_texture_filter_anisotropic!==null&&(Ir(a.minFilter===io.BILINEAR&&a.magFilter===io.BILINEAR&&a.mipmapFilter===xn.LINEAR),n.texParameteri(r,this.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,l))},e.prototype.destroy=function(){t.prototype.destroy.call(this),Me(this.device.gl)&&this.device.gl.deleteSampler(G$(this))},e.prototype.isNPOT=function(r,i){return!F4(r)||!F4(i)},e})(of),uDt=(function(){function t(){}return t.prototype.dispatchWorkgroups=function(e,r,i){},t.prototype.dispatchWorkgroupsIndirect=function(e,r){},t.prototype.setPipeline=function(e){},t.prototype.setBindings=function(e){},t.prototype.pushDebugGroup=function(e){},t.prototype.popDebugGroup=function(){},t.prototype.insertDebugMarker=function(e){},t})(),dDt=(function(t){Jo(e,t);function e(){var r=t!==null&&t.apply(this,arguments)||this;return r.type=Wi.RenderBundle,r.commands=[],r}return e.prototype.push=function(r){this.commands.push(r)},e.prototype.replay=function(){this.commands.forEach(function(r){return r()})},e})(of),Wot=65536,fDt=/uniform(?:\s+)(\w+)(?:\s?){([^]*?)}/g,pDt=(function(){function t(e,r){r===void 0&&(r={}),this.shaderDebug=!1,this.OES_vertex_array_object=null,this.ANGLE_instanced_arrays=null,this.OES_texture_float=null,this.OES_draw_buffers_indexed=null,this.WEBGL_draw_buffers=null,this.WEBGL_depth_texture=null,this.WEBGL_color_buffer_float=null,this.EXT_color_buffer_half_float=null,this.WEBGL_compressed_texture_s3tc=null,this.WEBGL_compressed_texture_s3tc_srgb=null,this.EXT_texture_compression_rgtc=null,this.EXT_texture_filter_anisotropic=null,this.KHR_parallel_shader_compile=null,this.EXT_texture_norm16=null,this.EXT_color_buffer_float=null,this.OES_texture_float_linear=null,this.OES_texture_half_float_linear=null,this.scTexture=null,this.scPlatformFramebuffer=null,this.currentActiveTexture=null,this.currentBoundVAO=null,this.currentProgram=null,this.resourceCreationTracker=null,this.resourceUniqueId=0,this.currentColorAttachments=[],this.currentColorAttachmentLevels=[],this.currentColorResolveTos=[],this.currentColorResolveToLevels=[],this.currentSampleCount=-1,this.currentIndexBufferByteOffset=null,this.currentMegaState=UT(GT),this.currentSamplers=[],this.currentTextures=[],this.currentUniformBuffers=[],this.currentUniformBufferByteOffsets=[],this.currentUniformBufferByteSizes=[],this.currentScissorEnabled=!1,this.currentStencilRef=null,this.currentRenderPassDescriptor=null,this.currentRenderPassDescriptorStack=[],this.debugGroupStack=[],this.resolveColorAttachmentsChanged=!1,this.resolveDepthStencilAttachmentsChanged=!1,this.explicitBindingLocations=!1,this.separateSamplerTextures=!1,this.viewportOrigin=QO.LOWER_LEFT,this.clipSpaceNearZ=Sh.NEGATIVE_ONE,this.supportMRT=!1,this.inBlitRenderPass=!1,this.supportedSampleCounts=[],this.occlusionQueriesRecommended=!1,this.computeShadersSupported=!1,this.gl=e,this.contextAttributes=RE(e.getContextAttributes()),Me(e)?(this.EXT_texture_norm16=e.getExtension("EXT_texture_norm16"),this.EXT_color_buffer_float=e.getExtension("EXT_color_buffer_float")):(this.OES_vertex_array_object=e.getExtension("OES_vertex_array_object"),this.ANGLE_instanced_arrays=e.getExtension("ANGLE_instanced_arrays"),this.OES_texture_float=e.getExtension("OES_texture_float"),this.WEBGL_draw_buffers=e.getExtension("WEBGL_draw_buffers"),this.WEBGL_depth_texture=e.getExtension("WEBGL_depth_texture"),this.WEBGL_color_buffer_float=e.getExtension("WEBGL_color_buffer_float"),this.EXT_color_buffer_half_float=e.getExtension("EXT_color_buffer_half_float"),e.getExtension("EXT_frag_depth"),e.getExtension("OES_element_index_uint"),e.getExtension("OES_standard_derivatives")),this.WEBGL_compressed_texture_s3tc=e.getExtension("WEBGL_compressed_texture_s3tc"),this.WEBGL_compressed_texture_s3tc_srgb=e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),this.EXT_texture_compression_rgtc=e.getExtension("EXT_texture_compression_rgtc"),this.EXT_texture_filter_anisotropic=e.getExtension("EXT_texture_filter_anisotropic"),this.EXT_texture_norm16=e.getExtension("EXT_texture_norm16"),this.OES_texture_float_linear=e.getExtension("OES_texture_float_linear"),this.OES_texture_half_float_linear=e.getExtension("OES_texture_half_float_linear"),this.KHR_parallel_shader_compile=e.getExtension("KHR_parallel_shader_compile"),Me(e)?(this.platformString="WebGL2",this.glslVersion="#version 300 es"):(this.platformString="WebGL1",this.glslVersion="#version 100"),this.scTexture=new j$({id:this.getNextUniqueId(),device:this,descriptor:{width:0,height:0,depthOrArrayLayers:1,dimension:ei.TEXTURE_2D,mipLevelCount:1,usage:xr.RENDER_TARGET,format:this.contextAttributes.alpha===!1?I.U8_RGB_RT:I.U8_RGBA_RT},fake:!0}),this.scTexture.formatKind=en.Float,this.scTexture.gl_target=null,this.scTexture.gl_texture=null,this.resolveColorReadFramebuffer=this.ensureResourceExists(e.createFramebuffer()),this.resolveColorDrawFramebuffer=this.ensureResourceExists(e.createFramebuffer()),this.resolveDepthStencilReadFramebuffer=this.ensureResourceExists(e.createFramebuffer()),this.resolveDepthStencilDrawFramebuffer=this.ensureResourceExists(e.createFramebuffer()),this.renderPassDrawFramebuffer=this.ensureResourceExists(e.createFramebuffer()),this.readbackFramebuffer=this.ensureResourceExists(e.createFramebuffer()),this.fallbackTexture2D=this.createFallbackTexture(ei.TEXTURE_2D,en.Float),this.fallbackTexture2DDepth=this.createFallbackTexture(ei.TEXTURE_2D,en.Depth),this.fallbackVertexBuffer=this.createBuffer({viewOrSize:1,usage:dt.VERTEX,hint:Et.STATIC}),Me(e)&&(this.fallbackTexture2DArray=this.createFallbackTexture(ei.TEXTURE_2D_ARRAY,en.Float),this.fallbackTexture3D=this.createFallbackTexture(ei.TEXTURE_3D,en.Float),this.fallbackTextureCube=this.createFallbackTexture(ei.TEXTURE_CUBE_MAP,en.Float)),this.currentMegaState.depthCompare=qe.
472LESS,this.currentMegaState.depthWrite=!1,this.currentMegaState.attachmentsState[0].channelWriteMask=Di.ALL,e.enable(e.DEPTH_TEST),e.enable(e.STENCIL_TEST),this.checkLimits(),r.shaderDebug&&(this.shaderDebug=!0),r.trackResources&&(this.resourceCreationTracker=new cDt)}return t.prototype.destroy=function(){this.blitBindings&&this.blitBindings.destroy(),this.blitInputLayout&&this.blitInputLayout.destroy(),this.blitRenderPipeline&&this.blitRenderPipeline.destroy(),this.blitVertexBuffer&&this.blitVertexBuffer.destroy(),this.blitProgram&&this.blitProgram.destroy()},t.prototype.createFallbackTexture=function(e,r){var i=e===ei.TEXTURE_CUBE_MAP?6:1,s=r===en.Depth?I.D32F:I.U8_RGBA_NORM,o=this.createTexture({dimension:e,format:s,usage:xr.SAMPLED,width:1,height:1,depthOrArrayLayers:i,mipLevelCount:1});return r===en.Float&&o.setImageData([new Uint8Array(4*i)]),XT(o)},t.prototype.getNextUniqueId=function(){return++this.resourceUniqueId},t.prototype.checkLimits=function(){var e=this.gl;if(this.maxVertexAttribs=e.getParameter(Z.MAX_VERTEX_ATTRIBS),Me(e)){this.uniformBufferMaxPageByteSize=Math.min(e.getParameter(Z.MAX_UNIFORM_BLOCK_SIZE),Wot),this.uniformBufferWordAlignment=e.getParameter(e.UNIFORM_BUFFER_OFFSET_ALIGNMENT)/4;var r=e.getInternalformatParameter(e.RENDERBUFFER,e.DEPTH32F_STENCIL8,e.SAMPLES);this.supportedSampleCounts=r?EE([],np(r),!1):[],this.occlusionQueriesRecommended=!0}else this.uniformBufferWordAlignment=64,this.uniformBufferMaxPageByteSize=Wot;this.uniformBufferMaxPageWordSize=this.uniformBufferMaxPageByteSize/4,this.supportedSampleCounts.includes(1)||this.supportedSampleCounts.push(1),this.supportedSampleCounts.sort(function(i,s){return i-s})},t.prototype.configureSwapChain=function(e,r,i){var s=this.scTexture;s.width=e,s.height=r,this.scPlatformFramebuffer=_It(i)},t.prototype.getDevice=function(){return this},t.prototype.getCanvas=function(){return this.gl.canvas},t.prototype.getOnscreenTexture=function(){return this.scTexture},t.prototype.beginFrame=function(){},t.prototype.endFrame=function(){},t.prototype.translateTextureInternalFormat=function(e,r){switch(r===void 0&&(r=!1),e){case I.ALPHA:return Z.ALPHA;case I.U8_LUMINANCE:case I.F16_LUMINANCE:case I.F32_LUMINANCE:return Z.LUMINANCE;case I.F16_R:return Z.R16F;case I.F16_RG:return Z.RG16F;case I.F16_RGB:return Z.RGB16F;case I.F16_RGBA:return Z.RGBA16F;case I.F32_R:return Z.R32F;case I.F32_RG:return Z.RG32F;case I.F32_RGB:return Z.RGB32F;case I.F32_RGBA:return Me(this.gl)?Z.RGBA32F:r?this.WEBGL_color_buffer_float.RGBA32F_EXT:Z.RGBA;case I.U8_R_NORM:return Z.R8;case I.U8_RG_NORM:return Z.RG8;case I.U8_RGB_NORM:case I.U8_RGB_RT:return Z.RGB8;case I.U8_RGB_SRGB:return Z.SRGB8;case I.U8_RGBA_NORM:case I.U8_RGBA_RT:return Me(this.gl)?Z.RGBA8:r?Z.RGBA4:Z.RGBA;case I.U8_RGBA:return Z.RGBA;case I.U8_RGBA_SRGB:case I.U8_RGBA_RT_SRGB:return Z.SRGB8_ALPHA8;case I.U16_R:return Z.R16UI;case I.U16_R_NORM:return this.EXT_texture_norm16.R16_EXT;case I.U16_RG_NORM:return this.EXT_texture_norm16.RG16_EXT;case I.U16_RGBA_NORM:return this.EXT_texture_norm16.RGBA16_EXT;case I.U16_RGBA_5551:return Z.RGB5_A1;case I.U16_RGB_565:return Z.RGB565;case I.U32_R:return Z.R32UI;case I.S8_RGBA_NORM:return Z.RGBA8_SNORM;case I.S8_RG_NORM:return Z.RG8_SNORM;case I.BC1:return this.WEBGL_compressed_texture_s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT;case I.BC1_SRGB:return this.WEBGL_compressed_texture_s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;case I.BC2:return this.WEBGL_compressed_texture_s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT;case I.BC2_SRGB:return this.WEBGL_compressed_texture_s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;case I.BC3:return this.WEBGL_compressed_texture_s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT;case I.BC3_SRGB:return this.WEBGL_compressed_texture_s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;case I.BC4_UNORM:return this.EXT_texture_compression_rgtc.COMPRESSED_RED_RGTC1_EXT;case I.BC4_SNORM:return this.EXT_texture_compression_rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT;case I.BC5_UNORM:return this.EXT_texture_compression_rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT;case I.BC5_SNORM:return this.EXT_texture_compression_rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;case I.D32F_S8:return Me(this.gl)?Z.DEPTH32F_STENCIL8:this.WEBGL_depth_texture?Z.DEPTH_STENCIL:Z.DEPTH_COMPONENT16;case I.D24_S8:return Me(this.gl)?Z.DEPTH24_STENCIL8:this.WEBGL_depth_texture?Z.DEPTH_STENCIL:Z.DEPTH_COMPONENT16;case I.D32F:return Me(this.gl)?Z.DEPTH_COMPONENT32F:this.WEBGL_depth_texture?Z.DEPTH_COMPONENT:Z.DEPTH_COMPONENT16;case I.D24:return Me(this.gl)?Z.DEPTH_COMPONENT24:this.WEBGL_depth_texture?Z.DEPTH_COMPONENT:Z.DEPTH_COMPONENT16;default:throw new Error("whoops")}},t.prototype.translateTextureType=function(e){var r=wm(e);switch(r){case St.U8:return Z.UNSIGNED_BYTE;case St.U16:return Z.UNSIGNED_SHORT;case St.U32:return Z.UNSIGNED_INT;case St.S8:return Z.BYTE;case St.F16:return Z.HALF_FLOAT;case St.F32:return Z.FLOAT;case St.U16_PACKED_5551:return Z.UNSIGNED_SHORT_5_5_5_1;case St.D32F:return Me(this.gl)?Z.FLOAT:this.WEBGL_depth_texture?Z.UNSIGNED_INT:Z.UNSIGNED_BYTE;case St.D24:return Me(this.gl)?Z.UNSIGNED_INT_24_8:this.WEBGL_depth_texture?Z.UNSIGNED_SHORT:Z.UNSIGNED_BYTE;case St.D24S8:return Me(this.gl)?Z.UNSIGNED_INT_24_8:this.WEBGL_depth_texture?Z.UNSIGNED_INT_24_8_WEBGL:Z.UNSIGNED_BYTE;case St.D32FS8:return Z.FLOAT_32_UNSIGNED_INT_24_8_REV;default:throw new Error("whoops")}},t.prototype.translateInternalTextureFormat=function(e){switch(e){case I.F32_R:return Z.R32F;case I.F32_RG:return Z.RG32F;case I.F32_RGB:return Z.RGB32F;case I.F32_RGBA:return Z.RGBA32F;case I.F16_R:return Z.R16F;case I.F16_RG:return Z.RG16F;case I.F16_RGB:return Z.RGB16F;case I.F16_RGBA:return Z.RGBA16F}return this.translateTextureFormat(e)},t.prototype.translateTextureFormat=function(e){if(kot(e)||e===I.F32_LUMINANCE||e===I.U8_LUMINANCE)return this.translateTextureInternalFormat(e);var r=Me(this.gl)||!Me(this.gl)&&!!this.WEBGL_depth_texture;switch(e){case I.D24_S8:case I.D32F_S8:return r?Z.DEPTH_STENCIL:Z.RGBA;case I.D24:case I.D32F:return r?Z.DEPTH_COMPONENT:Z.RGBA}var i=Lot(e),s=L$(e);switch(s){case xe.A:return Z.ALPHA;case xe.R:return i?Z.RED_INTEGER:Z.RED;case xe.RG:return i?Z.RG_INTEGER:Z.RG;case xe.RGB:return i?Z.RGB_INTEGER:Z.RGB;case xe.RGBA:return Z.RGBA}},t.prototype.setActiveTexture=function(e){this.currentActiveTexture!==e&&(this.gl.activeTexture(e),this.currentActiveTexture=e)},t.prototype.bindVAO=function(e){this.currentBoundVAO!==e&&(Me(this.gl)?this.gl.bindVertexArray(e):this.OES_vertex_array_object.bindVertexArrayOES(e),this.currentBoundVAO=e)},t.prototype.programCompiled=function(e){Ir(e.compileState!==uu.NeedsCompile),e.compileState===uu.Compiling&&(e.compileState=uu.NeedsBind,this.shaderDebug&&this.checkProgramCompilationForErrors(e))},t.prototype.useProgram=function(e){this.currentProgram!==e&&(this.programCompiled(e),this.gl.useProgram(e.gl_program),this.currentProgram=e)},t.prototype.ensureResourceExists=function(e){if(e===null){var r=this.gl.getError();throw new Error("Created resource is null; GL error encountered: ".concat(r))}else return e},t.prototype.createBuffer=function(e){return new eDt({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createTexture=function(e){return new j$({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createSampler=function(e){return new hDt({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createRenderTarget=function(e){return new iDt({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createRenderTargetFromTexture=function(e){var r=e,i=r.format,s=r.width,o=r.height,n=r.mipLevelCount;return Ir(n===1),this.createRenderTarget({format:i,width:s,height:o,sampleCount:1,texture:e})},t.prototype.createProgram=function(e){var r,i,s,o=(r=e.vertex)===null||r===void 0?void 0:r.glsl;return!((i=e.vertex)===null||i===void 0)&&i.glsl&&(e.vertex.glsl=$4(this.queryVendorInfo(),"vert",e.vertex.glsl)),!((s=e.fragment)===null||s===void 0)&&s.glsl&&(e.fragment.glsl=$4(this.queryVendorInfo(),"frag",e.fragment.glsl)),this.createProgramSimple(e,o)},t.prototype.createProgramSimple=function(e,r){var i=new sDt({id:this.getNextUniqueId(),device:this,descriptor:e},r);return i},t.prototype.createBindings=function(e){return new YIt({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createInputLayout=function(e){return new rDt({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createRenderPipeline=function(e){return new aDt({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createComputePass=function(){return new uDt},t.prototype.createComputePipeline=function(e){return new lDt({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createReadback=function(){return new nDt({id:this.getNextUniqueId(),device:this})},t.prototype.createQueryPool=function(e,r){return new oDt({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:r}})},t.prototype.formatRenderPassDescriptor=function(e){var r,i,s,o,n,a,l=e.colorAttachment;e.depthClearValue=(r=e.depthClearValue)!==null&&r!==void 0?r:"load",e.stencilClearValue=(i=e.stencilClearValue)!==null&&i!==void 0?i:"load";for(var c=0;c<l.length;c++)e.colorAttachmentLevel||(e.colorAttachmentLevel=[]),e.colorAttachmentLevel[c]=(s=e.colorAttachmentLevel[c])!==null&&s!==void 0?s:0,e.colorResolveToLevel||(e.colorResolveToLevel=[]),e.colorResolveToLevel[c]=(o=e.colorResolveToLevel[c])!==null&&o!==void 0?o:0,e.colorClearColor||(e.colorClearColor=[]),e.colorClearColor[c]=(n=e.colorClearColor[c])!==null&&n!==void 0?n:"load",e.colorStore||(e.colorStore=[]),e.colorStore[c]=(a=e.colorStore[c])!==null&&a!==void 0?a:!1},t.prototype.createRenderBundle=function(){return new dDt({id:this.getNextUniqueId(),device:this})},t.prototype.beginBundle=function(e){this.renderBundle=e},t.prototype.endBundle=function(){this.renderBundle=void 0},t.prototype.executeBundles=function(e){e.forEach(function(r){r.replay()})},t.prototype.createRenderPass=function(e){this.currentRenderPassDescriptor!==null&&this.currentRenderPassDescriptorStack.push(this.currentRenderPassDescriptor),this.currentRenderPassDescriptor=e,this.formatRenderPassDescriptor(e);var r=e.colorAttachment,i=e.colorAttachmentLevel,s=e.colorClearColor,o=e.colorResolveTo,n=e.colorResolveToLevel,a=e.depthStencilAttachment,l=e.depthClearValue,c=e.stencilClearValue,h=e.depthStencilResolveTo,u=o&&o.length===1&&o[0]===this.scTexture;this.setRenderPassParametersBegin(r.length,u);for(var d=0;d<r.length;d++)this.setRenderPassParametersColor(d,r[d],i[d],o[d],n[d],u);this.setRenderPassParametersDepthStencil(a,h,u),this.validateCurrentAttachments();for(var d=0;d<r.length;d++){var f=s[d];f!=="load"&&this.setRenderPassParametersClearColor(d,f.r,f.g,f.b,f.a)}return this.setRenderPassParametersClearDepthStencil(l,c),this},t.prototype.submitPass=function(e){Ir(this.currentRenderPassDescriptor!==null),this.endPass(),this.currentRenderPassDescriptorStack.length?this.currentRenderPassDescriptor=this.currentRenderPassDescriptorStack.pop():this.currentRenderPassDescriptor=null},t.prototype.copySubTexture2D=function(e,r,i,s,o,n){var a=this.gl,l=e,c=s;if(Ir(c.mipLevelCount===1),Ir(l.mipLevelCount===1),Me(a))l===this.scTexture?a.bindFramebuffer(a.DRAW_FRAMEBUFFER,this.scPlatformFramebuffer):(a.bindFramebuffer(a.DRAW_FRAMEBUFFER,this.resolveColorDrawFramebuffer),this.bindFramebufferAttachment(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0,l,0)),a.bindFramebuffer(a.READ_FRAMEBUFFER,this.resolveColorReadFramebuffer),this.bindFramebufferAttachment(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,c,0),a.blitFramebuffer(o,n,o+c.width,n+c.height,r,i,r+c.width,i+c.height,a.COLOR_BUFFER_BIT,a.LINEAR),a.bindFramebuffer(a.READ_FRAMEBUFFER,null),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,null);else if(l===this.scTexture){var h=this.createRenderTargetFromTexture(s);
472this.submitBlitRenderPass(h,l)}},t.prototype.queryLimits=function(){return this},t.prototype.queryTextureFormatSupported=function(e,r,i){switch(e){case I.BC1_SRGB:case I.BC2_SRGB:case I.BC3_SRGB:return this.WEBGL_compressed_texture_s3tc_srgb!==null?W$(r,i,4,4):!1;case I.BC1:case I.BC2:case I.BC3:return this.WEBGL_compressed_texture_s3tc!==null?W$(r,i,4,4):!1;case I.BC4_UNORM:case I.BC4_SNORM:case I.BC5_UNORM:case I.BC5_SNORM:return this.EXT_texture_compression_rgtc!==null?W$(r,i,4,4):!1;case I.U16_R_NORM:case I.U16_RG_NORM:case I.U16_RGBA_NORM:return this.EXT_texture_norm16!==null;case I.F32_R:case I.F32_RG:case I.F32_RGB:case I.F32_RGBA:return this.OES_texture_float_linear!==null;case I.F16_R:case I.F16_RG:case I.F16_RGB:case I.F16_RGBA:return this.OES_texture_half_float_linear!==null;default:return!0}},t.prototype.queryProgramReady=function(e){var r=this.gl;if(e.compileState===uu.NeedsCompile)throw new Error("whoops");if(e.compileState===uu.Compiling){var i=void 0;return this.KHR_parallel_shader_compile!==null?i=r.getProgramParameter(e.gl_program,this.KHR_parallel_shader_compile.COMPLETION_STATUS_KHR):i=!0,i&&this.programCompiled(e),i}return e.compileState===uu.NeedsBind||e.compileState===uu.ReadyToUse},t.prototype.queryPlatformAvailable=function(){return this.gl.isContextLost()},t.prototype.queryVendorInfo=function(){return this},t.prototype.queryRenderPass=function(e){return this.currentRenderPassDescriptor},t.prototype.queryRenderTarget=function(e){var r=e;return r},t.prototype.setResourceName=function(e,r){if(e.name=r,e.type===Wi.Buffer)for(var i=e.gl_buffer_pages,s=0;s<i.length;s++)iI(i[s],"".concat(r," Page ").concat(s));else if(e.type===Wi.Texture)iI(XT(e),r);else if(e.type===Wi.Sampler)iI(G$(e),r);else if(e.type===Wi.RenderTarget){var o=e.gl_renderbuffer;o!==null&&iI(o,r)}else e.type===Wi.InputLayout&&iI(e.vao,r)},t.prototype.setResourceLeakCheck=function(e,r){this.resourceCreationTracker!==null&&this.resourceCreationTracker.setResourceLeakCheck(e,r)},t.prototype.checkForLeaks=function(){this.resourceCreationTracker!==null&&this.resourceCreationTracker.checkForLeaks()},t.prototype.pushDebugGroup=function(e){},t.prototype.popDebugGroup=function(){},t.prototype.insertDebugMarker=function(e){},t.prototype.programPatched=function(e,r){Ir(this.shaderDebug)},t.prototype.getBufferData=function(e,r,i){i===void 0&&(i=0);var s=this.gl;Me(s)&&(s.bindBuffer(s.COPY_READ_BUFFER,jT(e,i*4)),s.getBufferSubData(s.COPY_READ_BUFFER,i*4,r))},t.prototype.debugGroupStatisticsDrawCall=function(e){e===void 0&&(e=1);for(var r=this.debugGroupStack.length-1;r>=0;r--)this.debugGroupStack[r].drawCallCount+=e},t.prototype.debugGroupStatisticsBufferUpload=function(e){e===void 0&&(e=1);for(var r=this.debugGroupStack.length-1;r>=0;r--)this.debugGroupStack[r].bufferUploadCount+=e},t.prototype.debugGroupStatisticsTextureBind=function(e){e===void 0&&(e=1);for(var r=this.debugGroupStack.length-1;r>=0;r--)this.debugGroupStack[r].textureBindCount+=e},t.prototype.debugGroupStatisticsTriangles=function(e){for(var r=this.debugGroupStack.length-1;r>=0;r--)this.debugGroupStack[r].triangleCount+=e},t.prototype.reportShaderError=function(e,r){var i=this.gl,s=i.getShaderParameter(e,i.COMPILE_STATUS);if(!s){console.error(wIt(r));var o=i.getExtension("WEBGL_debug_shaders");o&&console.error(o.getTranslatedShaderSource(e)),console.error(i.getShaderInfoLog(e))}return s},t.prototype.checkProgramCompilationForErrors=function(e){var r=this.gl,i=e.gl_program;if(!r.getProgramParameter(i,r.LINK_STATUS)){var s=e.descriptor;if(!this.reportShaderError(e.gl_shader_vert,s.vertex.glsl)||!this.reportShaderError(e.gl_shader_frag,s.fragment.glsl))return;console.error(r.getProgramInfoLog(e.gl_program))}},t.prototype.bindFramebufferAttachment=function(e,r,i,s){var o=this.gl;if(me(i))o.framebufferRenderbuffer(e,r,o.RENDERBUFFER,null);else if(i.type===Wi.RenderTarget)i.gl_renderbuffer!==null?o.framebufferRenderbuffer(e,r,o.RENDERBUFFER,i.gl_renderbuffer):i.texture!==null&&o.framebufferTexture2D(e,r,Z.TEXTURE_2D,XT(i.texture),s);else if(i.type===Wi.Texture){var n=XT(i);i.dimension===ei.TEXTURE_2D?o.framebufferTexture2D(e,r,Z.TEXTURE_2D,n,s):Me(o)&&(i.dimension,ei.TEXTURE_2D_ARRAY)}},t.prototype.bindFramebufferDepthStencilAttachment=function(e,r){var i=this.gl,s=me(r)?se.Depth|se.Stencil:LT(r.format),o=!!(s&se.Depth),n=!!(s&se.Stencil);if(o&&n){var a=Me(this.gl)||!Me(this.gl)&&!!this.WEBGL_depth_texture;a?this.bindFramebufferAttachment(e,i.DEPTH_STENCIL_ATTACHMENT,r,0):this.bindFramebufferAttachment(e,i.DEPTH_ATTACHMENT,r,0)}else o?(this.bindFramebufferAttachment(e,i.DEPTH_ATTACHMENT,r,0),this.bindFramebufferAttachment(e,i.STENCIL_ATTACHMENT,null,0)):n&&(this.bindFramebufferAttachment(e,i.STENCIL_ATTACHMENT,r,0),this.bindFramebufferAttachment(e,i.DEPTH_ATTACHMENT,null,0))},t.prototype.validateCurrentAttachments=function(){for(var e=-1,r=-1,i=-1,s=0;s<this.currentColorAttachments.length;s++){var o=this.currentColorAttachments[s];o!==null&&(e===-1?(e=o.sampleCount,r=o.width,i=o.height):(Ir(e===o.sampleCount),Ir(r===o.width),Ir(i===o.height)))}this.currentDepthStencilAttachment&&(e===-1?e=this.currentDepthStencilAttachment.sampleC
472ount:(Ir(e===this.currentDepthStencilAttachment.sampleCount),Ir(r===this.currentDepthStencilAttachment.width),Ir(i===this.currentDepthStencilAttachment.height))),this.currentSampleCount=e},t.prototype.setRenderPassParametersBegin=function(e,r){r===void 0&&(r=!1);var i=this.gl;if(r)i.bindFramebuffer(Z.FRAMEBUFFER,null);else if(Me(i)?i.bindFramebuffer(Z.DRAW_FRAMEBUFFER,this.renderPassDrawFramebuffer):this.inBlitRenderPass||i.bindFramebuffer(Z.FRAMEBUFFER,this.renderPassDrawFramebuffer),Me(i)?i.drawBuffers([Z.COLOR_ATTACHMENT0,Z.COLOR_ATTACHMENT1,Z.COLOR_ATTACHMENT2,Z.COLOR_ATTACHMENT3]):!this.inBlitRenderPass&&this.WEBGL_draw_buffers&&this.WEBGL_draw_buffers.drawBuffersWEBGL([Z.COLOR_ATTACHMENT0_WEBGL,Z.COLOR_ATTACHMENT1_WEBGL,Z.COLOR_ATTACHMENT2_WEBGL,Z.COLOR_ATTACHMENT3_WEBGL]),!this.inBlitRenderPass)for(var s=e;s<this.currentColorAttachments.length;s++){var o=Me(i)?Z.DRAW_FRAMEBUFFER:Z.FRAMEBUFFER,n=Me(i)?Z.COLOR_ATTACHMENT0:Z.COLOR_ATTACHMENT0_WEBGL;i.framebufferRenderbuffer(o,n+s,Z.RENDERBUFFER,null),i.framebufferTexture2D(o,n+s,Z.TEXTURE_2D,null,0)}this.currentColorAttachments.length=e},t.prototype.setRenderPassParametersColor=function(e,r,i,s,o,n){n===void 0&&(n=!1);var a=this.gl,l=Me(a);(this.currentColorAttachments[e]!==r||this.currentColorAttachmentLevels[e]!==i)&&(this.currentColorAttachments[e]=r,this.currentColorAttachmentLevels[e]=i,!n&&(l||!l&&this.WEBGL_draw_buffers)&&this.bindFramebufferAttachment(l?Z.DRAW_FRAMEBUFFER:Z.FRAMEBUFFER,(l?Z.COLOR_ATTACHMENT0:Z.COLOR_ATTACHMENT0_WEBGL)+e,r,i),this.resolveColorAttachmentsChanged=!0),(this.currentColorResolveTos[e]!==s||this.currentColorResolveToLevels[e]!==o)&&(this.currentColorResolveTos[e]=s,this.currentColorResolveToLevels[e]=o,s!==null&&(this.resolveColorAttachmentsChanged=!0))},t.prototype.setRenderPassParametersDepthStencil=function(e,r,i){i===void 0&&(i=!1);var s=this.gl;this.currentDepthStencilAttachment!==e&&(this.currentDepthStencilAttachment=e,!i&&!this.inBlitRenderPass&&this.bindFramebufferDepthStencilAttachment(Me(s)?Z.DRAW_FRAMEBUFFER:Z.FRAMEBUFFER,this.currentDepthStencilAttachment),this.resolveDepthStencilAttachmentsChanged=!0),this.currentDepthStencilResolveTo!==r&&(this.currentDepthStencilResolveTo=r,r&&(this.resolveDepthStencilAttachmentsChanged=!0))},t.prototype.setRenderPassParametersClearColor=function(e,r,i,s,o){var n=this.gl;if(this.OES_draw_buffers_indexed!==null){var a=this.currentMegaState.attachmentsState[e];a&&a.channelWriteMask!==Di.ALL&&(this.OES_draw_buffers_indexed.colorMaskiOES(e,!0,!0,!0,!0),a.channelWriteMask=Di.ALL)}else{var a=this.currentMegaState.attachmentsState[0];a&&a.channelWriteMask!==Di.ALL&&(n.colorMask(!0,!0,!0,!0),a.channelWriteMask=Di.ALL)}this.setScissorRectEnabled(!1),Me(n)?n.clearBufferfv(n.COLOR,e,[r,i,s,o]):(n.clearColor(r,i,s,o),n.clear(n.COLOR_BUFFER_BIT))},t.prototype.setRenderPassParametersClearDepthStencil=function(e,r){e===void 0&&(e="load"),r===void 0&&(r="load");var i=this.gl;e!=="load"&&(Ir(!!this.currentDepthStencilAttachment),this.currentMegaState.depthWrite||(i.depthMask(!0),this.currentMegaState.depthWrite=!0),Me(i)?i.clearBufferfv(i.DEPTH,0,[e]):(i.clearDepth(e),i.clear(i.DEPTH_BUFFER_BIT))),r!=="load"&&(Ir(!!this.currentDepthStencilAttachment),this.currentMegaState.stencilWrite||(i.enable(i.STENCIL_TEST),i.stencilMask(255),this.currentMegaState.stencilWrite=!0),Me(i)?i.clearBufferiv(i.STENCIL,0,[r]):(i.clearStencil(r),i.clear(i.STENCIL_BUFFER_BIT)))},t.prototype.setBindings=function(e){var r=this,i;if(this.renderBundle){this.renderBundle.push(function(){return r.setBindings(e)});return}var s=this.gl,o=e,n=o.uniformBufferBindings,a=o.samplerBindings,l=o.bindingLayouts;Ir(0<l.bindingLayoutTables.length);var c=l.bindingLayoutTables[0];Ir(n.length>=c.numUniformBuffers),Ir(a.length>=c.numSamplers);for(var h=0;h<n.length;h++){var u=n[h];if(u.size!==0){var d=c.firstUniformBuffer+h,f=u.buffer,g=u.offset||0,p=u.size||f.byteSize;if(f!==this.currentUniformBuffers[d]||g!==this.currentUniformBufferByteOffsets[d]||p!==this.currentUniformBufferByteSizes[d]){var m=g%f.pageByteSize,v=f.gl_buffer_pages[g/f.pageByteSize|0];Ir(m+p<=f.pageByteSize),Me(s)&&s.bindBufferRange(s.UNIFORM_BUFFER,d,v,m,p),this.currentUniformBuffers[d]=f,this.currentUniformBufferByteOffsets[d]=g,this.currentUniformBufferByteSizes[d]=p}}}for(var h=0;h<c.numSamplers;h++){var u=a[h],b=c.firstSampler+h,y=u!==null&&u.sampler!==null?G$(u.sampler):null,_=u!==null&&u.texture!==null?XT(u.texture):null;if(this.currentSamplers[b]!==y&&(Me(s)&&s.bindSampler(b,y),this.currentSamplers[b]=y),this.currentTextures[b]!==_){if(this.setActiveTexture(s.TEXTURE0+b),_!==null){var w=RE(u).texture,E=w.gl_target,A=w.width,x=w.height;u.texture.textureIndex=b,s.bindTexture(E,_),Me(s)||(i=u.sampler)===null||i===void 0||i.setTextureParameters(E,A,x),this.debugGroupStatisticsTextureBind()}else{var S=fo(fo({},u),Cot),T=S.dimension,R=S.formatKind,E=tDt(T);s.bindTexture(E,this.getFallbackTexture(fo({gl_target:E,formatKind:R},S)))}this.currentTextures[b]=_}}},t.prototype.setViewport=function(e,r,i,s){var o=this.gl;o.viewport(e,r,i,s)},t.prototype.setScissorRect=function(e,r,i,s){var o=this.gl;this.setScissorRectEnabled(!0),o.scissor(e,r,i,s)},t.prototype.applyAttachmentStateIndexed=function(e,r,i){var s=this.gl,o=this.OES_draw_buffers_indexed;r.channelWriteMask!==i.channelWriteMask&&(o.colorMaskiOES(e,!!(i.channelWriteMask&Di.RED),!!(i.channelWriteMask&Di.GREEN),!!(i.channelWriteMask&Di.BLUE),!!(i.channelWriteMask&Di.ALPHA)),r.channelWriteMask=i.channelWriteMask);var n=r.rgbBlendState.blendMode!==i.rgbBlendState.blendMode||r.alphaBlendState.blendMode!==i.alphaBlendState.blendMode,a=r.rgbBlendState.blendSrcFactor!==i.rgbBlendState.blendSrcFactor||r.alphaBlendState.blendSrcFactor!==i.alphaBlendState.blendSrcFactor||r.rgbBlendState.blendDstFactor!==i.rgbBlendState.blendDstFactor||r.alphaBlendState.blendDstFactor!==i.alphaBlendState.blendDstFactor;(a||n)&&($v(r.rgbBlendState)&&$v(r.alphaBlendState)?o.enableiOES(e,s.BLEND):$v(i.rgbBlendState)&&$v(i.alphaBlendState)&&o.disableiOES(e,s.BLEND)),n&&(o.blendEquationSeparateiOES(e,i.rgbBlendState.blendMode,i.alph
472aBlendState.blendMode),r.rgbBlendState.blendMode=i.rgbBlendState.blendMode,r.alphaBlendState.blendMode=i.alphaBlendState.blendMode),a&&(o.blendFuncSeparateiOES(e,i.rgbBlendState.blendSrcFactor,i.rgbBlendState.blendDstFactor,i.alphaBlendState.blendSrcFactor,i.alphaBlendState.blendDstFactor),r.rgbBlendState.blendSrcFactor=i.rgbBlendState.blendSrcFactor,r.alphaBlendState.blendSrcFactor=i.alphaBlendState.blendSrcFactor,r.rgbBlendState.blendDstFactor=i.rgbBlendState.blendDstFactor,r.alphaBlendState.blendDstFactor=i.alphaBlendState.blendDstFactor)},t.prototype.applyAttachmentState=function(e,r){var i=this.gl;e.channelWriteMask!==r.channelWriteMask&&(i.colorMask(!!(r.channelWriteMask&Di.RED),!!(r.channelWriteMask&Di.GREEN),!!(r.channelWriteMask&Di.BLUE),!!(r.channelWriteMask&Di.ALPHA)),e.channelWriteMask=r.channelWriteMask);var s=e.rgbBlendState.blendMode!==r.rgbBlendState.blendMode||e.alphaBlendState.blendMode!==r.alphaBlendState.blendMode,o=e.rgbBlendState.blendSrcFactor!==r.rgbBlendState.blendSrcFactor||e.alphaBlendState.blendSrcFactor!==r.alphaBlendState.blendSrcFactor||e.rgbBlendState.blendDstFactor!==r.rgbBlendState.blendDstFactor||e.alphaBlendState.blendDstFactor!==r.alphaBlendState.blendDstFactor;(o||s)&&($v(e.rgbBlendState)&&$v(e.alphaBlendState)?i.enable(i.BLEND):$v(r.rgbBlendState)&&$v(r.alphaBlendState)&&i.disable(i.BLEND)),s&&(i.blendEquationSeparate(r.rgbBlendState.blendMode,r.alphaBlendState.blendMode),e.rgbBlendState.blendMode=r.rgbBlendState.blendMode,e.alphaBlendState.blendMode=r.alphaBlendState.blendMode),o&&(i.blendFuncSeparate(r.rgbBlendState.blendSrcFactor,r.rgbBlendState.blendDstFactor,r.alphaBlendState.blendSrcFactor,r.alphaBlendState.blendDstFactor),e.rgbBlendState.blendSrcFactor=r.rgbBlendState.blendSrcFactor,e.alphaBlendState.blendSrcFactor=r.alphaBlendState.blendSrcFactor,e.rgbBlendState.blendDstFactor=r.rgbBlendState.blendDstFactor,e.alphaBlendState.blendDstFactor=r.alphaBlendState.blendDstFactor)},t.prototype.setMegaState=function(e){var r=this.gl,i=this.currentMegaState;if(this.OES_draw_buffers_indexed!==null)for(var s=0;s<e.attachmentsState.length;s++)this.applyAttachmentStateIndexed(s,i.attachmentsState[0],e.attachmentsState[0]);else Ir(e.attachmentsState.length===1),this.applyAttachmentState(i.attachmentsState[0],e.attachmentsState[0]);wot(i.blendConstant,e.blendConstant)||(r.blendColor(e.blendConstant.r,e.blendConstant.g,e.blendConstant.b,e.blendConstant.a),Eot(i.blendConstant,e.blendConstant)),i.depthCompare!==e.depthCompare&&(r.depthFunc(e.depthCompare),i.depthCompare=e.depthCompare),!!i.depthWrite!=!!e.depthWrite&&(r.depthMask(e.depthWrite),i.depthWrite=e.depthWrite),!!i.stencilWrite!=!!e.stencilWrite&&(r.stencilMask(e.stencilWrite?255:0),i.stencilWrite=e.stencilWrite);var o=!1;if(!U4(i.stencilFront,e.stencilFront)){o=!0;var n=e.stencilFront,a=n.passOp,l=n.failOp,c=n.depthFailOp,h=n.compare;(i.stencilFront.passOp!==a||i.stencilFront.failOp!==l||i.stencilFront.depthFailOp!==c)&&(r.stencilOpSeparate(r.FRONT,l,c,a),i.stencilFront.passOp=a,i.stencilFront.failOp=l,i.stencilFront.depthFailOp=c),i.stencilFront.compare!==h&&(this.setStencilReference(0),i.stencilFront.compare=h)}if(!U4(i.stencilBack,e.stencilBack)){o=!0;var u=e.stencilBack,a=u.passOp,l=u.failOp,c=u.depthFailOp,h=u.compare;(i.stencilBack.passOp!==a||i.stencilBack.failOp!==l||i.stencilBack.depthFailOp!==c)&&(r.stencilOpSeparate(r.BACK,l,c,a),i.stencilBack.passOp=a,i.stencilBack.failOp=l,i.stencilBack.depthFailOp=c),i.stencilBack.compare!==h&&(this.setStencilReference(0),i.stencilBack.compare=h)}(i.stencilFront.mask!==e.stencilFront.mask||i.stencilBack.mask!==e.stencilBack.mask)&&(o=!0,i.stencilFront.mask=e.stencilFront.mask,i.stencilBack.mask=e.stencilBack.mask),o&&this.applyStencil(),i.cullMode!==e.cullMode&&(i.cullMode===pp.NONE?r.enable(r.CULL_FACE):e.cullMode===pp.NONE&&r.disable(r.CULL_FACE),e.cullMode===pp.BACK?r.cullFace(r.BACK):e.cullMode===pp.FRONT?r.cullFace(r.FRONT):e.cullMode===pp.FRONT_AND_BACK&&r.cullFace(r.FRONT_AND_BACK),i.cullMode=e.cullMode),i.frontFace!==e.frontFace&&(r.frontFace(e.frontFace),i.frontFace=e.frontFace),i.polygonOffset!==e.polygonOffset&&(e.polygonOffset?r.enable(r.POLYGON_OFFSET_FILL):r.disable(r.POLYGON_OFFSET_FILL),i.polygonOffset=e.polygonOffset),(i.polygonOffsetFactor!==e.polygonOffsetFactor||i.polygonOffsetUnits!==e.polygonOffsetUnits)&&(r.polygonOffset(e.polygonOffsetFactor,e.polygonOffsetUnits),i.polygonOffsetFactor=e.polygonOffsetFactor,i.polygonOffsetUnits=e.polygonOffsetUnits)},t.prototype.validatePipelineFormats=function(e){for(var r=0;r<this.currentColorAttachments.length;r++)var i=this.currentColorAttachments[r];this.currentDepthStencilAttachment&&Ir(this.currentDepthStencilAttachment.format===e.depthStencilAttachmentFormat),this.currentSampleCount!==-1&&Ir(this.currentSampleCount===e.sampleC
472ount)},t.prototype.setPipeline=function(e){var r=this;if(this.renderBundle){this.renderBundle.push(function(){return r.setPipeline(e)});return}this.currentPipeline=e,this.validatePipelineFormats(this.currentPipeline),this.setMegaState(this.currentPipeline.megaState);var i=this.currentPipeline.program;if(this.useProgram(i),i.compileState===uu.NeedsBind){var s=this.gl,o=i.gl_program,n=i.descriptor,a=Got(n.vertex.glsl,fDt);if(Me(s))for(var l=0;l<a.length;l++){var c=np(a[l],2),h=c[1],u=s.getUniformBlockIndex(o,h);u!==-1&&u!==4294967295&&s.uniformBlockBinding(o,u,l)}for(var d=Got(n.fragment.glsl,/^uniform .*sampler\S+ (\w+);\s* \/\/ BINDING=(\d+)$/gm),l=0;l<d.length;l++){var f=np(d[l],3),g=f[1],p=f[2],m=s.getUniformLocation(o,g);s.uniform1i(m,parseInt(p))}i.compileState=uu.ReadyToUse}},t.prototype.setVertexInput=function(e,r,i){var s,o,n=this,a;if(this.renderBundle){this.renderBundle.push(function(){return n.setVertexInput(e,r,i)});return}if(e!==null){Ir(this.currentPipeline.inputLayout===e);var l=e;this.bindVAO(l.vao);for(var c=this.gl,h=0;h<l.vertexBufferDescriptors.length;h++){var u=l.vertexBufferDescriptors[h],d=u.arrayStride,f=u.attributes;try{for(var g=(s=void 0,r0(f)),p=g.next();!p.done;p=g.next()){var m=p.value,v=m.shaderLocation,b=m.offset,y=Me(c)?v:(a=l.program.attributes[v])===null||a===void 0?void 0:a.location;if(!me(y)){var _=r[h];if(_===null)continue;var w=m.vertexFormat;c.bindBuffer(c.ARRAY_BUFFER,jT(_.buffer));var E=(_.offset||0)+b;c.vertexAttribPointer(y,w.size,w.type,w.normalized,d,E)}}}catch(x){s={error:x}}finally{try{p&&!p.done&&(o=g.return)&&o.call(g)}finally{if(s)throw s.error}}}if(Ir(i!==null==(l.indexBufferFormat!==null)),i!==null){var A=i.buffer;Ir(A.usage===dt.INDEX),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,jT(A)),this.currentIndexBufferByteOffset=i.offset||0}else this.currentIndexBufferByteOffset=null}else Ir(this.currentPipeline.inputLayout===null),Ir(i===null),this.bindVAO(null),this.currentIndexBufferByteOffset=0},t.prototype.setStencilReference=function(e){this.currentStencilRef!==e&&(this.currentStencilRef=e,this.applyStencil())},t.prototype.draw=function(e,r,i,s){var o,n=this;if(this.renderBundle){this.renderBundle.push(function(){return n.draw(e,r,i,s)});return}var a=this.gl,l=this.currentPipeline;if(r){var c=[l.drawMode,i||0,e,r];Me(a)?a.drawArraysInstanced.apply(a,EE([],np(c),!1)):(o=this.ANGLE_instanced_arrays).drawArraysInstancedANGLE.apply(o,EE([],np(c),!1))}else a.drawArrays(l.drawMode,i,e);this.debugGroupStatisticsDrawCall(),this.debugGroupStatisticsTriangles(e/3*Math.max(r,1))},t.prototype.drawIndexed=function(e,r,i,s,o){var n,a=this;if(this.renderBundle){this.renderBundle.push(function(){return a.drawIndexed(e,r,i,s,o)});return}var l=this.gl,c=this.currentPipeline,h=RE(c.inputLayout),u=RE(this.currentIndexBufferByteOffset)+i*h.indexBufferCompByteSize;if(r){var d=[c.drawMode,e,h.indexBufferType,u,r];Me(l)?l.drawElementsInstanced.apply(l,EE([],np(d),!1)):(n=this.ANGLE_instanced_arrays).drawElementsInstancedANGLE.apply(n,EE([],np(d),!1))}else l.drawElements(c.drawMode,e,h.indexBufferType,u);this.debugGroupStatisticsDrawCall(),this.debugGroupStatisticsTriangles(e/3*Math.max(r,1))},t.prototype.drawIndirect=function(e,r){},t.prototype.drawIndexedIndirect=function(e,r){},t.prototype.beginOcclusionQuery=function(e){var r=this.gl;if(Me(r)){var i=this.currentRenderPassDescriptor.occlusionQueryPool;r.beginQuery(i.gl_query_type,i.gl_query[e])}},t.prototype.endOcclusionQuery=function(){var e=this.gl;if(Me(e)){var r=this.currentRenderPassDescriptor.occlusionQueryPool;e.endQuery(r.gl_query_type)}},t.prototype.pipelineQueryReady=function(e){var r=e;return this.queryProgramReady(r.program)},t.prototype.pipelineForceReady=function(e){},t.prototype.endPass=function(){for(var e=this.gl,r=Me(e),i=this.currentColorResolveTos.length===1&&this.currentColorResolveTos[0]===this.scTexture,s=!1,o=0;o<this.currentColorAttachments.length;o++){var n=this.currentColorAttachments[o];if(n!==null){var a=this.currentColorResolveTos[o],l=!1;a!==null&&(Ir(n.width===a.width&&n.height===a.height),this.setScissorRectEnabled(!1),i||(r&&e.bindFramebuffer(e.READ_FRAMEBUFFER,this.resolveColorReadFramebuffer),this.resolveColorAttachmentsChanged&&r&&this.bindFramebufferAttachment(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,n,this.currentColorAttachmentLevels[o])),l=!0,i||(a===this.scTexture?e.bindFramebuffer(r?Z.DRAW_FRAMEBUFFER:Z.FRAMEBUFFER,this.scPlatformFramebuffer):(e.bindFramebuffer(r?Z.DRAW_FRAMEBUFFER:Z.FRAMEBUFFER,this.resolveColorDrawFramebuffer),this.resolveColorAttachmentsChanged&&e.framebufferTexture2D(r?Z.DRAW_FRAMEBUFFER:Z.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,a.gl_texture,this.currentColorResolveToLevels[o]))),i||(r?(e.blitFramebuffer(0,0,n.width,n.height,0,0,a.width,a.height,e.COLOR_BUFFER_BIT,e.LINEAR),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null)):this.submitBl
472itRenderPass(n,a)),s=!0),this.currentRenderPassDescriptor.colorStore[o]||!i&&!l&&(e.bindFramebuffer(r?Z.READ_FRAMEBUFFER:Z.FRAMEBUFFER,this.resolveColorReadFramebuffer),this.resolveColorAttachmentsChanged&&this.bindFramebufferAttachment(r?Z.READ_FRAMEBUFFER:Z.FRAMEBUFFER,e.COLOR_ATTACHMENT0,n,this.currentColorAttachmentLevels[o])),i||e.bindFramebuffer(r?Z.READ_FRAMEBUFFER:Z.FRAMEBUFFER,null)}}this.resolveColorAttachmentsChanged=!1;var c=this.currentDepthStencilAttachment;if(c){var h=this.currentDepthStencilResolveTo,l=!1;h&&(Ir(c.width===h.width&&c.height===h.height),this.setScissorRectEnabled(!1),i||(e.bindFramebuffer(r?Z.READ_FRAMEBUFFER:Z.FRAMEBUFFER,this.resolveDepthStencilReadFramebuffer),e.bindFramebuffer(r?Z.DRAW_FRAMEBUFFER:Z.FRAMEBUFFER,this.resolveDepthStencilDrawFramebuffer),this.resolveDepthStencilAttachmentsChanged&&(this.bindFramebufferDepthStencilAttachment(r?Z.READ_FRAMEBUFFER:Z.FRAMEBUFFER,c),this.bindFramebufferDepthStencilAttachment(r?Z.DRAW_FRAMEBUFFER:Z.FRAMEBUFFER,h))),l=!0,i||(r&&e.blitFramebuffer(0,0,c.width,c.height,0,0,h.width,h.height,e.DEPTH_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(r?Z.DRAW_FRAMEBUFFER:Z.FRAMEBUFFER,null)),s=!0),!i&&!this.currentRenderPassDescriptor.depthStencilStore&&(l||(e.bindFramebuffer(r?Z.READ_FRAMEBUFFER:Z.FRAMEBUFFER,this.resolveDepthStencilReadFramebuffer),this.resolveDepthStencilAttachmentsChanged&&this.bindFramebufferDepthStencilAttachment(r?Z.READ_FRAMEBUFFER:Z.FRAMEBUFFER,c),l=!0),r&&e.invalidateFramebuffer(e.READ_FRAMEBUFFER,[e.DEPTH_STENCIL_ATTACHMENT])),!i&&l&&e.bindFramebuffer(r?Z.READ_FRAMEBUFFER:Z.FRAMEBUFFER,null),this.resolveDepthStencilAttachmentsChanged=!1}!i&&!s&&e.bindFramebuffer(r?Z.DRAW_FRAMEBUFFER:Z.FRAMEBUFFER,null)},t.prototype.setScissorRectEnabled=function(e){if(this.currentScissorEnabled!==e){var r=this.gl;e?r.enable(r.SCISSOR_TEST):r.disable(r.SCISSOR_TEST),this.currentScissorEnabled=e}},t.prototype.applyStencil=function(){me(this.currentStencilRef)||(this.gl.stencilFuncSeparate(Z.FRONT,this.currentMegaState.stencilFront.compare,this.currentStencilRef,this.currentMegaState.stencilFront.mask||255),this.gl.stencilFuncSeparate(Z.BACK,this.currentMegaState.stencilBack.compare,this.currentStencilRef,this.currentMegaState.stencilBack.mask||255))},t.prototype.getFallbackTexture=function(e){var r=e.gl_target,i=e.formatKind;if(r===Z.TEXTURE_2D)return i===en.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(r===Z.TEXTURE_2D_ARRAY)return this.fallbackTexture2DArray;if(r===Z.TEXTURE_3D)return this.fallbackTexture3D;if(r===Z.TEXTURE_CUBE_MAP)return this.fallbackTextureCube;throw new Error("whoops")},t.prototype.submitBlitRenderPass=function(e,r){this.blitRenderPipeline||(this.blitProgram=this.createProgram({vertex:{glsl:`layout(location = 0) in vec2 a_Position; 473out vec2 v_TexCoord; 474void main() { 475 v_TexCoord = 0.5 * (a_Position + 1.0); 476 gl_Position = vec4(a_Position, 0., 1.); 477 478 #ifdef VIEWPORT_ORIGIN_TL 479 v_TexCoord.y = 1.0 - v_TexCoord.y; 480 #endif 481}`},fragment:{glsl:`uniform sampler2D u_Texture; 482in vec2 v_TexCoord; 483out vec4 outputColor; 484void main() { 485 outputColor = texture(SAMPLER_2D(u_Texture), v_TexCoord); 486}`}}),this.blitVertexBuffer=this.createBuffer({usage:dt.VERTEX|dt.COPY_DST,viewOrSize:new Float32Array([-4,-4,4,-4,0,4])}),this.blitInputLayout=this.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{format:I.F32_RG,offset:0,shaderLocation:0}]}],indexBufferFormat:null,program:this.blitProgram}),this.blitRenderPipeline=this.createRenderPipeline({topology:Go.TRIANGLES,sampleCount:1,program:this.blitProgram,colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:null,inputLayout:this.blitInputLayout,megaStateDescriptor:UT(GT)}),this.blitBindings=this.createBindings({samplerBindings:[{sampler:null,texture:e.texture}],uniformBufferBindings:[]}),this.blitProgram.setUniformsLegacy({u_Texture:e}));var i=this.currentRenderPassDescriptor;this.currentRenderPassDescriptor=null,this.inBlitRenderPass=!0;var s=this.createRenderPass({colorAttachment:[e],colorResolveTo:[r],colorClearColor:[op]}),o=this.getCanvas(),n=o.width,a=o.height;s.setPipeline(this.blitRenderPipeline),s.setBindings(this.blitBindings),s.setVertexInput(this.blitInputLayout,[{buffer:this.blitVertexBuffer}
486],null),s.setViewport(0,0,n,a),this.gl.disable(this.gl.BLEND),s.draw(3,0),this.gl.enable(this.gl.BLEND),this.currentRenderPassDescriptor=i,this.inBlitRenderPass=!1},t})(),hd=(function(){function t(e){this.pluginOptions=e}return t.prototype.createSwapChain=function(e){return Rr(this,void 0,void 0,function(){var r,i,s,o,n,a,l,c,h,u,d,f,g;return hT(this,function(p){return r=this.pluginOptions,i=r.targets,s=r.xrCompatible,o=r.antialias,n=o===void 0?!1:o,a=r.preserveDrawingBuffer,l=a===void 0?!1:a,c=r.premultipliedAlpha,h=c===void 0?!0:c,u=r.shaderDebug,d=r.trackResources,f={antialias:n,preserveDrawingBuffer:l,stencil:!0,premultipliedAlpha:h,xrCompatible:s},this.handleContextEvents(e),i.includes("webgl2")&&(g=e.getContext("webgl2",f)||e.getContext("experimental-webgl2",f)),!g&&i.includes("webgl1")&&(g=e.getContext("webgl",f)||e.getContext("experimental-webgl",f)),[2,new pDt(g,{shaderDebug:u,trackResources:d})]})})},t.prototype.handleContextEvents=function(e){var r=this.pluginOptions,i=r.onContextLost,s=r.onContextRestored,o=r.onContextCreationError;o&&e.addEventListener("webglcontextcreationerror",o,!1),i&&e.addEventListener("webglcontextlost",i,!1),s&&e.addEventListener("webglcontextrestored",s,!1)},t})();let sn;const jot=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&jot.decode();let sI=null;function K4(){return(sI===null||sI.byteLength===0)&&(sI=new Uint8Array(sn.memory.buffer)),sI}function q4(t,e){return t=t>>>0,jot.decode(K4().subarray(t,t+e))}const g0=new Array(128).fill(void 0);g0.push(void 0,null,!0,!1);let oI=g0.length;function gDt(t){oI===g0.length&&g0.push(g0.length+1);const e=oI;return oI=g0[e],g0[e]=t,e}function Z4(t){return g0[t]}function mDt(t){t<132||(g0[t]=oI,oI=t)}function yDt(t){const e=Z4(t);return mDt(t),e}let zT=0;const J4=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},vDt=typeof J4.encodeInto=="function"?function(t,e){return J4.encodeInto(t,e)}:function(t,e){const r=J4.encode(t);return e.set(r),{read:t.length,written:r.length}};function Q4(t,e,r){if(r===void 0){const a=J4.encode(t),l=e(a.length,1)>>>0;return K4().subarray(l,l+a.length).set(a),zT=a.length,l}let i=t.length,s=e(i,1)>>>0;const o=K4();let n=0;for(;n<i;n++){const a=t.charCodeAt(n);if(a>127)break;o[s+n]=a}if(n!==i){n!==0&&(t=t.slice(n)),s=r(s,i,i=n+t.length*3,1)>>>0;const a=K4().subarray(s+n,s+i),l=vDt(t,a);n+=l.written}return zT=n,s}let nI=null;function t5(){return(nI===null||nI.byteLength===0)&&(nI=new Int32Array(sn.memory.buffer)),nI}function _Dt(t,e,r){let i,s;try{const a=sn.__wbindgen_add_to_stack_pointer(-16),l=Q4(t,sn.__wbindgen_malloc,sn.__wbindgen_realloc),c=zT,h=Q4(e,sn.__wbindgen_malloc,sn.__wbindgen_realloc),u=zT;sn.glsl_compile(a,l,c,h,u,r);var o=t5()[a/4+0],n=t5()[a/4+1];return i=o,s=n,q4(o,n)}finally{sn.__wbindgen_add_to_stack_pointer(16),sn.__wbindgen_free(i,s,1)}}let Xot=class het{static __wrap(e){e=e>>>0;const r=Object.create(het.prototype);return r.__wbg_ptr=e,r}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();sn.__wbg_wgslcomposer_free(e)}constructor(){const e=sn.wgslcomposer_new();return het.__wrap(e)}load_composable(e){const r=Q4(e,sn.__wbindgen_malloc,sn.__wbindgen_realloc),i=zT;sn.wgslcomposer_load_composable(this.__wbg_ptr,r,i)}wgsl_compile(e){let r,i;try{const n=sn.__wbindgen_add_to_stack_pointer(-16),a=Q4(e,sn.__wbindgen_malloc,sn.__wbindgen_realloc),l=zT;sn.wgslcomposer_wgsl_compile(n,this.__wbg_ptr,a,l);var s=t5()[n/4+0],o=t5()[n/4+1];return r=s,i=o,q4(s,o)}finally{sn.__wbindgen_add_to_stack_pointer(16),sn.__wbindgen_free(r,i,1)}}};async function bDt(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(i){if(t.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",i);else throw i}const r=await t.arrayBuffer();return await WebAssembly.instantiate(r,e)}else{const r=await WebAssembly.instantiate(t,e);return r instanceof WebAssembly.Instance?{instance:r,module:t}:r}}function wDt(){const t={};return t.wbg={},t.wbg.__wbindgen_string_new=function(e,r){const i=q4(e,r);return gDt(i)},t.wbg.__wbindgen_object_drop_ref=function(e){yDt(e)},t.wbg.__wbg_log_1d3ae0273d8f4f8a=function(e){console.log(Z4(e))},t.wbg.__wbg_log_576ca876af0d4a77=function(e,r){console.log(Z4(e),Z4(r))},t.wbg.__wbindgen_throw=function(e,r){throw new Error(q4(e,r))},t}function EDt(t,e){return sn=t.exports,zot.__wbindgen_wasm_module=e,nI=null,
486sI=null,sn}async function zot(t){if(sn!==void 0)return sn;const e=wDt();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));const{instance:r,module:i}=await bDt(await t,e);return EDt(r,i)}var Va;(function(t){t[t.COPY_SRC=1]="COPY_SRC",t[t.COPY_DST=2]="COPY_DST",t[t.TEXTURE_BINDING=4]="TEXTURE_BINDING",t[t.STORAGE_BINDING=8]="STORAGE_BINDING",t[t.STORAGE=8]="STORAGE",t[t.RENDER_ATTACHMENT=16]="RENDER_ATTACHMENT"})(Va||(Va={}));var X$;(function(t){t[t.READ=1]="READ",t[t.WRITE=2]="WRITE"})(X$||(X$={}));function ADt(t){var e=0;return t&xr.SAMPLED&&(e|=Va.TEXTURE_BINDING|Va.COPY_DST|Va.COPY_SRC),t&xr.STORAGE&&(e|=Va.TEXTURE_BINDING|Va.STORAGE_BINDING|Va.COPY_SRC|Va.COPY_DST),t&xr.RENDER_TARGET&&(e|=Va.RENDER_ATTACHMENT|Va.TEXTURE_BINDING|Va.COPY_SRC|Va.COPY_DST),e}function z$(t){if(t===I.U8_R_NORM)return"r8unorm";if(t===I.S8_R_NORM)return"r8snorm";if(t===I.U8_RG_NORM)return"rg8unorm";if(t===I.S8_RG_NORM)return"rg8snorm";if(t===I.U32_R)return"r32uint";if(t===I.S32_R)return"r32sint";if(t===I.F32_R)return"r32float";if(t===I.U16_RG)return"rg16uint";if(t===I.S16_RG)return"rg16sint";if(t===I.F16_RG)return"rg16float";if(t===I.U8_RGBA_RT)return"bgra8unorm";if(t===I.U8_RGBA_RT_SRGB)return"bgra8unorm-srgb";if(t===I.U8_RGBA_NORM)return"rgba8unorm";if(t===I.U8_RGBA_SRGB)return"rgba8unorm-srgb";if(t===I.S8_RGBA_NORM)return"rgba8snorm";if(t===I.U32_RG)return"rg32uint";if(t===I.S32_RG)return"rg32sint";if(t===I.F32_RG)return"rg32float";if(t===I.U16_RGBA)return"rgba16uint";if(t===I.S16_RGBA)return"rgba16sint";if(t===I.F16_RGBA)return"rgba16float";if(t===I.F32_RGBA)return"rgba32float";if(t===I.U32_RGBA)return"rgba32uint";if(t===I.S32_RGBA)return"rgba32sint";if(t===I.D24)return"depth24plus";if(t===I.D24_S8)return"depth24plus-stencil8";if(t===I.D32F)return"depth32float";if(t===I.D32F_S8)return"depth32float-stencil8";if(t===I.BC1)return"bc1-rgba-unorm";if(t===I.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(t===I.BC2)return"bc2-rgba-unorm";if(t===I.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(t===I.BC3)return"bc3-rgba-unorm";if(t===I.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(t===I.BC4_SNORM)return"bc4-r-snorm";if(t===I.BC4_UNORM)return"bc4-r-unorm";if(t===I.BC5_SNORM)return"bc5-rg-snorm";if(t===I.BC5_UNORM)return"bc5-rg-unorm";throw"whoops"}function xDt(t){if(t===ei.TEXTURE_2D||t===ei.TEXTURE_CUBE_MAP||t===ei.TEXTURE_2D_ARRAY)return"2d";if(t===ei.TEXTURE_3D)return"3d";throw new Error("whoops")}function SDt(t){if(t===ei.TEXTURE_2D)return"2d";if(t===ei.TEXTURE_CUBE_MAP)return"cube";if(t===ei.TEXTURE_2D_ARRAY)return"2d-array";if(t===ei.TEXTURE_3D)return"3d";throw new Error("whoops")}function TDt(t){var e=0;return t&dt.INDEX&&(e|=GPUBufferUsage.INDEX),t&dt.VERTEX&&(e|=GPUBufferUsage.VERTEX),t&dt.UNIFORM&&(e|=GPUBufferUsage.UNIFORM),t&dt.STORAGE&&(e|=GPUBufferUsage.STORAGE),t&dt.COPY_SRC&&(e|=GPUBufferUsage.COPY_SRC),t&dt.INDIRECT&&(e|=GPUBufferUsage.INDIRECT),e|=GPUBufferUsage.COPY_DST,e}function V$(t){if(t===Zn.CLAMP_TO_EDGE)return"clamp-to-edge";if(t===Zn.REPEAT)return"repeat";if(t===Zn.MIRRORED_REPEAT)return"mirror-repeat";throw new Error("whoops")}function Vot(t){if(t===io.BILINEAR)return"linear";if(t===io.POINT)return"nearest";throw new Error("whoops")}function RDt(t){if(t===xn.LINEAR)return"linear";if(t===xn.NEAREST||t===xn.NO_MIP)return"nearest";throw new Error("whoops")}function VT(t){var e=t;return e.gpuBuffer}function CDt(t){var e=t;return e.gpuSampler}function MDt(t){var e=t;return e.querySet}function BDt(t){if(t===D4.OcclusionConservative)return"occlusion";throw new Error("whoops")}function ODt(t){switch(t){case Go.TRIANGLES:return"triangle-list";case Go.POINTS:return"point-list";case Go.TRIANGLE_STRIP:return"triangle-strip";case Go.LINES:return"line-list";case Go.LINE_STRIP:return"line-strip";default:throw new Error("Unknown primitive topology mode")}}function IDt(t){if(t===pp.NONE)return"none";if(t===pp.FRONT)return"front";if(t===pp.BACK)return"back";throw new Error("whoops")}function DDt(t){if(t===JO.CCW)return"ccw";if(t===JO.CW)return"cw";throw new Error("whoops")}function PDt(t,e){return{topology:ODt(t),cullMode:IDt(e.cullMode),frontFace:DDt(e.frontFace)}}function Yot(t){if(t===kt.ZERO)return"zero";if(t===kt.ONE)return"one";if(t===kt.SRC)return"src";if(t===kt.ONE_MINUS_SRC)return"one-minus-src";if(t===kt.DST)return"dst";if(t===kt.ONE_MINUS_DST)return"one-minus-dst";if(t===kt.SRC_ALPHA)return"src-alpha";if(t===kt.ONE_MINUS_SRC_ALPHA)return"one-minus-src-alpha";if(t===kt.DST_ALPHA)return"dst-alpha";if(t===kt.ONE_MINUS_DST_ALPHA)return"one-minus-dst-alpha";if(t===kt.CONST)return"constant";if(t===kt.ONE_MINUS_CONSTANT)return"one-minus-constant";if(t===kt.SRC_ALPHA_SATURATE)return"src-alpha-saturated";throw new Error("whoops")}function FDt(t){if(t===hr.ADD)return"add";if(t===hr.SUBSTRACT)return"subtract";if(t===hr.REVERSE_SUBSTRACT)return"reverse-subtract";if(t===hr.MIN)return"min";if(t===hr.MAX)return"max";throw new Error("whoops")}function $ot(t){return{operation:FDt(t.blendMode),srcFactor:Yot(t.blendSrcFactor),dstFactor:Yot(t.blendDstFactor)}}function Hot(t){return t.blendMode===hr.ADD&&t.blendSrcFactor===kt.ONE&&t.blendDstFactor===kt.ZERO}
486function NDt(t){if(!(Hot(t.rgbBlendState)&&Hot(t.alphaBlendState)))return{color:$ot(t.rgbBlendState),alpha:$ot(t.alphaBlendState)}}function kDt(t,e){return{format:z$(e),blend:NDt(t),writeMask:t.channelWriteMask}}function LDt(t,e){return e.attachmentsState.map(function(r,i){return kDt(r,t[i])})}function e5(t){if(t===qe.NEVER)return"never";if(t===qe.LESS)return"less";if(t===qe.EQUAL)return"equal";if(t===qe.LEQUAL)return"less-equal";if(t===qe.GREATER)return"greater";if(t===qe.NOTEQUAL)return"not-equal";if(t===qe.GEQUAL)return"greater-equal";if(t===qe.ALWAYS)return"always";throw new Error("whoops")}function YT(t){if(t===ce.KEEP)return"keep";if(t===ce.REPLACE)return"replace";if(t===ce.ZERO)return"zero";if(t===ce.DECREMENT_CLAMP)return"decrement-clamp";if(t===ce.DECREMENT_WRAP)return"decrement-wrap";if(t===ce.INCREMENT_CLAMP)return"increment-clamp";if(t===ce.INCREMENT_WRAP)return"increment-wrap";if(t===ce.INVERT)return"invert";throw new Error("whoops")}function UDt(t,e){if(!me(t))return{format:z$(t),depthWriteEnabled:!!e.depthWrite,depthCompare:e5(e.depthCompare),depthBias:e.polygonOffset?e.polygonOffsetUnits:0,depthBiasSlopeScale:e.polygonOffset?e.polygonOffsetFactor:0,stencilFront:{compare:e5(e.stencilFront.compare),passOp:YT(e.stencilFront.passOp),failOp:YT(e.stencilFront.failOp),depthFailOp:YT(e.stencilFront.depthFailOp)},stencilBack:{compare:e5(e.stencilBack.compare),passOp:YT(e.stencilBack.passOp),failOp:YT(e.stencilBack.failOp),depthFailOp:YT(e.stencilBack.depthFailOp)},stencilReadMask:4294967295,stencilWriteMask:4294967295}}function GDt(t){if(t!==null){if(t===I.U16_R)return"uint16";if(t===I.U32_R)return"uint32";throw new Error("whoops")}}function WDt(t){if(t===ne.VERTEX)return"vertex";if(t===ne.INSTANCE)return"instance";throw new Error("whoops")}function jDt(t){if(t===I.U8_R||t===I.U8_RG)return"uint8x2";if(t===I.U8_RGB||t===I.U8_RGBA)return"uint8x4";if(t===I.U8_RG_NORM)return"unorm8x2";if(t===I.U8_RGBA_NORM)return"unorm8x4";if(t===I.S8_RGB_NORM||t===I.S8_RGBA_NORM)return"snorm8x4";if(t===I.U16_RG_NORM)return"unorm16x2";if(t===I.U16_RGBA_NORM)return"unorm16x4";if(t===I.S16_RG_NORM)return"snorm16x2";if(t===I.S16_RGBA_NORM)return"snorm16x4";if(t===I.S16_RG)return"uint16x2";if(t===I.F16_RG)return"float16x2";if(t===I.F16_RGBA)return"float16x4";if(t===I.F32_R)return"float32";if(t===I.F32_RG)return"float32x2";if(t===I.F32_RGB)return"float32x3";if(t===I.F32_RGBA)return"float32x4";throw"whoops"}function XDt(t){var e=wm(t);switch(e){case St.BC1:case St.BC2:case St.BC3:case St.BC4_SNORM:case St.BC4_UNORM:case St.BC5_SNORM:case St.BC5_UNORM:return!0;default:return!1}}function zDt(t){var e=wm(t);switch(e){case St.BC1:case St.BC2:case St.BC3:case St.BC4_SNORM:case St.BC4_UNORM:case St.BC5_SNORM:case St.BC5_UNORM:return 4;default:return 1}}function Kot(t,e,r,i){switch(r===void 0&&(r=!1),t){case I.S8_R:case I.S8_R_NORM:case I.S8_RG_NORM:case I.S8_RGB_NORM:case I.S8_RGBA_NORM:{var s=e instanceof ArrayBuffer?new Int8Array(e):new Int8Array(e);return i&&s.set(new Int8Array(i)),s}case I.U8_R:case I.U8_R_NORM:case I.U8_RG:case I.U8_RG_NORM:case I.U8_RGB:case I.U8_RGB_NORM:case I.U8_RGB_SRGB:case I.U8_RGBA:case I.U8_RGBA_NORM:case I.U8_RGBA_SRGB:{var o=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e);return i&&o.set(new Uint8Array(i)),o}case I.S16_R:case I.S16_RG:case I.S16_RG_NORM:case I.S16_RGB_NORM:case I.S16_RGBA:case I.S16_RGBA_NORM:{var n=e instanceof ArrayBuffer?new Int16Array(e):new Int16Array(r?e/2:e);return i&&n.set(new Int16Array(i)),n}case I.U16_R:case I.U16_RGB:case I.U16_RGBA_5551:case I.U16_RGBA_NORM:case I.U16_RG_NORM:case I.U16_R_NORM:{var a=e instanceof ArrayBuffer?new Uint16Array(e):new Uint16Array(r?e/2:e);return i&&a.set(new Uint16Array(i)),a}case I.S32_R:{var l=e instanceof ArrayBuffer?new Int32Array(e):new Int32Array(r?e/4:e);return i&&l.set(new Int32Array(i)),l}case I.U32_R:case I.U32_RG:{var c=e instanceof ArrayBuffer?new Uint32Array(e):new Uint32Array(r?e/4:e);return i&&c.set(new Uint32Array(i)),c}case I.F32_R:case I.F32_RG:case I.F32_RGB:case I.F32_RGBA:{var h=e instanceof ArrayBuffer?new Float32Array(e):new Float32Array(r?e/4:e);return i&&h.set(new Float32Array(i)),h}}var u=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e);return i&&u.set(new Uint8Array(i)),u}function VDt(t){var e=(t&32768)>>15,r=(t&31744)>>10,i=t&1023;return r===0?(e?-1:1)*Math.pow(2,-14)*(i/Math.pow(2,10)):r==31?i?NaN:(e?-1:1)*(1/0):(e?-1:1)*Math.pow(2,r-15
486)*(1+i/Math.pow(2,10))}function qot(t){switch(t){case"r8unorm":case"r8snorm":case"r8uint":case"r8sint":return{width:1,height:1,length:1};case"r16uint":case"r16sint":case"r16float":case"rg8unorm":case"rg8snorm":case"rg8uint":case"rg8sint":return{width:1,height:1,length:2};case"r32uint":case"r32sint":case"r32float":case"rg16uint":case"rg16sint":case"rg16float":case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8snorm":case"rgba8uint":case"rgba8sint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgb9e5ufloat":case"rgb10a2unorm":case"rg11b10ufloat":return{width:1,height:1,length:4};case"rg32uint":case"rg32sint":case"rg32float":case"rgba16uint":case"rgba16sint":case"rgba16float":return{width:1,height:1,length:8};case"rgba32uint":case"rgba32sint":case"rgba32float":return{width:1,height:1,length:16};case"stencil8":throw new Error("No fixed size for Stencil8 format!");case"depth16unorm":return{width:1,height:1,length:2};case"depth24plus":throw new Error("No fixed size for Depth24Plus format!");case"depth24plus-stencil8":throw new Error("No fixed size for Depth24PlusStencil8 format!");case"depth32float":return{width:1,height:1,length:4};case"depth32float-stencil8":return{width:1,height:1,length:5};case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc6h-rgb-ufloat":case"bc6h-rgb-float":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc5-rg-unorm":case"bc5-rg-snorm":return{width:4,height:4,length:16};case"bc4-r-unorm":case"bc4-r-snorm":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":return{width:4,height:4,length:8};default:return{width:1,height:1,length:4}}}var gp=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=t.call(this)||this;return o.id=i,o.device=s,o}return e.prototype.destroy=function(){},e})(Uo),YDt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n,a,l=t.call(this,{id:i,device:s})||this;l.type=Wi.Bindings;var c=o.pipeline;Ir(!!c);var h=o.uniformBufferBindings,u=o.storageBufferBindings,d=o.samplerBindings,f=o.storageTextureBindings;l.numUniformBuffers=(h==null?void 0:h.length)||0;var g=[[],[],[],[]],p=0;if(h&&h.length)for(var m=0;m<h.length;m++){var v=o.uniformBufferBindings[m],b=v.binding,y=v.size,_=v.offset,w=v.buffer,E={buffer:VT(w),offset:_??0,size:y};g[0].push({binding:b??p++,resource:E})}if(d&&d.length){p=0;for(var m=0;m<d.length;m++){var A=fo(fo({},d[m]),Cot),b=o.samplerBindings[m],x=b.texture!==null?b.texture:l.device.getFallbackTexture(A);A.dimension=x.dimension,A.formatKind=bot(x.format);var S=x.gpuTextureView;if(g[1].push({binding:(n=b.textureBinding)!==null&&n!==void 0?n:p++,resource:S}),b.samplerBinding!==-1){var T=b.sampler!==null?b.sampler:l.device.getFallbackSampler(A),R=CDt(T);g[1].push({binding:(a=b.samplerBinding)!==null&&a!==void 0?a:p++,resource:R})}}}if(u&&u.length){p=0;for(var m=0;m<u.length;m++){var B=o.storageBufferBindings[m],b=B.binding,y=B.size,_=B.offset,w=B.buffer,E={buffer:VT(w),offset:_??0,size:y};g[2].push({binding:b??p++,resource:E})}}if(f&&f.length){p=0;for(var m=0;m<f.length;m++){var O=o.storageTextureBindings[m],b=O.binding,x=O.texture,S=x.gpuTextureView;g[3].push({binding:b??p++,resource:S})}}var C=g.findLastIndex(function(F){return!!F.length});return l.gpuBindGroup=g.map(function(F,U){return U<=C&&l.device.device.createBindGroup({layout:c.getBindGroupLayout(U),entries:F})}),l}return e})(gp),$Dt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n=t.call(this,{id:i,device:s})||this;n.type=Wi.Buffer;var a=o.usage,l=o.viewOrSize,c=!!(a&dt.MAP_READ);n.usage=TDt(a),c&&(n.usage=dt.MAP_READ|dt.COPY_DST);var h=!lc(l);if(n.view=lc(l)?null:l,n.size=lc(l)?N4(l,4):N4(l.byteLength,4),lc(l))n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:c?h:!1});else{n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!0});var u=l&&l.constructor||Float32Array;new u(n.gpuBuffer.getMappedRange()).set(l),n.gpuBuffer.unmap()}return n}return e.prototype.setSubData=function(r,i,s,o){s===void 0&&(s=0),o===void 0&&(o=0);var n=this.gpuBuffer;o=o||i.byteLength,o=Math.min(o,this.size-r);var a=i.byteOffset+s,l=a+o,c=o+3&-4;if(c!==o){var h=new Uint8Array(i.buffer.slice(a,l));i=new Uint8Array(c),i.set(h),s=0,a=0,l=c,o=c}for(var u=1024*1024*15,d=0;l-(a+d)>u;)this.device.device.queue.writeBuffer(n,r+d,i.buffer,a+d,u),d+=u;this.device.device.queue.writeBuffer(n,r+d,i.buffer,a+d,o-d)},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.gpuBuffer.destroy()},e})(gp),Zot=(function(){function t(){this.gpuComputePassEncoder=null}return t.prototype.dispatchWorkgroups=function(e,r,i){this.gpuComputePassEncoder.dispatchWorkgroups(e,r,i)},t.prototype.dispatchWorkgroupsIndirect=function(e,r){this.gpuComputePassEncoder.dispatchWorkgroupsIndirect(e.gpuBuffer,r)},t.prototype.finish=function(){this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.frameCommandEncoder=null},t.prototype.beginComputePass=function(e){Ir(this.gpuComputePassEncoder===null),this.frameCommandEncoder=e,this.gpuComputePassEncoder=this.frameCommandEncoder.beginComputePass(this.gpuComputePassDescriptor)},t.prototype.setPipeline=function(e){var r=e,i=RE(r.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(i)},t.prototype.setBindings=function(e){var r=this,i=e;i.gpuBindGroup.forEach(function(s,o){s&&r.gpuComputePassEncoder.setBindGroup(o,i.gpuBindGroup[o])})},t.prototype.pushDebugGroup=function(e){this.gpuComputePassEncoder.pushDebugGroup(e)},t.prototype.popDebugGroup=function(){this.gpuComputePassEncoder.popDebugGroup()},t.prototype.insertDebugMarker=function(e){this.gpuComputePassEncoder.insertDebugMarker(e)},t})(),HDt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n=t.call(this,{id:i,device:s})||this;n.type=Wi.ComputePipeline,n.gpuComputePipeline=null,n.descriptor=o;var a=o.program,l=a.computeStage;if(l===null)return n;var c={layout:"auto",compute:fo({},l)};return n.gpuComputePipeline=n.device.device.createComputePipeline(c),n.name!==void 0&&(n.gpuComputePipeline.label=n.name),n}return e.prototype.getBindGroupLayout=function(r){return this.gpuComputePipeline.getBindGroupLayout(r)},e})(gp),KDt=(function(t){Jo(e,t);function e(r){var i,s,o,n,a=r.id,l=r.device,c=r.descriptor,h=t.call(this,{id:a,device:l})||this;h.type=Wi.InputLayout;var u=[];try{for(var d=r0(c.vertexBufferDescriptors),f=d.next();!f.done;
486f=d.next()){var g=f.value,p=g.arrayStride,m=g.stepMode,v=g.attributes;u.push({arrayStride:p,stepMode:WDt(m),attributes:[]});try{for(var b=(o=void 0,r0(v)),y=b.next();!y.done;y=b.next()){var _=y.value,w=_.shaderLocation,E=_.format,A=_.offset;u[u.length-1].attributes.push({shaderLocation:w,format:jDt(E),offset:A})}}catch(x){o={error:x}}finally{try{y&&!y.done&&(n=b.return)&&n.call(b)}finally{if(o)throw o.error}}}}catch(x){i={error:x}}finally{try{f&&!f.done&&(s=d.return)&&s.call(d)}finally{if(i)throw i.error}}return h.indexFormat=GDt(c.indexBufferFormat),h.buffers=u,h}return e})(gp),Jot=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n=t.call(this,{id:i,device:s})||this;return n.type=Wi.Program,n.vertexStage=null,n.fragmentStage=null,n.computeStage=null,n.descriptor=o,o.vertex&&(n.vertexStage=n.createShaderStage(o.vertex,"vertex")),o.fragment&&(n.fragmentStage=n.createShaderStage(o.fragment,"fragment")),o.compute&&(n.computeStage=n.createShaderStage(o.compute,"compute")),n}return e.prototype.setUniformsLegacy=function(r){},e.prototype.createShaderStage=function(r,i){var s,o,n=r.glsl,a=r.wgsl,l=r.entryPoint,c=r.postprocess,h=!1,u=a;if(!u)try{u=this.device.glsl_compile(n,i,h)}catch(v){throw console.error(v,n),new Error("whoops")}var d=function(v){if(!u.includes(v))return"continue";u=u.replace("var T_".concat(v,": texture_2d<f32>;"),"var T_".concat(v,": texture_depth_2d;")),u=u.replace(new RegExp("textureSample\\(T_".concat(v,"(.*)\\);$"),"gm"),function(b,y){return"vec4<f32>(textureSample(T_".concat(v).concat(y,"), 0.0, 0.0, 0.0);")})};try{for(var f=r0(["u_TextureFramebufferDepth"]),g=f.next();!g.done;g=f.next()){var p=g.value;d(p)}}catch(v){s={error:v}}finally{try{g&&!g.done&&(o=f.return)&&o.call(f)}finally{if(s)throw s.error}}c&&(u=c(u));var m=this.device.device.createShaderModule({code:u});return{module:m,entryPoint:l||"main"}},e})(gp),qDt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n=t.call(this,{id:i,device:s})||this;n.type=Wi.QueryPool;var a=o.elemCount,l=o.type;return n.querySet=n.device.device.createQuerySet({type:BDt(l),count:a}),n.resolveBuffer=n.device.device.createBuffer({size:a*8,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),n.cpuBuffer=n.device.device.createBuffer({size:a*8,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),n.results=null,n}return e.prototype.queryResultOcclusion=function(r){return this.results===null?null:this.results[r]!==BigInt(0)},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.querySet.destroy(),this.resolveBuffer.destroy(),this.cpuBuffer.destroy()},e})(gp),ZDt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=t.call(this,{id:i,device:s})||this;return o.type=Wi.Readback,o}return e.prototype.readTexture=function(r,i,s,o,n,a,l,c){return l===void 0&&(l=0),Rr(this,void 0,void 0,function(){var h,u,d,f,g,p,m,v;return hT(this,function(b){return h=r,u=0,d=qot(h.gpuTextureformat),f=Math.ceil(o/d.width)*d.length,g=Math.ceil(f/256)*256,p=g*n,m=this.device.createBuffer({usage:dt.STORAGE|dt.MAP_READ|dt.COPY_DST,hint:Et.STATIC,viewOrSize:p}),v=this.device.device.createCommandEncoder(),v.copyTextureToBuffer({texture:h.gpuTexture,mipLevel:0,origin:{x:i,y:s,z:Math.max(u,0)}},{buffer:m.gpuBuffer,offset:0,bytesPerRow:g},{width:o,height:n,depthOrArrayLayers:1}),this.device.device.queue.submit([v.finish()]),[2,this.readBuffer(m,0,a.byteLength===p?a:null,l,p,h.format,!0,!1,f,g,n)]})})},e.prototype.readTextureSync=function(r,i,s,o,n,a,l,c){throw new Error("ERROR_MSG_METHOD_NOT_IMPLEMENTED")},e.prototype.readBuffer=function(r,i,s,o,n,a,l,c,h,u,d){var f=this;i===void 0&&(i=0),s===void 0&&(s=null),n===void 0&&(n=0),a===void 0&&(a=I.U8_RGB),l===void 0&&(l=!1),h===void 0&&(h=0),u===void 0&&(u=0),d===void 0&&(d=0);var g=r,p=n||g.size,m=s||g.view,v=m&&m.constructor&&m.constructor.BYTES_PER_ELEMENT||_ot(a),b=g;if(!(g.usage&dt.MAP_READ&&g.usage&dt.COPY_DST)){var y=this.device.device.createCommandEncoder();b=this.device.createBuffer({usage:dt.STORAGE|dt.MAP_READ|dt.COPY_DST,hint:Et.STATIC,viewOrSize:p}),y.copyBufferToBuffer(g.gpuBuffer,i,b.gpuBuffer,0,p),this.device.device.queue.submit([y.finish()])}return new Promise(function(_,w){b.gpuBuffer.mapAsync(X$.READ,i,p).then(function(){var E=b.gpuBuffer.getMappedRange(i,p),A=m;if(l)A===null?A=Kot(a,p,!0,E):A=Kot(a,A.buffer,void 0,E);
486else if(A===null)switch(v){case 1:A=new Uint8Array(p),A.set(new Uint8Array(E));break;case 2:A=f.getHalfFloatAsFloatRGBAArrayBuffer(p/2,E);break;case 4:A=new Float32Array(p/4),A.set(new Float32Array(E));break}else switch(v){case 1:A=new Uint8Array(A.buffer),A.set(new Uint8Array(E));break;case 2:A=f.getHalfFloatAsFloatRGBAArrayBuffer(p/2,E,m);break;case 4:var x=m&&m.constructor||Float32Array;A=new x(A.buffer),A.set(new x(E));break}if(h!==u){v===1&&!l&&(h*=2,u*=2);for(var S=new Uint8Array(A.buffer),T=h,R=0,B=1;B<d;++B){R=B*u;for(var O=0;O<h;++O)S[T++]=S[R++]}v!==0&&!l?A=new Float32Array(S.buffer,0,T/4):A=new Uint8Array(S.buffer,0,T)}b.gpuBuffer.unmap(),_(A)},function(E){return w(E)})})},e.prototype.getHalfFloatAsFloatRGBAArrayBuffer=function(r,i,s){s||(s=new Float32Array(r));for(var o=new Uint16Array(i);r--;)s[r]=VDt(o[r]);return s},e})(gp),Qot=(function(){function t(e){this.device=e,this.gpuRenderPassEncoder=null,this.gfxColorAttachment=[],this.gfxColorAttachmentLevel=[],this.gfxColorResolveTo=[],this.gfxColorResolveToLevel=[],this.gfxDepthStencilAttachment=null,this.gfxDepthStencilResolveTo=null,this.gpuColorAttachments=[],this.gpuDepthStencilAttachment={view:null,depthLoadOp:"load",depthStoreOp:"store",stencilLoadOp:"load",stencilStoreOp:"store"},this.gpuRenderPassDescriptor={colorAttachments:this.gpuColorAttachments,depthStencilAttachment:this.gpuDepthStencilAttachment}}return t.prototype.getEncoder=function(){var e;return((e=this.renderBundle)===null||e===void 0?void 0:e.renderBundleEncoder)||this.gpuRenderPassEncoder},t.prototype.getTextureView=function(e,r){return Ir(r<e.mipLevelCount),e.mipLevelCount===1?e.gpuTextureView:e.gpuTexture.createView({baseMipLevel:r,mipLevelCount:1})},t.prototype.setRenderPassDescriptor=function(e){var r,i,s,o,n,a;this.descriptor=e,this.gpuRenderPassDescriptor.colorAttachments=this.gpuColorAttachments;var l=e.colorAttachment.length;this.gfxColorAttachment.length=l,this.gfxColorResolveTo.length=l;for(var c=0;c<e.colorAttachment.length;c++){var h=e.colorAttachment[c],u=e.colorResolveTo[c];if(h===null&&u!==null&&(h=u,u=null),this.gfxColorAttachment[c]=h,this.gfxColorResolveTo[c]=u,this.gfxColorAttachmentLevel[c]=((r=e.colorAttachmentLevel)===null||r===void 0?void 0:r[c])||0,this.gfxColorResolveToLevel[c]=((i=e.colorResolveToLevel)===null||i===void 0?void 0:i[c])||0,h!==null){this.gpuColorAttachments[c]===void 0&&(this.gpuColorAttachments[c]={});var d=this.gpuColorAttachments[c];d.view=this.getTextureView(h,((s=this.gfxColorAttachmentLevel)===null||s===void 0?void 0:s[c])||0);var f=(n=(o=e.colorClearColor)===null||o===void 0?void 0:o[c])!==null&&n!==void 0?n:"load";f==="load"?d.loadOp="load":(d.loadOp="clear",d.clearValue=f),d.storeOp=!((a=e.colorStore)===null||a===void 0)&&a[c]?"store":"discard",d.resolveTarget=void 0,u!==null&&(h.sampleCount>1?d.resolveTarget=this.getTextureView(u,this.gfxColorResolveToLevel[c]):d.storeOp="store")}else{this.gpuColorAttachments.length=c,this.gfxColorAttachment.length=c,this.gfxColorResolveTo.length=c;break}}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,e.depthStencilAttachment){var g=e.depthStencilAttachment,d=this.gpuDepthStencilAttachment;d.view=g.gpuTextureView;
486var p=!!(LT(g.format)&se.Depth);p?(e.depthClearValue==="load"?d.depthLoadOp="load":(d.depthLoadOp="clear",d.depthClearValue=e.depthClearValue),e.depthStencilStore||this.gfxDepthStencilResolveTo!==null?d.depthStoreOp="store":d.depthStoreOp="discard"):(d.depthLoadOp=void 0,d.depthStoreOp=void 0);var m=!!(LT(g.format)&se.Stencil);m?(e.stencilClearValue==="load"?d.stencilLoadOp="load":(d.stencilLoadOp="clear",d.stencilClearValue=e.stencilClearValue),e.depthStencilStore||this.gfxDepthStencilResolveTo!==null?d.stencilStoreOp="store":d.stencilStoreOp="discard"):(d.stencilLoadOp=void 0,d.stencilStoreOp=void 0),this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=me(e.occlusionQueryPool)?void 0:MDt(e.occlusionQueryPool)},t.prototype.beginRenderPass=function(e,r){Ir(this.gpuRenderPassEncoder===null),this.setRenderPassDescriptor(r),this.frameCommandEncoder=e,this.gpuRenderPassEncoder=this.frameCommandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)},t.prototype.flipY=function(e,r){var i=this.device.swapChainHeight;return i-e-r},t.prototype.setViewport=function(e,r,i,s,o,n){o===void 0&&(o=0),n===void 0&&(n=1),this.gpuRenderPassEncoder.setViewport(e,this.flipY(r,s),i,s,o,n)},t.prototype.setScissorRect=function(e,r,i,s){this.gpuRenderPassEncoder.setScissorRect(e,this.flipY(r,s),i,s)},t.prototype.setPipeline=function(e){var r=e,i=RE(r.gpuRenderPipeline);this.getEncoder().setPipeline(i)},t.prototype.setVertexInput=function(e,r,i){if(e!==null){var s=this.getEncoder(),o=e;i!==null&&s.setIndexBuffer(VT(i.buffer),RE(o.indexFormat),i.offset);for(var n=0;n<r.length;n++){var a=r[n];a!==null&&s.setVertexBuffer(n,VT(a.buffer),a.offset)}}},t.prototype.setBindings=function(e){var r=e,i=this.getEncoder();r.gpuBindGroup.forEach(function(s,o){s&&i.setBindGroup(o,r.gpuBindGroup[o])})},t.prototype.setStencilReference=function(e){this.gpuRenderPassEncoder.setStencilReference(e)},t.prototype.draw=function(e,r,i,s){this.getEncoder().draw(e,r,i,s)},t.prototype.drawIndexed=function(e,r,i,s,o){this.getEncoder().drawIndexed(e,r,i,s,o)},t.prototype.drawIndirect=function(e,r){this.getEncoder().drawIndirect(VT(e),r)},t.prototype.drawIndexedIndirect=function(e,r){this.getEncoder().drawIndexedIndirect(VT(e),r)},t.prototype.beginOcclusionQuery=function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)},t.prototype.endOcclusionQuery=function(){this.gpuRenderPassEncoder.endOcclusionQuery()},t.prototype.pushDebugGroup=function(e){this.gpuRenderPassEncoder.pushDebugGroup(e)},t.prototype.popDebugGroup=function(){this.gpuRenderPassEncoder.popDebugGroup()},t.prototype.insertDebugMarker=function(e){this.gpuRenderPassEncoder.insertDebugMarker(e)},t.prototype.beginBundle=function(e){this.renderBundle=e},t.prototype.endBundle=function(){this.renderBundle.finish()},t.prototype.executeBundles=function(e){this.gpuRenderPassEncoder.executeBundles(e.map(function(r){return r.renderBundle}))},t.prototype.finish=function(){var e;(e=this.gpuRenderPassEncoder)===null||e===void 0||e.end(),this.gpuRenderPassEncoder=null;for(var r=0;r<this.gfxColorAttachment.length;r++){var i=this.gfxColorAttachment[r],s=this.gfxColorResolveTo[r];i!==null&&s!==null&&i.sampleCount===1&&this.copyAttachment(s,this.gfxColorAttachmentLevel[r],i,this.gfxColorResolveToLevel[r])}this.gfxDepthStencilAttachment&&this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,0,this.gfxDepthStencilAttachment,0)),this.frameCommandEncoder=null},t.prototype.copyAttachment=function(e,r,i,s){Ir(i.sampleCount===1);var o={texture:i.gpuTexture,mipLevel:s},n={texture:e.gpuTexture,mipLevel:r};Ir(i.width>>>s===e.width>>>r),Ir(i.height>>>s===e.height>>>r),Ir(!!(i.usage&Va.COPY_SRC)),Ir(!!(e.usage&Va.COPY_DST)),this.frameCommandEncoder.copyTextureToTexture(o,n,[e.width,e.height,1])},t})(),JDt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n=t.call(this,{id:i,device:s})||this;return n.type=Wi.RenderPipeline,n.isCreatingAsync=!1,n.gpuRenderPipeline=null,n.descriptor=o,n.device.createRenderPipelineInternal(n,!1),n}return e.prototype.getBindGroupLayout=function(r){return this.gpuRenderPipeline.getBindGroupLayout(r)},e})(gp),QDt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n,a,l=t.call(this,{id:i,device:s})||this;l.type=Wi.Sampler;var c=o.lodMinClamp,h=o.mipmapFilter===xn.NO_MIP?o.lodMinClamp:o.lodMaxClamp,u=(n=o.maxAnisotropy)!==null&&n!==void 0?n:1;return u>1&&Ir(o.minFilter===io.BILINEAR&&o.magFilter===io.BILINEAR&&o.mipmapFilter===xn.LINEAR),l.gpuS
486ampler=l.device.device.createSampler({addressModeU:V$(o.addressModeU),addressModeV:V$(o.addressModeV),addressModeW:V$((a=o.addressModeW)!==null&&a!==void 0?a:o.addressModeU),lodMinClamp:c,lodMaxClamp:h,minFilter:Vot(o.minFilter),magFilter:Vot(o.magFilter),mipmapFilter:RDt(o.mipmapFilter),compare:o.compareFunction!==void 0?e5(o.compareFunction):void 0,maxAnisotropy:u}),l}return e})(gp),r5=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=r.descriptor,n=r.skipCreate,a=r.sampleCount,l=t.call(this,{id:i,device:s})||this;l.type=Wi.Texture,l.flipY=!1;var c=o.format,h=o.dimension,u=o.width,d=o.height,f=o.depthOrArrayLayers,g=o.mipLevelCount,p=o.usage,m=o.pixelStore;return l.flipY=!!(m!=null&&m.unpackFlipY),l.device.createTextureShared({format:c,dimension:h??ei.TEXTURE_2D,width:u,height:d,depthOrArrayLayers:f??1,mipLevelCount:g??1,usage:p,sampleCount:a??1},l,n),l}return e.prototype.textureFromImageBitmapOrCanvas=function(r,i,s){for(var o=i[0].width,n=i[0].height,a={size:{width:o,height:n,depthOrArrayLayers:s},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT},l=r.createTexture(a),c=0;c<i.length;c++)r.queue.copyExternalImageToTexture({source:i[c],flipY:this.flipY},{texture:l,origin:[0,0,c]},[o,n]);return[l,o,n]},e.prototype.isImageBitmapOrCanvases=function(r){var i=r[0];return i instanceof ImageBitmap||i instanceof HTMLCanvasElement||i instanceof OffscreenCanvas},e.prototype.isVideo=function(r){var i=r[0];return i instanceof HTMLVideoElement},e.prototype.setImageData=function(r,i){var s,o=this,n=this.device.device,a,l,c;if(this.isImageBitmapOrCanvases(r))s=np(this.textureFromImageBitmapOrCanvas(n,r,this.depthOrArrayLayers),3),a=s[0],l=s[1],c=s[2];else if(this.isVideo(r))a=n.importExternalTexture({source:r[0]});else{var h=qot(this.gpuTextureformat),u=Math.ceil(this.width/h.width)*h.length;r.forEach(function(d){n.queue.writeTexture({texture:o.gpuTexture},d,{bytesPerRow:u},{width:o.width,height:o.height})})}this.width=l,this.height=c,a&&(this.gpuTexture=a),this.gpuTextureView=this.gpuTexture.createView({dimension:SDt(this.dimension)})},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.gpuTexture.destroy()},e})(gp),tPt=(function(t){Jo(e,t);function e(r){var i=r.id,s=r.device,o=t.call(this,{id:i,device:s})||this;return o.type=Wi.RenderBundle,o.renderBundleEncoder=o.device.device.createRenderBundleEncoder({colorFormats:[o.device.swapChainFormat]}),o}return e.prototype.finish=function(){this.renderBundle=this.renderBundleEncoder.finish()},e})(gp),ePt=(function(){function t(e,r,i,s,o,n){this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=Va.RENDER_ATTACHMENT|Va.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.frameCommandEncoderPool=[],this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=QO.UPPER_LEFT,this.clipSpaceNearZ=Sh.ZERO,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.device=r,this.canvas=i,this.canvasContext=s,this.glsl_compile=o,this.WGSLComposer=n,this.fallbackTexture2D=this.createFallbackTexture(ei.TEXTURE_2D,en.Float),this.setResourceName(this.fallbackTexture2D,"Fallback Texture2D"),this.fallbackTexture2DDepth=this.createFallbackTexture(ei.TEXTURE_2D,en.Depth),this.setResourceName(this.fallbackTexture2DDepth,"Fallback Depth Texture2D"),this.fallbackTexture2DArray=this.createFallbackTexture(ei.TEXTURE_2D_ARRAY,en.Float),this.setResourceName(this.fallbackTexture2DArray,"Fallback Texture2DArray"),this.fallbackTexture3D=this.createFallbackTexture(ei.TEXTURE_3D,en.Float),this.setResourceName(this.fallbackTexture3D,"Fallback Texture3D"),this.fallbackTextureCube=this.createFallbackTexture(ei.TEXTURE_CUBE_MAP,en.Float),this.setResourceName(this.fallbackTextureCube,"Fallback TextureCube"),this.fallbackSamplerFiltering=this.createSampler({addressModeU:Zn.REPEAT,addressModeV:Zn.REPEAT,minFilter:io.POINT,magFilter:io.POINT,mipmapFilter:xn.NEAREST}),this.setResourceName(this.fallbackSamplerFiltering,"Fallback Sampler Filtering"),this.fallbackSamplerComparison=this.createSampler({addressModeU:Zn.REPEAT,addressModeV:Zn.REPEAT,minFilter:io.POINT,magFilter:io.POINT,mipmapFilter:xn.NEAREST,compareFunction:qe.ALWAYS}),this.setResourceName(this.fallbackSamplerComparison,"Fallback Sampler Comparison Filtering"),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=function(a){console.error(a.error)}
486,this.swapChainFormat=navigator.gpu.getPreferredCanvasFormat(),this.canvasContext.configure({device:this.device,format:this.swapChainFormat,usage:this.swapChainTextureUsage,alphaMode:"premultiplied"})}return t.prototype.destroy=function(){},t.prototype.configureSwapChain=function(e,r){this.swapChainWidth===e&&this.swapChainHeight===r||(this.swapChainWidth=e,this.swapChainHeight=r)},t.prototype.getOnscreenTexture=function(){var e=this.canvasContext.getCurrentTexture(),r=e.createView(),i=new r5({id:0,device:this,descriptor:{format:I.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depthOrArrayLayers:0,dimension:ei.TEXTURE_2D,mipLevelCount:1,usage:this.swapChainTextureUsage},skipCreate:!0});return i.depthOrArrayLayers=1,i.sampleCount=1,i.gpuTexture=e,i.gpuTextureView=r,i.name="Onscreen",this.setResourceName(i,"Onscreen Texture"),i},t.prototype.getDevice=function(){return this},t.prototype.getCanvas=function(){return this.canvas},t.prototype.beginFrame=function(){Ir(this.frameCommandEncoderPool.length===0)},t.prototype.endFrame=function(){Ir(this.frameCommandEncoderPool.every(function(e){return e!==null})),this.device.queue.submit(this.frameCommandEncoderPool.map(function(e){return e.finish()})),this.frameCommandEncoderPool=[]},t.prototype.getNextUniqueId=function(){return++this._resourceUniqueId},t.prototype.createBuffer=function(e){return new $Dt({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createTexture=function(e){return new r5({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createSampler=function(e){return new QDt({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createRenderTarget=function(e){var r=new r5({id:this.getNextUniqueId(),device:this,descriptor:fo(fo({},e),{dimension:ei.TEXTURE_2D,mipLevelCount:1,depthOrArrayLayers:1,usage:xr.RENDER_TARGET}),sampleCount:e.sampleCount});return r.depthOrArrayLayers=1,r.type=Wi.RenderTarget,r},t.prototype.createRenderTargetFromTexture=function(e){var r=e,i=r.format,s=r.width,o=r.height,n=r.depthOrArrayLayers,a=r.sampleCount,l=r.mipLevelCount,c=r.gpuTexture,h=r.gpuTextureView,u=r.usage;Ir(!!(u&Va.RENDER_ATTACHMENT));var d=new r5({id:this.getNextUniqueId(),device:this,descriptor:{format:i,width:s,height:o,depthOrArrayLayers:n,dimension:ei.TEXTURE_2D,mipLevelCount:l,usage:u},skipCreate:!0});return d.depthOrArrayLayers=n,d.sampleCount=a,d.gpuTexture=c,d.gpuTextureView=h,d},t.prototype.createProgram=function(e){var r,i;return!((r=e.vertex)===null||r===void 0)&&r.glsl&&(e.vertex.glsl=$4(this.queryVendorInfo(),"vert",e.vertex.glsl)),!((i=e.fragment)===null||i===void 0)&&i.glsl&&(e.fragment.glsl=$4(this.queryVendorInfo(),"frag",e.fragment.glsl)),new Jot({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createProgramSimple=function(e){return new Jot({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createTextureShared=function(e,r,i){var s={width:e.width,height:e.height,depthOrArrayLayers:e.depthOrArrayLayers},o=e.mipLevelCount,n=z$(e.format),a=xDt(e.dimension),l=ADt(e.usage);if(r.gpuTextureformat=n,r.dimension=e.dimension,r.format=e.format,r.width=e.width,r.height=e.height,r.depthOrArrayLayers=e.depthOrArrayLayers,r.mipLevelCount=o,r.usage=l,r.sampleCount=e.sampleCount,!i){var c=this.device.createTexture({size:s,mipLevelCount:o,format:n,dimension:a,sampleCount:e.sampleCount,usage:l}),h=c.createView();r.gpuTexture=c,r.gpuTextureView=h}},t.prototype.getFallbackSampler=function(e){var r=e.formatKind;return r===en.Depth&&e.comparison?this.fallbackSamplerComparison:this.fallbackSamplerFiltering},t.prototype.getFallbackTexture=function(e){var r=e.dimension,i=e.formatKind;if(r===ei.TEXTURE_2D)return i===en.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(r===ei.TEXTURE_2D_ARRAY)return this.fallbackTexture2DArray;if(r===ei.TEXTURE_3D)return this.fallbackTexture3D;if(r===ei.TEXTURE_CUBE_MAP)return this.fallbackTextureCube;throw new Error("whoops")},t.prototype.createFallbackTexture=function(e,r){var i=e===ei.TEXTURE_CUBE_MAP?6:1,s=r===en.Float?I.U8_RGBA_NORM:I.D24;return this.createTexture({dimension:e,format:s,usage:xr.SAMPLED,width:1,height:1,depthOrArrayLayers:i,mipLevelCount:1})},t.prototype.createBindings=function(e){return new YDt({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createInputLayout=function(e){return new KDt({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createComputePipeline=function(e){return new HDt({id:this.getNextUniqueId(),device:this,descriptor:e})},t.prototype.createRenderPipeline=function(e){return new JDt({id:this.getNextUniqueId(),device:this,descriptor:fo({},e)})},t.prototype.createQueryPool=function(e,r){return new qDt({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:r}})},t.prototype.createRenderPipelineInternal=function(e,r){var i;if(e.gpuRenderPipeline===null){var s=e.descriptor,o=s.program,n=o.vertexStage,a=o.fragmentStage;if(!(n===null||a===null)){var l=s.megaStateDescriptor||{},c=l.stencilBack,h=l.stencilFront,u=IMt(l,["stencilBack","stencilFront"]),d=UT(GT);s.megaStateDescriptor=fo(fo(fo({},d),{stencilBack:fo(fo({}
486,d.stencilBack),c),stencilFront:fo(fo({},d.stencilFront),h)}),u);var f=s.megaStateDescriptor.attachmentsState[0];s.colorAttachmentFormats.forEach(function(_,w){s.megaStateDescriptor.attachmentsState[w]||(s.megaStateDescriptor.attachmentsState[w]=Sot(void 0,f))});var g=PDt((i=s.topology)!==null&&i!==void 0?i:Go.TRIANGLES,s.megaStateDescriptor),p=LDt(s.colorAttachmentFormats,s.megaStateDescriptor),m=UDt(s.depthStencilAttachmentFormat,s.megaStateDescriptor),v=void 0;s.inputLayout!==null&&(v=s.inputLayout.buffers);var b=s.sampleCount,y={layout:"auto",vertex:fo(fo({},n),{buffers:v}),primitive:g,depthStencil:m,multisample:{count:b},fragment:fo(fo({},a),{targets:p})};e.gpuRenderPipeline=this.device.createRenderPipeline(y)}}},t.prototype.createReadback=function(){return new ZDt({id:this.getNextUniqueId(),device:this})},t.prototype.createRenderBundle=function(){return new tPt({id:this.getNextUniqueId(),device:this})},t.prototype.createRenderPass=function(e){var r=this.renderPassPool.pop();r===void 0&&(r=new Qot(this));var i=this.frameCommandEncoderPool.pop();return i===void 0&&(i=this.device.createCommandEncoder()),r.beginRenderPass(i,e),r},t.prototype.createComputePass=function(){var e=this.computePassPool.pop();e===void 0&&(e=new Zot);var r=this.frameCommandEncoderPool.pop();return r===void 0&&(r=this.device.createCommandEncoder()),e.beginComputePass(r),e},t.prototype.submitPass=function(e){var r=e;r instanceof Qot?(this.frameCommandEncoderPool.push(r.frameCommandEncoder),r.finish(),this.renderPassPool.push(r)):r instanceof Zot&&(this.frameCommandEncoderPool.push(r.frameCommandEncoder),r.finish(),this.computePassPool.push(r))},t.prototype.copySubTexture2D=function(e,r,i,s,o,n,a){var l=this.device.createCommandEncoder(),c=e,h=s,u={texture:h.gpuTexture,origin:[o,n,0],mipLevel:0,aspect:"all"},d={texture:c.gpuTexture,origin:[r,i,0],mipLevel:0,aspect:"all"};Ir(!!(h.usage&Va.COPY_SRC)),Ir(!!(c.usage&Va.COPY_DST)),l.copyTextureToTexture(u,d,[h.width,h.height,a||1]),this.device.queue.submit([l.finish()])},t.prototype.queryLimits=function(){return{uniformBufferMaxPageWordSize:this.device.limits.maxUniformBufferBindingSize>>>2,uniformBufferWordAlignment:this.device.limits.minUniformBufferOffsetAlignment>>>2,supportedSampleCounts:[1],occlusionQueriesRecommended:!0,computeShadersSupported:!0}},t.prototype.queryTextureFormatSupported=function(e,r,i){if(XDt(e)){if(!this.featureTextureCompressionBC)return!1;var s=zDt(e);return r%s!==0||i%s!==0?!1:this.featureTextureCompressionBC}switch(e){case I.U16_RGBA_NORM:return!1;case I.F32_RGBA:return!1}return!0},t.prototype.queryPlatformAvailable=function(){return!0},t.prototype.queryVendorInfo=function(){return this},t.prototype.queryRenderPass=function(e){var r=e;return r.descriptor},t.prototype.queryRenderTarget=function(e){var r=e;return r},t.prototype.setResourceName=function(e,r){if(e.name=r,e.type===Wi.Buffer){var i=e;i.gpuBuffer.label=r}else if(e.type===Wi.Texture){var i=e;i.gpuTexture.label=r,i.gpuTextureView.label=r}else if(e.type===Wi.RenderTarget){var i=e;i.gpuTexture.label=r,i.gpuTextureView.label=r}else if(e.type===Wi.Sampler){var i=e;i.gpuSampler.label=r}else if(e.type===Wi.RenderPipeline){var i=e;i.gpuRenderPipeline!==null&&(i.gpuRenderPipeline.label=r)}},t.prototype.setResourceLeakCheck=function(e,r){},t.prototype.checkForLeaks=function(){},t.prototype.programPatched=function(e){},t.prototype.pipelineQueryReady=function(e){var r=e;return r.gpuRenderPipeline!==null},t.prototype.pipelineForceReady=function(e){var r=e;this.createRenderPipelineInternal(r,!1)},t})(),ud=(function(){function t(e){this.pluginOptions=e}return t.prototype.createSwapChain=function(e){return Rr(this,void 0,void 0,function(){var r,i,s,o,n,a,l,c;return hT(this,function(h){switch(h.label){case 0:if(globalThis.navigator.gpu===void 0)return[2,null];r=null,h.label=1;case 1:return h.trys.push([1,3,,4]),i=this.pluginOptions.xrCompatible,[4,globalThis.navigator.gpu.requestAdapter({xrCompatible:i})];case 2:return r=h.sent(),[3,4];case 3:return s=h.sent(),console.log(s),[3,4];case 4:return r===null?[2,null]:(o=["depth32float-stencil8","texture-compression-bc","float32-filterable"],n=o.filter(function(u){return r.features.has(u)}),[4,r.requestDevice({requiredFeatures:n})]);case 5:if(a=h.sent(),a&&(l=this.pluginOptions.onContextLost,a.lost.then(function(){l&&l()})),a===null)return[2,null];if(c=e.getContext("webgpu"),!c)return[2,null];h.label=6;case 6:return h.trys.push([6,8,,9]),[4,zot(this.pluginOptions.shaderCompilerPath)];case 7:return h.sent(),[3,9];case 8:return h.sent(),[3,9];case 9:return[2,new ePt(r,a,e,c,_Dt,Xot&&new Xot)]}})})},t})(),Y$=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},aI;let rPt=class{constructor(){aI.set(this,[])}getCallbacksNum(){return Y$(this,aI,"f").length}tapPromise(t){Y$(this,aI,"f").push(t)}promise(...t){return Promise.all(Y$(this,aI,"f").map(e=>e(...t)))}};aI=new WeakMap;var tnt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},i5;let Rh=class{constructor(){i5.set(this,[])}tap(t){tnt(this,i5,"f").push(t)}call(...t){tnt(this,i5,"f").forEach(function(e){e.apply(void 0,t)})}};i5=new WeakMap;var lI=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},CE;let iPt=class{constructor(){CE.set(this,[])}tap(t){lI(this,CE,"f").push(t)}call(...t){if(lI(this,CE,"f").length){let e=lI(this,CE,"f")[0].apply(void 0,t);for(let r=0;r<lI(this,CE,"f").length-1;r++){const i=lI(this,CE,"f")[r];e=i(...e)}return e}return null}};CE=new WeakMap;const ent={createCanvas:(t,e)=>{const r=document.createElement("canvas");return r.width=t,r.height=e,r},createTexImageSource:t=>t,createImage:t=>{if(typeof t=="string")return nu(t,Hh);const e=URL.createObjectURL(t);return nu(e,Hh).finally(()=>URL.revokeObjectURL(e))},getWindow:()=>window,getDocument:()=>document,getXMLSerializer:()=>new XMLSerializer,getDOMParser:()=>new DOMParser,setCursor:(t,e)=>{const r=t.getDOM();r.style&&(t.root.cursor=e,r.style.cursor=e)},splitGraphemes:t=>typeof(Intl==null?void 0:Intl.Segmenter)=="function"?[...new Intl.Segmenter().segment(t)].map(e=>e.segment):[...t],requestAnimationFrame:t=>requestAnimationFrame(t),cancelAnimationFrame:t=>cancelAnimationFrame(t)};let rnt=ent;const Bo={get(){return rnt},set(t){rnt=t}},sPt=typeof window<"u"&&typeof window.document<"u",oPt=()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};function Qr(t){return Bo.get().getDocument().createElementNS("http://www.w3.org/2000/svg",t)}
486function $$(t,e){e(t)||(t.sorted||t.children).forEach(r=>{$$(r,e)})}function s5(t,e,r){const i=eG(Bt(),[-r[0],-r[1]]),s=TV(Bt(),e),o=eG(Bt(),[r[0],r[1]]),n=Bt();us(n,o,s),us(n,n,i),Qt(t,t,n)}const H$=0;function Hv(t){return[t[0],t[1],t[2],H$,t[3],t[4],t[5],H$,t[6],t[7],t[8],H$]}function int(t,e,r,i){return Math.sqrt(Math.pow(r-t,2)+Math.pow(i-e,2))}class snt{constructor(e){this.seed=e}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}}function nPt(t,e,r,i,s,o){const n=[r-t,i-e];if(hO(n,[0,0]))return Math.sqrt((s-t)*(s-t)+(o-e)*(o-e));const a=[-n[1],n[0]];aE(a,a);const l=[s-t,o-e];return Math.abs(Yy(l,a))}function aPt(t,e,r){const i=Ea(it(),Aa(it(),t,e),.5);return Ea(i,i,1/Yy(t,i)),Ea(i,i,r)}const lPt=new snt(Date.now()),cPt=()=>Math.floor(lPt.next()*Math.pow(2,31));var K$,ont;function hPt(){if(ont)return K$;ont=1;var t=4,e=.001,r=1e-7,i=10,s=11,o=1/(s-1),n=typeof Float32Array=="function";function a(p,m){return 1-3*m+3*p}function l(p,m){return 3*m-6*p}function c(p){return 3*p}function h(p,m,v){return((a(m,v)*p+l(m,v))*p+c(m))*p}function u(p,m,v){return 3*a(m,v)*p*p+2*l(m,v)*p+c(m)}function d(p,m,v,b,y){var _,w,E=0;do w=m+(v-m)/2,_=h(w,b,y)-p,_>0?v=w:m=w;while(Math.abs(_)>r&&++E<i);return w}function f(p,m,v,b){for(var y=0;y<t;++y){var _=u(m,v,b);if(_===0)return m;var w=h(m,v,b)-p;m-=w/_}return m}function g(p){return p}return K$=function(p,m,v,b){if(!(0<=p&&p<=1&&0<=v&&v<=1))throw new Error("bezier x values must be in [0, 1] range");if(p===m&&v===b)return g;for(var y=n?new Float32Array(s):new Array(s),_=0;_<s;++_)y[_]=h(_*o,p,v);function w(E){for(var A=0,x=1,S=s-1;x!==S&&y[x]<=E;++x)A+=o;--x;var T=(E-y[x])/(y[x+1]-y[x]),R=A+T*o,B=u(R,p,v);return B>=e?f(E,R,p,v):B===0?R:d(E,A,A+o,p,v)}return function(E){return E===0?0:E===1?1:h(w(E),m,b)}},K$}var uPt=hPt();let nnt;cr=Sv(uPt),nnt={linear:cr(0,0,1,1),ease:cr(.25,.1,.25,1),"ease-in":cr(.42,0,1,1),"ease-out":cr(0,0,.58,1),"ease-in-out":cr(.42,0,.58,1)};var q$;(function(t){t._bytes4=new Uint8Array(4),t._float=new Float32Array(t._bytes4.buffer);function e(r){return t._float[0]=r,t._bytes4}t.floatToBytes=e})(q$||(q$={}));const ant=256;let dPt=class{constructor(t=new Uint8Array(ant)){this._bytes=t,this.count=0,this.capacity=ant,this.count=this.capacity=t.length}clear(){this.count=0}bytes(){return this._bytes.subarray(0,this.count)}grow(){this.capacity*=2;const t=new Uint8Array(this.capacity);t.set(this._bytes),this._bytes=t}appendBytes(t){const e=t.length;return this.count+e>this.capacity&&this.grow(),this._bytes.set(t,this.count),this.count+=e,this}appendFloat(t){return this.appendBytes(q$.floatToBytes(t)),this}},cI,Z$,hI,Xo,J$,gl,lnt;cI=t=>t instanceof Object,Z$=t=>t===!!t,hI=t=>typeof t=="function",Xo=t=>t===void 0,J$=t=>t==null,gl=t=>typeof t=="string",lnt=new Set("none,currentcolor,transparent,aliceblue,antiquewhite,aqua,aquamarine,azure,beige,bisque,black,blanchedalmond,blue,blueviolet,brown,burlywood,cadetblue,chartreuse,chocolate,coral,cornflowerblue,cornsilk,crimson,cyan,darkblue,darkcyan,darkgoldenrod,darkgray,darkgreen,darkgrey,darkkhaki,darkmagenta,darkolivegreen,darkorange,darkorchid,darkred,darksalmon,darkseagreen,darkslateblue,darkslategray,darkslategrey,darkturquoise,darkviolet,deeppink,deepskyblue,dimgray,dimgrey,dodgerblue,firebrick,floralwhite,forestgreen,fuchsia,gainsboro,ghostwhite,gold,goldenrod,gray,green,greenyellow,grey,honeydew,hotpink,indianred,indigo,ivory,khaki,lavender,lavenderblush,lawngreen,lemonchiffon,lightblue,lightcoral,lightcyan,lightgoldenrodyellow,lightgray,lightgreen,lightgrey,lightpink,lightsalmon,lightseagreen,lightskyblue,lightslategray,lightslategrey,lightsteelblue,lightyellow,lime,limegreen,linen,magenta,maroon,mediumaquamarine,mediumblue,mediumorchid,mediumpurple,mediumseagreen,mediumslateblue,mediumspringgreen,mediumturquoise,mediumvioletred,midnightblue,mintcream,mistyrose,moccasin,navajowhite,navy,oldlace,olive,olivedrab,orange,orangered,orchid,palegoldenrod,palegreen,paleturquoise,palevioletred,papayawhip,peachpuff,peru,pink,plum,powderblue,purple,rebeccapurple,red,rosybrown,royalblue,saddlebrown,salmon,sandybrown,seagreen,seashell,sienna,silver,skyblue,slateblue,slategray,slategrey,snow,springgreen,steelblue,tan,teal,thistle,tomato,turquoise,violet,wheat,white,whitesmoke,yellow".split(",")),rtt=t=>typeof t!="string"?!1:(t=t.toLowerCase().trim(),/^#[0-9a-f]{3,8}$/.test(t)||/^(?:url|var|rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix)\(.*\)$/.test(t)||lnt.has(t));function fPt(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function pPt(t){return t.replace(/-([a-z])/g,(e,r)=>r.toUpperCase())}const gPt=/^data:([a-z]+\/[a-z0-9\-\+]+)?(;charset=[a-z0-9\-]+)?(;base64)?,[a-z0-9\!\$&',\(\)\*\+,;=\-\._\~:@\/\?%\s]*$/i;function Q$(t){return gPt.test(t)}function mPt(t){return Object.fromEntries(Object.entries(t).filter(([e,r])=>r!==void 0))}const m0=(t,e)=>t.reduce((r,i)=>(r[e?e(i):String(i)]=i,r),{}),yPt=(t,e)=>Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e,cnt=(t,e,r)=>{const i=Object.keys(t),s=Object.keys(e);return i.length!==s.length?!1:i.every(o=>t[o]===e[o]||yPt(t[o],e[o]))},vPt=(t,e,r)=>(e&&console.error(e),t),tH={default:-1};function eH(t="default"){return tH[t]===void 0&&(tH[t]=-1),++tH[t]}function uI(t){return t.split("").reduce(function(e,r){return e=(e<<5)-e+r.charCodeAt(0),e&e},0)}let hnt;hnt=Math.PI*2,id=180/Math.PI,eu=Math.PI/180;var unt=(t=>
vendor: 5,678 bytes, line 486
486(t[t.POLY=0]="POLY",t[t.RECT=1]="RECT",t[t.CIRC=2]="CIRC",t[t.ELIP=3]="ELIP",t[t.RREC=4]="RREC",t))(unt||{});ye=class{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new ye(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}},ye.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const o5=[new ye,new ye,new ye,new ye];Ua=class{constructor(t=0,e=0,r=0,i=0){this.x=Number(t),this.y=Number(e),this.width=Number(r),this.height=Number(i),this.type=unt.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 Ua(0,0,0,0)}clone(){return new Ua(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 A=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=A)return!1;const x=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>x}const r=this.left,i=this.right,s=this.top,o=this.bottom;if(i<=r||o<=s)return!1;const n=o5[0].set(t.left,t.top),a=o5[1].set(t.left,t.bottom),l=o5[2].set(t.right,t.top),c=o5[3].set(t.right,t.bottom);if(l.x<=n.x||a.y<=n.y)return!1;const h=Math.sign(e.a*e.d-e.b*e.c);if(h===0||(e.apply(n,n),e.apply(a,a),e.apply(l,l),e.apply(c,c),Math.max(n.x,a.x,l.x,c.x)<=r||Math.min(n.x,a.x,l.x,c.x)>=i||Math.max(n.y,a.y,l.y,c.y)<=s||Math.min(n.y,a.y,l.y,c.y)>=o))return!1;const u=h*(a.y-n.y),d=h*(n.x-a.x),f=u*r+d*s,g=u*i+d*s,p=u*r+d*o,m=u*i+d*o;if(Math.max(f,g,p,m)<=u*n.x+d*n.y||Math.min(f,g,p,m)>=u*c.x+d*c.y)return!1;const v=h*(n.y-l.y),b=h*(l.x-n.x),y=v*r+b*s,_=v*i+b*s,w=v*r+b*o,E=v*i+b*o;return!(Math.max(y,_,w,E)<=v*n.x+b*n.y||Math.min(y,_,w,E)>=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),r=Math.min(this.x+this.width,t.x+t.width),i=Math.max(this.y,t.y),s=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(r-e,0),this.y=i,this.height=Math.max(s-i,0),this}ceil(t=1,e=.001){const r=Math.ceil((this.x+this.width-e)*t)/t,i=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=r-this.x,this.height=i-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),r=Math.max(this.x+this.width,t.x+t.width),i=Math.min(this.y,t.y),s=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=r-e,this.y=i,this.height=s-i,this}},Ua.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`},uo=class tY{constructor(e=1,r=0,i=0,s=1,o=0,n=0){this.array=null,this.a=e,this.b=r,this.c=i,this.d=s,this.tx=o,this.ty=n}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,r,i,s,o,n){return this.a=e,this.b=r,this.c=i,this.d=s,this.tx=o,this.ty=n,this}toArray(e,r){this.array||(this.array=new Float32Array(9));const i=r||this.array;return e?(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(e,r){r=r||new ye;const i=e.x,s=e.y;return r.x=this.a*i+this.c*s+this.tx,r.y=this.b*i+this.d*s+this.ty,r}applyInverse(e,r){r=r||new ye;const i=1/(this.a*this.d+this.c*-this.b),s=e.x,o=e.y;return r.x=this.d*i*s+-this.c*i*o+(this.ty*this.c-this.tx*this.d)*i,r.y=this.a*i*o+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,r}translate(e,r){return this.tx+=e,this.ty+=r,this}scale(e,r){return this.a*=e,this.d*=r,this.c*=e,this.b*=r,this.tx*=e,this.ty*=r,this}rotate(e){const r=Math.cos(e),i=Math.sin(e),s=this.a,o=this.c,n=this.tx;return this.a=s*r-this.b*i,this.b=s*i+this.b*r,this.c=o*r-this.d*i,this.d=o*i+this.d*r,this.tx=n*r-this.ty*i,this.ty=n*i+this.ty*r,this}append(e){const r=this.a,i=this.b,s=this.c,o=this.d;return this.a=e.a*r+e.b*s,this.b=e.a*i+e.b*o,this.c=e.c*r+e.d*s,this.d=e.c*i+e.d*o,this.tx=e.tx*r+e.ty*s+this.tx,this.ty=e.tx*i+e.ty*o+this.ty,this}setTransform(e,r,i,s,o,n,a,l,c){return this.a=Math.cos(a+c)*o,this.b=Math.sin(a+c)*o,this.c=-Math.sin(a-l)*n,this.d=Math.cos(a-l)*n,this.tx=e-(i*this.a+s*this.c),this.ty=r-(i*this.b+s*this.d),this}prepend(e){const r=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const i=this.a,s=this.c;this.a=i*e.a+this.b*e.c,this.b=i*e.b+this.b*e.d,this.c=s*e.a+this.d*e.c,this.d=s*e.b+this.d*e.d}return this.tx=r*e.a+this.ty*e.c+e.tx,this.ty=r*e.b+this.ty*e.d+e.ty,this}decompose(e){const r=this.a,i=this.b,s=this.c,o=this.d,n=e.pivot,a=-Math.atan2(-s,o),l=Math.atan2(i,r),c=Math.abs(a+l);return c<1e-5||Math.abs(hnt-c)<1e-5?(e.rotation=l,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=a,e.skew.y=l),e.scale.x=Math.sqrt(r*r+i*i),e.scale.y=Math.sqrt(s*s+o*o),e.position.x=this.tx+(n.x*r+n.y*s),e.position.y=this.ty+(n.x*i+n.y*o),e}invert(){const e=this.a,r=this.b,i=this.c,s=this.d,o=this.tx,n=e*s-r*i;return this.a=s/n,this.b=-r/n,this.c=-i/n,this.d=e/n,this.tx=(i*this.ty-s*o)/n,this.ty=-(e*this.ty-r*o)/n,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const e=new tY;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}
486copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}static get IDENTITY(){return new tY}static get TEMP_MATRIX(){return new tY}},uo.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 $T=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],HT=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],KT=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],qT=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],n5=Math.sign;function _Pt(){for(let t=0;t<16;t++){const e=[];for(let r=0;r<16;r++){const i=n5($T[t]*$T[r]+KT[t]*HT[r]),s=n5(HT[t]*$T[r]+qT[t]*HT[r]),o=n5($T[t]*KT[r]+KT[t]*qT[r]),n=n5(HT[t]*KT[r]+qT[t]*qT[r]);for(let a=0;a<16;a++)if($T[a]===i&&HT[a]===s&&KT[a]===o&&qT[a]===n){e.push(a);break}}}for(let t=0;t<16;t++)new uo().set($T[t],HT[t],KT[t],qT[t],0,0)}_Pt();class ME{constructor(e,r,i=0,s=0){this._x=i,this._y=s,this.cb=e,this.scope=r}clone(e=this.cb,r=this.scope){return new ME(e,r,this._x,this._y)}set(e=0,r=e){return(this._x!==e||this._y!==r)&&(this._x=e,this._y=r,this.cb.call(this.scope)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this.cb.call(this.scope)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this.cb.call(this.scope))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this.cb.call(this.scope))}}ME.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const rH=class{constructor(){this.worldTransform=new uo,this.localTransform=new uo,this.position=new ME(this.onChange,this,0,0),this.scale=new ME(this.onChange,this,1,1),this.pivot=new ME(this.onChange,this,0,0),this.skew=new ME(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 t=this.localTransform;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)}updateTransform(t){const e=this.localTransform;if(this._localID!==this._currentLocalID&&(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==t._worldID){const r=t.worldTransform,i=this.worldTransform;i.a=e.a*r.a+e.b*r.c,i.b=e.a*r.b+e.b*r.d,i.c=e.c*r.a+e.d*r.c,i.d=e.c*r.b+e.d*r.d,i.tx=e.tx*r.a+e.ty*r.c+r.tx,i.ty=e.tx*r.b+e.ty*r.d+r.ty,this._parentID=t._worldID,this._worldID++}}setFromMatrix(t){t.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this.updateSkew())}};rH.IDENTITY=new rH,wn=rH,wn.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}) ]`};const dnt=new uo;let ea=class{constructor(t=1/0,e=1/0,r=-1/0,i=-1/0){this.matrix=dnt,this.minX=t,this.minY=e,this.maxX=r,this.maxY=i}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=dnt,this}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e||this.matrix)}addFrame(t,e,r,i,s){s||(s=this.matrix);const o=s.a,n=s.b,a=s.c,l=s.d,c=s.tx,h=s.ty;let u=this.minX,d=this.minY,f=this.maxX,g=this.maxY,p=o*t+a*e+c,m=n*t+l*e+h;p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*r+a*e+c,m=n*r+l*e+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*t+a*i+c,m=n*t+l*i+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*r+a*i+c,m=n*r+l*i+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),this.minX=u,this.minY=d,this.maxX=f,this.maxY=g}},iH=class n1t{get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=n1t.prototype.NONE,this.prop
486agationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ye,this.page=new ye,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}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(e,r,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,r,i,s,o){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}},a5=class extends iH{constructor(){super(...arguments),this.client=new ye,this.movement=new ye,this.offset=new ye,this.global=new ye,this.screen=new ye}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}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,r,i,s,o,n,a,l,c,h,u,d,f,g){throw new Error("Method not implemented.")}},mp=class extends a5{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!")}},sH=class extends a5{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}};var bPt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},wPt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},l5;const EPt=2048;let APt=class{constructor(t){this.dispatch=new Uo,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,l5.set(this,void 0),this.rootTarget=t,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)}setPickHandler(t){bPt(this,l5,t,"f")}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((r,i)=>r.priority-i.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.prop
vendor: 6,979 bytes, line 486
486agate(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 r=0,i=e.length;r<i;r++)e[r].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){return wPt(this,l5,"f").call(this,t,e)}propagate(t,e){if(!t.target)return;const r=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let i=0,s=r.length-1;i<s;i++)if(t.currentTarget=r[i],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 i=r.length-2;i>=0;i--)if(t.currentTarget=r[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,r=this._allInteractiveElements){if(r.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const i=Array.isArray(e)?e:[e];for(let s=r.length-1;s>=0;s--)i.forEach(o=>{t.currentTarget=r[s],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let r=0;r<EPt&&t!==this.rootTarget&&t.parent;r++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}notifyTarget(t,e){e=e??t.type;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){var e;if(!(t instanceof mp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.createPointerEvent(t);if(r.pointerType==="mouse"&&(this.cursor=(e=r.target)===null||e===void 0?void 0:e.cursor),this.dispatchEvent(r,"pointerdown"),r.pointerType==="touch")this.dispatchEvent(r,"touchstart");else if(r.pointerType==="mouse"||r.pointerType==="pen"){const s=r.button===2;this.dispatchEvent(r,s?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=r.composedPath(),this.freeEvent(r)}mapPointerMove(t){var e,r,i;if(!(t instanceof mp)){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 s=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const o=s.pointerType==="mouse"||s.pointerType==="pen",n=this.trackingData(t.pointerId),a=this.findMountedTarget(n.overTargets);if(((e=n.overTargets)===null||e===void 0?void 0:e.length)>0&&a!==s.target){const h=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,h,a);if(this.dispatchEvent(u,"pointerout"),o&&this.dispatchEvent(u,"mouseout"),!s.composedPath().includes(a)){const d=this.createPointerEvent(t,"pointerleave",a);for(d.eventPhase=d.AT_TARGET;d.target&&!s.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),o&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(u)}if(a!==s.target){const h=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(s,h);this.dispatchEvent(u,"pointerover"),o&&this.dispatchEvent(u,"mouseover");let d=a==null?void 0:a.parent;for(;d&&d!==this.rootTarget.parent&&d!==s.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(s,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==a&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),o&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(u)}const l=[],c=(r=this.enableGlobalMoveEvents)!==null&&r!==void 0?r:!0;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(s,"pointermove"),c&&l.push("globalpointermove"),s.pointerType==="touch"&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(s,"touchmove"),c&&l.push("globaltouchmove")),o&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(s,"mousemove"),c&&l.push("globalmousemove"),this.cursor=(i=s.target)===null||i===void 0?void 0:i.cursor),l.length>0&&this.all(s,l),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=s.composedPath(),this.freeEvent(s)}mapPointerOver(t){var e;if(!(t instanceof mp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(e=i.target)===null||e===void 0?void 0:e.cursor);const o=this.clonePointerEvent(i,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;r.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof mp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const r=t.pointerType==="mouse"||t.pointerType==="pen",i=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",i);this.dispatchEvent(s),r&&this.dispatchEvent(s,"mouseout");const o=this.createPointerEvent(t,"pointerleave",i);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),r&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(s),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){var e,r;if(!(t instanceof mp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const i=performance.now(),s=this.createPointerEvent(t);if(this.dispatchEvent(s,"pointerup"),s.pointerType==="mouse"&&(this.cursor=(e=s.target)===null||e===void 0?void 0:e.cursor),s.pointerType==="touch")this.dispatchEvent(s,"touchend");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const l=s.button===2;this.dispatchEvent(s,l?"rightup":"mouseup")}const o=this.trackingData(t.pointerId),n=this.findMountedTarget(o.pressTargetsByButton[t.button]);let a=n;if(n&&!s.composedPath().includes(n)){let l=n;for(;l&&!s.composedPath().includes(l);){if(s.currentTarget=l,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch")this.notifyTarget(s,"touchendoutside");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const c=s.button===2;this.notifyTarget(s,c?"rightupoutside":"mouseupoutside")}l=l.parent}delete o.pressTargetsByButton[t.button],a=l}if(a){const l=this.clonePointerEvent(s,"click");l.target=a,l.path=null,o.clicksByButton[t.button]||(o.clicksByButton[t.button]={clickCount:0,target:l.target,timeStamp:i});const c=o.clicksByButton[t.button];if(c.target===l.target&&i-c.timeStamp<200?++c.clickCount:c.clickCount=1,c.target=l.target,c.timeStamp=i,l.detail=c.clickCount,!(!((r=s.detail)===null||r===void 0)&&r.preventClick)){if
486(l.pointerType==="mouse"){const h=l.button===2;this.dispatchEvent(l,h?"rightclick":"click")}else l.pointerType==="touch"&&this.dispatchEvent(l,"tap");this.dispatchEvent(l,"pointertap")}this.freeEvent(l)}this.freeEvent(s)}mapPointerUpOutside(t){if(!(t instanceof mp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),r=this.findMountedTarget(e.pressTargetsByButton[t.button]),i=this.createPointerEvent(t);if(r){let s=r;for(;s;)i.currentTarget=s,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch"?this.notifyTarget(i,"touchendoutside"):(i.pointerType==="mouse"||i.pointerType==="pen")&&this.notifyTarget(i,i.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(i)}mapWheel(t){if(!(t instanceof sH)){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 r=1;r<t.length&&t[r].parent===e;r++)e=t[r];return e}createPointerEvent(t,e,r){var i;const s=this.allocateEvent(mp);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=(i=r??this.hitTest(s.global.x,s.global.y))!==null&&i!==void 0?i:this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(sH);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 r=this.allocateEvent(mp);return r.nativeEvent=t.nativeEvent,r.originalEvent=t.originalEvent,this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.target=t.target,r.path=t.composedPath().slice(),r.type=e??r.type,r}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof mp&&e instanceof mp&&(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.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof a5&&e instanceof a5&&(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 r=t.currentTarget._events[e];if(r)if("fn"in r)r.once&&t.currentTarget.removeListener(e,r.fn,void 0,!0),r.fn.call(r.context,t);else for(let i=0,s=r.length;i<s&&!t.propagationImmediatelyStopped;i++)r[i].once&&t.currentTarget.removeListener(e,r[i].fn,void 0,!0),r[i].fn.call(r[i].context,t)}};l5=new WeakMap;let xPt=class extends iH{constructor(t,e,r){super(t),this.type=e,this.detail=r}},SPt=class extends Uo{constructor(t={}){super();const{cursor:e,hitArea:r,pointerEvents:i,draggable:s,droppable:o}=t;this.cursor=e,this.hitArea=r,this.pointerEvents=i??"auto",this.draggable=s??!1,this.droppable=o??!1}addEventListener(t,e,r){const i=Z$(r)&&r||cI(r)&&r.capture,s=cI(r)?r.signal:void 0,o=cI(r)&&r.once,n=hI(e)?void 0:e;t=i?`${t}capture`:t;const a=hI(e)?e:e.handleEvent;s&&s.addEventListener("abort",()=>{this.off(t,a,n)}),o?this.once(t,a,n):this.on(t,a,n)}removeEventListener(t,e,r){const i=Z$(r)&&r||cI(r)&&r.capture,s=hI(e)?void 0:e;t=i?`${t}capture`:t,e=hI(e)?e:e==null?void 0:e.handleEvent,this.off(t,e,s)}dispatchEvent(t){if(!(t instanceof iH))throw new Error("Container cannot propagate events outside of the Federated Events API");return t.defaultPrevented=!1,t.path=[],t.target=this,t.manager.dispatchEvent(t),!t.defaultPrevented}};
vendor: 8,026 bytes, line 486
486var c5={exports:{}},TPt=c5.exports,fnt;function RPt(){return fnt||(fnt=1,(function(t,e){(function(r,i){i(e)})(TPt,(function(r){function i(z,ut,M){z.prototype=ut.prototype=M,M.constructor=z}function s(z,ut){var M=Object.create(z.prototype);for(var D in ut)M[D]=ut[D];return M}function o(){}var n=.7,a=1/n,l="\\s*([+-]?\\d+)\\s*",c="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",h="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",u=/^#([0-9a-f]{3,8})$/,d=new RegExp(`^rgb\\(${l},${l},${l}\\)$`),f=new RegExp(`^rgb\\(${h},${h},${h}\\)$`),g=new RegExp(`^rgba\\(${l},${l},${l},${c}\\)$`),p=new RegExp(`^rgba\\(${h},${h},${h},${c}\\)$`),m=new RegExp(`^hsl\\(${c},${h},${h}\\)$`),v=new RegExp(`^hsla\\(${c},${h},${h},${c}\\)$`),b={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function y(){return this.rgb().formatHex()}function _(){return this.rgb().formatRgb()}function w(z){var ut,M;return z=(z+"").trim().toLowerCase(),(ut=u.exec(z))?(M=ut[1].length,ut=parseInt(ut[1],16),M===6?E(ut):M===3?new T(ut>>8&15|ut>>4&240,ut>>4&15|240&ut,(15&ut)<<4|15&ut,1):M===8?A(ut>>24&255,ut>>16&255,ut>>8&255,(255&ut)/255):M===4?A(ut>>12&15|ut>>8&240,ut>>8&15|ut>>4&240,ut>>4&15|240&ut,((15&ut)<<4|15&ut)/255):null):(ut=d.exec(z))?new T(ut[1],ut[2],ut[3],1):(ut=f.exec(z))?new T(255*ut[1]/100,255*ut[2]/100,255*ut[3]/100,1):(ut=g.exec(z))?A(ut[1],ut[2],ut[3],ut[4]):(ut=p.exec(z))?A(255*ut[1]/100,255*ut[2]/100,255*ut[3]/100,ut[4]):(ut=m.exec(z))?U(ut[1],ut[2]/100,ut[3]/100,1):(ut=v.exec(z))?U(ut[1],ut[2]/100,ut[3]/100,ut[4]):b.hasOwnProperty(z)?E(b[z]):z==="transparent"?new T(NaN,NaN,NaN,0):null}function E(z){return new T(z>>16&255,z>>8&255,255&z,1)}function A(z,ut,M,D){return D<=0&&(z=ut=M=NaN),new T(z,ut,M,D)}function x(z){return z instanceof o||(z=w(z)),z?new T((z=z.rgb()).r,z.g,z.b,z.opacity):new T}function S(z,ut,M,D){return arguments.length===1?x(z):new T(z,ut,M,D??1)}function T(z,ut,M,D){this.r=+z,this.g=+ut,this.b=+M,this.opacity=+D}function R(){return`#${F(this.r)}${F(this.g)}${F(this.b)}`}function B(){const z=O(this.opacity);return`${z===1?"rgb(":"rgba("}${C(this.r)}, ${C(this.g)}, ${C(this.b)}${z===1?")":`, ${z})`}`}function O(z){return isNaN(z)?1:Math.max(0,Math.min(1,z))}function C(z){return Math.max(0,Math.min(255,Math.round(z)||0))}function F(z){return((z=C(z))<16?"0":"")+z.toString(16)}function U(z,ut,M,D){return D<=0?z=ut=M=NaN:M<=0||M>=1?z=ut=NaN:ut<=0&&(z=NaN),new G(z,ut,M,D)}function H(z){if(z instanceof G)return new G(z.h,z.s,z.l,z.opacity);if(z instanceof o||(z=w(z)),!z)return new G;if(z instanceof G)return z;var ut=(z=z.rgb()).r/255,M=z.g/255,D=z.b/255,k=Math.min(ut,M,D),j=Math.max(ut,M,D),Q=NaN,ft=j-k,ht=(j+k)/2;return ft?(Q=ut===j?(M-D)/ft+6*(M<D):M===j?(D-ut)/ft+2:(ut-M)/ft+4,ft/=ht<.5?j+k:2-j-k,Q*=60):ft=ht>0&&ht<1?0:Q,new G(Q,ft,ht,z.opacity)}function N(z,ut,M,D){return arguments.length===1?H(z):new G(z,ut,M,D??1)}function G(z,ut,M,D){this.h=+z,this.s=+ut,this.l=+M,this.opacity=+D}function Y(z){return(z=(z||0)%360)<0?z+360:z}function q(z){return Math.max(0,Math.min(1,z||0))}function L(z,ut,M){return 255*(z<60?ut+(M-ut)*z/60:z<180?M:z<240?ut+(M-ut)*(240-z)/60:ut)}i(o,w,{copy(z){return Object.assign(new this.constructor,this,z)},displayable(){return this.rgb().displayable()},hex:y,formatHex:y,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return H(this).formatHsl()},formatRgb:_,toString:_}),i(T,S,s(o,{brighter(z){return z=z==null?a:Math.pow(a,z),new T(this.r*z,this.g*z,this.b*z,this.opacity)},darker(z){return z=z==null?n:Math.pow(n,z),new T(this.r*z,this.g*z,this.b*z,this.opacity)},rgb(){return this},clamp(){return new T(C(this.r),C(this.g),C(this.b),O(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:R,formatHex:R,formatHex8:function(){return`#${F(this.r)}${F(this.g)}${F(this.b)}${F(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:B,toString:B})),i(G,N,s(o,{brighter(z){return z=z==null?a:Math.pow(a,z),new G(this.h,this.s,this.l*z,this.opacity)},darker(z){return z=z==null?n:Math.pow(n,z),new G(this.h,this.s,this.l*z,this.opacity)},rgb(){var z=this.h%360+360*(this.h<0),ut=isNaN(z)||isNaN(this.s)?0:this.s,M=this.l,D=M+(M<.5?M:1-M)*ut,k=2*M-D;return new T(L(z>=240?z-240:z+120,k,D),L(z,k,D),L(z<120?z+240:z-120,k,D),this.opacity)},clamp(){return new G(Y(this.h),q(this.s),q(this.l),O(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const z=O(this.opacity);return`${z===1?"hsl(":"hsla("}${Y(this.h)}, ${100*q(this.s)}%, ${100*q(this.l)}%${z===1?")":`, ${z})`}`}}));const J=Math.PI/180,tt=180/Math.PI,bt=.96422,ct=.82521,Xt=4/29,It=6/29,zt=3*It*It;function Ht(z){if(z instanceof tr)return new tr(z.l,z.a,z.b,z.opacity);if(z instanceof Vt)return de(z);z instanceof T||(z=x(z));var ut,M,D=Dt(z.r),k=Dt(z.g),j=Dt(z.b),Q=Gr((.2225045*D+.7168786*k+.0606169*j)/1);return D===k&&k===j?ut=M=Q:(ut=Gr((.4360747*D+.3850649*k+.1430804*j)/bt),M=Gr((.0139322*D+.0971045*k+.7141733*j)/ct)),new tr(116*Q-16,500*(ut-Q),200*(Q-M),z.opacity)}function Lt(z,ut,M,D){return arguments.length===1?Ht(z):new tr(z,ut,M,D??1)}function tr(z,ut,M,D){this.l=+z,this.a=+ut,this.b=+M,this.opacity=+D}function Gr(z){return z>.008856451679035631?Math.pow(z,1/3):z/zt+Xt}function re(z){return z>It?z*z*z:zt*(z-Xt)}
486function ci(z){return 255*(z<=.0031308?12.92*z:1.055*Math.pow(z,1/2.4)-.055)}function Dt(z){return(z/=255)<=.04045?z/12.92:Math.pow((z+.055)/1.055,2.4)}function rt(z){if(z instanceof Vt)return new Vt(z.h,z.c,z.l,z.opacity);if(z instanceof tr||(z=Ht(z)),z.a===0&&z.b===0)return new Vt(NaN,0<z.l&&z.l<100?0:NaN,z.l,z.opacity);var ut=Math.atan2(z.b,z.a)*tt;return new Vt(ut<0?ut+360:ut,Math.sqrt(z.a*z.a+z.b*z.b),z.l,z.opacity)}function At(z,ut,M,D){return arguments.length===1?rt(z):new Vt(z,ut,M,D??1)}function Vt(z,ut,M,D){this.h=+z,this.c=+ut,this.l=+M,this.opacity=+D}function de(z){if(isNaN(z.h))return new tr(z.l,0,0,z.opacity);var ut=z.h*J;return new tr(z.l,Math.cos(ut)*z.c,Math.sin(ut)*z.c,z.opacity)}i(tr,Lt,s(o,{brighter(z){return new tr(this.l+18*(z??1),this.a,this.b,this.opacity)},darker(z){return new tr(this.l-18*(z??1),this.a,this.b,this.opacity)},rgb(){var z=(this.l+16)/116,ut=isNaN(this.a)?z:z+this.a/500,M=isNaN(this.b)?z:z-this.b/200;return new T(ci(3.1338561*(ut=bt*re(ut))-1.6168667*(z=1*re(z))-.4906146*(M=ct*re(M))),ci(-.9787684*ut+1.9161415*z+.033454*M),ci(.0719453*ut-.2289914*z+1.4052427*M),this.opacity)}})),i(Vt,At,s(o,{brighter(z){return new Vt(this.h,this.c,this.l+18*(z??1),this.opacity)},darker(z){return new Vt(this.h,this.c,this.l-18*(z??1),this.opacity)},rgb(){return de(this).rgb()}}));var Rt=-.14861,De=1.78277,st=-.29227,ve=-.90649,Ct=1.97294,mi=Ct*ve,ws=Ct*De,$r=De*st-ve*Rt;function Ne(z){if(z instanceof Es)return new Es(z.h,z.s,z.l,z.opacity);z instanceof T||(z=x(z));var ut=z.r/255,M=z.g/255,D=z.b/255,k=($r*D+mi*ut-ws*M)/($r+mi-ws),j=D-k,Q=(Ct*(M-k)-st*j)/ve,ft=Math.sqrt(Q*Q+j*j)/(Ct*k*(1-k)),ht=ft?Math.atan2(Q,j)*tt-120:NaN;return new Es(ht<0?ht+360:ht,ft,k,z.opacity)}function mo(z,ut,M,D){return arguments.length===1?Ne(z):new Es(z,ut,M,D??1)}function Es(z,ut,M,D){this.h=+z,this.s=+ut,this.l=+M,this.opacity=+D}i(Es,mo,s(o,{brighter(z){return z=z==null?a:Math.pow(a,z),new Es(this.h,this.s,this.l*z,this.opacity)},darker(z){return z=z==null?n:Math.pow(n,z),new Es(this.h,this.s,this.l*z,this.opacity)},rgb(){var z=isNaN(this.h)?0:(this.h+120)*J,ut=+this.l,M=isNaN(this.s)?0:this.s*ut*(1-ut),D=Math.cos(z),k=Math.sin(z);return new T(255*(ut+M*(Rt*D+De*k)),255*(ut+M*(st*D+ve*k)),255*(ut+M*(Ct*D)),this.opacity)}})),r.color=w,r.cubehelix=mo,r.gray=function(z,ut){return new tr(z,0,0,ut??1)},r.hcl=At,r.hsl=N,r.lab=Lt,r.lch=function(z,ut,M,D){return arguments.length===1?rt(z):new Vt(M,ut,z,D??1)},r.rgb=S,Object.defineProperty(r,"__esModule",{value:!0})}))})(c5,c5.exports)),c5.exports}let Ei,Oo;sr=RPt(),Ei=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Oo=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r};function CPt(t){var e,r,i,s,o,n,a,l,c,h,u,d,f,g,p,m,v,b,y,_,w,E,A;return A=class extends t{constructor(x={}){super(x),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.sortDirtyFlag=!1,e.set(this,void 0),r.set(this,void 0),i.set(this,void 0),s.set(this,void 0),o.set(this,void 0),n.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),h.set(this,void 0),u.set(this,void 0),d.set(this,void 0),f.set(this,void 0),g.set(this,void 0),p.set(this,void 0),m.set(this,void 0),v.set(this,void 0),b.set(this,void 0),y.set(this,void 0),_.set(this,void 0),w.set(this,void 0),E.set(this,void 0);const{renderable:S,serializable:T,visible:R,cullable:B,batchable:O,selectable:C,sizeAttenuation:F,wireframe:U,fill:H,stroke:N,strokeWidth:G,strokeAlignment:Y,strokeLinecap:q,strokeLinejoin:L,strokeMiterlimit:J,strokeDasharray:tt,strokeDashoffset:bt,opacity:ct,fillOpacity:Xt,strokeOpacity:It,innerShadowColor:zt,innerShadowOffsetX:Ht,innerShadowOffsetY:Lt,innerShadowBlurRadius:tr}=x;this.renderable=S??!0,this.serializable=T??!0,this.visible=R??!0,this.cullable=B??!0,this.batchable=O??!0,this.selectable=C??!0,this.sizeAttenuation=F??!1,this.wireframe=U??!1,this.fill=H??"black",this.stroke=N??"none",this.strokeWidth=G??1,this.strokeAlignment=Y??"center",this.strokeLinecap=q??"butt",this.strokeLinejoin=L??"miter",this.strokeMiterlimit=J??4,this.strokeDasharray=tt??[],this.strokeDashoffset=bt??0,this.opacity=ct??1,this.fillOpacity=Xt??1,this.strokeOpacity=It??1,this.innerShadowColor=zt??"black",this.innerShadowOffsetX=Ht??0,this.innerShadowOffsetY=Lt??0,this.innerShadowBlurRadius=tr??0}get visible(){return Ei(this,e,"f")}set visible(x){Ei(this,e,"f")!==x&&(Oo(this,e,x,"f"),this.boundsDirtyFlag=!0,this.renderDirtyFlag=!0)}get fill(){return Ei(this,r,"f")}set fill(x){var S;if(Ei(this,r,"f")!==x){let T=!1;gl(x)?(Oo(this,i,void 0,"f"),Oo(this,s,void 0,"f"),x==="none"?Oo(this,i,sr.rgb(255,255,255,0),"f"):QB(x)?(Oo(this,s,qU(x),"f"),T=!0):Oo(this,i,((S=sr.rgb(x))===null||S===void 0?void 0:S.rgb())||sr.rgb(0,0,0,1),"f")):T=!0,(T||T!==Ei(this,o,"f"))&&(this.materialDirtyFlag=!0),Oo(this,r,x,"f"),Oo(this,o,T,"f"),this.renderDirtyFlag=!0}}get fillRGB(){return Ei(this,i,"f")}get fillGradient(){return Ei(this,s,"f")}get useFillImage(){return Ei(this,o,"f")}get stroke(){return Ei(this,n,"f")}set stroke(x){var S;Ei(this,n,"f")!==x&&(Oo(this,n,x,"f"),x==="none"?Oo(this,a,sr.rgb(255,255,255,0),"f"):Oo(this,a,((S=sr.rgb(x))===null||S===void 0?void 0:S.rgb())||sr.rgb(0,0,0,1),"f"),this.renderDirtyFlag=!0)}get strokeRGB(){return Ei(this,a,"f")}get strokeWidth(){return Ei(this,l,"f")}set strokeWidth(x){Ei(this,l,"f")!==x&&(Oo(this,l,x,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get strokeAlignment(){return Ei(this,c,"f")}set strokeAlignment(x){Ei(this,c,"f")!==x&&(Oo(this,c,x,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get strokeLinecap(){return Ei(this,h,"f")}set strokeLinecap(x){Ei(this,h,"f")!==x&&(Oo(this,h,x,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get strokeLinejoin(){return Ei(this,u,"f")}set strokeLinejoin(x){Ei(this,u,"f")!==x&&(Oo(this,u,x,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get strokeMiterlimit(){return Ei(this,d,"f")}set strokeMiterlimit(x){Ei(this,d,"f")!==x&&(Oo(this,d,x,"f"),this.renderDirtyFlag=!0)}get strokeDasharray(){return Ei(this,f,"f")}set strokeDasharray(x){var S;(!(!((S=Ei(this,f,"f"))===null||S===void 0)&&S.length)||!Ei(this,f,"f").every((T,R)=>T===x[R]))&&(Oo(this,f,x,"f"),this.renderDirtyFlag=!0)}get strokeDashoffset(){return Ei(this,g,"f")}set strokeDashoffset(x){Ei(this,g,"f")!==x&&(Oo(this,g,x,"f"),this.renderDirtyFlag=!0)}get opacity(){return Ei(this,p,"f")}set opacity(x){Ei(this,p,"f")!==x&&(Oo(this,p,x,"f"),this.renderDirtyFlag=!0)}get fillOpacity(){return Ei(this,m,"f")}set fillOpacity(x){Ei(this,m,"f")!==x&&(Oo(this,m,x,"f"),this.renderDirtyFlag=!0)}get strokeOpacity(){return Ei(this,v,"f")}set strokeOpacity(x){Ei(this,v,"f")!==x&&(Oo(this,v,x,"f"),this.renderDirtyFlag=!0)}get innerShadowColor(){return Ei(this,b,"f")}set innerShadowColor(x){var S;Ei(this,b,"f")!==x&&(Oo(this,b,x,"f"),Oo(this,y,((S=sr.rgb(x))===null||S===void 0?void 0:S.rgb())||sr.rgb(0,0,0,1),"f"),this.renderDirtyFlag=!0)}get innerShadowColorRGB(){return Ei(this,y,"f")}get innerShadowOffsetX(){return Ei(this,_,"f")}set innerShadowOffsetX(x){Ei(this,_,"f")!==x&&(Oo(this,_,x,"f"),this.renderDirtyFlag=!0)}get innerShadowOffsetY(){return Ei(this,w,"f")}set innerShadowOffsetY(x){Ei(this,w,"f")!==x&&(Oo(this,w,x,"f"),this.renderDirtyFlag=!0)}get innerShadowBlurRadius(){return Ei(this,E,"f")}set innerShadowBlurRadius(x){Ei(this,E,"f")!==x&&(Oo(this,E,x,"f"),this.renderDirtyFlag=!0)}},e=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap,o=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,g=new WeakMap,p=new WeakMap,m=new WeakMap,v=new WeakMap,b=new WeakMap,y=new WeakMap,_=new WeakMap,w=new WeakMap,E=new WeakMap,A}function MPt(t){return class extends t{constructor(){super(...arguments),this.transform=new wn}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(e){this.transform.position.copyFrom(e)}get translateX(){return this.transform.position.x}set translateX(e){this.transform.position.x=e}get translateY(){return this.transform.position.y}set translateY(e){this.transform.position.y=e}get scale(){return this.transform.scale}set scale(e){this.transform.scale.copyFrom(e)}get scaleX(){return this.transform.scale.x}set scaleX(e){this.transform.scale.x=e}get scaleY(){return this.transform.scale.y}set scaleY(e){this.transform.scale.y=e}get pivot(){return this.transform.pivot}set pivot(e){this.transform.pivot.copyFrom(e)}get skew(){return this.transform.skew}set skew(e){this.transform.skew.copyFrom(e)}get rotation(){return this.transform.rotation}set rotation(e){this.transform.rotation=e}get angle(){return this.transform.rotation*id}set angle(e){this.transform.rotation=e*eu}get transformDirtyFlag(){return this.transform._localID!==this.transform._currentLocalID||this.parent&&this.transform._parentID!==this.parent.transform._worldID}}}var pnt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
486return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},gnt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)};function BPt(t){var e,r;return r=class extends t{constructor(i={}){super(i),e.set(this,void 0),ytt(i.zIndex)||pnt(this,e,i.zIndex,"f")}get zIndex(){return gnt(this,e,"f")}set zIndex(i){gnt(this,e,"f")!==i&&(pnt(this,e,i,"f"),this.renderDirtyFlag=!0,this.parent&&(this.parent.sortDirtyFlag=!0))}},e=new WeakMap,r}const mnt=new wn,ynt=new uo,du=OPt(CPt(BPt(MPt(SPt))));function OPt(t){class e extends t{constructor(i={}){super(i),this.uid=eH(),this.children=[],this.geometryDirtyFlag=!0,this.materialDirtyFlag=!0}appendChild(i){var s;return i.parent&&i.parent.removeChild(i),i.parent=this,i.transform._parentID=-1,this.children.push(i),(!((s=this.sorted)===null||s===void 0)&&s.length||!Xo(i.zIndex))&&(this.sortDirtyFlag=!0),i}removeChild(i){var s;const o=this.children.indexOf(i);if(o===-1)return null;if(i.parent=void 0,i.transform._parentID=-1,this.children.splice(o,1),!((s=this.sorted)===null||s===void 0)&&s.length){const n=this.sorted.indexOf(i);n!==-1&&this.sorted.splice(n,1)}else Xo(i.zIndex)||(this.sortDirtyFlag=!0);return i}getBounds(i){if(!this.boundsDirtyFlag&&!this.transformDirtyFlag)return this.bounds;this.bounds=this.bounds||new ea,this.bounds.clear();let s;return this.parent?i?s=this.parent.worldTransform:(ynt.identity(),s=vnt(this,ynt)):s=uo.IDENTITY,oH(this,this.bounds,s,i),this.boundsDirtyFlag=!1,this.bounds}}return e}function oH(t,e,r,i){if(!t.visible)return;let s;i?s=t.worldTransform:(t.transform.updateLocalTransform(),s=new uo,s.copyFrom(t.localTransform),s.append(r)),t.renderable&&(e.matrix=s,e.addBounds(t.getRenderBounds()));for(let o=0;o<t.children.length;o++)oH(t.children[o],e,s,i)}function vnt(t,e){const r=t.parent;return r&&(vnt(r,e),r.transform.updateLocalTransform(),e.append(r.localTransform)),e}function Kv(t,e){return t==="center"?e/2:t==="inner"?0:t==="outer"?e:0}function ZT(t,e,r){let i=!1,s=!1;const o=!!e&&e!=="none",n=!!r&&r!=="none";return t==="visiblepainted"||t==="painted"||t==="auto"?(i=o,s=n):t==="visiblefill"||t==="fill"?i=!0:t==="visiblestroke"||t==="stroke"?s=!0:(t==="visible"||t==="all")&&(i=!0,s=!0),[i,s]}function _nt(t,e){return!!t&&e>0}function bnt(t){return t.decorationLine!=="none"&&t.decorationThickness>0}function wnt(t,e){var r,i;const s=(r=t.zIndex)!==null&&r!==void 0?r:0,o=(i=e.zIndex)!==null&&i!==void 0?i:0;if(s===o){const n=t.parent;if(n){const a=n.children||[];return a.indexOf(t)-a.indexOf(e)}}return s-o}var JT=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},nH=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r};Gl=class extends aH(du){};function aH(t){var e,r,i,s;return s=class extends t{static getGeometryBounds(o){const{cx:n=0,cy:a=0,r:l=0}=o;return new ea(n-l,a-l,n+l,a+l)}constructor(o={}){super(o),e.set(this,void 0),r.set(this,void 0),i.set(this,void 0);const{cx:n,cy:a,r:l}=o;this.cx=n??0,this.cy=a??0,this.r=l??0}get cx(){return JT(this,e,"f")}set cx(o){JT(this,e,"f")!==o&&(nH(this,e,o,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0)}get cy(){return JT(this,r,"f")}set cy(o){JT(this,r,"f")!==o&&(nH(this,r,o,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0)}get r(){return JT(this,i,"f")}
486set r(o){JT(this,i,"f")!==o&&(nH(this,i,o,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0)}containsPoint(o,n){const{strokeWidth:a,strokeAlignment:l,cx:c,cy:h,r:u,pointerEvents:d,fill:f,stroke:g}=this,p=int(c,h,o,n),m=Kv(l,a),[v,b]=ZT(d,f,g);return v&&b?p<=u+m:v?p<=u:b?p>=u+m-a&&p<=u+m:!1}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.geometryBoundsDirtyFlag=!1,this.geometryBounds=Gl.getGeometryBounds(this)),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){const{strokeWidth:o,strokeAlignment:n,cx:a,cy:l,r:c}=this,h=Kv(n,o);this.renderBoundsDirtyFlag=!1,this.renderBounds=new ea(a-c-h,l-c-h,a+c+h,l+c+h)}return this.renderBounds}},e=new WeakMap,r=new WeakMap,i=new WeakMap,s}var qv=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},h5=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r};$h=class extends lH(du){};function lH(t){var e,r,i,s,o;return o=class extends t{static getGeometryBounds(n){const{cx:a=0,cy:l=0,rx:c=0,ry:h=0}=n;return new ea(a-c,l-h,a+c,l+h)}constructor(n={}){var a,l;super(n),e.set(this,void 0),r.set(this,void 0),i.set(this,void 0),s.set(this,void 0);const{cx:c,cy:h,rx:u,ry:d}=n;this.cx=c??0,this.cy=h??0,this.rx=(a=u??d)!==null&&a!==void 0?a:0,this.ry=(l=d??u)!==null&&l!==void 0?l:0}get cx(){return qv(this,e,"f")}set cx(n){qv(this,e,"f")!==n&&(h5(this,e,n,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0)}get cy(){return qv(this,r,"f")}set cy(n){qv(this,r,"f")!==n&&(h5(this,r,n,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0)}get rx(){return qv(this,i,"f")}set rx(n){qv(this,i,"f")!==n&&(h5(this,i,n,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0)}get ry(){return qv(this,s,"f")}set ry(n){qv(this,s,"f")!==n&&(h5(this,s,n,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0)}containsPoint(n,a){const{cx:l,cy:c,rx:h,ry:u,strokeWidth:d,strokeAlignment:f,pointerEvents:g,fill:p,stroke:m}=this,v=Kv(f,d),[b,y]=ZT(g,p,m);return b&&y?u5(n,a,l,c,h+v,u+v):b?u5(n,a,l,c,h,u):y?!u5(n,a,l,c,h+v-d,u+v-d)&&u5(n,a,l,c,h+v,u+v):!1}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.geometryBoundsDirtyFlag=!1,this.geometryBounds=$h.getGeometryBounds(this)),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){const{strokeWidth:n,strokeAlignment:a,cx:l,cy:c,rx:h,ry:u}=this,d=Kv(a,n);this.renderBoundsDirtyFlag=!1,this.renderBounds=new ea(l-h-d,c-u-d,l+h+d,c+u+d)}return this.renderBounds}},e=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap,o}function u5(t,e,r,i,s,o){const n=t-r,a=e-i;return n*n/(s*s)+a*a/(o*o)<=1}var ml=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Em=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
486return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r};ed=class extends cH(du){};function cH(t){var e,r,i,s,o,n,a,l,c,h,u;return u=class extends t{static getGeometryBounds(d){const{x:f=0,y:g=0,width:p=0,height:m=0}=d;return new ea(Math.min(f,f+p),Math.min(g,g+m),Math.max(f,f+p),Math.max(g,g+m))}constructor(d={}){super(d),e.set(this,void 0),r.set(this,void 0),i.set(this,void 0),s.set(this,void 0),o.set(this,void 0),n.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),h.set(this,void 0);const{x:f,y:g,width:p,height:m,cornerRadius:v,dropShadowColor:b,dropShadowOffsetX:y,dropShadowOffsetY:_,dropShadowBlurRadius:w}=d;this.x=f??0,this.y=g??0,this.width=p??0,this.height=m??0,this.cornerRadius=v??0,this.dropShadowColor=b??"black",this.dropShadowOffsetX=y??0,this.dropShadowOffsetY=_??0,this.dropShadowBlurRadius=w??0}get x(){return ml(this,e,"f")}set x(d){ml(this,e,"f")!==d&&(Em(this,e,d,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0)}get y(){return ml(this,r,"f")}set y(d){ml(this,r,"f")!==d&&(Em(this,r,d,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0)}get width(){return ml(this,i,"f")}set width(d){ml(this,i,"f")!==d&&(Em(this,i,d,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0)}get height(){return ml(this,s,"f")}set height(d){ml(this,s,"f")!==d&&(Em(this,s,d,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0)}get cornerRadius(){return ml(this,o,"f")}set cornerRadius(d){ml(this,o,"f")!==d&&(Em(this,o,d,"f"),this.renderDirtyFlag=!0)}get dropShadowColor(){return ml(this,n,"f")}set dropShadowColor(d){var f;ml(this,n,"f")!==d&&(Em(this,n,d,"f"),Em(this,a,((f=sr.rgb(d))===null||f===void 0?void 0:f.rgb()
486)||sr.rgb(0,0,0,1),"f"),this.renderDirtyFlag=!0)}get dropShadowColorRGB(){return ml(this,a,"f")}get dropShadowOffsetX(){return ml(this,l,"f")}set dropShadowOffsetX(d){ml(this,l,"f")!==d&&(Em(this,l,d,"f"),this.renderDirtyFlag=!0)}get dropShadowOffsetY(){return ml(this,c,"f")}set dropShadowOffsetY(d){ml(this,c,"f")!==d&&(Em(this,c,d,"f"),this.renderDirtyFlag=!0)}get dropShadowBlurRadius(){return ml(this,h,"f")}set dropShadowBlurRadius(d){ml(this,h,"f")!==d&&(Em(this,h,d,"f"),this.renderDirtyFlag=!0)}containsPoint(d,f){const{x:g,y:p,width:m,height:v,strokeWidth:b,strokeAlignment:y,cornerRadius:_,pointerEvents:w,stroke:E,fill:A}=this,x=Kv(y,b),[S,T]=ZT(w,A,E),R=Math.min(g,g+m),B=Math.min(p,p+v),O=Math.max(g,g+m),C=Math.max(p,p+v);if(S&&T)return d5(d,f,R-x,B-x,O+x,C+x,_);if(S)return d5(d,f,R,B,O,C,_);if(T){const F=x-b;return!d5(d,f,R-F,B-F,O+F,C+F,_)&&d5(d,f,R-x,B-x,O+x,C+x,_)}return!1}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.geometryBoundsDirtyFlag=!1,this.geometryBounds=u.getGeometryBounds(this)),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){const{x:d,y:f,width:g,height:p,strokeWidth:m,strokeAlignment:v,dropShadowOffsetX:b,dropShadowOffsetY:y,dropShadowBlurRadius:_}=this,w=Kv(v,m);this.renderBoundsDirtyFlag=!1,this.renderBounds=new ea(d-w,f-w,d+g+w,f+p+w),this.renderBounds.addBounds(new ea(d+b-_,f+y-_,d+b+g+_,f+y+p+_))}return this.renderBounds}},e=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap,o=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,u}function d5(t,e,r,i,s,o,n){function a(l,c,h,u,d){return Math.sqrt(Math.pow(l-h,2)+Math.pow(c-u,2))<=d}return t>=r&&t<=s&&e>=i&&e<=o?a(t,e,r+n,i+n,n)||a(t,e,s-n,i+n,n)||a(t,e,s-n,o-n,n)||a(t,e,r+n,o-n,n)?!0:!(t<=r+n||t>=s-n||e<=i+n||e>=o-n):!1}var Zv=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Ent=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r};sp=class extends hH(du){};function hH(t){var e,r,i;return i=class extends t{static getGeometryBounds(s){const{points:o}=s;if(!o||o.length<2)return new ea(0,0,0,0);const n=Math.min(...o.map(h=>isNaN(h[0])?1/0:h[0])),a=Math.max(...o.map(h=>isNaN(h[0])?-1/0:h[0])),l=Math.min(...o.map(h=>isNaN(h[1])?1/0:h[1])),c=Math.max(...o.map(h=>isNaN(h[1])?-1/0:h[1]));return new ea(n,l,a,c)}constructor(s={}){super(s),e.set(this,void 0),r.set(this,[]),this.batchable=!1;const{points:o}=s;this.points=o??[[0,0],[0,0]]}get points(){return Zv(this,e,"f")}set points(s){(!Zv(this,e,"f")||Zv(this,e,"f").length!==s.length||!Zv(this,e,"f").every((o,n)=>o[0]===s[n][0]&&o[1]===s[n][1]))&&(Ent(this,e,s,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0)}computeShiftedPoints(){const{strokeWidth:s,strokeAlignment:o}=this;Ent(this,r,o==="center"?Zv(this,e,"f"):uH(Zv(this,e,"f"),o==="inner",s),"f")}containsPoint(s,o){const{strokeWidth:n,pointerEvents:a,fill:l,stroke:c}=this;this.getGeometryBounds();const[,h]=ZT(a,l,c);return h?xnt(Zv(this,r,"f"),n,s,o):!1}getTotalLength(){const{points:s}=this;let o=0;for(let n=0;n<s.length-1;n++){const[a,l]=s[n],[c,h]=s[n+1];o+=Math.hypot(c-a,h-l)}return o}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.computeShiftedPoints(),this.geometryBoundsDirtyFlag=!1,this.geometryBounds=sp.getGeometryBounds(Object.assign(Object.assign({},this),{points:Zv(this,r,"f")}))),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){this.renderBoundsDirtyFlag=!1;const{strokeWidth:s,strokeLinecap:o}=this;let n=.5;o==="square"&&(n=Math.SQRT1_2),n*=s;const{minX:a,minY:l,maxX:c,maxY:h}=this.getGeometryBounds();this.renderBounds=new ea(a-n,l-n,c+n,h+n)}return this.renderBounds}},e=new WeakMap,r=new WeakMap,i}function Ant(t,e,r,i,s,o,n){const a=Math.min(t,r),l=Math.max(t,r),c=Math.min(e,i),h=Math.max(e,i),u=s/2;return o>=a-u&&o<=l+u&&n>=c-u&&n<=h+u?nPt(t,e,r,i,o,n)<=s/2:!1}function uH(t,e,r){const i=[];return t.forEach(([s,o],n)=>{const a=Be(s,o),l=n===0?a:Be(t[n-1][0],t[n-1][1]),c=n===t.length-1?a:Be(t[n+1][0],t[n+1][1]),h=ru(it(),a,l),u=rm(h),d=it();$y(d,h,Be(u,u));const f=Be(d[1],-d[0]),g=ru(it(),c,a),p=rm(g),m=it();$y(m,g,Be(p,p));const v=Be(m[1],-m[0]),b=f[0]*v[1]-f[1]*v[0],y=2*(e?0:1)-1,_=r/2*y;u===0?Aa(a,a,Ea(v,v,_)):p===0||Math.abs(b)<.01?Aa(a,a,Ea(f,f,_)):Aa(a,a,aPt(f,v,_)),i.push([a[0],a[1]])}),i}function xnt(t,e,r,i){for(let s=0;s<t.length-1;s++){const o=t[s][0],n=t[s][1],a=t[s+1][0],l=t[s+1][1];if(Ant(o,n,a,l,e,r,i))return!0}return!1}let dH,Snt;dH=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Snt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
486return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},(function(t){t[t.EARCUT=0]="EARCUT",t[t.LIBTESS=1]="LIBTESS"})(cE||(cE={})),Wc=class extends fH(du){};function fH(t){var e,r;return r=class extends t{static getGeometryBounds(i){const{d:s,points:o}=i;if(!s)return new ea(0,0,0,0);const n=o.flat(),a=Math.min(...n.map(u=>u[0])),l=Math.max(...n.map(u=>u[0])),c=Math.min(...n.map(u=>u[1])),h=Math.max(...n.map(u=>u[1]));return new ea(a,c,l,h)}constructor(i={}){super(i),e.set(this,void 0),this.points=[],this.batchable=!1;const{d:s,tessellationMethod:o,fillRule:n}=i;this.d=s,this.tessellationMethod=o??cE.EARCUT,this.fillRule=n??"nonzero"}get d(){return dH(this,e,"f")}set d(i){if(dH(this,e,"f")!==i){Snt(this,e,i,"f");const{subPaths:s}=TI(i),o=s.map(n=>n.getPoints().map(a=>[a[0],a[1]]));this.points=o,this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0}}containsPoint(i,s,o){const{d:n,pointerEvents:a,fill:l,stroke:c}=this;if(!o||!n)return!1;this.getGeometryBounds();const[h,u]=ZT(a,l,c);return u&&!h?o.isPointInStroke(new Path2D(n),i,s):o.isPointInPath(new Path2D(n),i,s)}getTotalLength(){return 0}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.geometryBoundsDirtyFlag=!1,this.geometryBounds=Wc.getGeometryBounds(this)),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){this.renderBoundsDirtyFlag=!1;const{strokeWidth:i,strokeLinecap:s}=this;let o=.5;s==="square"&&(o=Math.SQRT1_2),o*=i;const{minX:n,minY:a,maxX:l,maxY:c}=this.getGeometryBounds();this.renderBounds=new ea(n-o,a-o,l+o,c+o)}return this.renderBounds}},e=new WeakMap,r}var xs=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Ze=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)};Ny=class extends Tnt(du){};function Tnt(t){var e,r,i,s,o,n,a,l,c,h,u,d,f,g,p,m,v,b,y,_,w,E,A,x,S,T,R,B,O,C,F,U,H;return H=class extends t{static getGeometryBounds(N){const{x:G,y:Y,textAlign:q,textBaseline:L,metrics:J,path:tt}=N;if(tt)return new Wc({d:tt}).getGeometryBounds();const{width:bt,height:ct}=J,Xt=bt/2;let It=G;q==="center"?It+=-Xt:(q==="right"||q==="end")&&(It+=-Xt*2);let zt=Y;return J.fontMetrics&&(zt+=Knt(L,J.fontMetrics)),new ea(It,zt,It+bt,zt+ct)}constructor(N={}){super(N),e.set(this,void 0),r.set(this,void 0),i.set(this,void 0),s.set(this,void 0),o.set(this,void 0),n.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),h.set(this,void 0),u.set(this,void 0),d.set(this,void 0),f.set(this,void 0),g.set(this,void 0),p.set(this,void 0),m.set(this,void 0),v.set(this,void 0),b.set(this,void 0),y.set(this,void 0),_.set(this,void 0),w.set(this,void 0),E.set(this,void 0),A.set(this,void 0),x.set(this,void 0),S.set(this,void 0),T.set(this,void 0),R.set(this,void 0),B.set(this,void 0),O.set(this,void 0),C.set(this,void 0),F.set(this,void 0),U.set(this,void 0),this.batchable=!1;const{x:G,y:Y,content:q,fontFamily:L,fontVariant:J,fontSize:tt,fontWeight:bt,fontStyle:ct,wordWrap:Xt,wordWrapWidth:It,letterSpacing:zt,whiteSpace:Ht,textOverflow:Lt,textAlign:tr,textBaseline:Gr,maxLines:re,lineHeight:ci,leading:Dt,bitmapFont:rt,bitmapFontKerning:At,esdt:Vt,physical:de,dropShadowColor:Rt,dropShadowOffsetX:De,dropShadowOffsetY:st,dropShadowBlurRadius:ve,decorationColor:Ct,decorationLine:mi,decorationStyle:ws,decorationThickness:$r,path:Ne,side:mo,startOffset:Es}=N;xs(this,r,G??0,"f"),xs(this,i,Y??0,"f"),xs(this,s,q??"","f"),this.fontFamily=L??"sans-serif",this.fontSize=tt??12,this.fontWeight=bt??400,this.fontStyle=ct??"normal",this.fontVariant=J??"normal",this.letterSpacing=zt??0,this.whiteSpace=Ht??"normal",this.wordWrap=Xt??!1,this.wordWrapWidth=It??0,this.textOverflow=Lt??"ellipsis",this.textAlign=tr??"start",this.textBaseline=Gr??"alphabetic",this.maxLines=re??1/0,this.lineHeight=ci??0,this.leading=Dt??0,this.bitmapFont=rt??null,this.bitmapFontKerning=At??!0,this.esdt=Vt??!0,this.physical=de??!1,this.dropShadowColor=Rt??"black",this.dropShadowOffsetX=De??0,this.dropShadowOffsetY=st??0,this.dropShadowBlurRadius=ve??0,this.decorationColor=Ct??"black",this.decorationLine=mi??"none",this.decorationStyle=ws??"solid",this.decorationThickness=$r??1,this.path=Ne??null,this.side=mo??"left",this.startOffset=Es??0}containsPoint(N,G){const{minX:Y,minY:q,maxX:L,maxY:J}=this.getGeometryBounds();return N>=Y&&N<=L&&G>=q&&G<=J}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.geometryBoundsDirtyFlag=!1,this.geometryBounds=H.getGeometryBounds(this)),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){const{strokeWidth:N,strokeAlignment:G,dropShadowOffsetX:Y,dropShadowOffsetY:q,dropShadowBlurRadius:L}=this,J=Kv(G,N);this.renderBoundsDirtyFlag=!1;const{minX:tt,minY:bt,maxX:ct,maxY:Xt}=this.getGeometryBounds();this.renderBounds=new ea(tt-J,bt-J,ct+J,Xt+J),this.renderBounds.addBounds(new ea(tt+Y-L,bt+q-L,ct+Y+L,Xt+q+L))}return this.renderBounds}get metrics(){return this.renderDirtyFlag&&xs(this,e,gFt().measureText(this.content,this),"f"),Ze(this,e,"f")}get x(){return Ze(this,r,"f")}set x(N){Ze(this,r,"f")!==N&&(xs(this,r,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0)}get y(){return Ze(this,i,"f")}set y(N){Ze(this,i,"f")!==N&&(xs(this,i,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0)}get content(){return Ze(this,s,"f")}set content(N){Ze(this,s,"f")!==N&&(xs(this,s,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0)}get fontFamily(){return Ze(this,o,"f")}set fontFamily(N){Ze(this,o,"f")!==N&&(xs(this,o,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0,this.materialDirtyFlag=!0)}get fontSize(){return Ze(this,n,"f")}set fontSize(N){Ze(this,n,"f")!==N&&(xs(this,n,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0,this.materialDirtyFlag=!0)}get fontWeight(){return Ze(this,a,"f")}set fontWeight(N){Ze(this,a,"f")!==N&&(xs(this,a,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0,this.materialDirtyFlag=!0)}get fontStyle(){return Ze(this,l,"f")}set fontStyle(N){Ze(this,l,"f")!==N&&(xs(this,l,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0,this.materialDirtyFlag=!0)}get fontVariant(){return Ze(this,c,"f")}set fontVariant(N){Ze(this,c,"f")!==N&&(xs(this,c,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0,this.materialDirtyFlag=!0)}get letterSpacing(){return Ze(this,h,"f")}set letterSpacing(N){Ze(this,h,"f")!==N&&(xs(this,h,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0,this.materialDirtyFlag=!0)}get whiteSpace(){return Ze(this,u,"f")}set whiteSpace(N){Ze(this,u,"f")!==N&&(xs(this,u,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0)}get wordWrap(){return Ze(this,d,"f")}set wordWrap(N){Ze(this,d,"f")!==N&&(xs(this,d,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0)}get wordWrapWidth(){return Ze(this,f,"f")}set wordWrapWidth(N){Ze(this,f,"f")!==N&&(xs(this,f,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0)}get textOverflow(){return Ze(this,g,"f")}set textOverflow(N){Ze(this,g,"f")!==N&&(xs(this,g,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0)}get maxLines(){return Ze(this,p,"f")}set maxLines(N){Ze(this,p,"f")!==N&&(xs(this,p,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0)}get lineHeight(){return Ze(this,m,"f")}set lineHeight(N){Ze(this,m,"f")!==N&&(xs(this,m,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0)}get leading(){return Ze(this,v,"f")}set leading(N){Ze(this,v,"f")!==N&&(xs(this,v,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0)}get textAlign(){return Ze(this,b,"f")}set textAlign(N){Ze(this,b,"f")!==N&&(xs(this,b,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0,this.materialDirtyFlag=!0)}get textBaseline(){return Ze(this,y,"f")}set textBaseline(N){Ze(this,y,"f")!==N&&(xs(this,y,N,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.geometryDirtyFlag=!0,this.materialDirtyFlag=!0)}get dropShadowColor(){return Ze(this,_,"f")}set dropShadowColor(N){var G;Ze(this,_,"f")!==N&&(xs(this,_,N,"f"),xs(this,w,((G=sr.rgb(N))===null||G===void 0?void 0:G.rgb()
486)||sr.rgb(0,0,0,1),"f"),this.renderDirtyFlag=!0)}get dropShadowColorRGB(){return Ze(this,w,"f")}get dropShadowOffsetX(){return Ze(this,E,"f")}set dropShadowOffsetX(N){Ze(this,E,"f")!==N&&(xs(this,E,N,"f"),this.renderDirtyFlag=!0)}get dropShadowOffsetY(){return Ze(this,A,"f")}set dropShadowOffsetY(N){Ze(this,A,"f")!==N&&(xs(this,A,N,"f"),this.renderDirtyFlag=!0)}get dropShadowBlurRadius(){return Ze(this,x,"f")}set dropShadowBlurRadius(N){Ze(this,x,"f")!==N&&(xs(this,x,N,"f"),this.renderDirtyFlag=!0)}get decorationColor(){return Ze(this,S,"f")}set decorationColor(N){var G;Ze(this,S,"f")!==N&&(xs(this,S,N,"f"),xs(this,T,((G=sr.rgb(N))===null||G===void 0?void 0:G.rgb())||sr.rgb(0,0,0,1),"f"),this.renderDirtyFlag=!0)}get decorationColorRGB(){return Ze(this,T,"f")}get decorationLine(){return Ze(this,R,"f")}set decorationLine(N){Ze(this,R,"f")!==N&&(xs(this,R,N,"f"),this.renderDirtyFlag=!0)}get decorationStyle(){return Ze(this,B,"f")}set decorationStyle(N){Ze(this,B,"f")!==N&&(xs(this,B,N,"f"),this.renderDirtyFlag=!0)}get decorationThickness(){return Ze(this,O,"f")}set decorationThickness(N){Ze(this,O,"f")!==N&&(xs(this,O,N,"f"),this.renderDirtyFlag=!0)}get path(){return Ze(this,C,"f")}set path(N){Ze(this,C,"f")!==N&&(xs(this,C,N,"f"),this.renderDirtyFlag=!0)}get side(){return Ze(this,F,"f")}set side(N){Ze(this,F,"f")!==N&&(xs(this,F,N,"f"),this.renderDirtyFlag=!0)}get startOffset(){return Ze(this,U,"f")}set startOffset(N){Ze(this,U,"f")!==N&&(xs(this,U,N,"f"),this.renderDirtyFlag=!0)}},e=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap,o=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,g=new WeakMap,p=new WeakMap,m=new WeakMap,v=new WeakMap,b=new WeakMap,y=new WeakMap,_=new WeakMap,w=new WeakMap,E=new WeakMap,A=new WeakMap,x=new WeakMap,S=new WeakMap,T=new WeakMap,R=new WeakMap,B=new WeakMap,O=new WeakMap,C=new WeakMap,F=new WeakMap,U=new WeakMap,H}const IPt=` 487layout(std140) uniform SceneUniforms { 488 mat3 u_ProjectionMatrix; 489 mat3 u_ViewMatrix; 490 mat3 u_ViewProjectionInvMatrix; 491 vec4 u_BackgroundColor; 492 vec4 u_GridColor; 493 float u_ZoomScale; 494 float u_CheckboardStyle; 495}; 496 497layout(location = 0) in vec2 a_Position; 498 499out vec2 v_Position; 500 501vec2 project_clipspace_to_world(vec2 p) { 502 return (u_ViewProjectionInvMatrix * vec3(p, 1)).xy; 503} 504 505void main() { 506 v_Position = project_clipspace_to_world(a_Position); 507 gl_Position = vec4(a_Position, 0, 1); 508} 509`,DPt=` 510layout(std140) uniform SceneUniforms { 511 mat3 u_ProjectionMatrix; 512 mat3 u_ViewMatrix; 513 mat3 u_ViewProjectionInvMatrix; 514 vec4 u_BackgroundColor; 515 vec4 u_GridColor; 516 float u_ZoomScale; 517 float u_CheckboardStyle; 518}; 519 520out vec4 outputColor; 521 522in vec2 v_Position; 523 524const int CHECKERBOARD_STYLE_NONE = 0; 525const int CHECKERBOARD_STYLE_GRID = 1; 526const int CHECKERBOARD_STYLE_DOTS = 2; 527const float BASE_GRID_PIXEL_SIZE = 100.0; 528const float BASE_DOT_SIZE = 8.0; 529 530vec2 scale_grid_size(float zoom) { 531 if (zoom < 0.125) return vec2(BASE_GRID_PIXEL_SIZE * 125.0, 0.125); 532 else if (zoom < 0.25) return vec2(BASE_GRID_PIXEL_SIZE * 25.0, 0.25); 533 else if (zoom < 0.5) return vec2(BASE_GRID_PIXEL_SIZE * 5.0, 0.5); 534 return vec2(BASE_GRID_PIXEL_SIZE, 4.0); 535} 536 537vec4 render_grid_checkerboard(vec2 coord) { 538 float alpha = 0.0; 539 540 vec2 size = scale_grid_size(u_ZoomScale); 541 float gridSize1 = size.x; 542 float gridSize2 = gridSize1 / 10.0; 543 float zoomStep = size.y; 544 int checkboardStyle = int(floor(u_CheckboardStyle + 0.5)); 545 546 if (checkboardStyle == CHECKERBOARD_STYLE_GRID) { 547 vec2 grid1 = abs(fract(coord / gridSize1 - 0.5) - 0.5) / fwidth(coord) * gridSize1 / 2.0; 548 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2; 549 float v1 = 1.0 - min(min(grid1.x, grid1.y), 1.0); 550 float v2 = 1.0 - min(min(grid2.x, grid2.y), 1.0); 551 552 if (v1 > 0.0) { 553 alpha = v1; 554 } else { 555 alpha = v2 * clamp(u_ZoomScale / zoomStep, 0.0, 1.0); 556 } 557 } else if (checkboardStyle == CHECKERBOARD_STYLE_DOTS) { 558 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2;
559 alpha = 1.0 - smoothstep(0.0, 1.0, length(grid2) - BASE_DOT_SIZE * u_ZoomScale / zoomStep); 560 } 561 562 return mix(u_BackgroundColor, u_GridColor, alpha); 563} 564 565void main() { 566 outputColor = render_grid_checkerboard(v_Position); 567} 568`;var zl=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},dI=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Jv,QT,tR,fI,pI,gI;let Rnt=class{constructor(){Jv.set(this,void 0),QT.set(this,void 0),tR.set(this,void 0),fI.set(this,void 0),pI.set(this,void 0),gI.set(this,new dPt)}appendVertex(t,e){zl(this,gI,"f").appendFloat(t).appendFloat(e)}render(t,e,r,i){if(!zl(this,Jv,"f")){dI(this,Jv,t.createProgram({vertex:{glsl:IPt},fragment:{glsl:DPt}}),"f"),dI(this,tR,t.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{format:I.F32_RG,offset:0,shaderLocation:0}]}],indexBufferFormat:null,program:zl(this,Jv,"f")}),"f"),dI(this,QT,t.createRenderPipeline({inputLayout:zl(this,tR,"f"),program:zl(this,Jv,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,topology:Go.TRIANGLE_STRIP}),"f"),zl(this,gI,"f").clear(),this.appendVertex(-1,-1),this.appendVertex(-1,1),this.appendVertex(1,-1),this.appendVertex(1,1);const s=zl(this,gI,"f").bytes(),o=t.createBuffer({viewOrSize:s.byteLength,usage:dt.VERTEX,hint:Et.DYNAMIC});dI(this,pI,o,"f"),o.setSubData(0,s),dI(this,fI,t.createBindings({pipeline:zl(this,QT,"f"),uniformBufferBindings:[{buffer:r}]}),"f")}zl(this,Jv,"f").setUniformsLegacy(i),e.setBindings(zl(this,fI,"f")),e.setP
568ipeline(zl(this,QT,"f")),e.setVertexInput(zl(this,tR,"f"),[{buffer:zl(this,pI,"f")}],null),e.draw(4)}destroy(){var t,e,r,i,s;(t=zl(this,Jv,"f"))===null||t===void 0||t.destroy(),(e=zl(this,pI,"f"))===null||e===void 0||e.destroy(),(r=zl(this,QT,"f"))===null||r===void 0||r.destroy(),(i=zl(this,tR,"f"))===null||i===void 0||i.destroy(),(s=zl(this,fI,"f"))===null||s===void 0||s.destroy()}};Jv=new WeakMap,QT=new WeakMap,tR=new WeakMap,fI=new WeakMap,pI=new WeakMap,gI=new WeakMap,Tv=class extends du{constructor(){super(...arguments),this.renderable=!1,this.visible=!0}containsPoint(t,e){throw new Error("Method not implemented.")}getGeometryBounds(){throw new Error("Method not implemented.")}getRenderBounds(){throw new Error("Method not implemented.")}destroy(){}};var fs=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Qi=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)};function mI(t){var e,r,i,s,o,n,a,l,c,h,u,d,f,g,p,m,v,b;class y extends t{constructor(w={}){var E;super(w),this.strokePoints=[],this.fillPoints=[],this.fillPathPoints=[],e.set(this,void 0),r.set(this,void 0),i.set(this,void 0),s.set(this,void 0),o.set(this,void 0),n.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),h.set(this,void 0),u.set(this,void 0),d.set(this,void 0),f.set(this,void 0),g.set(this,void 0),p.set(this,void 0),m.set(this,void 0),v.set(this,void 0),b.set(this,void 0);const{seed:A,bowing:x,roughness:S,fillStyle:T,fillWeight:R,hachureAngle:B,hachureGap:O,curveStepCount:C,curveFitting:F,disableMultiStroke:U,disableMultiStrokeFill:H,simplification:N,dashOffset:G,dashGap:Y,zigzagOffset:q,preserveVertices:L,fillLineDash:J,fillLineDashOffset:tt}=w;fs(this,s,A??1,"f"),fs(this,r,x??1,"f"),fs(this,e,S??1,"f"),fs(this,i,T??"hachure","f"),fs(this,o,R,"f"),fs(this,n,B??-41,"f"),fs(this,a,O,"f"),fs(this,l,C??9,"f"),fs(this,c,F??.95,"f"),fs(this,h,U,"f"),fs(this,u,H,"f"),fs(this,d,N??0,"f"),fs(this,f,G,"f"),fs(this,g,Y,"f"),fs(this,p,q,"f"),fs(this,m,L,"f"),fs(this,v,J,"f"),fs(this,b,tt,"f"),(E=this.preCreateGeometry)===null||E===void 0||E.call(this),this.geometryDirtyFlag=!1}get seed(){return Qi(this,s,"f")}set seed(w){Qi(this,s,"f")!==w&&(fs(this,s,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get roughness(){return Qi(this,e,"f")}set roughness(w){Qi(this,e,"f")!==w&&(fs(this,e,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get bowing(){return Qi(this,r,"f")}set bowing(w){Qi(this,r,"f")!==w&&(fs(this,r,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get fillStyle(){return Qi(this,i,"f")}set fillStyle(w){Qi(this,i,"f")!==w&&(fs(this,i,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get fillWeight(){return Qi(this,o,"f")}set fillWeight(w){Qi(this,o,"f")!==w&&(fs(this,o,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get hachureAngle(){return Qi(this,n,"f")}set hachureAngle(w){Qi(this,n,"f")!==w&&(fs(this,n,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get hachureGap(){return Qi(this,a,"f")}set hachureGap(w){Qi(this,a,"f")!==w&&(fs(this,a,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get curveStepCount(){return Qi(this,l,"f")}set curveStepCount(w){Qi(this,l,"f")!==w&&(fs(this,l,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get curveFitting(){return Qi(this,c,"f")}set curveFitting(w){Qi(this,c,"f")!==w&&(fs(this,c,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get disableMultiStroke(){return Qi(this,h,"f")}set disableMultiStroke(w){Qi(this,h,"f")!==w&&(fs(this,h,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get disableMultiStrokeFill(){return Qi(this,u,"f")}set disableMultiStrokeFill(w){Qi(this,u,"f")!==w&&(fs(this,u,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get simplification(){return Qi(this,d,"f")}set simplification(w){Qi(this,d,"f")!==w&&(fs(this,d,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get dashOffset(){return Qi(this,f,"f")}set dashOffset(w){Qi(this,f,"f")!==w&&(fs(this,f,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get dashGap(){return Qi(this,g,"f")}set dashGap(w){Qi(this,g,"f")!==w&&(fs(this,g,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get zigzagOffset(){return Qi(this,p,"f")}set zigzagOffset(w){Qi(this,p,"f")!==w&&(fs(this,p,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get preserveVertices(){return Qi(this,m,"f")}set preserveVertices(w){Qi(this,m,"f")!==w&&(fs(this,m,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get fillLineDash(){return Qi(this,v,"f")}set fillLineDash(w){var E;(!(!((E=Qi(this,v,"f"))===null||E===void 0)&&E.length)||!Qi(this,v,"f").every((A,x)=>A===w[x]))&&(fs(this,v,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get fillLineDashOffset(){return Qi(this,b,"f")}set fillLineDashOffset(w){Qi(this,b,"f")!==w&&(fs(this,b,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get roughOptions(){const{fill:w,stroke:E,strokeWidth:A,seed:x,bowing:S,roughness:T,fillStyle:R,fillWeight:B,hachureAngle:O,hachureGap:C,curveStepCount:F,curveFitting:U,disableMultiStroke:H,disableMultiStrokeFill:N,simplification:G,dashOffset:Y,dashGap:q,zigzagOffset:L,preserveVertices:J,strokeDasharray:tt,strokeDashoffset:bt,fillLineDash:ct,fillLineDashOffset:Xt}=this;return mPt({fill:w,stroke:E,strokeWidth:A,seed:x,bowing:S,roughness:T,fillStyle:R,fillWeight:B,hachureAngle:O,hachureGap:C,curveStepCount:F,curveFitting:U,disableMultiStroke:H,disableMultiStrokeFill:N,simplification:G,dashOffset:Y,dashGap:q,zigzagOffset:L,preserveVertices:J,strokeLineDash:tt,strokeLineDashOffset:bt,fillLineDash:ct,fillLineDashOffset:Xt})}preCreateGeometry(){const w=this.generateDrawable();this.drawableSets=w.sets,this.strokePoints=[],this.fillPoints=[],this.fillPathPoints=[],this.drawableSets.forEac
568h(E=>{const{subPaths:A}=TI(E),x=A.map(S=>S.getPoints().map(T=>[T[0],T[1]]));E.type==="path"?this.strokePoints=x:E.type==="fillPath"?this.fillPathPoints=x:E.type==="fillSketch"&&(this.fillPoints=x)})}}return e=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap,o=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,g=new WeakMap,p=new WeakMap,m=new WeakMap,v=new WeakMap,b=new WeakMap,y}let pH;Zh=class extends mI(aH(du)){constructor(t={}){super(t)}generateDrawable(){const{cx:t,cy:e,r}=this;return bI.circle(t,e,r*2,this.roughOptions)}},Qh=class extends mI(lH(du)){constructor(t={}){super(t)}generateDrawable(){const{cx:t,cy:e,rx:r,ry:i}=this;return bI.ellipse(t,e,r*2,i*2,this.roughOptions)}},au=class extends mI(cH(du)){constructor(t={}){super(t)}generateDrawable(){const{x:t,y:e,width:r,height:i}=this;return bI.rectangle(t,e,r,i,this.roughOptions)}},ky=class extends mI(hH(du)){constructor(t={}){super(t)}generateDrawable(){const{points:t}=this;return bI.linearPath(t,this.roughOptions)}},tp=class extends mI(fH(du)){constructor(t={}){super(t)}generateDrawable(){const{d:t}=this;return bI.path(t,this.roughOptions)}},pH=class extends Cnt(du){};function Cnt(t){return class extends t{getGeometryBounds(){return new ea(0,0,0,0)}getRenderBounds(){return new ea(0,0,0,0)}constructor(e={}){super(e),this.batchable=!1,this.cullable=!1;const{render:r}=e;this.render=r}}}function gH(t,e,r){if(t&&t.length){const[i,s]=e,o=Math.PI/180*r,n=Math.cos(o),a=Math.sin(o);for(const l of t){const[c,h]=l;l[0]=(c-i)*n-(h-s)*a+i,l[1]=(c-i)*a+(h-s)*n+s}}}function PPt(t,e){return t[0]===e[0]&&t[1]===e[1]}function FPt(t,e,r,i=1){const s=r,o=Math.max(e,.1),n=t[0]&&t[0][0]&&typeof t[0][0]=="number"?[t]:t,a=[0,0];if(s)for(const c of n)gH(c,a,s);const l=(function(c,h,u){const d=[];for(const b of c){const y=[...b];PPt(y[0],y[y.length-1])||y.push([y[0][0],y[0][1]]),y.length>2&&d.push(y)}const f=[];h=Math.max(h,.1);const g=[];for(const b of d)for(let y=0;y<b.length-1;y++){const _=b[y],w=b[y+1];if(_[1]!==w[1]){const E=Math.min(_[1],w[1]);g.push({ymin:E,ymax:Math.max(_[1],w[1]),x:E===_[1]?_[0]:w[0],islope:(w[0]-_[0])/(w[1]-_[1])})}}if(g.sort(((b,y)=>b.ymin<y.ymin?-1:b.ymin>y.ymin?1:b.x<y.x?-1:b.x>y.x?1:b.ymax===y.ymax?0:(b.ymax-y.ymax)/Math.abs(b.ymax-y.ymax))),!g.length)return f;let p=[],m=g[0].ymin,v=0;for(;p.length||g.length;){if(g.length){let b=-1;for(let y=0;y<g.length&&!(g[y].ymin>m);y++)b=y;g.splice(0,b+1).forEach((y=>{p.push({s:m,edge:y})}))}if(p=p.filter((b=>!(b.edge.ymax<=m))),p.sort(((b,y)=>b.edge.x===y.edge.x?0:(b.edge.x-y.edge.x)/Math.abs(b.edge.x-y.edge.x))),(u!==1||v%h==0)&&p.length>1)for(let b=0;b<p.length;b+=2){const y=b+1;if(y>=p.length)break;const _=p[b].edge,w=p[y].edge;f.push([[Math.round(_.x),m],[Math.round(w.x),m]])}m+=u,p.forEach((b=>{b.edge.x=b.edge.x+u*b.edge.islope})),v++}return f})(n,o,i);if(s){for(const c of n)gH(c,a,-s);(function(c,h,u){const d=[];c.forEach((f=>d.push(...f))),gH(d,h,u)})(l,a,-s)}return l}function yI(t,e){var r;const i=e.hachureAngle+90;let s=e.hachureGap;s<0&&(s=4*e.strokeWidth),s=Math.round(Math.max(s,.1));let o=1;return e.roughness>=1&&(((r=e.randomizer)===null||r===void 0?void 0:r.next())||Math.random())>.7&&(o=s),FPt(t,s,i,o||1)}let mH=class{constructor(t){this.helper=t}fillPolygons(t,e){return this._fillPolygons(t,e)}_fillPolygons(t,e){const r=yI(t,e);return{type:"fillSketch",ops:this.renderLines(r,e)}}renderLines(t,e){const r=[];for(const i of t)r.push(...this.helper.doubleLineOps(i[0][0],i[0][1],i[1][0],i[1][1],e));return r}};function f5(t){const e=t[0],r=t[1];return Math.sqrt(Math.pow(e[0]-r[0],2)+Math.pow(e[1]-r[1],2))}let NPt=class extends mH{fillPolygons(t,e){let r=e.hachureGap;r<0&&(r=4*e.strokeWidth),r=Math.max(r,.1);const i=yI(t,Object.assign({},e,{hachureGap:r})),s=Math.PI/180*e.hachureAngle,o=[],n=.5*r*Math.cos(s),a=.5*r*Math.sin(s);for(const[l,c]of i)f5([l,c])&&o.push([[l[0]-n,l[1]+a],[...c]],[[l[0]+n,l[1]-a],[...c]]);return{type:"fillSketch",ops:this.renderLines(o,e)}}},kPt=class extends mH{fillPolygons(t,e){const r=this._fillPolygons(t,e),i=Object.assign({},e,{hachureAngle:e.hachureAngle+90}),s=this._fillPolygons(t,i);return r.ops=r.ops.concat(s.ops),r}},LPt=class{constructor(t){this.helper=t}fillPolygons(t,e){const r=yI(t,e=Object.assign({},e,{hachureAngle:0}));return this.dotsOnLines(r,e)}dotsOnLines(t,e){const r=[];let i=e.hachureGap;i<0&&(i=4*e.strokeWidth),i=Math.max(i,.1);let s=e.fillWeight;s<0&&(s=e.strokeWidth/2);const o=i/4;for(const n of t){const a=f5(n),l=a/i,c=Math.ceil(l)-1,h=a-c*i,u=(n[0][0]+n[1][0])/2-i/4,d=Math.min(n[0][1],n[1][1]);for(let f=0;f<c;f++){const g=d+h+f*i,p=u-o+2*Math.random()*o,m=g-o+2*Math.random()*o,v=this.helper.ellipse(p,m,s,s,e);r.push(...v.ops)}}return{type:"fillSketch",ops:r}}},UPt=class{constructor(t){this.helper=t}fillPolygons(t,e){const r=yI(t,e);return{type:"fillSketch",ops:this.dashedLine(r,e)}}dashedLine(t,e){const r=e.dashOffset<0?e.hachureGap<0?4*e.strokeWidth:e.hachureGap:e.dashOffset,i=e.dashGap<0?e.hachureGap<0?4*e.strokeWidth:e.hachureGap:e.dashGap,s=[];return t.forEach((o=>{const n=f5(o),a=Math.floor(n/(r+i)),l=(n+i-a*(r+i))/2;let c=o[0],h=o[1];c[0]>h[0]&&(c=o[1],h=o[0]);
vendor: 25,846 bytes, line 568
568const u=Math.atan((h[1]-c[1])/(h[0]-c[0]));for(let d=0;d<a;d++){const f=d*(r+i),g=f+r,p=[c[0]+f*Math.cos(u)+l*Math.cos(u),c[1]+f*Math.sin(u)+l*Math.sin(u)],m=[c[0]+g*Math.cos(u)+l*Math.cos(u),c[1]+g*Math.sin(u)+l*Math.sin(u)];s.push(...this.helper.doubleLineOps(p[0],p[1],m[0],m[1],e))}})),s}},GPt=class{constructor(t){this.helper=t}fillPolygons(t,e){const r=e.hachureGap<0?4*e.strokeWidth:e.hachureGap,i=e.zigzagOffset<0?r:e.zigzagOffset,s=yI(t,e=Object.assign({},e,{hachureGap:r+i}));return{type:"fillSketch",ops:this.zigzagLines(s,i,e)}}zigzagLines(t,e,r){const i=[];return t.forEach((s=>{const o=f5(s),n=Math.round(o/(2*e));let a=s[0],l=s[1];a[0]>l[0]&&(a=s[1],l=s[0]);const c=Math.atan((l[1]-a[1])/(l[0]-a[0]));for(let h=0;h<n;h++){const u=2*h*e,d=2*(h+1)*e,f=Math.sqrt(2*Math.pow(e,2)),g=[a[0]+u*Math.cos(c),a[1]+u*Math.sin(c)],p=[a[0]+d*Math.cos(c),a[1]+d*Math.sin(c)],m=[g[0]+f*Math.cos(c+Math.PI/4),g[1]+f*Math.sin(c+Math.PI/4)];i.push(...this.helper.doubleLineOps(g[0],g[1],m[0],m[1],r),...this.helper.doubleLineOps(m[0],m[1],p[0],p[1],r))}})),i}};const fu={};let WPt=class{constructor(t){this.seed=t}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}};const jPt=0,yH=1,Mnt=2,p5={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:2,t:2,V:1,v:1,Z:0,z:0};function vH(t,e){return t.type===e}function _H(t){const e=[],r=(function(n){const a=new Array;for(;n!=="";)if(n.match(/^([ \t\r\n,]+)/))n=n.substr(RegExp.$1.length);else if(n.match(/^([aAcChHlLmMqQsStTvVzZ])/))a[a.length]={type:jPt,text:RegExp.$1},n=n.substr(RegExp.$1.length);else{if(!n.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))return[];a[a.length]={type:yH,text:`${parseFloat(RegExp.$1)}`},n=n.substr(RegExp.$1.length)}return a[a.length]={type:Mnt,text:""},a})(t);let i="BOD",s=0,o=r[s];for(;!vH(o,Mnt);){let n=0;const a=[];if(i==="BOD"){if(o.text!=="M"&&o.text!=="m")return _H("M0,0"+t);s++,n=p5[o.text],i=o.text}else vH(o,yH)?n=p5[i]:(s++,n=p5[o.text],i=o.text);if(!(s+n<r.length))throw new Error("Path data ended short");for(let l=s;l<s+n;l++){const c=r[l];if(!vH(c,yH))throw new Error("Param not a number: "+i+","+c.text);a[a.length]=+c.text}if(typeof p5[i]!="number")throw new Error("Bad segment: "+i);{const l={key:i,data:a};e.push(l),s+=n,o=r[s],i==="M"&&(i="L"),i==="m"&&(i="l")}}return e}function Bnt(t){let e=0,r=0,i=0,s=0;const o=[];for(const{key:n,data:a}of t)switch(n){case"M":o.push({key:"M",data:[...a]}),[e,r]=a,[i,s]=a;break;case"m":e+=a[0],r+=a[1],o.push({key:"M",data:[e,r]}),i=e,s=r;break;case"L":o.push({key:"L",data:[...a]}),[e,r]=a;break;case"l":e+=a[0],r+=a[1],o.push({key:"L",data:[e,r]});break;case"C":o.push({key:"C",data:[...a]}),e=a[4],r=a[5];break;case"c":{const l=a.map(((c,h)=>h%2?c+r:c+e));o.push({key:"C",data:l}),e=l[4],r=l[5];break}case"Q":o.push({key:"Q",data:[...a]}),e=a[2],r=a[3];break;case"q":{const l=a.map(((c,h)=>h%2?c+r:c+e));o.push({key:"Q",data:l}),e=l[2],r=l[3];break}case"A":o.push({key:"A",data:[...a]}),e=a[5],r=a[6];break;case"a":e+=a[5],r+=a[6],o.push({key:"A",data:[a[0],a[1],a[2],a[3],a[4],e,r]});break;case"H":o.push({key:"H",data:[...a]}),e=a[0];break;case"h":e+=a[0],o.push({key:"H",data:[e]});break;case"V":o.push({key:"V",data:[...a]}),r=a[0];break;case"v":r+=a[0],o.push({key:"V",data:[r]});break;case"S":o.push({key:"S",data:[...a]}),e=a[2],r=a[3];break;case"s":{const l=a.map(((c,h)=>h%2?c+r:c+e));o.push({key:"S",data:l}),e=l[2],r=l[3];break}case"T":o.push({key:"T",data:[...a]}),e=a[0],r=a[1];break;case"t":e+=a[0],r+=a[1],o.push({key:"T",data:[e,r]});break;case"Z":case"z":o.push({key:"Z",data:[]}),e=i,r=s}return o}function Ont(t){const e=[];let r="",i=0,s=0,o=0,n=0,a=0,l=0;for(const{key:c,data:h}of t){switch(c){case"M":e.push({key:"M",data:[...h]}),[i,s]=h,[o,n]=h;break;case"C":e.push({key:"C",data:[...h]}),i=h[4],s=h[5],a=h[2],l=h[3];break;case"L":e.push({key:"L",data:[...h]}),[i,s]=h;break;case"H":i=h[0],e.push({key:"L",data:[i,s]});break;case"V":s=h[0],e.push({key:"L",data:[i,s]});break;case"S":{let u=0,d=0;r==="C"||r==="S"?(u=i+(i-a),d=s+(s-l)):(u=i,d=s),e.push({key:"C",data:[u,d,...h]}),a=h[0],l=h[1],i=h[2],s=h[3];break}case"T":{const[u,d]=h;let f=0,g=0;r==="Q"||r==="T"?(f=i+(i-a),g=s+(s-l)):(f=i,g=s);const p=i+2*(f-i)/3,m=s+2*(g-s)/3,v=u+2*(f-u)/3,b=d+2*(g-d)/3;e.push({key:"C",data:[p,m,v,b,u,d]}),a=f,l=g,i=u,s=d;break}case"Q":{const[u,d,f,g]=h,p=i+2*(u-i)/3,m=s+2*(d-s)/3,v=f+2*(u-f)/3,b=g+2*(d-g)/3;e.push({key:"C",data:[p,m,v,b,f,g]}),a=u,l=d,i=f,s=g;break}case"A":{const u=Math.abs(h[0]),d=Math.abs(h[1]),f=h[2],g=h[3],p=h[4],m=h[5],v=h[6];u===0||d===0?(e.push({key:"C",data:[i,s,m,v,m,v]}),i=m,s=v):(i!==m||s!==v)&&(Int(i,s,m,v,u,d,f,g,p).forEach((function(b){e.push({key:"C",data:b})})),i=m,s=v);break}case"Z":e.push({key:"Z",data:[]}),i=o,s=n}r=c}return e}function vI(t,e,r){return[t*Math.cos(r)-e*Math.sin(r),t*Math.sin(r)+e*Math.cos(r)]}function Int(t,e,r,i,s,o,n,a,l,c){const h=(u=n,Math.PI*u/180);var u;let d=[],f=0,g=0,p=0,m=0;if(c)[f,g,p,m]=c;else{[t,e]=vI(t,e,-h),[r,i]=vI(r,i,-h);const O=(t-r)/2,C=(e-i)/2;let F=O*O/(s*s)+C*C/(o*o);F>1&&(F=Math.sqrt(F),s*=F,o*=F);const U=s*s,H=o*o,N=U*H-U*C*C-H*O*O,G=U*C*C+H*O*O,Y=(a===l?-1:1)*Math.sqrt(Math.abs(N/G));p=Y*s*C/o+(t+r)/2,m=Y*-o*O/s+(e+i)/2,f=Math.asin(parseFloat(((e-m)/o).toFixed(9))),g=Math.asin(parseFloat(((i-m)/o).toFixed(9))),t<p&&(f=Math.PI-f),r<p&&(g=Math.PI-g),f<0&&(f=2*Math.PI+f),g<0&&(g=2*Math.PI+g),l&&f>g&&(f-=2*Math.PI),!l&&g>f&&(g-=2*Math.PI)}let v=g-f;if(Math.abs(v)>120*Math.PI/180){const O=g,C=r,F=i;g=l&&g>f?f+120*Math.PI/180*1:f+120*Math.PI/180*-1,d=Int(r=p+s*Math.cos(g),i=m+o*Math.sin(g),C,F,s,o,n,0,l,[g,O,p,m])}v=g-f;const b=Math.cos(f),y=Math.sin(f),_=Math.cos(g),w=Math.sin(g),E=Math.tan(v/4),A=4/3*s*E,x=4/3*o*E,S=[t,e],T=[t+A*y,e-x*b],R=[r+A*w,i-x*_],B=[r,i];if(T[0]=2*S[0]-T[0],T[1]=2*S[1]-T[1],c)return[T,R,B].concat(d);{d=[T,R,B].concat(d);const O=[];for(let C=0;C<d.length;C+=3){const F=vI(d[C][0],d[C][1],h),U=vI(d[C+1][0],d[C+1][1],h),H=vI(d[C+2][0],d[C+2][1],h);O.push([F[0],F[1],U[0],U[1],H[0],H[1]])}return O}}const XPt={randOffset:function(t,e){return Vr(t,e)},randOffsetWithRange:function(t,e,r){return m5(t,e,r)},ellipse:function(t,e,r,i,s){const o=Fnt(r,i,s);return bH(t,e,s,o).opset},doubleLineOps:function(t,e,r,i,s){return Qv(t,e,r,i,s,!0)}};function Dnt(t,e,r,i,s){return{type:"path",ops:Qv(t,e,r,i,s)}}function g5(t,e,r){const i=(t||[]).length;if(i>2){const s=[];for(let o=0;o<i-1;o++)s.push(...Qv(t[o][0],t[o][1],t[o+1][0],t[o+1][1],r));return e&&s.push(...Qv(t[i-1][0],t[i-1][1],t[0][0],t[0][1],r)),{type:"path",ops:s}}return i===2?Dnt(t[0][0],t[0][1],t[1][0],t[1][1],r):{type:"path",ops:[]}}function zPt(t,e,r,i,s){return(function(o,n){return g5(o,!0,n)})([[t,e],[t+r,e],[t+r,e+i],[t,e+i]],s)}function Pnt(t,e){if(t.length){const r=typeof t[0][0]=="number"?[t]:t,i=y5(r[0],1*(1+.2*e.roughness),e),s=e.disableMultiStroke?[]:y5(r[0],1.5*(1+.22*e.roughness),Lnt(e));for(let o=1;o<r.length;o++){const n=r[o];if(n.length){const a=y5(n,1*(1+.2*e.roughness),e),l=e.disableMultiStroke?[]:y5(n,1.5*(1+.22*e.roughness),Lnt(e));for(const c of a)c.op!=="move"&&i.push(c);for(const c of l)c.op!=="move"&&s.push(c)}}return{type:"path",ops:i.concat(s)}}return{type:"path",ops:[]}}function Fnt(t,e,r){const i=Math.sqrt(2*Math.PI*Math.sqrt((Math.pow(t/2,2)+Math.pow(e/2,2))/2)),s=Math.ceil(Math.max(r.curveStepCount,r.curveStepCount/Math.sqrt(200)*i)),o=2*Math.PI/s;let n=Math.abs(t/2),a=Math.abs(e/2);const l=1-r.curveFitting;return n+=Vr(n*l,r),a+=Vr(a*l,r),{increment:o,rx:n,ry:a}}function bH(t,e,r,i){const[s,o]=Gnt(i.increment,t,e,i.rx,i.ry,1,i.increment*m5(.1,m5(.4,1,r),r),r);let n=v5(s,null,r);if(!r.disableMultiStroke&&r.roughness!==0){const[a]=Gnt(i.increment,t,e,i.rx,i.ry,1.5,0,r),l=v5(a,null,r);n=n.concat(l)}return{estimatedPoints:o,opset:{type:"path",ops:n}}}function Nnt(t,e,r,i,s,o,n,a,l){const c=t,h=e;let u=Math.abs(r/2),d=Math.abs(i/2);u+=Vr(.01*u,l),d+=Vr(.01*d,l);let f=s,g=o;for(;f<0;)f+=2*Math.PI,g+=2*Math.PI;g-f>2*Math.PI&&(f=0,g=2*Math.PI);const p=2*Math.PI/l.curveStepCount,m=Math.min(p/2,(g-f)/2),v=Wnt(m,c,h,u,d,f,g,1,l);if(!l.disableMultiStroke){const b=Wnt(m,c,h,u,d,f,g,1.5,l);v.push(...b)}return n&&(a?v.push(...Qv(c,h,c+u*Math.cos(f),h+d*Math.sin(f),l),...Qv(c,h,c+u*Math.cos(g),h+d*Math.sin(g),l)):v.push({op:"lineTo",data:[c,h]},{op:"lineTo",data:[c+u*Math.cos(f),h+d*Math.sin(f)]})),{type:"path",ops:v}}function knt(t,e){const r=Ont(Bnt(_H(t))),i=[];let s=[0,0],o=[0,0];for(const{key:n,data:a}of r)switch(n){case"M":o=[a[0],a[1]],s=[a[0],a[1]];break;case"L":i.push(...Qv(o[0],o[1],a[0],a[1],e)),o=[a[0],a[1]];break;case"C":{const[l,c,h,u,d,f]=a;i.push(...VPt(l,c,h,u,d,f,o,e)),o=[d,f];break}case"Z":i.push(...Qv(o[0],o[1],s[0],s[1],e)),o=[s[0],s[1]]}return{type:"path",ops:i}}function wH(t,e){const r=[];for(const i of t)if(i.length){const s=e.maxRandomnessOffset||0,o=i.length;if(o>2){r.push({op:"move",data:[i[0][0]+Vr(s,e),i[0][1]+Vr(s,e)]});for(let n=1;n<o;n++)r.push({op:"lineTo",data:[i[n][0]+Vr(s,e),i[n][1]+Vr(s,e)]})}}return{type:"fillPath",ops:r}}function eR(t,e){return(function(r,i){let s=r.fillStyle||"hachure";if(!fu[s])switch(s){case"zigzag":fu[s]||(fu[s]=new NPt(i));break;case"cross-hatch":fu[s]||(fu[s]=new kPt(i));break;case"dots":fu[s]||(fu[s]=new LPt(i));break;case"dashed":fu[s]||(fu[s]=new UPt(i));break;case"zigzag-line":fu[s]||(fu[s]=new GPt(i));break;default:s="hachure",fu[s]||(fu[s]=new mH(i))}return fu[s]})(e,XPt).fillPolygons(t,e)}function Lnt(t){const e=Object.assign({},t);return e.randomizer=void 0,t.seed&&(e.seed=t.seed+1),e}function Unt(t){return t.randomizer||(t.randomizer=new WPt(t.seed||0)),t.randomizer.next()}function m5(t,e,r,i=1){return r.roughness*i*(Unt(r)*(e-t)+t)}function Vr(t,e,r=1){return m5(-t,t,e,r)}function Qv(t,e,r,i,s,o=!1){const n=o?s.disableMultiStrokeFill:s.disableMultiStroke,a=EH(t,e,r,i,s,!0,!1);if(n)return a;const l=EH(t,e,r,i,s,!0,!0);return a.concat(l)}function EH(t,e,r,i,s,o,n){const a=Math.pow(t-r,2)+Math.pow(e-i,2),l=Math.sqrt(a);let c=1;c=l<200?1:l>500?.4:-.0016668*l+1.233334;let h=s.maxRandomnessOffset||0;h*h*100>a&&(h=l/10);const u=h/2,d=.2+.2*Unt(s);let f=s.bowing*s.maxRandomnessOffset*(i-e)/200,g=s.bowing*s.maxRandomnessOffset*(t-r)/200;f=Vr(f,s,c),g=Vr(g,s,c);const p=[],m=()=>Vr(u,s,c),v=()=>Vr(h,s,c),b=s.preserveVertices;return n?p.push({op:"move",data:[t+(b?0:m()),e+(b?0:m())]}):p.push({op:"move",data:[t+(b?0:Vr(h,s,c)),e+(b?0:Vr(h,s,c))]}),n?p.push({op:"bcurveTo",data:[f+t+(r-t)*d+m(),g+e+(i-e)*d+m(),f+t+2*(r-t)*d+m(),g+e+2*(i-e)*d+m(),r+(b?0:m()),i+(b?0:m())]}):p.push({op:"bcurveTo",data:[f+t+(r-t)*d+v(),g+e+(i-e)*d+v(),f+t+2*(r-t)*d+v(),g+e+2*(i-e)*d+v(),r+(b?0:v()),i+(b?0:v())]}),p}function y5(t,e,r){if(!t.length)return[];const i=[];i.push([t[0][0]+Vr(e,r),t[0][1]+Vr(e,r)]),i.push([t[0][0]+Vr(e,r),t[0][1]+Vr(e,r)]);for(let s=1;s<t.length;s++)i.push([t[s][0]+Vr(e,r),t[s][1]+Vr(e,r)]),s===t.length-1&&i.push([t[s][0]+Vr(e,r),t[s][1]+Vr(e,r)]);return v5(i,null,r)}function v5(t,e,r){const i=t.length,s=[];if(i>3){const o=[],n=1-r.curveTightness;s.push({op:"move",data:[t[1][0],t[1][1]]});for(let a=1;a+2<i;a++){const l=t[a];o[0]=[l[0],l[1]],o[1]=[l[0]+(n*t[a+1][0]-n*t[a-1][0])/6,l[1]+(n*t[a+1][1]-n*t[a-1][1])/6],o[2]=[t[a+1][0]+(n*t[a][0]-n*t[a+2][0])/6,t[a+1][1]+(n*t[a][1]-n*t[a+2][1])/6],o[3]=[t[a+1][0],t[a+1][1]],s.push({op:"bcurveTo",data:[o[1][0],o[1][1],o[2][0],o[2][1],o[3][0],o[3][1]]})}}else i===3?(s.push({op:"move",data:[t[1][0],t[1][1]]}),s.push({op:"bcurveTo",data:[t[1][0],t[1][1],t[2][0],t[2][1],t[2][0],t[2][1]]})):i===2&&s.push(...EH(t[0][0],t[0][1],t[1][0],t[1][1],r,!0,!0));return s}function Gnt(t,e,r,i,s,o,n,a){const l=[],c=[];if(a.roughness===0){t/=4,c.push([e+i*Math.cos(-t),r+s*Math.sin(-t)]);for(let h=0;h<=2*Math.PI;h+=t){const u=[e+i*Math.cos(h),r+s*Math.sin(h)];l.push(u),c.push(u)}c.push([e+i*Math.cos(0),r+s*Math.sin(0)]),c.push([e+i*Math.cos(t),r+s*Math.sin(t)])}else{const h=Vr(.5,a)-Math.PI/2;c.push([Vr(o,a)+e+.9*i*Math.cos(h-t),Vr(o,a)+r+.9*s*Math.sin(h-t)]);const u=2*Math.PI+h-.01;for(let d=h;d<u;d+=t){const f=[Vr(o,a)+e+i*Math.cos(d),Vr(o,a)+r+s*Math.sin(d)];l.push(f),c.push(f)}c.push([Vr(o,a)+e+i*Math.cos(h+2*Math.PI+.5*n),Vr(o,a)+r+s*Math.sin(h+2*Math.PI+.5*n)]),c.push([Vr(o,a)+e+.98*i*Math.cos(h+n),Vr(o,a)+r+.98*s*Math.sin(h+n)]),c.push([Vr(o,a)+e+.9*i*Math.cos(h+.5*n),Vr(o,a)+r+.9*s*Math.sin(h+.5*n)])}return[c,l]}function Wnt(t,e,r,i,s,o,n,a,l){const c=o+Vr(.1,l),h=[];h.push([Vr(a,l)+e+.9*i*Math.cos(c-t),Vr(a,l)+r+.9*s*Math.sin(c-t)]);for(let u=c;u<=n;u+=t)h.push([Vr(a,l)+e+i*Math.cos(u),Vr(a,l)+r+s*Math.sin(u)]);return h.push([e+i*Math.cos(n),r+s*Math.sin(n)]),h.push([e+i*Math.cos(n),r+s*Math.sin(n)]),v5(h,null,l)}function VPt(t,e,r,i,s,o,n,a){const l=[],c=[a.maxRandomnessOffset||1,(a.maxRandomnessOffset||1)+.3];let h=[0,0];const u=a.disableMultiStroke?1:2,d=a.preserveVertices;for(let f=0;f<u;f++)f===0?l.push({op:"move",data:[n[0],n[1]]}):l.push({op:"move",data:[n[0]+(d?0:Vr(c[0],a)),n[1]+(d?0:Vr(c[0],a))]}),h=d?[s,o]:[s+Vr(c[f],a),o+Vr(c[f],a)],l.push({op:"bcurveTo",data:[t+Vr(c[f],a),e+Vr(c[f],a),r+Vr(c[f],a),i+Vr(c[f],a),h[0],h[1]]});return l}function _I(t){return[...t]}function jnt(t,e=0){const r=t.length;if(r<3)throw new Error("A curve must have at least three points.");const i=[];if(r===3)i.push(_I(t[0]),_I(t[1]),_I(t[2]),_I(t[2]));else{const s=[];s.push(t[0],t[0]);for(let a=1;a<t.length;a++)s.push(t[a]),a===t.length-1&&s.push(t[a]);const o=[],n=1-e;i.push(_I(s[0]));for(let a=1;a+2<s.length;a++){const l=s[a];o[0]=[l[0],l[1]],o[1]=[l[0]+(n*s[a+1][0]-n*s[a-1][0])/6,l[1]+(n*s[a+1][1]-n*s[a-1][1])/6],o[2]=[s[a+1][0]+(n*s[a][0]-n*s[a+2][0])/6,s[a+1][1]+(n*s[a][1]-n*s[a+2][1])/6],o[3]=[s[a+1][0],s[a+1][1]],i.push(o[1],o[2],o[3])}}return i}function _5(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)}function YPt(t,e,r){const i=_5(e,r);if(i===0)return _5(t,e);let s=((t[0]-e[0])*(r[0]-e[0])+(t[1]-e[1])*(r[1]-e[1]))/i;return s=Math.max(0,Math.min(1,s)),_5(t,BE(e,r,s))}function BE(t,e,r){return[t[0]+(e[0]-t[0])*r,t[1]+(e[1]-t[1])*r]}function AH(t,e,r,i){const s=i||[];if((function(a,l){const c=a[l+0],h=a[l+1],u=a[l+2],d=a[l+3];let f=3*h[0]-2*c[0]-d[0];f*=f;let g=3*h[1]-2*c[1]-d[1];g*=g;let p=3*u[0]-2*d[0]-c[0];p*=p;let m=3*u[1]-2*d[1]-c[1];return m*=m,f<p&&(f=p),g<m&&(g=m),f+g})(t,e)<r){const a=t[e+0];s.length?(o=s[s.length-1],n=a,Math.sqrt(_5(o,n))>1&&s.push(a)):s.push(a),s.push(t[e+3])}else{const a=t[e+0],l=t[e+1],c=t[e+2],h=t[e+3],u=BE(a,l,.5),d=BE(l,c,.5),f=BE(c,h,.5),g=BE(u,d,.5),p=BE(d,f,.5),m=BE(g,p,.5);AH([a,u,g,m],0,r,s),AH([m,p,f,h],0,r,s)}var o,n;return s}function $Pt(t,e){return b5(t,0,t.length,e)}function b5(t,e,r,i,s){const o=s||[],n=t[e],a=t[r-1];let l=0,c=1;for(let h=e+1;h<r-1;++h){const u=YPt(t[h],n,a);u>l&&(l=u,c=h)}return Math.sqrt(l)>i?(b5(t,e,c+1,i,o),b5(t,c,r,i,o)):(o.length||o.push(n),o.push(a)),o}function xH(t,e=.15,r){const i=[],s=(t.length-1)/3;for(let o=0;o<s;o++)AH(t,3*o,e,i);return r&&r>0?b5(i,0,i.length,r):i}const dd="none";class w5{constructor(e){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=e||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Math.floor(Math.random()*2**31)}_o(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_d(e,r,i){return{shape:e,sets:r||[],options:i||this.defaultOptions}}line(e,r,i,s,o){const n=this._o(o);return this._d("line",[Dnt(e,r,i,s,n)],n)}rectangle(e,r,i,s,o){const n=this._o(o),a=[],l=zPt(e,r,i,s,n);if(n.fill){const c=[[e,r],[e+i,r],[e+i,r+s],[e,r+s]];n.fillStyle==="solid"?a.push(wH([c],n)):a.push(eR([c],n))}return n.stroke!==dd&&a.push(l),this._d("rectangle",a,n)}ellipse(e,r,i,s,o){const n=this._o(o),a=[],l=Fnt(i,s,n),c=bH(e,r,n,l);if(n.fill)if(n.fillStyle==="solid"){const h=bH(e,r,n,l).opset;h.type="fillPath",a.push(h)}else a.push(eR([c.estimatedPoints],n));return n.stroke!==dd&&a.push(c.opset),this._d("ellipse",a,n)}circle(e,r,i,s){const o=this.ellipse(e,r,i,i,s);return o.shape="circle",o}linearPath(e,r){const i=this._o(r);return this._d("linearPath",[g5(e,!1,i)],i)}arc(e,r,i,s,o,n,a=!1,l){const c=this._o(l),h=[],u=Nnt(e,r,i,s,o,n,a,!0,c);if(a&&c.fill)if(c.fillStyle==="solid"){const d=Object.assign({},c);d.disableMultiStroke=!0;const f=Nnt(e,r,i,s,o,n,!0,!1,d);f.type="fillPath",h.push(f)}else h.push((function(d,f,g,p,m,v,b){const y=d,_=f;let w=Math.abs(g/2),E=Math.abs(p/2);w+=Vr(.01*w,b),E+=Vr(.01*E,b);let A=m,x=v;for(;A<0;)A+=2*Math.PI,x+=2*Math.PI;x-A>2*Math.PI&&(A=0,x=2*Math.PI);const S=(x-A)/b.curveStepCount,T=[];for(let R=A;R<=x;R+=S)T.push([y+w*Math.cos(R),_+E*Math.sin(R)]);return T.push([y+w*Math.cos(x),_+E*Math.sin(x)]),T.push([y,_]),eR([T],b)})(e,r,i,s,o,n,c));return c.stroke!==dd&&h.push(u),this._d("arc",h,c)}curve(e,r){const i=this._o(r),s=[],o=Pnt(e,i);if(i.fill&&i.fill!==dd)if(i.fillStyle==="solid"){const n=Pnt(e,Object.assign(Object.assign({},i),{disableMultiStroke:!0,roughness:i.roughness?i.roughness+i.fillShapeRoughnessGain:0}));s.push({type:"fillPath",ops:this._mergedShape(n.ops)})}else{const n=[],a=e;if(a.length){const l=typeof a[0][0]=="number"?[a]:a;for(const c of l)c.length<3?n.push(...c):c.length===3?n.push(...xH(jnt([c[0],c[0],c[1],c[2]]),10,(1+i.roughness)/2)):n.push(...xH(jnt(c),10,(1+i.roughness)/2))}n.length&&s.push(eR([n],i))}return i.stroke!==dd&&s.push(o),this._d("curve",s,i)}polygon(e,r){const i=this._o(r),s=[],o=g5(e,!0,i);return i.fill&&(i.fillStyle==="solid"?s.push(wH([e],i)):s.push(eR([e],i))),i.stroke!==dd&&s.push(o),this._d("polygon",s,i)}path(e,r){const i=this._o(r),s=[];if(!e)return this._d("path",s,i);e=(e||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");const o=i.fill&&i.fill!=="transparent"&&i.fill!==dd,n=i.stroke!==dd,a=!!(i.simplification&&i.simplification<1),l=(function(h,u,d){const f=Ont(Bnt(_H(h))),g=[];let p=[],m=[0,0],v=[];const b=()=>{v.length>=4&&p.push(...xH(v,u)),v=[]},y=()=>{b(),p.length&&(g.push(p),p=[])};for(const{key:w,data:E}of f)switch(w){case"M":y(),m=[E[0],E[1]],p.push(m);break;case"L":b(),p.push([E[0],E[1]]);break;case"C":if(!v.length){const A=p.length?p[p.length-1]:m;v.push([A[0],A[1]])}v.push([E[0],E[1]]),v.push([E[2],E[3]]),v.push([E[4],E[5]]);break;case"Z":b(),p.push([m[0],m[1]])}if(y(),!d)return g;const _=[];for(const w of g){const E=$Pt(w,d);E.length&&_.push(E)}return _})(e,1,a?4-4*(i.simplification||1):(1+i.roughness)/2),c=knt(e,i);if(o)if(i.fillStyle==="solid")if(l.length===1){const h=knt(e,Object.assign(Object.assign({},i),{disableMultiStroke:!0,roughness:i.roughness?i.roughness+i.fillShapeRoughnessGain:0}));s.push({type:"fillPath",ops:this._mergedShape(h.ops)})}else s.push(wH(l,i));else s.push(eR(l,i));return n&&(a?l.forEach((h=>{s.push(g5(h,!1,i))})):s.push(c)),this._d("path",s,i)}opsToPath(e,r){let i="";for(const s of e.ops){const o=typeof r=="number"&&r>=0?s.data.map((n=>+n.toFixed(r))):s.data;switch(s.op){case"move":i+=`M${o[0]} ${o[1]} `;break;case"bcurveTo":i+=`C${o[0]} ${o[1]}, ${o[2]} ${o[3]}, ${o[4]} ${o[5]} `;break;case"lineTo":i+=`L${o[0]} ${o[1]} `}}return i.trim()}toPaths(e){const r=e.sets||[],i=e.options||this.defaultOptions,s=[];for(const o of r){let n=null;switch(o.type){case"path":n={d:this.opsToPath(o),stroke:i.stroke,strokeWidth:i.strokeWidth,fill:dd};break;case"fillPath":n={d:this.opsToPath(o),stroke:dd,strokeWidth:0,fill:i.fill||dd};break;case"fillSketch":n=this.fillSketch(o,i)}n&&s.push(n)}return s}fillSketch(e,r){let i=r.fillWeight;return i<0&&(i=r.strokeWidth/2),{d:this.opsToPath(e),stroke:r.fill||dd,strokeWidth:i,fill:dd}}_mergedShape(e){return e.filter(((r,i)=>i===0||r.op!=="move"))}}class HPt{constructor(e,r){this.canvas=e,this.ctx=this.canvas.getContext("2d"),this.gen=new w5(r)}draw(e){const r=e.sets||[],i=e.options||this.getDefaultOptions(),s=this.ctx,o=e.options.fixedDecimalPlaceDigits;for(const n of r)switch(n.type){case"path":s.save(),s.strokeStyle=i.stroke==="none"?"transparent":i.stroke,s.lineWidth=i.strokeWidth,i.strokeLineDash&&s.setLineDash(i.strokeLineDash),i.strokeLineDashOffset&&(s.lineDashOffset=i.strokeLineDashOffset),this._drawToContext(s,n,o),s.restore();break;case"fillPath":{s.save(),s.fillStyle=i.fill||"";const a=e.shape==="curve"||e.shape==="polygon"||e.shape==="path"?"evenodd":"nonzero";this._drawToContext(s,n,o,a),s.restore();break}case"fillSketch":this.fillSketch(s,n,i)}}fillSketch(e,r,i){let s=i.fillWeight;s<0&&(s=i.strokeWidth/2),e.save(),i.fillLineDash&&e.setLineDash(i.fillLineDash),i.fillLineDashOffset&&(e.lineDashOffset=i.fillLineDashOffset),e.strokeStyle=i.fill||"",e.lineWidth=s,this._drawToContext(e,r,i.fixedDecimalPlaceDigits),e.restore()}_drawToContext(e,r,i,s="nonzero"){e.beginPath();for(const o of r.ops){const n=typeof i=="number"&&i>=0?o.data.map((a=>+a.toFixed(i))):o.data;switch(o.op){case"move":e.moveTo(n[0],n[1]);break;case"bcurveTo":e.bezierCurveTo(n[0],n[1],n[2],n[3],n[4],n[5]);break;case"lineTo":e.lineTo(n[0],n[1])}}r.type==="fillPath"?e.fill(s):e.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(e,r,i,s,o){const n=this.gen.line(e,r,i,s,o);return this.draw(n),n}rectangle(e,r,i,s,o){const n=this.gen.rectangle(e,r,i,s,o);return this.draw(n),n}ellipse(e,r,i,s,o){const n=this.gen.ellipse(e,r,i,s,o);return this.draw(n),n}circle(e,r,i,s){const o=this.gen.circle(e,r,i,s);return this.draw(o),o}linearPath(e,r){const i=this.gen.linearPath(e,r);return this.draw(i),i}polygon(e,r){const i=this.gen.polygon(e,r);return this.draw(i),i}arc(e,r,i,s,o,n,a=!1,l){const c=this.gen.arc(e,r,i,s,o,n,a,l);return this.draw(c),c}curve(e,r){const i=this.gen.curve(e,r);return this.draw(i),i}path(e,r){const i=this.gen.path(e,r);return this.draw(i),i}}const E5="http://www.w3.org/2000/svg";class KPt{constructor(e,r){this.svg=e,this.gen=new w5(r)}draw(e){const r=e.sets||[],i=e.options||this.getDefaultOptions(),s=this.svg.ownerDocument||window.document,o=s.createElementNS(E5,"g"),n=e.options.fixedDecimalPlaceDigits;for(const a of r){let l=null;switch(a.type){case"path":l=s.createElementNS(E5,"path"),l.setAttribute("d",this.opsToPath(a,n)),l.setAttribute("stroke",i.stroke),l.setAttribute("stroke-width",i.strokeWidth+""),l.setAttribute("fill","none"),i.strokeLineDash&&l.setAttribute("stroke-dasharray",i.strokeLineDash.join(" ").trim()),i.strokeLineDashOffset&&l.setAttribute("stroke-dashoffset",`${i.strokeLineDashOffset}`);break;case"fillPath":l=s.createElementNS(E5,"path"),l.setAttribute("d",this.opsToPath(a,n)),l.setAttribute("stroke","none"),l.setAttribute("stroke-width","0"),l.setAttribute("fill",i.fill||""),e.shape!=="curve"&&e.shape!=="polygon"||l.setAttribute("fill-rule","evenodd");break;case"fillSketch":l=this.fillSketch(s,a,i)}l&&o.appendChild(l)}return o}fillSketch(e,r,i){let s=i.fillWeight;s<0&&(s=i.strokeWidth/2);const o=e.createElementNS(E5,"path");return o.setAttribute("d",this.opsToPath(r,i.fixedDecimalPlaceDigits)),o.setAttribute("stroke",i.fill||""),o.setAttribute("stroke-width",s+""),o.setAttribute("fill","none"),i.fillLineDash&&o.setAttribute("stroke-dasharray",i.fillLineDash.join(" ").trim()),i.fillLineDashOffset&&o.setAttribute("stroke-dashoffset",`${i.fillLineDashOffset}`),o}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(e,r){return this.gen.opsToPath(e,r)}line(e,r,i,s,o){const n=this.gen.line(e,r,i,s,o);return this.draw(n)}rectangle(e,r,i,s,o){const n=this.gen.rectangle(e,r,i,s,o);return this.draw(n)}ellipse(e,r,i,s,o){const n=this.gen.ellipse(e,r,i,s,o);return this.draw(n)}circle(e,r,i,s){const o=this.gen.circle(e,r,i,s);return this.draw(o)}linearPath(e,r){const i=this.gen.linearPath(e,r);return this.draw(i)}polygon(e,r){const i=this.gen.polygon(e,r);return this.draw(i)}arc(e,r,i,s,o,n,a=!1,l){const c=this.gen.arc(e,r,i,s,o,n,a,l);return this.draw(c)}curve(e,r){const i=this.gen.curve(e,r);return this.draw(i)}path(e,r){const i=this.gen.path(e,r);return this.draw(i)}}AG={canvas:(t,e)=>new HPt(t,e),svg:(t,e)=>new KPt(t,e),generator:t=>new w5(t),newSeed:()=>w5.newSeed()};const bI=AG.generator();function Xnt(t){const e=[];return t.ops.forEach(({op:r,data:i})=>{r==="move"?e.push(["M",i[0],i[1]]):r==="lineTo"?e.push(["L",i[0],i[1]]):r==="bcurveTo"&&e.push(["C",i[0],i[1],i[2],i[3],i[4],i[5]])}),e}CV=function(){var t=(function(e){var r={R:"13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",EN:"1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",ES:"17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",ET:"z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",AN:"16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",CS:"18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",B:"a,3,f+2,2v,690",S:"9,2,k",WS:"c,k,4f4,1vk+a,u,1j,335",ON:"x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",BN:"0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,
568119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",NSM:"lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",AL:"16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",LRO:"6ct",RLO:"6cu",LRE:"6cq",RLE:"6cr",PDF:"6cs",LRI:"6ee",RLI:"6ef",FSI:"6eg",PDI:"6eh"},i={},s={};i.L=1,s[1]="L",Object.keys(r).forEach(function(At,Vt){i[At]=1<<Vt+1,s[i[At]]=At}),Object.freeze(i);var o=i.LRI|i.RLI|i.FSI,n=i.L|i.R|i.AL,a=i.B|i.S|i.WS|i.ON|i.FSI|i.LRI|i.RLI|i.PDI,l=i.BN|i.RLE|i.LRE|i.RLO|i.LRO|i.PDF,c=i.S|i.WS|i.B|o|i.PDI|l,h=null;function u(){if(!h){h=new Map;var At=function(de){if(r.hasOwnProperty(de)){var Rt=0;r[de].split(",").forEach(function(De){var st=De.split("+"),ve=st[0],Ct=st[1];ve=parseInt(ve,36),Ct=Ct?parseInt(Ct,36):0,h.set(Rt+=ve,i[de]);for(var mi=0;mi<Ct;mi++)h.set(++Rt,i[de])})}};for(var Vt in r)At(Vt)}}function d(At){return u(),h.get(At.codePointAt(0))||i.L}function f(At){return s[d(At)]}var g={pairs:"14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",canonical:"6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"};function p(At,Vt){var de=36,Rt=0,De=new Map,st=Vt&&new Map,ve;return At.split(",").forEach(function Ct(mi){if(mi.indexOf("+")!==-1)for(var ws=+mi;ws--;)Ct(ve);else{ve=mi;var $r=mi.split(">"),Ne=$r[0],mo=$r[1];Ne=String.fromCodePoint(Rt+=parseInt(Ne,de)),mo=String.fromCodePoint(Rt+=parseInt(mo,de)),De.set(Ne,mo),Vt&&st.set(mo,Ne)}}),{map:De,reverseMap:st}}var m,v,b;function y(){if(!m){var At=p(g.pairs,!0),Vt=At.map,de=At.reverseMap;m=Vt,v=de,b=p(g.canonical,!1).map}}function _(At){return y(),m.get(At)||null}function w(At){return y(),v.get(At)||null}function E(At){return y(),b.get(At)||null}var A=i.L,x=i.R,S=i.EN,T=i.ES,R=i.ET,B=i.AN,O=i.CS,C=i.B,F=i.S,U=i.ON,H=i.BN,N=i.NSM,G=i.AL,Y=i.LRO,q=i.RLO,L=i.LRE,J=i.RLE,tt=i.PDF,bt=i.LRI,ct=i.RLI,Xt=i.FSI,It=i.PDI;function zt(At,Vt){for(var de=125,Rt=new Uint32Array(At.length),De=0;De<At.length;De++)Rt[De]=d(At[De]);var st=new Map;function ve(Qu,tm){var td=Rt[Qu];Rt[Qu]=tm,st.set(td,st.get(td)-1),td&a&&st.set(a,st.get(a)-1),st.set(tm,(st.get(tm)||0)+1),tm&a&&st.set(a,(st.get(a)||0)+1)}for(var Ct=new Uint8Array(At.length),mi=new Map,ws=[],$r=null,Ne=0;Ne<At.length;Ne++)$r||ws.push($r={start:Ne,end:At.length-1,level:Vt==="rtl"?1:Vt==="ltr"?0:EEt(Ne,!1)}),Rt[Ne]&C&&($r.end=Ne,$r=null);for(var mo=J|L|q|Y|o|It|tt|C,Es=function(Qu){return Qu+(Qu&1?1:2)},z=function(Qu){return Qu+(Qu&1?2:1)},ut=0;ut<ws.length;ut++){$r=ws[ut];var M=[{_level:$r.level,_override:0,_isolate:0}],D=void 0,k=0,j=0,Q=0;st.clear();for(var ft=$r.start;ft<=$r.end;ft++){var ht=Rt[ft];
vendor: 5,159 bytes, line 568
568if(D=M[M.length-1],st.set(ht,(st.get(ht)||0)+1),ht&a&&st.set(a,(st.get(a)||0)+1),ht&mo)if(ht&(J|L)){Ct[ft]=D._level;var ge=(ht===J?z:Es)(D._level);ge<=de&&!k&&!j?M.push({_level:ge,_override:0,_isolate:0}):k||j++}else if(ht&(q|Y)){Ct[ft]=D._level;var Ge=(ht===q?z:Es)(D._level);Ge<=de&&!k&&!j?M.push({_level:Ge,_override:ht&q?x:A,_isolate:0}):k||j++}else if(ht&o){ht&Xt&&(ht=EEt(ft+1,!0)===1?ct:bt),Ct[ft]=D._level,D._override&&ve(ft,D._override);var Ye=(ht===ct?z:Es)(D._level);Ye<=de&&k===0&&j===0?(Q++,M.push({_level:Ye,_override:0,_isolate:1,_isolInitIndex:ft})):k++}else if(ht&It){if(k>0)k--;else if(Q>0){for(j=0;!M[M.length-1]._isolate;)M.pop();var Ki=M[M.length-1]._isolInitIndex;Ki!=null&&(mi.set(Ki,ft),mi.set(ft,Ki)),M.pop(),Q--}D=M[M.length-1],Ct[ft]=D._level,D._override&&ve(ft,D._override)}else ht&tt?(k===0&&(j>0?j--:!D._isolate&&M.length>1&&(M.pop(),D=M[M.length-1])),Ct[ft]=D._level):ht&C&&(Ct[ft]=$r.level);else Ct[ft]=D._level,D._override&&ht!==H&&ve(ft,D._override)}for(var Wr=[],hi=null,Xs=$r.start;Xs<=$r.end;Xs++){var Kr=Rt[Xs];if(!(Kr&l)){var zs=Ct[Xs],qu=Kr&o,vv=Kr===It;hi&&zs===hi._level?(hi._end=Xs,hi._endsWithIsolInit=qu):Wr.push(hi={_start:Xs,_end:Xs,_level:zs,_startsWithPDI:vv,_endsWithIsolInit:qu})}}for(var lr=[],V=0;V<Wr.length;V++){var pt=Wr[V];if(!pt._startsWithPDI||pt._startsWithPDI&&!mi.has(pt._start)){for(var Ot=[hi=pt],ee=void 0;hi&&hi._endsWithIsolInit&&(ee=mi.get(hi._end))!=null;)for(var qr=V+1;qr<Wr.length;qr++)if(Wr[qr]._start===ee){Ot.push(hi=Wr[qr]);break}for(var Oe=[],mt=0;mt<Ot.length;mt++)for(var Pt=Ot[mt],He=Pt._start;He<=Pt._end;He++)Oe.push(He);for(var ui=Ct[Oe[0]],kl=$r.level,rc=Oe[0]-1;rc>=0;rc--)if(!(Rt[rc]&l)){kl=Ct[rc];break}var Kg=Oe[Oe.length-1],Wd=Ct[Kg],qg=$r.level;if(!(Rt[Kg]&o)){for(var jd=Kg+1;jd<=$r.end;jd++)if(!(Rt[jd]&l)){qg=Ct[jd];break}}lr.push({_seqIndices:Oe,_sosType:Math.max(kl,ui)%2?x:A,_eosType:Math.max(qg,Wd)%2?x:A})}}for(var Jf=0;Jf<lr.length;Jf++){var kc=lr[Jf],er=kc._seqIndices,My=kc._sosType,Zg=kc._eosType,Zu=Ct[er[0]]&1?x:A;if(st.get(N))for(var ph=0;ph<er.length;ph++){var VS=er[ph];if(Rt[VS]&N){for(var Xe=My,Dr=ph-1;Dr>=0;Dr--)if(!(Rt[er[Dr]]&l)){Xe=Rt[er[Dr]];break}ve(VS,Xe&(o|It)?U:Xe)}}if(st.get(S))for(var yo=0;yo<er.length;yo++){var vo=er[yo];if(Rt[vo]&S)for(var $n=yo-1;$n>=-1;$n--){var Ho=$n===-1?My:Rt[er[$n]];if(Ho&n){Ho===G&&ve(vo,B);break}}}if(st.get(G))for(var Ll=0;Ll<er.length;Ll++){var Jg=er[Ll];Rt[Jg]&G&&ve(Jg,x)}if(st.get(T)||st.get(O))for(var Xd=1;Xd<er.length-1;Xd++){var Qg=er[Xd];if(Rt[Qg]&(T|O)){for(var ic=0,zd=0,_v=Xd-1;_v>=0&&(ic=Rt[er[_v]],!!(ic&l));_v--);for(var bv=Xd+1;bv<er.length&&(zd=Rt[er[bv]],!!(zd&l));bv++);ic===zd&&(Rt[Qg]===T?ic===S:ic&(S|B))&&ve(Qg,ic)}}if(st.get(S))for(var Ul=0;Ul<er.length;Ul++){var Yw=er[Ul];if(Rt[Yw]&S){for(var Ko=Ul-1;Ko>=0&&Rt[er[Ko]]&(R|l);Ko--)ve(er[Ko],S);for(Ul++;Ul<er.length&&Rt[er[Ul]]&(R|l|S);Ul++)Rt[er[Ul]]!==S&&ve(er[Ul],S)}}if(st.get(R)||st.get(T)||st.get(O))for(var Qf=0;Qf<er.length;Qf++){var $w=er[Qf];if(Rt[$w]&(R|T|O)){ve($w,U);for(var sc=Qf-1;sc>=0&&Rt[er[sc]]&l;sc--)ve(er[sc],U);for(var nl=Qf+1;nl<er.length&&Rt[er[nl]]&l;nl++)ve(er[nl],U)}}if(st.get(S))for(var By=0,YS=My;By<er.length;By++){var wv=er[By],Hw=Rt[wv];Hw&S?YS===A&&ve(wv,A):Hw&n&&(YS=Hw)}if(st.get(a)){var Oy=x|S|B,Ev=Oy|A,$S=[];{for(var Av=[],Kw=0;Kw<er.length;Kw++)if(Rt[er[Kw]]&a){var As=At[er[Kw]],jU=void 0;if(_(As)!==null)if(Av.length<63)Av.push({char:As,seqIndex:Kw});else break;else if((jU=w(As))!==null)for(var Iy=Av.length-1;Iy>=0;Iy--){var HS=Av[Iy].char;if(HS===jU||HS===w(E(As))||_(E(HS))===As){$S.push([Av[Iy].seqIndex,Kw]),Av.length=Iy;break}}}$S.sort(function(Qu,tm){return Qu[0]-tm[0]})}for(var KB=0;KB<$S.length;KB++){for(var xv=$S[KB],KS=xv[0],qB=xv[1],XU=!1,Ju=0,ZB=KS+1;ZB<qB;ZB++){var zU=er[ZB];if(Rt[zU]&Ev){XU=!0;var qi=Rt[zU]&Oy?x:A;if(qi===Zu){Ju=qi;break}}}if(XU&&!Ju){Ju=My;for(var _n=KS-1;_n>=0;_n--){var vEt=er[_n];if(Rt[vEt]&Ev){var _Et=Rt[vEt]&Oy?x:A;_Et!==Zu?Ju=_Et:Ju=Zu;break}}}if(Ju){if(Rt[er[KS]]=Rt[er[qB]]=Ju,Ju!==Zu){for(var VU=KS+1;VU<er.length;VU++)if(!(Rt[er[VU]]&l)){d(At[er[VU]])&N&&(Rt[er[VU]]=Ju);break}}if(Ju!==Zu){for(var YU=qB+1;YU<er.length;YU++)if(!(Rt[er[YU]]&l)){d(At[er[YU]])&N&&(Rt[er[YU]]=Ju);break}}}}for(var qw=0;qw<er.length;qw++)if(Rt[er[qw]]&a){for(var bEt=qw,YQ=qw,$Q=My,$U=qw-1;$U>=0;$U--)if(Rt[er[$U]]&l)bEt=$U;else{$Q=Rt[er[$U]]&Oy?x:A;break}for(var wEt=Zg,HU=qw+1;HU<er.length;HU++)if(Rt[er[HU]]&(a|l))YQ=HU;else{wEt=Rt[er[HU]]&Oy?x:A;break}for(var HQ=bEt;HQ<=YQ;HQ++)Rt[er[HQ]]=$Q===wEt?$Q:Zu;qw=YQ}}}for(var Vd=$r.start;Vd<=$r.end;Vd++){var fae=Ct[Vd],gV=Rt[Vd];if(fae&1?gV&(A|S|B)&&Ct[Vd]++:gV&x?Ct[Vd]++:gV&(B|S)&&(Ct[Vd]+=2),gV&l&&(Ct[Vd]=Vd===0?$r.level:Ct[Vd-1]),Vd===$r.end||d(At[Vd])&(F|C))for(var mV=Vd;mV>=0&&d(At[mV])&c;mV--)Ct[mV]=$r.level}}return{levels:Ct,paragraphs:ws};function EEt(Qu,tm){for(var td=Qu;td<At.length;td++){var Zw=Rt[td];if(Zw&(x|G))return 1;if(Zw&(C|A)||tm&&Zw===It)return 0;if(Zw&o){var AEt=pae(td);td=AEt===-1?At.length:AEt}}return 0}function pae(Qu){for(var tm=1,td=Qu+1;td<At.length;td++){var Zw=Rt[td];if(Zw&C)break;if(Zw&It){if(--tm===0)return td}else Zw&o&&tm++}return-1}}var Ht="14>1,j>2,t>2,u>2,1a>g,2v3>
5681,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1",Lt;function tr(){if(!Lt){var At=p(Ht,!0),Vt=At.map,de=At.reverseMap;de.forEach(function(Rt,De){Vt.set(De,Rt)}),Lt=Vt}}function Gr(At){return tr(),Lt.get(At)||null}function re(At,Vt,de,Rt){var De=At.length;de=Math.max(0,de==null?0:+de),Rt=Math.min(De-1,Rt==null?De-1:+Rt);for(var st=new Map,ve=de;ve<=Rt;ve++)if(Vt[ve]&1){var Ct=Gr(At[ve]);Ct!==null&&st.set(ve,Ct)}return st}function ci(At,Vt,de,Rt){var De=At.length;de=Math.max(0,de==null?0:+de),Rt=Math.min(De-1,Rt==null?De-1:+Rt);var st=[];return Vt.paragraphs.forEach(function(ve){var Ct=Math.max(de,ve.start),mi=Math.min(Rt,ve.end);if(Ct<mi){for(var ws=Vt.levels.slice(Ct,mi+1),$r=mi;$r>=Ct&&d(At[$r])&c;$r--)ws[$r]=ve.level;for(var Ne=ve.level,mo=1/0,Es=0;Es<ws.length;Es++){var z=ws[Es];z>Ne&&(Ne=z),z<mo&&(mo=z|1)}for(var ut=Ne;ut>=mo;ut--)for(var M=0;M<ws.length;M++)if(ws[M]>=ut){for(var D=M;M+1<ws.length&&ws[M+1]>=ut;)M++;M>D&&st.push([D+Ct,M+Ct])}}}),st}function Dt(At,Vt,de,Rt){var De=rt(At,Vt,de,Rt),st=[].concat(At);return De.forEach(function(ve,Ct){st[Ct]=(Vt.levels[ve]&1?Gr(At[ve]):null)||At[ve]}),st.join("")}function rt(At,Vt,de,Rt){for(var De=ci(At,Vt,de,Rt),st=[],ve=0;ve<At.length;ve++)st[ve]=ve;return De.forEach(function(Ct){for(var mi=Ct[0],ws=Ct[1],$r=st.slice(mi,ws+1),Ne=$r.length;Ne--;)st[ws-Ne]=$r[Ne]}),st}return e.closingToOpeningBracket=w,e.getBidiCharType=d,e.getBidiCharTypeName=f,e.getCanonicalBracket=E,e.getEmbeddingLevels=zt,e.getMirroredCharacter=Gr,e.getMirroredCharactersMap=re,e.getReorderSegments=ci,e.getReorderedIndices=rt,e.getReorderedString=Dt,e.openingToClosingBracket=_,Object.defineProperty(e,"__esModule",{value:!0}),e})({});return t};var SH={exports:{}},qPt=SH.exports,znt;function ZPt(){return znt||(znt=1,(function(t){(function(e,r){var i="ArabicReshaper";t.exports?t.exports=r():e[i]=r()})(qPt,function(){var e=[[1569,65152,null,null,null],[1570,65153,null,null,65154],[1571,65155,null,null,65156],[1572,65157,null,null,65158],[1573,65159,null,null,65160],[1574,65161,65163,65164,65162],[1575,65165,null,null,65166],[1576,65167,65169,65170,65168],[1577,65171,null,null,65172],[1578,65173,65175,65176,65174],[1579,65177,65179,65180,65178],[1580,65181,65183,65184,65182],[1581,65185,65187,65188,65186],[1582,65189,65191,65192,65190],[1583,65193,null,null,65194],[1584,65195,null,
568null,65196],[1585,65197,null,null,65198],[1586,65199,null,null,65200],[1587,65201,65203,65204,65202],[1588,65205,65207,65208,65206],[1589,65209,65211,65212,65210],[1590,65213,65215,65216,65214],[1591,65217,65219,65220,65218],[1592,65221,65223,65224,65222],[1593,65225,65227,65228,65226],[1594,65229,65231,65232,65230],[1600,1600,1600,1600,1600],[1601,65233,65235,65236,65234],[1602,65237,65239,65240,65238],[1603,65241,65243,65244,65242],[1604,65245,65247,65248,65246],[1605,65249,65251,65252,65250],[1606,65253,65255,65256,65254],[1607,65257,65259,65260,65258],[1608,65261,null,null,65262],[1609,65263,null,null,65264],[1610,65265,65267,65268,65266],[1662,64342,64344,64345,64343],[1740,64508,64510,64511,64509],[1670,64378,64380,64381,64379],[1705,64398,64400,64401,64399],[1711,64402,64404,64405,64403],[1688,64394,null,null,64395]],r=[[[1604,1570],65269,null,null,65270],[[1604,1571],65271,null,null,65272],[[1604,1573],65273,null,null,65274],[[1604,1575],65275,null,null,65276]],i=[1552,1554,1555,1556,1557,1611,1612,1613,1614,1615,1616,1617,1618,1619,1620,1621,1622,1623,1624,1648,1750,1751,1752,1753,1754,1755,1756,1759,1760,1761,1762,1763,1764,1767,1768,1770,1771,1772,1773];function s(c){for(var h=0;h<e.length;++h)if(e[h][0]===c)return!0;return!1}function o(c){for(var h=0;h<e.length;++h)if(e[h][0]===c)return e[h];return!1}function n(c,h){for(var u=0;u<r.length;++u)if(r[u][0][0]===c&&r[u][0][1]===h)return r[u];return!1}function a(c){for(var h=0;h<i.length;++h)if(i[h]===c)return!0;return!1}function l(c){var h;for(h=0;h<e.length;++h)if(e[h].indexOf(c)>-1)return String.fromCharCode(e[h][0]);for(h=0;h<r.length;++h)if(r[h].indexOf(c)>-1)return String.fromCharCode(r[h][0][0])+String.fromCharCode(r[h][0][1]);return String.fromCharCode(c)}return{convertArabic:function(c){for(var h,u,d="",f=0;f<c.length;++f){var g=c.charCodeAt(f);if(s(g)){for(var p=null,m=null,v=f-1,b=f+1;v>=0&&a(c.charCodeAt(v));--v);for(p=v>=0?c.charCodeAt(v):null,h=p?o(p):!1,(!h||h[2]==null&&h[3]==null)&&(p=null);b<c.length&&a(c.charCodeAt(b));++b);if(m=b<c.length?c.charCodeAt(b):null,h=m?o(m):!1,(!h||h[3]==null&&h[4]==null)&&(m=null),g===1604&&m!=null&&(m===1570||m===1571||m===1573||m===1575)){u=n(g,m),p!=null?d+=String.fromCharCode(u[4]):d+=String.fromCharCode(u[1]),++f;continue}if(h=o(g),p!=null&&m!=null&&h[3]!=null){d+=String.fromCharCode(h[3]);continue}else if(p!=null&&h[4]!=null){d+=String.fromCharCode(h[4]);continue}else if(m!=null&&h[2]!=null){d+=String.fromCharCode(h[2]);continue}else d+=String.fromCharCode(h[1])}else d+=String.fromCharCode(g)}return d},convertArabicBack:function(c){var h="",u,d;for(d=0;d<c.length;++d)u=c.charCodeAt(d),h+=l(u);return h}}})})(SH)),SH.exports}var JPt=ZPt();MV=Sv(JPt);var Vnt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},pu=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},wI,EI,t_,TH,AI;const QPt="|\xC9q\xC5",tFt="M",eFt=[10,13],rFt=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Ynt=/[a-zA-Z0-9\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff!"#$%&'()*+,-./:;]/,iFt=/[!%),.:;?\]}¢°·'""â â¡âºââ¶ãããããããï¹ï¹ï¼ï¼ï¼
ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼½ï½ï½]/,sFt=/[$(£¥·'"ããããããããï¹ï¹ï¼ï¼ï¼ï¼»ï½ï¿¡ï¿¥]/,oFt=/[!),.:;?\]}¢·ââ'"â¢"ãããããããã︰︱︲︳ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¸¶ï¸¸ï¸ºï¸¼ï¸¾ï¹ï¹ï¹ï¼½ï½ï½ï½¤]/,nFt=/[([{£¥'"âµãããããã︴ï¹ï¹ï¼ï½ï¸µï¸·ï¸¹ï¸»ï¸½ï¸¿ï¹ï¹ï¹]/,aFt=/[)\]ï½ããããããããã'"ï½ Â»ã½ã¾ã¼ã¡ã£ã¥ã§ã©ãã£ã¥ã§ã®ãµã¶ããã
ããã£ãã
ããããã°ã±ã²ã³ã´ãµã¶ã·ã¸ã¹ãºã»ã¼ã½ã¾ã¿ã
ã»âã âã?!â¼âââã»ã:;,ã.]/,lFt=/[([ï½ããããããããã'"ï½Â«â...â¥ã³ã´ãµ]/,cFt=/[!%),.:;?\]}¢°'"â â¡âããããããï¼ï¼
ï¼ï¼ï¼ï¼ï¼ï¼ï¼½ï½]/,hFt=/[$([{£¥'"ã
ãããããï¼ï¼ï¼»ï½ï½ ¥₩#]/,uFt=new RegExp(`${iFt.source}|${oFt.source}|${aFt.source}|${cFt.source}`),dFt=new RegExp(`${sFt.source}|${nFt.source}|${lFt.source}|${hFt.source}`),$nt=1;class fFt{constructor(){wI.set(this,{}),EI.set(this,void 0),t_.set(this,void 0),TH.set(this,CV()),AI.set(this,{}),this.shouldBreakByKinsokuShorui=(r,i)=>this.isBreakingSpace(i)?!1:!!(r&&(dFt.exec(i)||uFt.exec(r))),this.trimByKinsokuShorui=r=>{const i=[...r],s=i[i.length-2];if(!s)return r;const o=s[s.length-1];return i[i.length-2]=s.slice(0,-1),i[i.length-1]=o+i[i.length-1],i};const e=Bo.get().createCanvas(1,1);e&&(Vnt(this,EI,e,"f"),Vnt(this,t_,e.getContext("2d"),"f"))}getCanvas(){return pu(this,EI,"f")}measureBitmapFont(e,r){const{fontMetrics:i,lineHeight:s}=e,o=r/e.baseMeasurementFontSize;return{scale:o,lineHeight:s*o,fontMetrics:{fontBoundingBoxAscent:(i.ascent||s*$nt)*o,fontBoundingBoxDescent:i.descent*o,hangingBaseline:0,ideographicBaseline:0,actualBoundingBoxAscent:(i.ascent||s*$nt)*o,actualBoundingBoxDescent:i.descent*o,fontSize:r}}}measureText(e,r){if(!pu(this,AI,"f")[e]){const A=[new Array],x=(O,C)=>{const F=C<0?0:C;for(;O.length>F+1;){const U=O.pop();O[O.length-1].push(...U.reverse())}},S=(O,C,F)=>{F+1>O.length?O.push(...Array.from({length:F+1-O.length},()=>new Array)):x(O,F),O[F].push({text:C,direction:F%2===0?"ltr":"rtl"})},T=pu(this,TH,"f").getEmbeddingLevels(e).levels.entries(),R=T.next();if(!R.done){let[O,C]=R.value;for(const[F,U]of T)U!==C&&(S(A,e.slice(O,F),C),O=F,C=U);S(A,e.slice(O),C),x(A,0)}let B="";for(const O of A[0]){const{text:C,direction:F}=O;
568F==="ltr"?B+=C:B+=MV.convertArabic(C).split("").reverse().join("")}pu(this,AI,"f")[e]=B}r.bidiChars=pu(this,AI,"f")[e];const{wordWrap:i,letterSpacing:s,textAlign:o,textBaseline:n,strokeWidth:a,leading:l,bitmapFont:c,bitmapFontKerning:h,bidiChars:u,fontSize:d}=r;let f=r.lineHeight;const g=Hnt(r);let p,m=1;if(c){const A=this.measureBitmapFont(c,r.fontSize);f=A.lineHeight,p=A.fontMetrics,m=A.scale}else p=this.measureFont(g),pu(this,t_,"f").font=g;f*=m,p.fontSize===0&&(p.fontSize=d);const v=(i?this.wordWrap(u,r,m):u).split(/(?:\r\n|\r|\n)/),b=new Array(v.length);let y=0;for(let A=0;A<v.length;A++){const x=this.measureTextInternal(v[A],s,c,h,m);b[A]=x,y=Math.max(y,x)}const _=y+a;f=f||p.fontSize+a;const w=Math.max(f,p.fontSize+a)+(v.length-1)*(f+l);f+=l;let E=0;return n==="middle"?E=-w/2:n==="bottom"||n==="alphabetic"||n==="ideographic"?E=-w:(n==="top"||n==="hanging")&&(E=0),{font:g,width:_,height:w,lines:v,lineWidths:b,lineHeight:f,maxLineWidth:y,fontMetrics:p,lineMetrics:b.map((A,x)=>{let S=0;return o==="center"?S-=A/2:(o==="right"||o==="end")&&(S-=A),new Ua(S-a/2,E+x*f,A+a,f)})}}measureFont(e){if(pu(this,wI,"f")[e])return pu(this,wI,"f")[e];pu(this,t_,"f").font=e;const{actualBoundingBoxAscent:r,actualBoundingBoxDescent:i,actualBoundingBoxLeft:s,actualBoundingBoxRight:o,alphabeticBaseline:n,fontBoundingBoxAscent:a,fontBoundingBoxDescent:l,hangingBaseline:c,ideographicBaseline:h,width:u,emHeightAscent:d,emHeightDescent:f}=pu(this,t_,"f").measureText(QPt+tFt),g={actualBoundingBoxAscent:r,actualBoundingBoxDescent:i,actualBoundingBoxLeft:s,actualBoundingBoxRight:o,alphabeticBaseline:n,fontBoundingBoxAscent:a,fontBoundingBoxDescent:l,hangingBaseline:c,ideographicBaseline:h,emHeightAscent:d,emHeightDescent:f,width:u,fontSize:r+i};return pu(this,wI,"f")[e]=g,g}
568wordWrap(e,r,i){const s=pu(this,EI,"f").getContext("2d",{willReadFrequently:!0}),{letterSpacing:o,textOverflow:n,maxLines:a,bitmapFont:l}=r,c=r.wordWrapWidth+o;let h="";n==="ellipsis"?h="...":n&&n!=="clip"&&(h=n);let u=[],d=0,f=0;const g={},p=y=>this.getFromCache(y,o,g,s,l,i),m=Array.from(h).reduce((y,_)=>y+p(_),0);function v(y){if(m<=0||m>c)return;const _=u[y].length;let w=0,E=_;for(let A=0;A<_;A++){const x=p(u[y][A]);if(w+x+m>c){E=A;break}w+=x}u[y]=(u[y]||"").slice(0,E)+h}const b=Array.from(e);for(let y=0;y<b.length;y++){const _=b[y],w=e[y-1],E=e[y+1],A=p(_);if(this.isNewline(_)){if(d++,d>=a){y<b.length-1&&v(d-1);break}f=0,u[d]="";continue}if(f>0&&f+A>c){if(d+1>=a){v(d);break}if(d++,f=0,u[d]="",this.isBreakingSpace(_))continue;this.canBreakInLastChar(_)||(u=this.trimToBreakable(u),f=this.sumTextWidthByCache(u[d]||"",g)),this.shouldBreakByKinsokuShorui(_,E)&&(u=this.trimByKinsokuShorui(u),f+=p(w||""))}f+=A,u[d]=(u[d]||"")+_}return u.join(` 569`)}collapseSpaces(e){return e==="normal"||e==="pre-line"}collapseNewlines(e){return e==="normal"}isBreakingSpace(e){return rFt.includes(e.charCodeAt(0))}isNewline(e){return eFt.includes(e.charCodeAt(0))}trimToBreakable(e){const r=[...e],i=r[r.length-2],s=this.findBreakableIndex(i);if(s===-1||!i)return r;const o=i.slice(s,s+1),n=this.isBreakingSpace(o),a=s+1,l=s+(n?0:1);return r[r.length-1]+=i.slice(a,i.length),r[r.length-2]=i.slice(0,l),r}canBreakInLastChar(e){return!(e&&Ynt.test(e))}sumTextWidthByCache(e,r){return e.split("").reduce((i,s)=>{if(!r[s])throw Error("cannot count the word without cache");return i+r[s]},0)}findBreakableIndex(e){for(let r=e.length-1;r>=0;r--)if(!Ynt.test(e[r]))return r;return-1}getFromCache(e,r,i,s,o,n){var a;let l=i[e];if(typeof l!="number"){const c=e.length*r;l=(o?((a=o.chars[e])===null||a===void 0?void 0:a.xAdvance)||0:s.measureText(e).width)*n+c,i[e]=l}return l}measureTextInternal(e,r,i,s,o){const n=Bo.get().splitGraphemes(e);let a,l,c;if(i)a=n.reduce((h,u)=>{var d,f;const g=(d=i.chars[u])===null||d===void 0?void 0:d.xAdvance,p=s&&c&&((f=i.chars[u])===null||f===void 0?void 0:f.kerning[c])||0;return c=u,h+((g+p)*o||0)},0),l=a;else{pu(this,t_,"f").letterSpacing=`${r}px`;const h=pu(this,t_,"f").measureText(e);a=h.width;const u=-h.actualBoundingBoxLeft;l=h.actualBoundingBoxRight-u}if(a>0){const h=(n.length-1)*r;a+=h,l+=h}return Math.max(a,l)}}wI=new WeakMap,EI=new WeakMap,t_=new WeakMap,TH=new WeakMap,AI=new WeakMap;const pFt=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Hnt(t){const e=typeof t.fontSize=="number"?`${t.fontSize}px`:t.fontSize;let r=t.fontFamily;Array.isArray(t.fontFamily)||(r=t.fontFamily.split(","));for(let i=r.length-1;i>=0;i--){let s=r[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!pFt.includes(s)&&(s=`"${s}"`),r[i]=s}return`${t.fontStyle} ${t.fontVariant} ${t.fontWeight} ${e} ${r.join(",")}`}function Knt(t,e){let r=0;const{fontBoundingBoxAscent:i=0,fontBoundingBoxDescent:s=0,hangingBaseline:o=0,ideographicBaseline:n=0}=e;return t==="alphabetic"?r-=i:t==="middle"?r-=(i+s)/2:t==="hanging"?r-=o:t==="ideographic"?r-=n:t==="bottom"?r-=i+s:t==="top"&&(r=0),r}let RH;function gFt(){return RH||(RH=new fFt),RH}const mFt=[[0,0],[.5,0],[1,0],[0,.5],[.5,.5],[1,.5],[0,1],[.5,1],[1,1],[0,0]];function CH(t){const{type:e,value:r}=t;return e==="hex"?`#${r}`:e==="literal"?r:e==="rgb"?`rgb(${r.join(",")})`:`rgba(${r.join(",")})`}const yFt=(function(){const t={linearGradient:/^(linear\-gradient)/i,repeatingLinearGradient:/^(repeating\-linear\-gradient)/i,radialGradient:/^(radial\-gradient)/i,repeatingRadialGradient:/^(repeating\-radial\-gradient)/i,conicGradient:/^(conic\-gradient)/i,meshGradient:/^(mesh\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})/i,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/};let e="";function r(L){throw new Error(`${e}: ${L}`)}function i(){const L=s();return e.length>0&&r("Invalid input not EOF"),L}function s(){return x(h)}function o(){const L=e.replace(/^\s+/,"");return/^warp\s*\(/i.test(L)||/^gtype\s*\(/i.test(L)||/^wshape\s*\(/i.test(L)||/^time\s*\(/i.test(L)||/^points\s*\(/i.test(L)}function n(){const L={};function J(){if(!Y(/^warp\s*\(/i))return!1;const ct=a();ct===null&&r("mesh-gradient: warp() expects a number"),Y(t.comma)||r("mesh-gradient: warp() expected comma between numbers");const Xt=a();return Xt===null&&r("mesh-gradient: warp() expects two numbers"),Y(t.endCall)||r("mesh-gradient: warp() expected )"),L.warpSize=ct,L.warpRatio=Xt,!0}function tt(ct,Xt){if(!Y(ct))return!1;const It=a();return It===null&&r("mesh-gradient: expected number in ()"),Y(t.endCall)||r("mesh-gradient: expected )"),L[Xt]=It,!0}let bt=!0;for(;;){if(/^\s*\)/.test(e))return{extras:L};if(bt){if(bt=!1,!Y(t.comma)&&!o()){if(/^\s*\)/.test(e))return{extras:L};r("mesh-gradient: expected color / tail options or )")}}
569else if(!Y(t.comma)){if(/^\s*\)/.test(e))return{extras:L};r("mesh-gradient: expected , or )")}J()||tt(/^gtype\s*\(/i,"gradientTypeIndex")||tt(/^wshape\s*\(/i,"warpShapeIndex")||tt(/^time\s*\(/i,"time")||tt(/^points\s*\(/i,"pointsNum")||r("mesh-gradient: expected warp(), gtype(), wshape(), time() or points()")}}function a(){const L=Y(t.number);return L?Number(L[1]):null}function l(){const L=T();if(!L)return null;const J=e,tt=a();if(tt===null)return{color:L};const bt=a();return bt===null&&(e=J,r("mesh-gradient: after a corner color, either omit U V or provide two numbers")),{color:L,uv:[tt,bt]}}function c(){return d(t.meshGradient,function(){const L=T();L||r("mesh-gradient: expected background color"),Y(t.comma)||r("mesh-gradient: expected comma after background color");const J=l();J||r("mesh-gradient: expected at least one corner color");const tt=[J];for(;tt.length<9&&!(!Y(t.comma)||o());){const ct=l();ct||r("mesh-gradient: expected color or tail options after comma"),tt.push(ct)}const{extras:bt}=n();return Object.assign({type:"mesh-gradient",background:L,corners:tt},bt)})}function h(){return c()||u("linear-gradient",t.linearGradient,f)||u("repeating-linear-gradient",t.repeatingLinearGradient,f)||u("radial-gradient",t.radialGradient,m)||u("repeating-radial-gradient",t.repeatingRadialGradient,m)||u("conic-gradient",t.conicGradient,m)}function u(L,J,tt){return d(J,function(bt){const ct=tt();return ct&&(Y(t.comma)||r("Missing comma before color stops")),{type:L,orientation:ct,colorStops:x(S)}})}function d(L,J){const tt=Y(L);if(tt){Y(t.startCall)||r("Missing (");const bt=J(tt);return Y(t.endCall)||r("Missing )"),bt}}function f(){return g()||p()}function g(){return G("directional",t.sideOrCorner,1)}function p(){return G("angular",t.angleValue,1)}function m(){let L,J=v(),tt;return J&&(L=[],L.push(J),tt=e,Y(t.comma)&&(J=v(),J?L.push(J):e=tt)),L}function v(){let L=b()||y();if(L)L.at=w();else{const J=_();if(J){L=J;const tt=w();tt&&(L.at=tt)}else{const tt=E();tt&&(L={type:"default-radial",at:tt})}}return L}function b(){const L=G("shape",/^(circle)/i,0);return L&&(L.style=N()||_()),L}function y(){const L=G("shape",/^(ellipse)/i,0);return L&&(L.style=U()||_()),L}function _(){return G("extent-keyword",t.extentKeywords,1)}function w(){if(G("position",/^at/,0)){const L=E();return L||r("Missing positioning value"),L}}function E(){const L=A();if(L.x||L.y)return{type:"position",value:L}}function A(){return{x:U(),y:U()}}function x(L){let J=L();const tt=[];if(J)for(tt.push(J);Y(t.comma);)J=L(),J?tt.push(J):r("One extra comma");return tt}function S(){const L=T();return L||r("Expected color definition"),L.length=U(),L}function T(){return B()||C()||O()||R()}function R(){return G("literal",t.literalColor,0)}function B(){return G("hex",t.hexColor,1)}function O(){return d(t.rgbColor,function(){return{type:"rgb",value:x(F)}})}function C(){return d(t.rgbaColor,function(){return{type:"rgba",value:x(F)}})}function F(){return Y(t.number)[1]}function U(){return G("%",t.percentageValue,1)||H()||N()}function H(){return G("position-keyword",t.positionKeywords,1)}function N(){return G("px",t.pixelValue,1)||G("em",t.emValue,1)}function G(L,J,tt){const bt=Y(J);if(bt)return{type:L,value:bt[tt]}}function Y(L){const J=/^[\n\r\t\s]+/.exec(e);J&&q(J[0].length);const tt=L.exec(e);return tt&&q(tt[0].length),tt}function q(L){e=e.substring(L)}return function(L){return e=L,i()}})();function MH(t,e,r,i){const s=eu*i,o=0,n=0,a=o+e/2,l=n+r/2,c=Math.abs(e*Math.cos(s))+Math.abs(r*Math.sin(s)),h=t[0]+a-Math.cos(s)*c/2,u=t[1]+l-Math.sin(s)*c/2,d=t[0]+a+Math.cos(s)*c/2,f=t[1]+l+Math.sin(s)*c/2;return{x1:h,y1:u,x2:d,y2:f}}function vFt(t,e,r,i,s){let o=i.value,n=s.value;return i.type==="%"&&(o=i.value/100*e),s.type==="%"&&(n=s.value/100*r),{x:o+t[0],y:n+t[1]}}function qnt(t,e,r,i,s,o){let n=i.value,a=s.value;i.type==="%"&&(n=i.value/100*e),s.type==="%"&&(a=s.value/100*r);let l=Math.max(qn([0,0],[n,a]),qn([0,r],[n,a]),qn([e,r],[n,a]),qn([e,0],[n,a]));return o&&(o.type==="extent-keyword"?o.value==="closest-side"?l=Math.min(n,e-n,a,r-a):o.value==="farthest-side"?l=Math.max(n,e-n,a,r-a):o.value==="closest-corner"&&(l=Math.min(qn([0,0],[n,a]),qn([0,r],[n,a]),qn([e,r],[n,a]),qn([e,0],[n,a]))):l=Number(o.value)),{x:n+t[0],y:a+t[1],r:l}}function _Ft(t){var e,r,i;const{length:s}=t;t[s-1].length=(e=t[s-1].length)!==null&&e!==void 0?e:{type:"%",value:"100"},s>1&&(t[0].length=(r=t[0].length)!==null&&r!==void 0?r:{type:"%",value:"
5690"});let o=0,n=Number(t[0].length.value);for(let a=1;a<s;a++){const l=(i=t[a].length)===null||i===void 0?void 0:i.value;if(!me(l)&&!me(n)){for(let c=1;c<a-o;c++)t[o+c].length={type:"%",value:`${n+(Number(l)-n)*c/(a-o)}`};o=a,n=Number(l)}}}const bFt={left:180,top:-90,bottom:90,right:0,"left top":225,"top left":225,"left bottom":135,"bottom left":135,"right top":-45,"top right":-45,"right bottom":45,"bottom right":45};function Znt(t){let e;return t.type==="angular"?e=Number(t.value):e=bFt[t.value]||0,e}function Jnt(t){let e=50,r=50,i="%",s="%";if((t==null?void 0:t.type)==="position"){const{x:o,y:n}=t.value;(o==null?void 0:o.type)==="position-keyword"&&(o.value==="left"?e=0:o.value==="center"?e=50:o.value==="right"?e=100:o.value==="top"?r=0:o.value==="bottom"&&(r=100)),(n==null?void 0:n.type)==="position-keyword"&&(n.value==="left"?e=0:n.value==="center"?r=50:n.value==="right"?e=100:n.value==="top"?r=0:n.value==="bottom"&&(r=100)),((o==null?void 0:o.type)==="px"||(o==null?void 0:o.type)==="%"||(o==null?void 0:o.type)==="em")&&(i=o==null?void 0:o.type,e=Number(o.value)),((n==null?void 0:n.type)==="px"||(n==null?void 0:n.type)==="%"||(n==null?void 0:n.type)==="em")&&(s=n==null?void 0:n.type,r=Number(n.value))}return{cx:{value:e,type:i},cy:{value:r,type:s}}}QB=function(t){return Na(t)&&(t.indexOf("linear")>-1||t.indexOf("radial")>-1||t.indexOf("conic")>-1||t.indexOf("mesh-gradient")>-1)},qU=function(t){return!t||!QB(t)?void 0:yFt(t).map(e=>{if(e.type==="mesh-gradient"){const n=CH(e.background),a=mFt,l=[],c=[];for(let u=0;u<9;u++){const d=e.corners[u];d?(l.push(CH(d.color)),c[u]=d.uv?[d.uv[0],d.uv[1]]:[a[u][0],a[u][1]]):(l.push(n),c[u]=[a[u][0],a[u][1]])}c[9]=[a[9][0],a[9][1]];const h={type:"mesh-gradient",backgroundColor:n,colors:l,positions:c};return e.gradientTypeIndex!=null&&(h.gradientTypeIndex=e.gradientTypeIndex),e.warpShapeIndex!=null&&(h.warpShapeIndex=e.warpShapeIndex),e.warpSize!=null&&(h.warpSize=e.warpSize),e.warpRatio!=null&&(h.warpRatio=e.warpRatio),e.time!=null&&(h.time=e.time),h.pointsNum=e.pointsNum!=null?e.pointsNum:Math.min(9,Math.max(1,e.corners.length)),h}const{type:r,colorStops:i}=e;let{orientation:s}=e;_Ft(i);const o=i.map(n=>({offset:{type:n.length.type,value:Number(n.length.value)},color:CH(n)}));if(r==="linear-gradient")return{type:r,angle:s?Znt(s):0,steps:o};if(r==="radial-gradient"){if(s||(s=[{type:"shape",value:"circle"}]),s[0].type==="shape"&&s[0].value==="circle"){const{cx:n,cy:a}=Jnt(s[0].at);let l;if(s[0].style){const{type:c,value:h}=s[0].style;l={value:h,type:c}}return{type:r,cx:n,cy:a,size:l,steps:o}}}else if(r==="conic-gradient"&&(s||(s=[{type:"shape",value:"circle"}]),s[0].type==="shape"&&s[0].value==="circle")){const{cx:n,cy:a}=Jnt(s[0].at);return{type:r,cx:n,cy:a,angle:s?Znt(s):0,steps:o}}}).filter(e=>e!=null)};const wFt={createCanvas:(t,e)=>new OffscreenCanvas(t??0,e??0),createTexImageSource:t=>t,createImage:t=>{if(typeof t=="string")return nu(t,Hh);const e=URL.createObjectURL(t);return nu(e,Hh).finally(()=>URL.revokeObjectURL(e))},getWindow:()=>self,getDocument:()=>null,getXMLSerializer:()=>null,getDOMParser:()=>null,setCursor:(t,e)=>{},splitGraphemes:t=>typeof(Intl==null?void 0:Intl.Segmenter)=="function"?[...new Intl.Segmenter().segment(t)].map(e=>e.segment):[...t],requestAnimationFrame:t=>requestAnimationFrame(t),cancelAnimationFrame:t=>cancelAnimationFrame(t)};var A5=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Un=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},yp,vp,OE,rR;let EFt=class{constructor(){yp.set(this,void 0),vp.set(this,void 0),OE.set(this,{}),rR.set(this,{}),A5(this,yp,Bo.get().createCanvas(128,128),"f"),A5(this,vp,Un(this,yp,"f").getContext("2d"),"f")}destroy(){A5(this,OE,{},"f"),A5(this,rR,{},"f")}getOrCreatePattern(t){const{pattern:e,width:r,height:i}=t,{image:s,repetition:o}=e;if(Un(this,yp,"f").width=r,Un(this,yp,"f").height=i,gl(s))return Un(this,yp,"f");let n=null;const a=tat(t);return Un(this,rR,"f")[a]?n=Un(this,rR,"f")[a]:(n=s&&Un(this,vp,"f").createPattern(s,o),Un(this,rR,"f")[a]=n),Un(this,vp,"f").fillStyle=n,Un(this,vp,"f").fillRect(0,0,r,i),Bo.get().createTexImageSource(Un(this,yp,"f"))}getOrCreateGradient(t){const{width:e,height:r,gradients:i}=t;return Un(this,yp,"f").width=e,Un(this,yp,"f").height=r,i.forEac
569h(s=>{if(!s||s.type==="mesh-gradient")return;const o=this.getOrCreateGradientInternal(Object.assign(Object.assign({},s),{width:e,height:r,min:[0,0]}));Un(this,vp,"f").fillStyle=o,Un(this,vp,"f").fillRect(0,0,e,r)}),Bo.get().createTexImageSource(Un(this,yp,"f"))}getOrCreateGradientInternal(t){const e=Qnt(t),{type:r,steps:i,min:s,width:o,height:n}=t;if(Un(this,OE,"f")[e])return Un(this,OE,"f")[e];let a=null;if(r==="linear-gradient"){const{x1:l,y1:c,x2:h,y2:u}=MH(s,o,n,t.angle);a=Un(this,vp,"f").createLinearGradient(l,c,h,u)}else if(r==="radial-gradient"){const{cx:l,cy:c,size:h}=t,{x:u,y:d,r:f}=qnt(s,o,n,l,c,h);a=Un(this,vp,"f").createRadialGradient(u,d,0,u,d,f)}else if(r==="conic-gradient"){const{cx:l,cy:c,angle:h}=t,{x:u,y:d}=vFt(s,o,n,l,c);a=Un(this,vp,"f").createConicGradient(h,u,d)}return a&&(i.forEach(({offset:l,color:c})=>{l.type==="%"&&(a==null||a.addColorStop(l.value/100,c.toString()))}),Un(this,OE,"f")[e]=a),Un(this,OE,"f")[e]}};yp=new WeakMap,vp=new WeakMap,OE=new WeakMap,rR=new WeakMap;function Qnt(t){const{type:e,min:r,width:i,height:s,steps:o}=t,n=`${Math.round(r[0])}-${Math.round(r[1])}-${Math.round(i)}-${Math.round(s)}-${o.map(({offset:a,color:l})=>`${a.value}${l}`).join("-")}`;if(e==="linear-gradient"){const{angle:a}=t;return`${e}-${uI(`${Math.round(a)}-${n}`)}`}else if(e==="radial-gradient"){const{cx:a,cy:l,size:c}=t;return`${e}-${uI(`${Math.round(a.value)}-${Math.round(l.value)}-${Math.round(Number((c==null?void 0:c.value)||0))}-${n}`)}`}else if(e==="conic-gradient"){const{cx:a,cy:l,angle:c}=t;return`${e}-${uI(`${Math.round(a.value)}-${Math.round(l.value)}-${Math.round(c||0)}-${n}`)}`}}function tat(t){const{image:e,repetition:r,transform:i}=t.pattern;return`pattern-${uI(`${e}-${r}-${i}`)}`}Rv=function(t){return t&&!!t.image};var eat=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},rat=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};const iat=["renderable","serializable","visible","zIndex"],_p=["cullable","batchable","fill","stroke","strokeWidth","strokeAlignment","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeDasharray","strokeDashoffset","opacity","fillOpacity","strokeOpacity","innerShadowColor","innerShadowOffsetX","innerShadowOffsetY","innerShadowBlurRadius"],xI=["drawableSets","seed","roughness","bowing","fillStyle","fillWeight","hachureAngle","hachureGap","curveStepCount","simplification","curveFitting","fillLineDash","fillLineDashOffset","disableMultiStroke","disableMultiStrokeFill","dashOffset","dashGap","zigzagOffset","preserveVertices"],sat=["cx","cy","r"],oat=["cx","cy","rx","ry"],nat=["x","y","width","height","cornerRadius","dropShadowColor","dropShadowOffsetX","dropShadowOffsetY","dropShadowBlurRadius"],aat=["points"],lat=["d","fillRule"],AFt=["x","y","content","fontFamily","fontSize","fontWeight","fontStyle","fontVariant","letterSpacing","lineHeight","whiteSpace","wordWrap","wordWrapWidth","decorationLine","decorationStyle","decorationColor","decorationThickness"],xFt={opacity:1,fillOpacity:1,strokeOpacity:1,fill:"black",stroke:"none",strokeWidth:1,strokeLinecap:"butt",strokeLinejoin:"miter",strokeAlignment:"center",strokeMiterlimit:4,strokeDasharray:"none",strokeDashoffset:0,innerShadowBlurRadius:0,innerShadowColor:"none",innerShadowOffsetX:0,innerShadowOffsetY:0,visibility:"visible",transform:"matrix(1,0,0,1,0,0)",cornerRadius:0,dropShadowColor:"none",dropShadowOffsetX:0,dropShadowOffsetY:0,dropShadowBlurRadius:0,fillRule:"nonzero"};function SFt(t){if(t instanceof Tv)return["g",iat];if(t instanceof Gl)return["circle",[..._p,...sat]];if(t instanceof $h)return["ellipse",[..._p,...oat]];if(t instanceof ed)return["rect",[..._p,...nat]];if(t instanceof sp)return["polyline",[..._p,...aat]];if(t instanceof Wc)return["path",[..._p,...lat]];if(t instanceof Ny)return["text",[..._p,...AFt]];if(t instanceof Zh)return["rough-circle",[..._p,...sat,...xI]];if(t instanceof Qh)return["rough-ellipse",[..._p,...oat,...xI]];if(t instanceof au)return["rough-rect",[..._p,...nat,...xI]];if(t instanceof ky)return["rough-polyline",[..._p,...aat,...xI]];if(t instanceof tp)return["rough-path",[..._p,...lat,...xI]]}FV=function(t){return eat(this,void 0,void 0,function*(){const{type:e,attributes:r,children:i,text:s}=t;let o;e==="g"?o=new Tv:e==="circle"?o=new Gl:e==="ellipse"?o=new $h:e==="rect"?o=new ed:e==="polyline"?o=new sp:e==="line"?(o=new sp,r.points=[[r.x1,r.y1],[r.x2,r.y2]],delete r.x1,delete r.y1,delete r.x2,delete r.y2):e==="polygon"?(
569o=new Wc,r.d=r.points.split(" ").map((d,f,g)=>{const[p,m]=d.split(",").map(Number),v=f===0?"M":"L";return f===g.length-1?`${v} ${p},${m} Z`:`${v} ${p},${m}`}).join(" "),delete r.points):e==="path"?o=new Wc:e==="text"?(o=new Ny,r.content=s):e==="rough-circle"?o=new Zh:e==="rough-ellipse"?o=new Qh:e==="rough-rect"?o=new au:e==="rough-polyline"?o=new ky:e==="rough-path"&&(o=new tp);let{transform:n}=r;const{transform:a}=r,l=rat(r,["transform"]);Object.assign(o,l);const{fill:c,points:h,strokeDasharray:u}=l;if(c&&gl(c)&&Q$(c)&&(o.fill=yield Bo.get().createImage(c)),c&&Rv(c)&&gl(c.image)&&Q$(c.image)&&(c.image=yield Bo.get().createImage(c.image)),h&&gl(h)&&(o.points=h.split(" ").map(d=>d.split(",").map(Number))),u&&gl(u)&&(o.strokeDasharray=u.split(" ").map(Number)),n){gl(n)&&(n=fG(n));const{position:d,scale:f,skew:g,rotation:p,pivot:m}=n;o.transform.position.set(d.x,d.y),o.transform.scale.set(f.x,f.y),o.transform.skew.set(g.x,g.y),o.transform.rotation=p,o.transform.pivot.set(m.x,m.y)}return i&&i.length>0&&(yield Promise.all(i.map(d=>eat(this,void 0,void 0,function*(){o.appendChild(yield FV(d))})))),o})};function BH(t){const[e,r]=SFt(t),i={uid:t.uid,type:e,attributes:[...iat,...r].reduce((a,l)=>(Xo(t[l])||(a[l]=t[l]),a),{})};if(!i.attributes.serializable)return;delete i.attributes.serializable;const{fill:s,points:o,strokeDasharray:n}=i.attributes;return s&&!gl(s)&&(Rv(s)?gl(s.image)||(i.attributes.fill.width=s.image.width,i.attributes.fill.height=s.image.height,i.attributes.fill.image=hat(s.image)):i.attributes.fill=hat(s)),o&&(i.attributes.points=o.map(([a,l])=>`${a},${l}`).join(" ")),n&&(i.attributes.strokeDasharray=n.join(" ")),i.attributes.transform=TFt(t.transform),i.children=t.children.filter(a=>a.serializable).map(BH),i}function cat(t){const e=Bo.get().createCanvas(t.width,t.height);return e.getContext("2d").drawImage(t,0,0),e.toDataURL()}function hat(t){if(sPt){if(t instanceof ImageBitmap)return cat(t);if(t instanceof HTMLImageElement)return t.src;if(t instanceof HTMLCanvasElement)return t.toDataURL()}else return cat(t)}function TFt(t){const{a:e,b:r,c:i,d:s,tx:o,ty:n}=t.localTransform;return{matrix:{a:e,b:r,c:i,d:s,tx:o,ty:n},position:{x:t.position.x,y:t.position.y},scale:{x:t.scale.x,y:t.scale.y},skew:{x:t.skew.x,y:t.skew.y},rotation:t.rotation,pivot:{x:t.pivot.x,y:t.pivot.y}}}function RFt(t,e,r){const{type:i,attributes:s}=t,{strokeWidth:o,strokeAlignment:n}=s,a=n==="inner",l=o/2;if(i==="polyline"){const{points:c}=s,h=c.split(" ").map(d=>d.split(",").map(Number)),u=uH(h,a,o);e.setAttribute("points",u.map(d=>d.join(",")).join(" "))}else{const c=e.cloneNode();if(e.setAttribute("stroke","none"),c.setAttribute("fill","none"),i==="circle"){const{r:h}=s,u=a?-l:l;c.setAttribute("r",`${h+u}`)}else if(i==="ellipse"){const{rx:h,ry:u}=s,d=a?-l:l;c.setAttribute("rx",`${h+d}`),c.setAttribute("ry",`${u+d}`)}else if(i==="rect"){const{x:h,y:u,width:d,height:f,strokeWidth:g}=s;c.setAttribute("x",`${h+(a?l:-l)}`),c.setAttribute("y",`${u+(a?l:-l)}`),c.setAttribute("width",`${d+(a?-g:g)}`),c.setAttribute("height",`${f+(a?-g:g)}`)}r.appendChild(c)}}function CFt(t,e,r){const{uid:i,attributes:{innerShadowOffsetX:s,innerShadowOffsetY:o,innerShadowBlurRadius:n,innerShadowColor:a}}=t,l=Qr("defs"),c=Qr("filter");c.id=`filter_inner_shadow_${i}`;const h=Qr("feComponentTransfer");h.setAttribute("in","SourceAlpha");const u=Qr("feFuncA");u.setAttribute("type","table"),u.setAttribute("tableValues","1 0"),h.appendChild(u),c.appendChild(h);const d=Qr("feGaussianBlur");d.setAttribute("stdDeviation",`${(n||0)/4}`),c.appendChild(d);const f=Qr("feOffset");f.setAttribute("dx",`${(s||0)/2}`),f.setAttribute("dy",`${(o||0)/2}`),f.setAttribute("result","offsetblur"),c.appendChild(f);const g=Qr("feFlood");g.setAttribute("flood-color",a),g.setAttribute("result","color"),c.appendChild(g);const p=Qr("feComposite");p.setAttribute("in2","offsetblur"),p.setAttribute("operator","in"),c.appendChild(p);const m=Qr("feComposite");m.setAttribute("in2","SourceAlpha"),m.setAttribute("operator","in"),c.appendChild(m);const v=Qr("feMerge");c.appendChild(v);const b=Qr("feMergeNode");b.setAttribute("in","SourceGraphic");const y=Qr("feMergeNode");
569v.appendChild(b),v.appendChild(y),l.appendChild(c),e.appendChild(l);const _=e.getAttribute("filter")||"";e.setAttribute("filter",`${_} url(#${c.id})`.trim())}function MFt(t,e,r){const{uid:i,attributes:{width:s,height:o,dropShadowBlurRadius:n,dropShadowColor:a,dropShadowOffsetX:l,dropShadowOffsetY:c}}=t,h=Qr("defs"),u=Qr("filter");u.id=`filter_drop_shadow_${i}`;const d=Qr("feDropShadow");d.setAttribute("dx",`${(l||0)/2*Math.sign(s)}`),d.setAttribute("dy",`${(c||0)/2*Math.sign(o)}`),d.setAttribute("stdDeviation",`${(n||0)/4}`),d.setAttribute("flood-color",a),u.appendChild(d),h.appendChild(u),e.appendChild(h);const f=e.getAttribute("filter")||"";e.setAttribute("filter",`${f} url(#${u.id})`.trim())}function BFt(t,e,r,i){const{repetition:s,transform:o,width:n,height:a}=r,l=Qr("pattern");o&&l.setAttribute("patternTransform",o),l.setAttribute("patternUnits","userSpaceOnUse"),l.id=i,e.appendChild(l);const{minX:c,minY:h,maxX:u,maxY:d}=x5(t);l.setAttribute("x",`${c}`),l.setAttribute("y",`${h}`);let f=n,g=a;return s==="repeat-x"?g=d-h:s==="repeat-y"?f=u-c:s==="no-repeat"&&(f=u-c,g=d-h),l.setAttribute("width",`${f}`),l.setAttribute("height",`${g}`),l}function OFt(t,e,r){const i=x5(t),s=i.maxX-i.minX,o=i.maxY-i.minY,n=tat({pattern:r});if(!e.querySelector(`#${n}`)){const a=r.image;if(a){const l=Qr("image");l.setAttribute("href",a);const c=BFt(t,e,r,n);e.appendChild(c),c.appendChild(l),l.setAttribute("x","0"),l.setAttribute("y","0"),l.setAttribute("width",`${r.width||s}`),l.setAttribute("height",`${r.height||o}`)}}return n}function uat(t,e,r){var i;const s=x5(t),o=[s.minX,s.minY],n=s.maxX-s.minX,a=s.maxY-s.minY;if(r.type==="mesh-gradient"){const h=`meshg_${uI(`${r.backgroundColor}|${r.colors.join("|")}`)}`;let u=e.querySelector(`#${h}`);if(!u){u=Qr("linearGradient"),u.setAttribute("gradientUnits","userSpaceOnUse");const m=(i=r.colors[4])!==null&&i!==void 0?i:"#888888";u.innerHTML=`<stop offset="0" stop-color="${r.backgroundColor}"></stop><stop offset="1" stop-color="${m}"></stop>`,u.id=h,e.appendChild(u)}const{x1:d,y1:f,x2:g,y2:p}=MH([o[0],o[1]],n,a,0);return u.setAttribute("x1",`${d}`),u.setAttribute("y1",`${f}`),u.setAttribute("x2",`${g}`),u.setAttribute("y2",`${p}`),h}const l=Qnt(Object.assign(Object.assign({},r),{min:o,width:n,height:a}));let c=e.querySelector(`#${l}`);if(!c){c=Qr(r.type==="linear-gradient"?"linearGradient":"radialGradient"),c.setAttribute("gradientUnits","userSpaceOnUse");let h="";r.steps.sort((u,d)=>u.offset.value-d.offset.value).forEach(({offset:u,color:d})=>{h+=`<stop offset="${u.value/100}" stop-color="${d}"></stop>`}),c.innerHTML=h,c.id=l,e.appendChild(c)}if(r.type==="linear-gradient"){const{angle:h}=r,{x1:u,y1:d,x2:f,y2:g}=MH([o[0],o[1]],n,a,h);c.setAttribute("x1",`${u}`),c.setAttribute("y1",`${d}`),c.setAttribute("x2",`${f}`),c.setAttribute("y2",`${g}`)}else if(r.type==="radial-gradient"){const{cx:h,cy:u,size:d}=r,{x:f,y:g,r:p}=qnt([o[0],o[1]],n,a,h,u,d);c.setAttribute("cx",`${f}`),c.setAttribute("cy",`${g}`),c.setAttribute("r",`${p}`)}return l}function IFt(t,e,r){const i=`filter-${t.uid}-gradient`;let s=e.querySelector(`#${i}`);s||(s=Qr("filter"),s.setAttribute("filterUnits","userSpaceOnUse"),s.setAttribute("x","0%"),s.setAttribute("y","0%"),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.id=i,e.appendChild(s));let o=0;r.forEach((a,l)=>{const c=uat(t,e,a),h=`${c}_rect`,u=Qr("rect");u.setAttribute("x","0"),u.setAttribute("y","0"),u.setAttribute("width","100%"),u.setAttribute("height","100%"),u.setAttribute("fill",`url(#${c})`),u.id=h,e.appendChild(u);const d=Qr("feImage");if(d.setAttribute("href",`#${h}`),d.setAttribute("result",`${i}-${l}`),s.appendChild(d),l>0){const f=Qr("feBlend");f.setAttribute("in",l===1?`${i}-${l-1}`:`${i}-blended-${o-1}`),f.setAttribute("in2",`${i}-${l}`),f.setAttribute("result",`${i}-blended-${o++}`),f.setAttribute("mode","multiply"),s.appendChild(f)}});const n=Qr("feComposite");return n.setAttribute("in",`${i}-blended-${o}`),n.setAttribute("in2","SourceGraphic"),n.setAttribute("operator","in"),s.appendChild(n),i}function DFt(t,e,r){const i=Qr("defs");r.appendChild(i);const s=t.attributes.fill;if(Rv(s)){const o=OFt(t,i,s);e==null||e.setAttribute("fill",`url(#${o})`)}else{const o=qU(s);if(o.length===1){const n=uat(t,i,o[0]);e==null||e.setAttribute("fill",`url(#${n})`)}else{const n=IFt(t,i,o);e==null||e.setAttribute("filter",`url(#${n})`),e==null||e.setAttribute("fill","black")}}}function x5(t){let e;return t.type==="circle"?e=Gl.getGeometryBounds(t.attributes):t.type==="ellipse"?e=$h.getGeometryBounds(t.attributes):t.type==="rect"?e=ed.getGeometryBounds(t.attributes):t.type==="polyline"?e=sp.getGeometryBounds(t.attributes):t.type==="path"&&(e=Wc.getGeometryBounds(t.attributes)),e}function PFt(t,e,r){const i=Qr("defs"),s=Qr("pattern");s.id=`image-fill_${t.uid}`,s.setAttribute("patternUnits","objectBoundingBox"),s.setAttribute("width","1"),s.setAttribute("height","1");const o=Qr("image");o.setAttribute("href",t.attributes.fill),o.setAttribute("x","0"),o.setAttribute("y","0");const n=x5(t);o.setAttribute("width",`${n.maxX-n.minX}`),o.setAttribute("height",`${n.maxY-n.minY}`),s.appendChild(o),i.appendChild(s),r.appendChild(i),e.setAttribute("fill",`url(#${s.id})`)}function FFt(t,e,r){const{content:i,fontFamily:s,fontSize:o,fontWeight:n,fontStyle:a,fontVariant:l,fill:c,decorationLine:h,decorationStyle:u,decorationColor:d,decorationThickness:f}=t.attributes;if(e.textContent=i,e===r)e.setAttribute("font-family",s),e.setAttribute("font-size",`${o}`),e.setAttribute("font-weight",`${n}`),e.setAttribute("font-style",a),e.setAttribute("font-variant",l),e.setAttribute("fill",c);else{let g="";const p=Hnt({fontFamily:s,fontSize:o,fontWeight:n,fontStyle:a,fontVariant:l});p&&(g+=`font: ${p};`),c&&(g+=`fill: ${c};`),g&&e.setAttribute("style",g)}if(h!=="none"&&f>0){const g=e.getAttribute("style")||"";e.setAttribute("style",g+`text-decoration: ${u} ${h} ${d} ${f}px;`)}}function NFt(t,e){const{attributes:{drawableSets:r,stroke:i,fill:s}}=t;r.forEach(o=>{const{type:n}=o,a=Xnt(o),l=Bv(a,2),c=Qr("path");c.setAttribute("d",l),e.appendChild(c),n==="fillSketch"?(c.setAttribute("stroke",s),c.setAttribute("fill","none")):n==="path"?(c.setAttribute("stroke",i),c.setAttribute("fill","none")):n==="fillPath"&&(c.setAttribute("fill",s),c.setAttribute("stroke","none"))})}function OH(t){if(!t)return;const{type:e,attributes:r,children:i}=t,s=e.startsWith("rough-"),o=!s&&Qr(e),{transform:n,visible:a,cullable:l,renderable:c,batchable:h,innerShadowColor:u,innerShadowOffsetX:d,innerShadowOffsetY:f,innerShadowBlurRadius:g,dropShadowColor:p,dropShadowOffsetX:m,dropShadowOffsetY:v,dropShadowBlurRadius:b,decorationLine:y,decorationStyle:_,decorationColor:w,decorationThickness:E,strokeAlignment:A,cornerRadius:x,zIndex:S,fontFamily:T,fontSize:R,fontWeight:B,fontStyle:O,fontVariant:C,content:F,letterSpacing:U,lineHeight:H,whiteSpace:N,wordWrap:G,wordWrapWidth:Y}=r,q=rat(r,["transform","visible","cullable","renderable","batchable","innerShadowColor","innerShadowOffsetX","innerShadowOffsetY","innerShadowBlurRadius","dropShadowColor","dropShadowOffsetX","dropShadowOffsetY","dropShadowBlurRadius","decorationLine","decorationStyle","decorationColor","decorationThickness","strokeAlignment","cornerRadius","zIndex","fontFamily","fontSize","fontWeight","fontStyle","fontVariant","content","letterSpacing","lineHeight","whiteSpace","wordWrap","wordWrapWidth"]);if(o&&Object.entries(q).forEach(([Gr,re])=>{`${re}`!=""&&`${xFt[Gr]}`!=`${re}`&&o.setAttribute(fPt(Gr),`${re}`)}),e==="rect"){const{width:Gr,height:re,x:ci,y:Dt}=r;if(Gr<0||re<0){const rt=ci,At=Dt,Vt=ci+Gr,de=Dt+re;o.setAttribute("x",`${Math.min(rt,Vt)}`),o.setAttribute("y",`${Math.min(At,de)}`),o.setAttribute("width",`${Math.abs(Gr)}`),o.setAttribute("height",`${Math.abs(re)}`)}}const L=A==="inner"||A==="outer",J=q.fill&&gl(q.fill)&&Q$(q.fill),tt=q.fill&&gl(q.fill)&&QB(q.fill),bt=q.fill&&Rv(q.fill);let ct;(i&&i.length>0&&e!=="g"||L&&e!=="polyline"||s||J||tt||bt)&&(ct=Qr("g"),o&&ct.appendChild(o)),L&&RFt(t,o,ct),g>0&&CFt(t,o),b>0&&MFt(t,o||ct),J&&PFt(t,o,ct),(tt||bt)&&DFt(t,o,ct),ct=ct||o,a===!1&&ct.setAttribute("visibility","hidden"),x&&(ct.setAttribute("rx",`${x}`),ct.setAttribute("ry",`${x}`)),s&&NFt(t,ct),F&&FFt(t,ct,o);const{a:Xt,b:It,c:zt,d:Ht,tx:Lt,ty:tr}=n.matrix;return(Xt!==1||It!==0||zt!==0||Ht!==1||Lt!==0||tr!==0)&&ct.setAttribute("transform",`matrix(${Xt},${It},${zt},${Ht},${Lt},${tr})`),[...i].sort(kFt).map(Gr=>
569OH(Gr)).forEach(Gr=>{ct.appendChild(Gr)}),ct}yG=function(t,e=0,r=[]){let i=t.tagName.toLowerCase();if(i==="svg")i="g";else if(i==="defs"){r.push(...Array.from(t.childNodes));return}else if(i==="use"){const n=t.getAttribute("xlink:href");if(n){const a=r.find(l=>l.id===n.replace("#",""));if(a)return yG(a,e,r)}return}else if(i==="tspan")return;const s=Array.from(t.attributes).reduce((n,a)=>{let l=pPt(a.name),c=a.value;return l==="transform"?c=fG(c):i==="rect"&&(l==="rx"||l==="ry")?(l="radius",c=Number(c)):l==="cx"||l==="cy"||l==="x"||l==="y"||l==="rx"||l==="ry"||l==="r"||l==="width"||l==="height"||l==="opacity"||l==="fillOpacity"||l==="strokeOpacity"||l==="strokeWidth"||l==="strokeMiterlimit"||l==="strokeDashoffset"||l==="fontSize"?c=Number(c.replace("px","")):l==="textAnchor"&&(l="textAlign",c==="middle"&&(c="center")),n[l]=c,n},{});i==="text"?s.content=t.textContent:i==="line"&&(i="polyline",s.points=`${s.x1},${s.y1} ${s.x2},${s.y2}`,delete s.x1,delete s.y1,delete s.x2,delete s.y2);const o=Array.from(t.children).map(n=>yG(n,e++,r)).filter(Boolean);return{uid:e,type:i,attributes:s,children:o}},fG=function(t){const e={matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0},position:{x:0,y:0},scale:{x:1,y:1},skew:{x:0,y:0},rotation:0,pivot:{x:0,y:0}},r=/translate\(([^,]+),([^,]+)\)/,i=/translateX\(([^,\)]+)\)/,s=/translateY\(([^,\)]+)\)/,o=/rotate\(([^,]+)\)/,n=/scale\(([^,\)]+)(?:,([^,\)]+))?\)/,a=/scaleX\(([^,\)]+)\)/,l=/scaleY\(([^,\)]+)\)/,c=/skew\(([^,]+),([^,]+)\)/,h=/skewX\(([^,\)]+)\)/,u=/skewY\(([^,\)]+)\)/,d=/matrix\(([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)\)/,f=t.match(r);f&&(e.position.x=parseFloat(f[1]),e.position.y=parseFloat(f[2]));const g=t.match(i);g&&(e.position.x=parseFloat(g[1]));const p=t.match(s);p&&(e.position.y=parseFloat(p[1]));const m=t.match(o);m&&(e.rotation=parseFloat(m[1]));const v=t.match(n);if(v){const x=parseFloat(v[1]);e.scale.x=x,e.scale.y=v[2]?parseFloat(v[2]):x}const b=t.match(a);b&&(e.scale.x=parseFloat(b[1]));const y=t.match(l);y&&(e.scale.y=parseFloat(y[1]));const _=t.match(c);_&&(e.skew.x=parseFloat(_[1]),e.skew.y=parseFloat(_[2]));const w=t.match(h);w&&(e.skew.x=parseFloat(w[1]));const E=t.match(u);
569E&&(e.skew.y=parseFloat(E[1]));const A=t.match(d);return A&&(e.matrix.a=parseFloat(A[1]),e.matrix.b=parseFloat(A[2]),e.matrix.c=parseFloat(A[3]),e.matrix.d=parseFloat(A[4]),e.matrix.tx=parseFloat(A[5]),e.matrix.ty=parseFloat(A[6])),e};function kFt(t,e){var r,i;const s=(r=t.attributes.zIndex)!==null&&r!==void 0?r:0,o=(i=e.attributes.zIndex)!==null&&i!==void 0?i:0;return s-o}function dat(t){return JSON.parse(JSON.stringify(t))}const fat=(t,e,r=!1)=>{let i=!1;for(const s in e){const o=e[s];if(typeof o<"u"){if(t[s]===o&&(typeof o!="object"||o===null))continue;i=!0}}return!i&&!r?t:Object.assign(Object.assign(Object.assign({},t),e),{updated:Date.now(),version:t.version+1,versionNonce:cPt()})};let SI=class{constructor(){this.arcLengthDivisions=200,this.needsUpdate=!0}getPointAt(t,e){const r=this.getUtoTmapping(t);return this.getPoint(r,e)}getPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}getSpacedPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let r,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=Hy(r,i),e.push(s),i=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const r=this.getLengths();let i=0;const s=r.length;let o;e?o=e:o=t*r[s-1];let n=0,a=s-1,l;for(;n<=a;)if(i=Math.floor(n+(a-n)/2),l=r[i]-o,l<0)n=i+1;else if(l>0)a=i-1;else{a=i;break}if(i=a,r[i]===o)return i/(s-1);const c=r[i],h=r[i+1]-c,u=(o-c)/h;return(i+u)/(s-1)}getTangent(t,e){let r=t-1e-4,i=t+1e-4;r<0&&(r=0),i>1&&(i=1);const s=this.getPoint(r),o=this.getPoint(i),n=e||it();return ru(n,o,s),aE(n,n),n}getTangentAt(t,e){const r=this.getUtoTmapping(t);return this.getTangent(r,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},IH=class extends SI{constructor(t=it(),e=it()){super(),this.v1=t,this.v2=e,this.v1=t,this.v2=e}getPoint(t,e=it()){const r=e;return t===1?di(r,this.v2):(ru(r,di(r,this.v2),this.v1),lG(r,this.v1,r,t)),r}getPointAt(t,e){return this.getPoint(t,e)}},pat=class extends SI{constructor(t=0,e=0,r=1,i=1,s=0,o=Math.PI*2,n=!1,a=0){super(),this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=n,this.aRotation=a}getPoint(t,e=it()){const r=e,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);const n=this.aStartAngle+t*s;let a=this.aX+this.xRadius*Math.cos(n),l=this.aY+this.yRadius*Math.sin(n);if(this.aRotation!==0){const c=Math.cos(this.aRotation),h=Math.sin(this.aRotation),u=a-this.aX,d=l-this.aY;a=u*c-d*h+this.aX,l=u*h+d*c+this.aY}return Jn(r,a,l)}},LFt=class extends SI{constructor(){super(...arguments),this.curves=[],this.autoClose=!1,this.cacheLengths=null}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);return sd(t,e)||this.curves.push(new IH(e,t)),this}getPoint(t,e){const r=t*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=r){const o=i[s]-r,n=this.curves[s],a=n.getLength(),l=a===0?0:1-o/a;return n.getPointAt(l,e)}s++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let r=0,i=this.curves.length;r<i;r++)e+=this.curves[r].getLength(),t.push(e);return this.cacheLengths=t,t}getPoints(t=12){const e=[];let r;for(let i=0,s=this.curves;i<s.length;i++){const o=s[i],n=o instanceof pat?t*2:o instanceof IH?1:o.isSplineCurve?t*o.points.length:t,a=o.getPoints(n);for(let l=0;l<a.length;l++){const c=a[l];r&&sd(r,c)||(e.push(c),r=c)}}return this.autoClose&&e.length>1&&!sd(e[e.length-1],e[0])&&e.push(e[0]),e}};function UFt(t,e){const r=1-t;return r*r*e}function GFt(t,e){return 2*(1-t)*t*e}function WFt(t,e){return t*t*e}function gat(t,e,r,i){return UFt(t,e)+GFt(t,r)+WFt(t,i)}function jFt(t,e){const r=1-t;return r*r*r*e}function XFt(t,e){const r=1-t;return 3*r*r*t*e}function zFt(t,e){return 3*(1-t)*t*t*e}function VFt(t,e){return t*t*t*e}
569function mat(t,e,r,i,s){return jFt(t,e)+XFt(t,r)+zFt(t,i)+VFt(t,s)}let YFt=class extends SI{constructor(t=it(),e=it(),r=it()){super(),this.v0=t,this.v1=e,this.v2=r,this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=it()){const r=e,{v0:i,v1:s,v2:o}=this;return Jn(r,gat(t,i[0],s[0],o[0]),gat(t,i[1],s[1],o[1])),r}getPointAt(t,e){return this.getPoint(t,e)}},$Ft=class extends SI{constructor(t=it(),e=it(),r=it(),i=it()){super(),this.v0=t,this.v1=e,this.v2=r,this.v3=i,this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=it()){const r=e,{v0:i,v1:s,v2:o,v3:n}=this;return Jn(r,mat(t,i[0],s[0],o[0],n[0]),mat(t,i[1],s[1],o[1],n[1])),r}getPointAt(t,e){return this.getPoint(t,e)}},HFt=class extends LFt{constructor(t){super(),this.currentPoint=it(),t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0][0],t[0][1]);for(let e=1,r=t.length;e<r;e++)this.lineTo(t[e][0],t[e][1]);return this}moveTo(t,e){return Jn(this.currentPoint,t,e),this}lineTo(t,e){const r=new IH(Ta(this.currentPoint),Be(t,e));return this.curves.push(r),Jn(this.currentPoint,t,e),this}quadraticCurveTo(t,e,r,i){const s=new YFt(Ta(this.currentPoint),Be(t,e),Be(r,i));return this.curves.push(s),Jn(this.currentPoint,r,i),this}bezierCurveTo(t,e,r,i,s,o){const n=new $Ft(Ta(this.currentPoint),Be(t,e),Be(r,i),Be(s,o));return this.curves.push(n),Jn(this.currentPoint,s,o),this}arc(t,e,r,i,s,o){const[n,a]=this.currentPoint;return this.absarc(t+n,e+a,r,i,s,o),this}absarc(t,e,r,i,s,o){return this.absellipse(t,e,r,r,i,s,o),this}absellipse(t,e,r,i,s,o,n,a){const l=new pat(t,e,r,i,s,o,n,a);if(this.curves.length>0){const h=l.getPoint(0);sd(h,this.currentPoint)||this.lineTo(h[0],h[1])}this.curves.push(l);const c=l.getPoint(1);return di(this.currentPoint,c),this}},KFt=class{constructor(){this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new HFt,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,r,i){return this.currentPath.quadraticCurveTo(t,e,r,i),this}bezierCurveTo(t,e,r,i,s,o){return this.currentPath.bezierCurveTo(t,e,r,i,s,o),this}};function TI(t){const e=new KFt,r=it(),i=it(),s=it();let o=!0,n=!1;return(gl(t)?ep(t):Xnt(t)).forEach(a=>{const l=a[0],c=a.slice(1);o===!0&&(n=!0,o=!1);let h;switch(l){case"M":h=c;for(let u=0,d=h.length;u<d;u+=2)r[0]=h[u+0],r[1]=h[u+1],i[0]=r[0],i[1]=r[1],u===0?e.moveTo(r[0],r[1]):e.lineTo(r[0],r[1]),u===0&&di(s,r);break;case"H":h=c;for(let u=0,d=h.length;u<d;u++)r[0]=h[u],i[0]=r[0],i[1]=r[1],e.lineTo(r[0],r[1]),u===0&&n===!0&&di(s,r);break;case"V":h=c;for(let u=0,d=h.length;u<d;u++)r[1]=h[u],i[0]=r[0],i[1]=r[1],e.lineTo(r[0],r[1]),u===0&&n===!0&&di(s,r);break;case"L":h=c;for(let u=0,d=h.length;u<d;u+=2)r[0]=h[u+0],r[1]=h[u+1],i[0]=r[0],i[1]=r[1],e.lineTo(r[0],r[1]),u===0&&n===!0&&di(s,r);break;case"C":h=c;for(let u=0,d=h.length;u<d;u+=6)e.bezierCurveTo(h[u+0],h[u+1],h[u+2],h[u+3],h[u+4],h[u+5]),i[0]=h[u+2],i[1]=h[u+3],r[0]=h[u+4],r[1]=h[u+5],u===0&&n===!0&&di(s,r);break;case"S":h=c;for(let u=0,d=h.length;u<d;u+=4)e.bezierCurveTo(S5(r[0],i[0]),S5(r[1],i[1]),h[u+0],h[u+1],h[u+2],h[u+3]),i[0]=h[u+0],i[1]=h[u+1],r[0]=h[u+2],r[1]=h[u+3],u===0&&n===!0&&di(s,r);break;case"Q":h=c;for(let u=0,d=h.length;u<d;u+=4)e.quadraticCurveTo(h[u+0],h[u+1],h[u+2],h[u+3]),i[0]=h[u+0],i[1]=h[u+1],r[0]=h[u+2],r[1]=h[u+3],u===0&&n===!0&&di(s,r);break;case"T":h=c;for(let u=0,d=h.length;u<d;u+=2){const f=S5(r[0],i[0]),g=S5(r[1],i[1]);e.quadraticCurveTo(f,g,h[u+0],h[u+1]),i[0]=f,i[1]=g,r[0]=h[u+0],r[1]=h[u+1],u===0&&n===!0&&di(s,r)}break;case"A":h=c;for(let u=0,d=h.length;u<d;u+=7){if(h[u+5]==r[0]&&h[u+6]==r[1])continue;const f=Ta(r);r[0]=h[u+5],r[1]=h[u+6],i[0]=r[0],i[1]=r[1],qFt(e,h[u],h[u+1],h[u+2],h[u+3],h[u+4],f,r),u===0&&n===!0&&di(s,r)}break;case"Z":e.currentPath.autoClose=!0,e.currentPath.curves.length>0&&(di(r,s),di(e.currentPath.currentPoint,r),o=!0);break;default:console.warn(a)}n=!1}),e}function S5(t,e){return t-(e-t)}function qFt(t,e,r,i,s,o,n,a){if(e==0||r==0){t.lineTo(a[0],a[1]);return}i=i*Math.PI/180,e=Math.abs(e),r=Math.abs(r);const l=(n[0]-a[0])/2,c=(n[1]-a[1])/2,h=Math.cos(i)*l+Math.sin(i)*c,u=-Math.sin(i)*l+Math.cos(i)*c;let d=e*e,f=r*r;const g=h*h,p=u*u,m=g/d+p/f;if(m>1){const T=Math.sqrt(m);e=T*e,r=T*r,d=e*e,f=r*r}const v=d*p+f*g,b=(d*f-v)/v;let y=Math.sqrt(Math.max(0,b));s===o&&(y=-y);const _=y*e*u/r,w=-y*r*h/e,E=Math.cos(i)*_-Math.sin(i)*w+(n[0]+a[0])/2,A=Math.sin(i)*_+Math.cos(i)*w+(n[1]+a[1])/2,x=yat(1,0,(h-_)/e,(u-w)/r),S=yat((h-_)/e,(u-w)/r,(-h-_)/e,(-u-w)/r)%(Math.PI*2);t.currentPath.absellipse(E,A,e,r,x,x+S,o===0,i)}function yat(t,e,r,i){const s=t*r+e*i,o=Math.sqrt(t*t+e*e)*Math.sqrt(r*r+i*i);let n=Math.acos(Math.max(-1,Math.min(1,s/o)));return t*i-e*r<0&&(n=-n),n}function ZFt(t){const e=t.length;let r=0;for(let i=e-1,s=0;s<e;i=s++)r+=t[i][0]*t[s][1]-t[s][0]*t[i][1];return r*.5}function DH(t){return ZFt(t)>0}var PH={exports:{}},vat=PH.exports,_at;function JFt(){return _at||(_at=1,(function(t){var e;function r(M,D){return M.b===D.b&&M.a===D.a}function i(M,D){return M.b<D.b||M.b===D.b&&M.a<=D.a}function s(M,D,k){var j=D.b-M.b,Q=k.b-D.b;return 0<j+Q?j<Q?D.a-M.a+j/(j+Q)*(M.a-k.a):D.a-k.a+Q/(j+Q)*(k.a-M.a):0}function o(M,D,k){var j=D.b-M.b,Q=k.b-D.b;return 0<j+Q?(D.a-k.a)*j+(D.a-M.a)*Q:0}function n(M,D){return M.a<D.a||M.a===D.a&&M.b<=D.b}function a(M,D,k){var j=D.a-M.a,Q=k.a-D.a;return 0<j+Q?j<Q?D.b-M.b+j/(j+Q)*(M.b-k.b):D.b-k.b+Q/(j+Q)*(k.b-M.b):0}function l(M,D,k){var j=D.a-M.a,Q=k.a-D.a;return 0<j+Q?(D.b-k.b)*j+(D.b-M.b)*Q:0}function c(M){return i(M.b.a,M.a)}function h(M){return i(M.a,M.b.a)}function u(M,D,k,j){return M=0>M?0:M,k=0>k?0:k,M<=k?k===0?(D+j)/2:D+M/(M+k)*(j-D):j+k/(M+k)*(D-j)}function d(M){var D=v(M.b);return y(D,M.c),y(D.b,M.c),_(D,M.a),D}function f(M,D){var k=!1,j=!1;M!==D&&(D.a!==M.a&&(j=!0,E(D.a,M.a)),D.d!==M.d&&(k=!0,A(D.d,M.d)),b(D,M),j||(y(D,M.a),M.a.c=M),k||(_(D,M.d),M.d.a=M))}function g(M){var D=M.b,k=!1;M.d!==M.b.d&&(k=!0,A(M.d,M.b.d)),M.c===M?E(M.a,null):(M.b.d.a=rt(M),M.a.c=M.c,b(M,rt(M)),k||_(M,M.d)),D.c===D?(E(D.a,null),A(D.d,null)):(M.d.a=rt(D),D.a.c=D.c,b(D,rt(D))),w(M)}function p(M){var D=v(M),k=D.b;return b(D,M.e),D.a=M.b.a,y(k,D.a),D.d=k.d=M.d,D=D.b,b(M.b,rt(M.b)),b(M.b,D),M.b.a=D.a,D.b.a.c=D.b,D.b.d=M.b.d,D.f=M.f,D.b.f=M.b.f,D}function m(M,D){var k=!1,j=v(M),Q=j.b;return D.d!==M.d&&(k=!0,A(D.d,M.d)),b(j,M.e),b(Q,D),j.a=M.b.a,Q.a=D.a,j.d=Q.d=M.d,M.d.a=Q,k||_(j,M.d),j}function v(M){var D=new Dt,k=new Dt,j=M.b.h;return k.h=j,j.b.h=D,D.h=M,M.b.h=k,D.b=k,D.c=D,D.e=k,k.b=D,k.c=k,k.e=D}function b(M,D){var k=M.c,j=D.c;k.b.e=D,j.b.e=M,M.c=j,D.c=k}function y(M,D){var k=D.f,j=new Vt(D,k);k.e=j,D.f=j,k=j.c=M;do k.a=j,k=k.c;while(k!==M)}function _(M,D){var k=D.d,j=new ci(D,k);k.b=j,D.d=j,j.a=M,j.c=D.c,k=M;do k.d=j,k=k.e;while(k!==M)}function w(M){var D=M.h;M=M.b.h,D.b.h=M,M.b.h=D}function E(M,D){var k=M.c,j=k;do j.a=D,j=j.c;while(j!==k);k=M.f,j=M.e,j.f=k,k.e=j}function A(M,D){var k=M.a,j=k;do j.d=D,j=j.e;while(j!==k);k=M.d,j=M.b,j.d=k,k.b=j}function x(M){var D=0;return Math.abs(M[1])>Math.abs(M[0])&&(D=1),Math.abs(M[2])>
569Math.abs(M[D])&&(D=2),D}var S=4*1e150;function T(M,D){M.f+=D.f,M.b.f+=D.b.f}function R(M,D,k){return M=M.a,D=D.a,k=k.a,D.b.a===M?k.b.a===M?i(D.a,k.a)?0>=o(k.b.a,D.a,k.a):0<=o(D.b.a,k.a,D.a):0>=o(k.b.a,M,k.a):k.b.a===M?0<=o(D.b.a,M,D.a):(D=s(D.b.a,M,D.a),M=s(k.b.a,M,k.a),D>=M)}function B(M){M.a.i=null;var D=M.e;D.a.c=D.c,D.c.a=D.a,M.e=null}function O(M,D){g(M.a),M.c=!1,M.a=D,D.i=M}function C(M){var D=M.a.a;do M=ut(M);while(M.a.a===D);return M.c&&(D=m(z(M).a.b,M.a.e),O(M,D),M=ut(M)),M}function F(M,D,k){var j=new Es;return j.a=k,j.e=zt(M.f,D.e,j),k.i=j}function U(M,D){switch(M.s){case 100130:return(D&1)!==0;case 100131:return D!==0;case 100132:return 0<D;case 100133:return 0>D;case 100134:return 2<=D||-2>=D}return!1}function H(M){var D=M.a,k=D.d;k.c=M.d,k.a=D,B(M)}function N(M,D,k){for(M=D,D=D.a;M!==k;){M.c=!1;var j=z(M),Q=j.a;if(Q.a!==D.a){if(!j.c){H(M);break}Q=m(D.c.b,Q.b),O(j,Q)}D.c!==Q&&(f(rt(Q),Q),f(D,Q)),H(M),D=j.a,M=j}return D}function G(M,D,k,j,Q,ft){var ht=!0;do F(M,D,k.b),k=k.c;while(k!==j);for(Q===null&&(Q=z(D).a.b.c);j=z(D),k=j.a.b,k.a===Q.a;)k.c!==Q&&(f(rt(k),k),f(rt(Q),k)),j.f=D.f-k.f,j.d=U(M,j.f),D.b=!0,!ht&&J(M,D)&&(T(k,Q),B(D),g(Q)),ht=!1,D=j,Q=k;D.b=!0,ft&&bt(M,D)}function Y(M,D,k,j,Q){var ft=[D.g[0],D.g[1],D.g[2]];D.d=null,D.d=M.o&&M.o(ft,k,j,M.c)||null,D.d===null&&(Q?M.n||(re(M,100156),M.n=!0):D.d=k[0])}function q(M,D,k){var j=[null,null,null,null];j[0]=D.a.d,j[1]=k.a.d,Y(M,D.a,j,[.5,.5,0,0],!1),f(D,k)}function L(M,D,k,j,Q){var ft=Math.abs(D.b-M.b)+Math.abs(D.a-M.a),ht=Math.abs(k.b-M.b)+Math.abs(k.a-M.a),ge=Q+1;j[Q]=.5*ht/(ft+ht),j[ge]=.5*ft/(ft+ht),M.g[0]+=j[Q]*D.g[0]+j[ge]*k.g[0],M.g[1]+=j[Q]*D.g[1]+j[ge]*k.g[1],M.g[2]+=j[Q]*D.g[2]+j[ge]*k.g[2]}function J(M,D){var k=z(D),j=D.a,Q=k.a;if(i(j.a,Q.a)){if(0<o(Q.b.a,j.a,Q.a))return!1;if(!r(j.a,Q.a))p(Q.b),f(j,rt(Q)),D.b=k.b=!0;else if(j.a!==Q.a){var k=M.e,ft=j.a.h;if(0<=ft){var k=k.b,ht=k.d,ge=k.e,Ge=k.c,Ye=Ge[ft];ht[Ye]=ht[k.a],Ge[ht[Ye]]=Ye,Ye<=--k.a&&(1>=Ye||i(ge[ht[Ye>>1]],ge[ht[Ye]])?Ne(k,Ye):mo(k,Ye)),ge[ft]=null,Ge[ft]=k.b,k.b=ft}else for(k.c[-(ft+1)]=null;0<k.a&&k.c[k.d[k.a-1]]===null;)--k.a;q(M,rt(Q),j)}}else{if(0>o(j.b.a,Q.a,j.a))return!1;ut(D).b=D.b=!0,p(j.b),f(rt(Q),j)}return!0}function tt(M,D){var k=z(D),j=D.a,Q=k.a,ft=j.a,ht=Q.a,ge=j.b.a,Ge=Q.b.a,Ye=new Vt;if(o(ge,M.a,ft),o(Ge,M.a,ht),ft===ht||Math.min(ft.a,ge.a)>Math.max(ht.a,Ge.a))return!1;if(i(ft,ht)){if(0<o(Ge,ft,ht))return!1}else if(0>o(ge,ht,ft))return!1;var Ki=ge,Wr=ft,hi=Ge,Xs=ht,Kr,zs;if(i(Ki,Wr)||(Kr=Ki,Ki=Wr,Wr=Kr),i(hi,Xs)||(Kr=hi,hi=Xs,Xs=Kr),i(Ki,hi)||(Kr=Ki,Ki=hi,hi=Kr,Kr=Wr,Wr=Xs,Xs=Kr),i(hi,Wr)?i(Wr,Xs)?(Kr=s(Ki,hi,Wr),zs=s(hi,Wr,Xs),0>Kr+zs&&(Kr=-Kr,zs=-zs),Ye.b=u(Kr,hi.b,zs,Wr.b)):(Kr=o(Ki,hi,Wr),zs=-o(Ki,Xs,Wr),0>Kr+zs&&(Kr=-Kr,zs=-zs),Ye.b=u(Kr,hi.b,zs,Xs.b)):Ye.b=(hi.b+Wr.b)/2,n(Ki,Wr)||(Kr=Ki,Ki=Wr,Wr=Kr),n(hi,Xs)||(Kr=hi,hi=Xs,Xs=Kr),n(Ki,hi)||(Kr=Ki,Ki=hi,hi=Kr,Kr=Wr,Wr=Xs,Xs=Kr),n(hi,Wr)?n(Wr,Xs)?(Kr=a(Ki,hi,Wr),zs=a(hi,Wr,Xs),0>Kr+zs&&(Kr=-Kr,zs=-zs),Ye.a=u(Kr,hi.a,zs,Wr.a)):(Kr=l(Ki,hi,Wr),zs=-l(Ki,Xs,Wr),0>Kr+zs&&(Kr=-Kr,zs=-zs),Ye.a=u(Kr,hi.a,zs,Xs.a)):Ye.a=(hi.a+Wr.a)/2,i(Ye,M.a)&&(Ye.b=M.a.b,Ye.a=M.a.a),Ki=i(ft,ht)?ft:ht,i(Ki,Ye)&&(Ye.b=Ki.b,Ye.a=Ki.a),r(Ye,ft)||r(Ye,ht))return J(M,D),!1;if(!r(ge,M.a)&&0<=o(ge,M.a,Ye)||!r(Ge,M.a)&&0>=o(Ge,M.a,Ye)){if(Ge===M.a)return p(j.b),f(Q.b,j),D=C(D),j=z(D).a,N(M,z(D),k),G(M,D,rt(j),j,j,!0),!0;if(ge===M.a){p(Q.b),f(j.e,rt(Q)),ft=k=D,ht=ft.a.b.a;do ft=ut(ft);while(ft.a.b.a===ht);return D=ft,ft=z(D).a.b.c,k.a=rt(Q),Q=N(M,k,null),G(M,D,Q.c,j.b.c,ft,!0),!0}return 0<=o(ge,M.a,Ye)&&(ut(D).b=D.b=!0,p(j.b),j.a.b=M.a.b,j.a.a=M.a.a),0>=o(Ge,M.a,Ye)&&(D.b=k.b=!0,p(Q.b),Q.a.b=M.a.b,Q.a.a=M.a.a),!1}return p(j.b),p(Q.b),f(rt(Q),j),j.a.b=Ye.b,j.a.a=Ye.a,j.a.h=De(M.e,j.a),j=j.a,Q=[0,0,0,0],Ye=[ft.d,ge.d,ht.d,Ge.d],j.g[0]=j.g[1]=j.g[2]=0,L(j,ft,ge,Q,0),L(j,ht,Ge,Q,2),Y(M,j,Ye,Q,!0),ut(D).b=D.b=k.b=!0,!1}
569function bt(M,D){for(var k=z(D);;){for(;k.b;)D=k,k=z(k);if(!D.b&&(k=D,D=ut(D),D===null||!D.b))break;D.b=!1;var j=D.a,Q=k.a,ft;if(ft=j.b.a!==Q.b.a)t:{ft=D;var ht=z(ft),ge=ft.a,Ge=ht.a,Ye=void 0;if(i(ge.b.a,Ge.b.a)){if(0>o(ge.b.a,Ge.b.a,ge.a)){ft=!1;break t}ut(ft).b=ft.b=!0,Ye=p(ge),f(Ge.b,Ye),Ye.d.c=ft.d}else{if(0<o(Ge.b.a,ge.b.a,Ge.a)){ft=!1;break t}ft.b=ht.b=!0,Ye=p(Ge),f(ge.e,Ge.b),Ye.b.d.c=ft.d}ft=!0}if(ft&&(k.c?(B(k),g(Q),k=z(D),Q=k.a):D.c&&(B(D),g(j),D=ut(k),j=D.a)),j.a!==Q.a){if(j.b.a===Q.b.a||D.c||k.c||j.b.a!==M.a&&Q.b.a!==M.a)J(M,D);else if(tt(M,D))break}j.a===Q.a&&j.b.a===Q.b.a&&(T(Q,j),B(D),g(j),D=ut(k))}}function ct(M,D){M.a=D;for(var k=D.c;k.i===null;)if(k=k.c,k===D.c){var k=M,j=D,ht=new Es;ht.a=j.c.b;var Q=k.f,ge=Q.a;do ge=ge.a;while(ge.b!==null&&!Q.c(Q.b,ht,ge.b));var Q=ge.b,ft=z(Q),ht=Q.a,ge=ft.a;if(o(ht.b.a,j,ht.a)===0)ht=Q.a,r(ht.a,j)||r(ht.b.a,j)||(p(ht.b),Q.c&&(g(ht.c),Q.c=!1),f(j.c,ht),ct(k,j));else{var Ge=i(ge.b.a,ht.b.a)?Q:ft,ft=void 0;Q.d||Ge.c?(Ge===Q?ft=m(j.c.b,ht.e):ft=m(ge.b.c.b,j.c).b,Ge.c?O(Ge,ft):(ht=k,Q=F(k,Q,ft),Q.f=ut(Q).f+Q.a.f,Q.d=U(ht,Q.f)),ct(k,j)):G(k,Q,j.c,j.c,null,!0)}return}if(k=C(k.i),ht=z(k),Q=ht.a,ht=N(M,ht,null),ht.c===Q){var Q=ht,ht=Q.c,ge=z(k),ft=k.a,Ge=ge.a,Ye=!1;ft.b.a!==Ge.b.a&&tt(M,k),r(ft.a,M.a)&&(f(rt(ht),ft),k=C(k),ht=z(k).a,N(M,z(k),ge),Ye=!0),r(Ge.a,M.a)&&(f(Q,rt(Ge)),Q=N(M,ge,null),Ye=!0),Ye?G(M,k,Q.c,ht,ht,!0):(i(Ge.a,ft.a)?j=rt(Ge):j=ft,j=m(Q.c.b,j),G(M,k,j,j.c,j.c,!1),j.b.i.c=!0,bt(M,k))}else G(M,k,ht.c,Q,Q,!0)}function Xt(M,D){var k=new Es,j=d(M.b);j.a.b=S,j.a.a=D,j.b.a.b=-S,j.b.a.a=D,M.a=j.b.a,k.a=j,k.f=0,k.d=!1,k.c=!1,k.h=!0,k.b=!1,j=M.f,j=zt(j,j.a,k),k.e=j}function It(M){this.a=new Ht,this.b=M,this.c=R}function zt(M,D,k){do D=D.c;while(D.b!==null&&!M.c(M.b,D.b,k));return M=new Ht(k,D.a,D),D.a.c=M,D.a=M}function Ht(M,D,k){this.b=M||null,this.a=D||this,this.c=k||this}function Lt(){this.d=tr,this.p=this.b=this.q=null,this.j=[0,0,0],this.s=100130,this.n=!1,this.o=this.a=this.e=this.f=null,this.m=!1,this.c=this.r=this.i=this.k=this.l=this.h=null}var tr=0;e=Lt.prototype,e.x=function(){Gr(this,tr)},e.B=function(M,D){switch(M){case 100142:return;case 100140:switch(D){case 100130:case 100131:case 100132:case 100133:case 100134:this.s=D;return}break;case 100141:this.m=!!D;return;default:re(this,100900);return}re(this,100901)},e.y=function(M){switch(M){case 100142:return 0;case 100140:return this.s;case 100141:return this.m;default:re(this,100900)}return!1},e.A=function(M,D,k){this.j[0]=M,this.j[1]=D,this.j[2]=k},e.z=function(M,D){var k=D||null;switch(M){case 100100:case 100106:this.h=k;break;case 100104:case 100110:this.l=k;break;case 100101:case 100107:this.k=k;break;case 100102:case 100108:this.i=k;break;case 100103:case 100109:this.p=k;break;case 100105:case 100111:this.o=k;break;case 100112:this.r=k;break;default:re(this,100900)}},e.C=function(M,D){var k=!1,j=[0,0,0];Gr(this,2);for(var Q=0;3>Q;++Q){var ft=M[Q];-1e150>ft&&(ft=-1e150,k=!0),1e150<ft&&(ft=1e150,k=!0),j[Q]=ft}k&&re(this,100155),k=this.q,k===null?(k=d(this.b),f(k,k.b)):(p(k),k=k.e),k.a.d=D,k.a.g[0]=j[0],k.a.g[1]=j[1],k.a.g[2]=j[2],k.f=1,k.b.f=-1,this.q=k},e.u=function(M){Gr(this,tr),this.d=1,this.b=new At,this.c=M},e.t=function(){Gr(this,1),this.d=2,this.q=null},e.v=function(){Gr(this,2),this.d=1},e.w=function(){Gr(this,1),this.d=tr;var M=this.j[0],D=this.j[1],k=this.j[2],j=!1,Q=[M,D,k];if(M===0&&D===0&&k===0){for(var D=[-2*1e150,-2*1e150,-2*1e150],ft=[2*1e150,2*1e150,2*1e150],k=[],ht=[],j=this.b.c,M=j.e;M!==j;M=M.e)for(var ge=0;3>ge;++ge){var Ge=M.g[ge];Ge<ft[ge]&&(ft[ge]=Ge,ht[ge]=M),Ge>D[ge]&&(D[ge]=Ge,k[ge]=M)}if(M=0,D[1]-ft[1]>D[0]-ft[0]&&(M=1),D[2]-ft[2]>D[M]-ft[M]&&(M=2),ft[M]>=D[M])Q[0]=0,Q[1]=0,Q[2]=1;else{for(D=0,ft=ht[M],k=k[M],ht=[0,0,0],ft=[ft.g[0]-k.g[0],ft.g[1]-k.g[1],ft.g[2]-k.g[2]],ge=[0,0,0],M=j.e;M!==j;M=M.e)ge[0]=M.g[0]-k.g[0],ge[1]=M.g[1]-k.g[1],ge[2]=M.g[2]-k.g[2],ht[0]=ft[1]*ge[2]-ft[2]*ge[1],ht[1]=ft[2]*ge[0]-ft[0]*ge[2],ht[2]=ft[0]*ge[1]-ft[1]*ge[0],Ge=ht[0]*ht[0]+ht[1]*ht[1]+ht[2]*ht[2],Ge>D&&(D=Ge,Q[0]=ht[0],Q[1]=ht[1],Q[2]=ht[2]);0>=D&&(Q[0]=Q[1]=Q[2]=0,Q[x(ft)]=1)}j=!0}for(ht=x(Q),M=this.b.c,D=(ht+1)%3,k=(ht+2)%3,ht=0<Q[ht]?1:-1,Q=M.e;Q!==M;Q=Q.e)Q.b=Q.g[D],Q.a=ht*Q.g[k];if(j){for(Q=0,j=this.b.a,M=j.b;M!==j;M=M.b)if(D=M.a,!(0>=D.f))do Q+=(D.a.b-D.b.a.b)*(D.a.a+D.b.a.a),D=D.e;while(D!==M.a);if(0>Q)for(Q=this.b.c,j=Q.e;j!==Q;j=j.e)j.a=-j.a}for(this.n=!1,Q=this.b.b,M=Q.h;M!==Q;M=j)j=M.h,D=M.e,r(M.a,M.b.a)&&M.e.e!==M&&(q(this,D,M),g(M),M=D,D=M.e),D.e===M&&(D!==M&&((D===j||D===j.b)&&(j=j.h),g(D)),(M===j||M===j.b)&&(j=j.h),g(M));for(this.e=Q=new de,j=this.b.c,M=j.e;M!==j;M=M.e)M.h=De(Q,M);for(Rt(Q),this.f=new It(this),Xt(this,-S),Xt(this,S);(Q=st(this.e))!==null;){for(;;){t:if(M=this.e,M.a===0)j=ws(M.b);else if(j=M.c[M.d[M.a-1]],M.b.a!==0&&(M=ws(M.b),i(M,j))){j=M;break t}if(j===null||!r(j,Q))break;j=st(this.e),q(this,Q.c,j.c)}ct(this,Q)}for(this.a=this.f.a.a.b.a.a,Q=0;(j=this.f.a.a.b)!==null;)j.h||++Q,B(j);for(this.f=null,Q=this.e,Q.b=null,Q.d=null,this.e=Q.c=null,Q=this.b,M=Q.a.b;M!==Q.a;M=j)j=M.b,M=M.a,M.e.e===M&&(T(M.c,M),g(M));
569if(!this.n){if(Q=this.b,this.m)for(M=Q.b.h;M!==Q.b;M=j)j=M.h,M.b.d.c!==M.d.c?M.f=M.d.c?1:-1:g(M);else for(M=Q.a.b;M!==Q.a;M=j)if(j=M.b,M.c){for(M=M.a;i(M.b.a,M.a);M=M.c.b);for(;i(M.a,M.b.a);M=M.e);for(D=M.c.b,k=void 0;M.e!==D;)if(i(M.b.a,D.a)){for(;D.e!==M&&(c(D.e)||0>=o(D.a,D.b.a,D.e.b.a));)k=m(D.e,D),D=k.b;D=D.c.b}else{for(;D.e!==M&&(h(M.c.b)||0<=o(M.b.a,M.a,M.c.b.a));)k=m(M,M.c.b),M=k.b;M=M.e}for(;D.e.e!==M;)k=m(D.e,D),D=k.b}if(this.h||this.i||this.k||this.l)if(this.m){for(Q=this.b,j=Q.a.b;j!==Q.a;j=j.b)if(j.c){this.h&&this.h(2,this.c),M=j.a;do this.k&&this.k(M.a.d,this.c),M=M.e;while(M!==j.a);this.i&&this.i(this.c)}}else{for(Q=this.b,j=!!this.l,M=!1,D=-1,k=Q.a.d;k!==Q.a;k=k.d)if(k.c){M||(this.h&&this.h(4,this.c),M=!0),ht=k.a;do j&&(ft=ht.b.d.c?0:1,D!==ft&&(D=ft,this.l&&this.l(!!D,this.c))),this.k&&this.k(ht.a.d,this.c),ht=ht.e;while(ht!==k.a)}M&&this.i&&this.i(this.c)}if(this.r){for(Q=this.b,M=Q.a.b;M!==Q.a;M=j)if(j=M.b,!M.c){D=M.a,k=D.e,ht=void 0;do ht=k,k=ht.e,ht.d=null,ht.b.d===null&&(ht.c===ht?E(ht.a,null):(ht.a.c=ht.c,b(ht,rt(ht))),ft=ht.b,ft.c===ft?E(ft.a,null):(ft.a.c=ft.c,b(ft,rt(ft))),w(ht));while(ht!==D);D=M.d,M=M.b,M.d=D,D.b=M}this.r(this.b),this.c=this.b=null;return}}this.b=this.c=null};function Gr(M,D){if(M.d!==D)for(;M.d!==D;)if(M.d<D)switch(M.d){case tr:re(M,100151),M.u(null);break;case 1:re(M,100152),M.t()}else switch(M.d){case 2:re(M,100154),M.v();break;case 1:re(M,100153),M.w()}}function re(M,D){M.p&&M.p(D,M.c)}function ci(M,D){this.b=M||this,this.d=D||this,this.a=null,this.c=!1}function Dt(){this.h=this,this.i=this.d=this.a=this.e=this.c=this.b=null,this.f=0}function rt(M){return M.b.e}function At(){this.c=new Vt,this.a=new ci,this.b=new Dt,this.d=new Dt,this.b.b=this.d,this.d.b=this.b}function Vt(M,D){this.e=M||this,this.f=D||this,this.d=this.c=null,this.g=[0,0,0],this.h=this.a=this.b=0}function de(){this.c=[],this.d=null,this.a=0,this.e=!1,this.b=new ve}function Rt(M){M.d=[];for(var D=0;D<M.a;D++)M.d[D]=D;M.d.sort((function(k){return function(j,Q){return i(k[j],k[Q])?1:-1}})(M.c)),M.e=!0,mi(M.b)}function De(M,D){if(M.e){var k=M.b,j=++k.a;2*j>k.f&&(k.f*=2,k.c=Ct(k.c,k.f+1));var Q;return k.b===0?Q=j:(Q=k.b,k.b=k.c[k.b]),k.e[Q]=D,k.c[Q]=j,k.d[j]=Q,k.h&&mo(k,j),Q}return k=M.a++,M.c[k]=D,-(k+1)}function st(M){if(M.a===0)return $r(M.b);var D=M.c[M.d[M.a-1]];if(M.b.a!==0&&i(ws(M.b),D))return $r(M.b);do--M.a;while(0<M.a&&M.c[M.d[M.a-1]]===null);return D}function ve(){this.d=Ct([0],33),this.e=[null,null],this.c=[0,0],this.a=0,this.f=32,this.b=0,this.h=!1,this.d[1]=1}function Ct(M,D){for(var k=Array(D),j=0;j<M.length;j++)k[j]=M[j];for(;j<D;j++)k[j]=0;return k}function mi(M){for(var D=M.a;1<=D;--D)Ne(M,D);M.h=!0}function ws(M){return M.e[M.d[1]]}function $r(M){var D=M.d,k=M.e,j=M.c,Q=D[1],ft=k[Q];return 0<M.a&&(D[1]=D[M.a],j[D[1]]=1,k[Q]=null,j[Q]=M.b,M.b=Q,0<--M.a&&Ne(M,1)),ft}function Ne(M,D){for(var k=M.d,j=M.e,Q=M.c,ft=D,ht=k[ft];;){var ge=ft<<1;ge<M.a&&i(j[k[ge+1]],j[k[ge]])&&(ge+=1);var Ge=k[ge];if(ge>M.a||i(j[ht],j[Ge])){k[ft]=ht,Q[ht]=ft;break}k[ft]=Ge,Q[Ge]=ft,ft=ge}}function mo(M,D){for(var k=M.d,j=M.e,Q=M.c,ft=D,ht=k[ft];;){var ge=ft>>1,Ge=k[ge];if(ge===0||i(j[Ge],j[ht])){k[ft]=ht,Q[ht]=ft;break}k[ft]=Ge,Q[Ge]=ft,ft=ge}}function Es(){this.e=this.a=null,this.f=0,this.c=this.b=this.h=this.d=!1}function z(M){return M.e.c.b}function ut(M){return M.e.a.b}vat.libtess={GluTesselator:Lt,windingRule:{GLU_TESS_WINDING_ODD:100130,GLU_TESS_WINDING_NONZERO:100131,GLU_TESS_WINDING_POSITIVE:100132,GLU_TESS_WINDING_NEGATIVE:100133,GLU_TESS_WINDING_ABS_GEQ_TWO:100134},primitiveType:{GL_LINE_LOOP:2,GL_TRIANGLES:4,GL_TRIANGLE_STRIP:5,GL_TRIANGLE_FAN:6},errorType:{GLU_TESS_MISSING_BEGIN_POLYGON:100151,GLU_TESS_MISSING_END_POLYGON:100153,GLU_TESS_MISSING_BEGIN_CONTOUR:100152,GLU_TESS_MISSING_END_CONTOUR:100154,GLU_TESS_COORD_TOO_LARGE:100155,GLU_TESS_NEED_COMBINE_CALLBACK:100156},gluEnum:{GLU_TESS_MESH:100112,GLU_TESS_TOLERANCE:100142,GLU_TESS_WINDING_RULE:100140,GLU_TESS_BOUNDARY_ONLY:100141,GLU_INVALID_ENUM:100900,GLU_INVALID_VALUE:100901,GLU_TESS_BEGIN:100100,GLU_TESS_VERTEX:100101,GLU_TESS_END:100102,GLU_TESS_ERROR:100103,GLU_TESS_EDGE_FLAG:100104,GLU_TESS_COMBINE:100105,GLU_TESS_BEGIN_DATA:100106,GLU_TESS_VERTEX_DATA:100107,GLU_TESS_END_DATA:100108,GLU_TESS_ERROR_DATA:100109,GLU_TESS_EDGE_FLAG_DATA:100110,GLU_TESS_COMBINE_DATA:100111}},Lt.prototype.gluDeleteTess=Lt.prototype.x,Lt.prototype.gluTessProperty=Lt.prototype.B,Lt.prototype.gluGetTessProperty=Lt.prototype.y,Lt.prototype.gluTessNormal=Lt.prototype.A,Lt.prototype.gluTessCallback=Lt.prototype.z,Lt.prototype.gluTessVertex=Lt.prototype.C,Lt.prototype.gluTessBeginPolygon=Lt.prototype.u,Lt.prototype.gluTessBeginContour=Lt.prototype.t,Lt.prototype.gluTessEndContour=Lt.prototype.v,Lt.prototype.gluTessEndPolygon=Lt.prototype.w,t.exports=vat.libtess})(PH)),PH.exports}var QFt=JFt();Eo=Sv(QFt);function tNt(t,e){e[e.length]=t[0],e[e.length]=t[1]}function eNt(t){t!==Eo.primitiveType.GL_TRIANGLES&&console.log("expected TRIANGLES but got type: "+t)}
569function rNt(t){console.log("error callback"),console.log("error number: "+t)}function iNt(t,e,r){return[t[0],t[1],t[2]]}function sNt(t){}function oNt(t,e){const r=new Eo.GluTesselator;r.gluTessProperty(Eo.gluEnum.GLU_TESS_WINDING_RULE,e==="evenodd"?Eo.windingRule.GLU_TESS_WINDING_ODD:Eo.windingRule.GLU_TESS_WINDING_NONZERO),r.gluTessCallback(Eo.gluEnum.GLU_TESS_VERTEX_DATA,tNt),r.gluTessCallback(Eo.gluEnum.GLU_TESS_BEGIN,eNt),r.gluTessCallback(Eo.gluEnum.GLU_TESS_ERROR,rNt),r.gluTessCallback(Eo.gluEnum.GLU_TESS_COMBINE,iNt),r.gluTessCallback(Eo.gluEnum.GLU_TESS_EDGE_FLAG,sNt),r.gluTessNormal(0,0,1);const i=[];r.gluTessBeginPolygon(i);for(let s=0;s<t.length;s++){r.gluTessBeginContour();const o=t[s];for(let n=0;n<o.length;n++){const a=[o[n][0],o[n][1],0];r.gluTessVertex(a,a)}r.gluTessEndContour()}return r.gluTessEndPolygon(),i}PV=function(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort((n,a)=>a.h-n.h);const i=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let s=0,o=0;for(const n of t)for(let a=i.length-1;a>=0;a--){const l=i[a];if(!(n.w>l.w||n.h>l.h)){if(n.x=l.x,n.y=l.y,o=Math.max(o,n.y+n.h),s=Math.max(s,n.x+n.w),n.w===l.w&&n.h===l.h){const c=i.pop();a<i.length&&(i[a]=c)}else n.h===l.h?(l.x+=n.w,l.w-=n.w):n.w===l.w?(l.y+=n.h,l.h-=n.h):(i.push({x:l.x+n.w,y:l.y,w:l.w-n.w,h:n.h}),l.y+=n.h,l.h-=n.h);break}}return{w:s,h:o,fill:e/(s*o)||0}};function nNt(t,{width:e,height:r},i,s){if(!s)s=new Uint8Array(e*r*i);else if(s.length!==e*r*i)throw new RangeError("mismatched image size");return t.width=e,t.height=r,t.data=s,t}function aNt(t,e,r,i,s,o){if(s.width===0||s.height===0)return e;if(s.width>t.width||s.height>t.height||r.x>t.width-s.width||r.y>t.height-s.height)throw new RangeError("out of range source coordinates for image copy");if(s.width>e.width||s.height>e.height||i.x>e.width-s.width||i.y>e.height-s.height)throw new RangeError("out of range destination coordinates for image copy");const n=t.data,a=e.data;for(let l=0;l<s.height;l++){const c=((r.y+l)*t.width+r.x)*o,h=((i.y+l)*e.width+i.x)*o;for(let u=0;u<s.width*o;u++)a[h+u]=n[c+u]}return e}let FH=class{constructor(t,e){nNt(this,t,4,e)}static copy(t,e,r,i,s){aNt(t,e,r,i,s,4)}};const lNt=(t,e,r,i,s)=>{const o=r+s*2,n=i+s*2,a=o*n,{outer:l,inner:c}=t;l.fill(gu,0,a),c.fill(0,0,a);const h=(u,d)=>{var f;return((f=e[4*(d*r+u)+3])!==null&&f!==void 0?f:0)/255};for(let u=0;u<i;u++)for(let d=0;d<r;d++){const f=h(d,u),g=(u+s)*o+d+s;if(f>=254/255)e[4*(u*r+d)+3]=255,l[g]=0,c[g]=gu;else if(f>0){const p=.5-f;l[g]=p>0?p*p:0,c[g]=p<0?p*p:0}}},cNt=(t,e,r,i=4,s=3,o=.25)=>{const n=e+i*2,a=r+i*2,l=n*a,c=Math.max(n,a),h=new Uint8Array(l),u=Aat(c);lNt(u,t,e,r,i);const{outer:d,inner:f,f:g,z:p,v:m}=u;Sat(d,0,0,n,a,n,g,p,m),Sat(f,i,i,e,r,n,g,p,m);for(let v=0;v<l;v++){const b=Math.sqrt(d[v])-Math.sqrt(f[v]);h[v]=Math.max(0,Math.min(255,Math.round(255-255*(b/s+o))))}return Eat(h,n,a)},hNt=(t,e,r,i,s)=>{const o=r+s*2,n=i+s*2,a=o*n,{outer:l,inner:c}=t;l.fill(gu,0,a),c.fill(0,0,a);const h=(u,d)=>{var f;return(f=e[d*r+u])!==null&&f!==void 0?f:0};for(let u=0;u<i;u++)for(let d=0;d<r;d++){const f=h(d,u);if(!f)continue;const g=(u+s)*o+d+s;f>=254?(e[u*r+d]=255,l[g]=0,c[g]=gu):(l[g]=0,c[g]=0)}},uNt=(t,e,r,i,s,o,n)=>{const a=r+s*2,l=(c,h)=>{var u;return((u=e[h*r+c])!==null&&u!==void 0?u:0)/255};for(let c=0;c<i;c++)for(let h=0;h<r;h++){const u=l(h,c);if(!mu(u)){const d=h+s+(c+s)*a,f=.5-u;t[d]=Math.max(0,Math.min(255,Math.round(255-255*(f/o+n))))}}},dNt=(t,e,r,i,s,o,n)=>{const a=r+s*2,l=i+s*2,c=a*l,{outer:h,inner:u,xo:d,yo:f,xi:g,yi:p}=t;d.fill(0,0,c),f.fill(0,0,c),g.fill(0,0,c),p.fill(0,0,c);const m=(y,_)=>{var w;return y>=0&&y<r&&_>=0&&_<i?((w=e[_*r+y])!==null&&w!==void 0?w:0)/255:0};for(let y=0;y<i;y++)for(let _=0;_<r;_++){const w=m(_,y),E=(y+s)*a+_+s;if(mu(w)){if(vNt(w)){const A=m(_-1,y),x=m(_+1,y),S=m(_,y-1),T=m(_,y+1);T5(A)&&(d[E-1]=.4999,h[E-1]=0,u[E-1]=0),T5(x)&&(d[E+1]=-.4999,h[E+1]=0,u[E+1]=0),T5(S)&&(f[E-a]=.4999,h[E-a]=0,u[E-a]=0),T5(T)&&(f[E+a]=-.4999,h[E+a]=0,u[E+a]=0)}}else{const A=w-.5,x=m(_-1,y),S=m(_+1,y),T=m(_,y-1),R=m(_,y+1),B=m(_-1,y-1),O=m(_+1,y-1),C=m(_-1,y+1),F=m(_+1,y+1),U=(B+x*2+C)/4,H=(O+S*2+F)/4,N=(B+T*2+O)/4,G=(C+R*2+F)/4,Y=Math.min(x,S,T,R,B,O,C,F),q=Math.max(x,S,T,R,B,O,C,F);if(Y>0){u[E]=gu;continue}if(q<1){h[E]=gu;continue}let L=H-U,J=G-N;const tt=1/Math.sqrt(Am(L)+Am(J));L*=tt,J*=tt,d[E]=-A*L,f[E]=-A*J}}let v=d,b=f;if(o){const y=(_,w,E,A,x,S,T,R,B)=>(S*_+T*w)*(E*A)>0&&(R*_+B*w)*(E*x)>0&&(S*R+T*B)*(A*x)>0;for(let _=0;_<i;_++)for(let w=0;w<r;w++){const E=(_+s)*a+w+s,A=d[E],x=f[E];if(!A&&!x)continue;const S=m(w,_),T=m(w-1,_),R=m(w+1,_),B=m(w,_-1),O=m(w,_+1),C=d[E-1],F=d[E+1],U=d[E-a],H=d[E+a],N=f[E-1],G=f[E+1],Y=f[E-a],q=f[E+a];let L=A,J=x,tt=1;const bt=S-.5,ct=T-.5,Xt=R-.5,It=B-.5,zt=O-.5;!mu(T)&&!mu(R)&&y(A,x,bt,ct,Xt,C,N,F,G)&&(L+=(C+F)/2,J+=(N+G)/2,tt++),!mu
569(B)&&!mu(O)&&y(A,x,bt,It,zt,U,Y,H,q)&&(L+=(U+H)/2,J+=(Y+q)/2,tt++),!mu(T)&&!mu(B)&&y(A,x,bt,ct,It,C,N,U,Y)&&(L+=(C+U-1)/2,J+=(N+Y-1)/2,tt++),!mu(R)&&!mu(B)&&y(A,x,bt,Xt,It,F,G,U,Y)&&(L+=(F+U+1)/2,J+=(G+Y-1)/2,tt++),!mu(T)&&!mu(O)&&y(A,x,bt,ct,zt,C,N,H,q)&&(L+=(C+H-1)/2,J+=(N+q+1)/2,tt++),!mu(R)&&!mu(O)&&y(A,x,bt,Xt,zt,F,G,H,q)&&(L+=(F+H+1)/2,J+=(G+q+1)/2,tt++);const Ht=Math.sqrt(A*A+x*x),Lt=(L*A+J*x)/Ht;L=A*Lt/tt/Ht,J=x*Lt/tt/Ht,g[E]=L,p[E]=J}v=g,b=p}for(let y=0;y<i;y++)for(let _=0;_<r;_++){const w=(y+s)*a+_+s,E=v[w],A=b[w];if(!E&&!A)continue;const x=Math.sqrt(Am(E)+Am(A)),S=Math.abs(E/x)-.5>0?Math.sign(E):0,T=Math.abs(A/x)-.5>0?Math.sign(A):0,R=m(_,y),B=m(_+S,y+T),O=Math.sign(B-R);let C=x+.4999*O,F=x-.4999*O;F/=x,C/=x,d[w]=E*C,f[w]=A*C,g[w]=E*F,p[w]=A*F}},fNt=(t,e,r,i,s)=>{const o=r+s*2,{xo:n,yo:a,xi:l,yi:c}=t,h=(d,f,g,p,m,v,b,y,_,w)=>{const E=(p+s)*o+g+s,A=m+d[E],x=v+f[E],S=Math.sqrt(Am(A)+Am(x));return S<_?(d[w]=A,f[w]=x,S):_},u=(d,f)=>{for(let g=0;g<i;g++)for(let p=0;p<r;p++){const m=(g+s)*o+p+s,v=d[m],b=f[m];if(!v&&!b)continue;let y=Math.sqrt(v*v+b*b);const _=(y-.5)/y,w=p+v*_,E=g+b*_,A=Math.round(w),x=Math.round(E);y=h(d,f,A+1,x,A-p+1,x-g,w,E,y,m),y=h(d,f,A-1,x,A-p-1,x-g,w,E,y,m),y=h(d,f,A,x+1,A-p,x-g+1,w,E,y,m),y=h(d,f,A,x-1,A-p,x-g-1,w,E,y,m)}};u(n,a),u(l,c)},pNt=(t,e,r,i,s,o,n)=>{const a=s+n*2,l=o+n*2;{let c=0,h=(n+n*a)*4;for(let u=0;u<o;u++){for(let d=0;d<s;d++)e[c+3]&&(t[h]=e[c],t[h+1]=e[c+1],t[h+2]=e[c+2],t[h+3]=e[c+3]),c+=4,h+=4;h+=n*8}}{let c=0,h=0;for(let u=0;u<l;u++)for(let d=0;d<a;d++){if(t[c+3]===0){const f=r[h],g=i[h],p=Math.round(d+f),m=Math.round(u+g),v=(p+m*a)*4;t[c]=t[v],t[c+1]=t[v+1],t[c+2]=t[v+2],t[c+3]=1}c+=4,h++}}},gNt=(t,e,r,i,s)=>{const o=r+s*2;let n=0,a=(s+s*o)*4;for(let l=0;l<i;l++){for(let c=0;c<r;c++)t[a+3]=e[n],n++,a+=4;a+=s*8}},bat=(t,e,r,i,s,o,n,a,l,c,h)=>{h[0]=0,l[0]=e[i],c[0]=r[i],a[0]=-gu,a[1]=gu,n[0]=t[i]?gu:r[i]*r[i];let u=0;for(let d=1,f=0;d<o;d++){const g=i+d*s,p=e[g],m=r[g],v=n[d]=t[g]?gu:m*m;c[d]=m;const b=d+p,y=b*b;l[d]=b;do{const _=h[u],w=l[_],E=w*w;f=(v-n[_]+y-E)/(b-w)/2}while(f<=a[u]&&--u>-1);u++,h[u]=d,a[u]=f,a[u+1]=gu}for(let d=0,f=0;d<o;d++){for(;a[f+1]<d;)f++;const g=h[f],p=l[g],m=c[g],v=p-d,b=i+d*s;e[b]=v,r[b]=m,g!==d&&(t[b]=0)}},wat=(t,e,r,i,s,o,n,a,l,c,h=0)=>{if(h!==1)for(let u=0;u<i;++u)bat(t,r,e,u,i,s,o,n,a,l,c);if(h!==2)for(let u=0;u<s;++u)bat(t,e,r,u*i,1,i,o,n,a,l,c)},mNt=(t,e,r,i,s=4,o=3,n=.25,a=!1,l=!1)=>{const c=r+s*2,h=i+s*2,u=c*h,d=Math.max(c,h),f=Aat(d),{outer:g,inner:p,xo:m,yo:v,xi:b,yi:y,f:_,z:w,b:E,t:A,v:x}=f;hNt(f,t,r,i,s),dNt(f,t,r,i,s,a),wat(g,m,v,c,h,_,w,E,A,x),wat(p,b,y,c,h,_,w,E,A,x),l&&fNt(f,t,r,i,s);const S=new Uint8Array(u);for(let T=0;T<u;++T){const R=Math.max(0,Math.sqrt(Am(m[T])+Am(v[T]))-.5),B=Math.max(0,Math.sqrt(Am(b[T])+Am(y[T]))-.5),O=R>=B?R:-B;S[T]=Math.max(0,Math.min(255,Math.round(255-255*(O/o+n))))}if(a||uNt(S,t,r,i,s,o,n),e){const T=new Uint8Array(u*4);return pNt(T,e,m,v,r,i,s),gNt(T,S,c,h,0),{data:T,width:c,height:h}}else return Eat(S,c,h)},Eat=(t,e,r,i=0)=>{const s=e+i*2,o=r+i*2,n=new Uint8Array(s*o*4);for(let a=0;a<t.length;a++)n[a*4]=t[a],n[a*4+1]=t[a],n[a*4+2]=t[a],n[a*4+3]=t[a];return{data:n,width:s,height:o}},gu=1e10,Aat=t=>{const e=t*t,r=new Float32Array(e),i=new Float32Array(e),s=new Float32Array(e),o=new Float32Array(e),n=new Float32Array(e),a=new Float32Array(e),l=new Float32Array(t),c=new Float32Array(t+1),h=new Float32Array(t),u=new Float32Array(t),d=new Uint16Array(t);return{outer:r,inner:i,xo:s,yo:o,xi:n,yi:a,f:l,z:c,b:h,t:u,v:d,size:t}};let yNt=class{constructor({fontSize:t=24,buffer:e=3,radius:r=8,cutoff:i=.25,fontFamily:s="sans-serif",fontWeight:o="normal",fontStyle:n="normal",fill:a="black"}={}){this.buffer=e,this.cutoff=i,this.radius=r;const l=this.size=t+e*4,c=Bo.get().createCanvas(l,l),h=this.ctx=c.getContext("2d",{willReadFrequently:!0});h.font=`${n} ${o} ${t}px ${s}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle=a}draw(t,e=!1,r=!1){const{width:i,actualBoundingBoxAscent:s,actualBoundingBoxDescent:o,actualBoundingBoxLeft:n,actualBoundingBoxRight:a}=this.ctx.measureText(t),l=Math.ceil(s),c=0,h=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-n))
569),u=Math.min(this.size-this.buffer,l+Math.ceil(o));if(h===0||u===0){const y=h+2*this.buffer,_=u+2*this.buffer,w=Math.max(y*_,0);return{data:new Uint8ClampedArray(w*4),width:y,height:_,glyphWidth:h,glyphHeight:u,glyphTop:l,glyphLeft:c,glyphAdvance:i}}const d=this.buffer,{ctx:f,buffer:g}=this;f.clearRect(g,g,h,u),f.fillText(t,g,g+l);const p=f.getImageData(g,g,h,u);let m,v,b;if(e){const y=new Uint8ClampedArray(p.data.length/4);for(let _=0;_<p.data.length;_+=4)y[_/4]=p.data[_+3];({data:m,width:v,height:b}=mNt(y,r?p.data:null,h,u,d,this.radius,this.cutoff))}else({data:m,width:v,height:b}=cNt(p.data,h,u,d,this.radius,this.cutoff));return{data:m,width:v,height:b,glyphWidth:h,glyphHeight:u,glyphTop:l,glyphLeft:c,glyphAdvance:i}}};const xat=(t,e,r,i,s,o,n)=>{n[0]=0,o[0]=-gu,o[1]=gu,s[0]=t[e];for(let a=1,l=0,c=0;a<i;a++){s[a]=t[e+a*r];const h=a*a;do{const u=n[l];c=(s[a]-s[u]+h-u*u)/(a-u)/2}while(c<=o[l]&&--l>-1);l++,n[l]=a,o[l]=c,o[l+1]=gu}for(let a=0,l=0;a<i;a++){for(;o[l+1]<a;)l++;const c=n[l],h=a-c,u=s[c];t[e+a*r]=u+h*h}},Sat=(t,e,r,i,s,o,n,a,l,c)=>{for(let h=r;h<r+s;h++)xat(t,h*o+e,1,i,n,a,l);for(let h=e;h<e+i;h++)xat(t,r*o+h,o,s,n,a,l)},T5=t=>!t,vNt=t=>t===1,mu=t=>!(t&&1-t),Am=t=>t*t,fd=2,Tat=24*fd,Rat=3*fd,_Nt=8*fd;function bNt(){const t=[];for(let e=32;e<128;e++)t.push(String.fromCharCode(e));return t}let wNt=class{constructor(){this.sdfGeneratorCache={},this.glyphMap={}}destroy(){this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy()}getMap(){return this.glyphMap}getAtlas(){return this.glyphAtlas}getAtlasTexture(){return this.glyphAtlasTexture}layout(t,e,r,i,s,o,n,a,l,c,h,u,d){const f=[];let g=l??0,p=c??0;const m=i==="right"||i==="end"?1:i==="left"||i==="start"?0:.5,v=u==="right";let b=0,y;return h&&TI(h).subPaths.forEach(_=>{y=_,b+=_.getLength()}),t.forEach(_=>{let w=0;const E=f.length;let A;Bo.get().splitGraphemes(_).forEach(T=>{let R,B=0;if(o){const C=o.chars[T];R=C.xAdvance,B=a&&A&&C.kerning[A]||0}else{const C=this.glyphMap[e];R=(C&&C[T]).metrics.advance}const O=(R+B)*n+s;f.push({glyph:T,x:g,y:p,scale:n,fontStack:e,width:O}),g+=O,A=T});const x=g-s;for(let T=E;T<f.length;T++)f[T].x-=m*x;g=0,p+=r;const S=f.length-E;if(h){i==="left"?w=v?b-x:0:i==="right"?w=v?0:b-x:i==="center"&&(w=(b-x)/2),w+=d*(v?-1:1);for(let T=v?S-1:0;v?T>=0:T<S;v?T--:T++){const R=f[T];w>b?w%=b:w<0&&(w+=b),this.layoutOnPath(y,w,b,R),w+=R.width}}}),f}layoutOnPath(t,e,r,i){const s=(e+i.width/2)/r,o=t.getPointAt(s),n=t.getTangentAt(s),a=Math.atan2(n[1],n[0]);o&&(i.x=o[0],i.y=o[1],i.rotation=a)}generateAtlas(t="",e,r,i="",s,o,n,a){let l=[];this.glyphMap[t]||(l=bNt());const c=Object.keys(this.glyphMap[t]||{});if(Array.from(new Set(Bo.get().splitGraphemes(s))).forEach(h=>{c.indexOf(h)===-1&&l.push(h)}),l.length){const h=l.map(g=>this.generateSDF(t,e,r,i,g,n,a)).reduce((g,p)=>(g[p.id]=p,g),{});this.glyphMap[t]=Object.assign(Object.assign({},this.glyphMap[t]),h),this.glyphAtlas=new ENt(this.glyphMap);const{width:u,height:d,data:f}=this.glyphAtlas.image;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=o.createTexture(Object.assign({},Stt(I.U8_RGBA_NORM,u,d,1))),this.glyphAtlasTexture.setImageData([f])}}generateSDF(t="",e,r,i,s,o,n){let a=this.sdfGeneratorCache[t+n];a||(a=this.sdfGeneratorCache[t+n]=new yNt({fontSize:Tat,fontFamily:e,fontWeight:r,fontStyle:i,buffer:Rat,radius:_Nt,fill:n}));const{data:l,width:c,height:h,glyphWidth:u,glyphHeight:d,glyphLeft:f,glyphTop:g,glyphAdvance:p}=a.draw(s,o,!!n);return{id:s,bitmap:new FH({width:c,height:h},l),metrics:{width:u/fd,height:d/fd,left:f/fd,top:g/fd,advance:p/fd}}}};const Cat=1,R5=Cat*fd;let ENt=class{constructor(t){const e={},r=[];for(const n in t){const a=t[n],l=e[n]={};for(const c in a){const h=a[c];if(!h||h.bitmap.width===0||h.bitmap.height===0)continue;const u={x:0,y:0,w:h.bitmap.width+2*R5,h:h.bitmap.height+2*R5};r.push(u),l[c]={rect:u,metrics:h.metrics}}}const{w:i,h:s}=PV(r),o=new FH({width:i||1,height:s||1});for(const n in t){const a=t[n];for(const l in a){const c=a[l];if(!c||c.bitmap.width===0||c.bitmap.height===0)continue;const h=e[n][l].rect;FH.copy(c.bitmap,o,{x:0,y:0},{x:h.x+R5,y:h.y+R5},c.bitmap)}}this.image=o,this.positions=e}};function ANt(t,e,r){var i;const s=[];for(let o=0;o<t.length;o++){const n=t[o],a=e[n.fontStack],l=a&&a[n.glyph];if(!l)continue;const{rect:c,metrics:h}=l;if(!c)continue;const{x:u,y:d,scale:f,width:g}=n,p=r?0:Rat/fd+Cat,m=1,v=c.w*f/(m*(r?1:fd)),b=c.h*f/(m*(r?1:fd)),y=(h.left-p)*n.scale+u,_=(-h.top-p)*n.scale+d,w=y+v,E=_+b,A={x:y,y:_},x={x:w,y:_},S={x:y,y:E},T={x:w,y:E};s.push({tl:A,tr:x,bl:S,br:T,tex:c,rotation:(i=n.rotation)!==null&&i!==void 0?i:0,width:g})}return s}const Mat={test(t){return typeof t=="string"&&t.startsWith("info face=")},parse(t){var e,r,i;const s=t.match(/^[a-z]+\s+.+$/gm),o={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const g in s){const p=s[g].match(/^[a-z]+/gm)[0],m=s[g].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),v={};for(const b in m){const y=m[b].split("="),_=y[0],w=y[1].replace(/"/gm,""),E=parseFloat(w),A=isNaN(E)?w:E;v[_]=A}o[p].push(v)}const n={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0}
569,[a]=o.info,[l]=o.common,[c]=(e=o.distanceField)!==null&&e!==void 0?e:[];c&&(n.distanceField={range:parseInt(c.distanceRange,10),type:c.fieldType}),n.fontSize=parseInt(a.size,10),n.fontFamily=a.face,n.lineHeight=parseInt(l.lineHeight,10);const h=o.page;for(let g=0;g<h.length;g++)n.pages.push({id:parseInt(h[g].id,10)||0,file:h[g].file});const u={};n.baseLineOffset=n.lineHeight-parseInt(l.base,10);const d=o.char;for(let g=0;g<d.length;g++){const p=d[g],m=parseInt(p.id,10);let v=(i=(r=p.letter)!==null&&r!==void 0?r:p.char)!==null&&i!==void 0?i:String.fromCharCode(m);v==="space"&&(v=" "),u[m]=v,n.chars[v]={id:m,page:parseInt(p.page,10)||0,x:parseInt(p.x,10),y:parseInt(p.y,10),width:parseInt(p.width,10),height:parseInt(p.height,10),xOffset:parseInt(p.xoffset,10),yOffset:parseInt(p.yoffset,10),xAdvance:parseInt(p.xadvance,10),kerning:{}}}const f=o.kerning||[];for(let g=0;g<f.length;g++){const p=parseInt(f[g].first,10),m=parseInt(f[g].second,10),v=parseInt(f[g].amount,10);n.chars[u[m]].kerning[u[p]]=v}return n}};let xNt=class extends Uo{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const r in this.chars)(e=this.chars[r].texture)===null||e===void 0||e.destroy();this.chars=null,t&&(this.pages.forEach(r=>r.texture.destroy()),this.pages=null)}},SNt=class extends xNt{constructor(t){var e;super(),this.options=t;const{data:r}=this.options;Object.keys(r.chars).forEach(i=>{var s;const o=r.chars[i],n={x:o.x,y:o.y,w:o.width,h:o.height};this.chars[i]={id:i.codePointAt(0),xOffset:o.xOffset,yOffset:o.yOffset,xAdvance:o.xAdvance,kerning:(s=o.kerning)!==null&&s!==void 0?s:{},rect:n}}),this.baseRenderedFontSize=r.fontSize,this.baseMeasurementFontSize=r.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:r.fontSize},this.baseLineOffset=r.baseLineOffset,this.lineHeight=r.lineHeight,this.fontFamily=r.fontFamily,this.distanceField=(e=r.distanceField)!==null&&e!==void 0?e:{type:"none",range:0}}createTexture(t){const{images:e,data:r}=this.options,i=e.map(s=>{const o=t.createTexture({format:I.U8_RGBA_NORM,width:s.width,height:s.height,usage:xr.SAMPLED});return o.setImageData([s]),{texture:o,width:s.width,height:s.height}});Object.keys(r.pages).forEach(s=>{const o=r.pages[parseInt(s,10)],{texture:n,width:a,height:l}=i[o.id];this.pages.push({texture:n,width:a,height:l})}),Object.keys(r.chars).forEach(s=>{const o=r.chars[s],{texture:n}=i[o.page];this.chars[s].texture=n})}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy()}this.pages=null}};const Bat={test(t){const e=t;return typeof e!="string"&&"getElementsByTagName"in e&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(t){var e,r;const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},s=t.getElementsByTagName("info")[0],o=t.getElementsByTagName("common")[0],n=t.getElementsByTagName("distanceField")[0];n&&(i.distanceField={type:n.getAttribute("fieldType"),range:parseInt(n.getAttribute("distanceRange"),10)});const a=t.getElementsByTagName("page"),l=t.getElementsByTagName("char"),c=t.getElementsByTagName("kerning");i.fontSize=parseInt(s.getAttribute("size"),10),i.fontFamily=s.getAttribute("face"),i.lineHeight=parseInt(o.getAttribute("lineHeight"),10);for(let u=0;u<a.length;u++)i.pages.push({id:parseInt(a[u].getAttribute("id"),10)||0,file:a[u].getAttribute("file")});const h={};i.baseLineOffset=i.lineHeight-parseInt(o.getAttribute("base"),10);for(let u=0;u<l.length;u++){const d=l[u],f=parseInt(d.getAttribute("id"),10);let g=(r=(e=d.getAttribute("letter"))!==null&&e!==void 0?e:d.getAttribute("char"))!==null&&r!==void 0?r:String.fromCharCode(f);g==="space"&&(g=" "),h[f]=g,i.chars[g]={id:f,page:parseInt(d.getAttribute("page"),10)||0,x:parseInt(d.getAttribute("x"),10),y:parseInt(d.getAttribute("y"),10),width:parseInt(d.getAttribute("width"),10),height:parseInt(d.getAttribute("height"),10),xOffset:parseInt(d.getAttribute("xoffset"),10),yOffset:parseInt(d.getAttribute("yoffset"),10),xAdvance:parseInt(d.getAttribute("xadvance"),10),kerning:{}}}for(let u=0;u<c.length;u++){const d=parseInt(c[u].getAttribute("first"),10),f=parseInt(c[u].getAttribute("second"),10),g=parseInt(c[u].getAttribute("amount"),10);i.chars[h[f]].kerning[h[d]]=g}return i}},TNt={test(t){var e;return typeof t=="string"&&t.includes("<font>")?Bat.test((e=Bo.get().getDOMParser())===null||e===void 0?void 0:e.parseFromString(t,"text/xml")):!1},parse(t){var e;return Bat.parse((e=Bo.get().getDOMParser())===null||e===void 0?void 0:e.parseFromString(t,"text/xml"))}},Oat={test(t){try{return JSON.parse(t),!0}catch{return!1}},parse(t){var e,r,i,s;const o={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},n=JSON.parse(t),a=n.info,l=n.common,c=n.distanceField;c&&(o.distanceField={type:c.fieldType,range:c.distanceRange});const h=n.pages,u=n.chars,d=n.kernings;o.fontSize=a.size,o.fontFamily=a.face,o.lineHeight=l.lineHeight;for(let g=0;g<h.length;g++)o.pages.push({id:((e=h[g])===null||e===void 0?void 0:e.id)||0,file:((r=h[g])===null||r===void 0?void 0:r.file)||h[g]});const f={};o.baseLineOffset=o.lineHeight-l.base;for(let g=0;g<u.length;g++){const p=u[g],m=p.id;let v=(s=(i=p.letter)!==null&&i!==void 0?i:p.char)!==null&&s!==void 0?s:String.fromCharCode(m);v==="space"&&(v=" "),f[m]=v,o.chars[v]={id:m,page:p.page||0,x:p.x,y:p.y,width:p.width,height:p.height,xOffset:p.xoffset,yOffset:p.yoffset,xAdvance:p.xadvance,kerning:{}}}for(let g=0;g<d.length;g++){const p=d[g],m=p.first,v=p.second,b=p.amount;o.chars[f[v]].kerning[f[m]]=b}return o}};var Iat=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};let Dat;Dat=[".xml",".fnt"],net={test(t){return Dat.includes(t.split(".").pop().toLowerCase())},parse(t){return Iat(this,void 0,void 0,function*(){const e=Oat.test(t)?Oat.parse(t):Mat.test(t)?Mat.parse(t):TNt.parse(t),{pages:r}=e,i=[],s=e.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let n=0;n<r.length;++n){const a=r[n].file;i.push({src:a,data:s})}const o=yield Promise.all(i.map(n=>Iat(this,[n],void 0,function*({src:a}){return yield Bo.get().createImage(a)})));return new SNt({data:e,images:o})})}};function Pat(t){return/[\u{1F300}-\u{1F9FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]|[\u{1F100}-\u{1F1FF}]|[\u{1F200}-\u{1F2FF}]|[\u{1F600}-\u{1F64F}]|[\u{1F680}-\u{1F6FF}]|[\u{1F900}-\u{1F9FF}]|[\u{2B00}-\u{2BFF}]|[\u{2900}-\u{297F}]|[\u{2B00}-\u{2BFF}]|[\u{1F000}-\u{1F02F}]|[\u{1F0A0}-\u{1F0FF}]|[\u{1F100}-\u{1F64F}]|[\u{1F680}-\u{1F6FF}]|[\u{1F910}-\u{1F96B}]|[\u{1F980}-\u{1F9E0}]/u.test(t)}var pr=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},hc=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
569return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},bp,yu,vu,nf,RI,CI,wp,MI,BI,OI,C5,II;const Fat=1e-4;let Nat=class a1t{constructor(e,r){this.clipSpaceNearZ=Sh.NEGATIVE_ONE,bp.set(this,1),yu.set(this,0),vu.set(this,0),nf.set(this,0),RI.set(this,0),CI.set(this,0),wp.set(this,Bt()),MI.set(this,Bt()),BI.set(this,Bt()),OI.set(this,Bt()),C5.set(this,Bt()),II.set(this,void 0),this.projection(e,r),this.updateMatrix()}clone(){const e=new a1t(pr(this,RI,"f"),pr(this,CI,"f"));return hc(e,yu,pr(this,yu,"f"),"f"),hc(e,vu,pr(this,vu,"f"),"f"),hc(e,bp,pr(this,bp,"f"),"f"),hc(e,nf,pr(this,nf,"f"),"f"),e.updateMatrix(),e}projection(e,r){hc(this,RI,e,"f"),hc(this,CI,r,"f"),ld(pr(this,MI,"f"),e,r),this.updateViewProjectionMatrix()}updateMatrix(){const e=1/pr(this,bp,"f");Yc(pr(this,wp,"f")),bi(pr(this,wp,"f"),pr(this,wp,"f"),[pr(this,yu,"f"),pr(this,vu,"f")]),Mo(pr(this,wp,"f"),pr(this,wp,"f"),pr(this,nf,"f")),xh(pr(this,wp,"f"),pr(this,wp,"f"),[e,e]),_i(pr(this,BI,"f"),pr(this,wp,"f")),this.updateViewProjectionMatrix()}updateViewProjectionMatrix(){us(pr(this,OI,"f"),pr(this,MI,"f"),pr(this,BI,"f")),_i(pr(this,C5,"f"),pr(this,OI,"f")),this.onchange&&this.onchange()}get projectionMatrix(){return pr(this,MI,"f")}get viewMatrix(){return pr(this,BI,"f")}get viewProjectionMatrix(){return pr(this,OI,"f")}get viewProjectionMatrixInv(){return pr(this,C5,"f")}get matrix(){return pr(this,wp,"f")}get zoom(){return pr(this,bp,"f")}set zoom(e){pr(this,bp,"f")!==e&&(hc(this,bp,e,"f"),this.updateMatrix())}get x(){return pr(this,yu,"f")}set x(e){pr(this,yu,"f")!==e&&(hc(this,yu,e,"f"),this.updateMatrix())}get y(){return pr(this,vu,"f")}set y(e){pr(this,vu,"f")!==e&&(hc(this,vu,e,"f"),this.updateMatrix())}get rotation(){return pr(this,nf,"f")}set rotation(e){pr(this,nf,"f")!==e&&(hc(this,nf,e,"f"),this.updateMatrix())}get width(){return pr(this,RI,"f")}get height(){return pr(this,CI,"f")}createLandmark(e={}){return Object.assign({zoom:pr(this,bp,"f"),x:pr(this,yu,"f"),y:pr(this,vu,"f"),rotation:pr(this,nf,"f")},e)}gotoLandmark(e,r={}){const{easing:i="linear",duration:s=100,onframe:o=void 0,onfinish:n=void 0}=r,{zoom:a=pr(this,bp,"f"),x:l=pr(this,yu,"f"),y:c=pr(this,vu,"f"),rotation:h=pr(this,nf,"f"),viewportX:u=0,viewportY:d=0}=e,f=u||d,g=()=>{this.applyLandmark({x:l,y:c,zoom:a,rotation:h,viewportX:u,viewportY:d}),n&&n()};if(s===0){g();return}this.cancelLandmarkAnimation();let p;const m=[l,c],v=[a,h],b=y=>{p===void 0&&(p=y);const _=y-p;if(_>s){g();return}const w=nnt[i](_/s),E=it(),A=Be(1,0);if(ta(E,[pr(this,yu,"f"),pr(this,vu,"f")],m,w),ta(A,[this.zoom,pr(this,nf,"f")],v,w),this.applyLandmark({x:E[0],y:E[1],zoom:A[0],rotation:A[1],viewportX:u,viewportY:d}),f?za(A,v)<=Fat:za(E,m)<=Fat){g();return}_<s&&(o&&o(w),hc(this,II,Bo.get().requestAnimationFrame(b),"f"))};Bo.get().requestAnimationFrame(b)}cancelLandmarkAnimation(){pr(this,II,"f")!==void 0&&Bo.get().cancelAnimationFrame(pr(this,II,"f"))}viewport2Canvas({x:e,y:r},i){const{width:s,height:o,viewProjectionMatrixInv:n}=i||this,a=Qt(it(),[e/s*2-1,(1-r/o)*2-1],n);return{x:a[0],y:a[1]}}canvas2Viewport({x:e,y:r},i){const{width:s,height:o,viewProjectionMatrix:n}=i||this,a=Qt(it(),[e,r],n);return{x:(a[0]+1)/2*s,y:(1-(a[1]+1)/2)*o}}applyLandmark(e){const{x:r,y:i,zoom:s,rotation:o,viewportX:n,viewportY:a}=e,l=n||a;let c=0,h=0;if(l){const u=this.viewport2Canvas({x:n,y:a});c=u.x,h=u.y}if(hc(this,bp,s,"f"),hc(this,nf,o,"f"),hc(this,yu,r,"f"),hc(this,vu,i,"f"),this.updateMatrix(),l){const{x:u,y:d}=this.viewport2Canvas({x:n,y:a});hc(this,yu,pr(this,yu,"f")+(c-u),"f"),hc(this,vu,pr(this,vu,"f")+(h-d),"f"),this.updateMatrix()}}};bp=new WeakMap,yu=new WeakMap,vu=new WeakMap,nf=new WeakMap,RI=new WeakMap,CI=new WeakMap,wp=new WeakMap,MI=new WeakMap,BI=new WeakMap,OI=new WeakMap,C5=new WeakMap,II=new WeakMap;var M5;(function(t){t[t.BARYCENTRIC=0]="BARYCENTRIC"})(M5||(M5={}));const DI=` 570#ifdef USE_WIREFRAME 571 v_Barycentric = a_Barycentric; 572#endif 573`,PI=` 574#ifdef USE_WIREFRAME 575 layout(location = ${M5.BARYCENTRIC}) in vec3 a_Barycentric; 576 out vec3 v_Barycentric; 577#endif 578`,iR=` 579#ifdef USE_WIREFRAME 580 vec3 u_WireframeLineColor = vec3(0.0, 0.0, 0.0); 581 582 outputColor.xyz = mix(outputColor.xyz, u_WireframeLineColor, (1.0 - edgeFactor())); 583 if (any(lessThan(v_Barycentric, vec3(0.01)))) { 584 outputColor.a = 0.95; 585 } 586#endif 587`,sR=` 588#ifdef USE_WIREFRAME 589 in vec3 v_Barycentric; 590 591 float edgeFactor() { 592 float u_WireframeLineWidth = 1.0; 593 vec3 d = fwidth(v_Barycentric); 594 vec3 a3 = smoothstep(vec3(0.0), d * u_WireframeLineWidth, v_Barycentric); 595 return min(min(a3.x, a3.y), a3.z); 596 } 597#endif 598`,IE=1e5;let oR=class{constructor(t,e,r,i,s){this.device=t,this.renderCache=e,this.texturePool=r,this.instanced=i,this.index=s,this.uid=eH(),this.shapes=[],this.maxInstances=1/0,this.geometryDirty=!0,this.materialDirty=!0,this.destroyed=!1,this.vertexBuffers=[],this.vertexBufferDatas=[],this.vertexBufferOffsets=[],this.barycentricBufferDescriptor={arrayStri
598de:12,stepMode:ne.VERTEX,attributes:[{shaderLocation:M5.BARYCENTRIC,offset:0,format:I.F32_RGB}]}}destroy(){var t;this.program&&((t=this.indexBuffer)===null||t===void 0||t.destroy(),this.vertexBuffers.forEach(e=>e.destroy()),this.vertexBuffers=[],this.vertexBufferDatas=[],this.vertexBufferDescriptors=[]),this.destroyed=!0}validate(t){var e;return((e=this.shapes[0])===null||e===void 0?void 0:e.wireframe)!==t.wireframe?!1:this.count()<=this.maxInstances-1}submit(t,e,r){if(this.geometryDirty&&this.createGeometry(),this.materialDirty){let i="";this.instanced&&(i+=`#define USE_INSTANCES 599`),this.useFillImage&&(i+=`#define USE_FILLIMAGE 600`),this.useWireframe&&(i+=`#define USE_WIREFRAME 601`),this.createMaterial(i,e)}this.render(t,r),this.geometryDirty&&(this.geometryDirty=!1),this.materialDirty&&(this.materialDirty=!1)}add(t){this.shapes.includes(t)||(this.shapes.push(t),this.geometryDirty=!0)}remove(t){if(this.shapes.includes(t)){const e=this.shapes.indexOf(t);this.shapes.splice(e,1),this.geometryDirty=!0}}count(){return this.shapes.length}get useWireframe(){var t;return(t=this.shapes[0])===null||t===void 0?void 0:t.wireframe}get useFillImage(){return this.shapes[0].useFillImage}createProgram(t,e,r){const i=this.device.queryVendorInfo().platformString==="WebGPU"?`diagnostic(off,derivative_uniformity); 602`:"";this.program=this.renderCache.createProgram({vertex:{glsl:r+t},fragment:{glsl:r+e,postprocess:o=>i+o}});const s=this.vertexBufferDescriptors;this.useWireframe&&s.push(this.barycentricBufferDescriptor),this.inputLayout=this.renderCache.createInputLayout({vertexBufferDescriptors:s,indexBufferFormat:I.U32_R,program:this.program})}generateWireframe(){const t=this.indexBufferData.length,e=this.vertexBufferDatas.map(o=>o.slice());for(let o=0;o<this.vertexBufferDatas.length;o++){const{arrayStride:n,stepMode:a}=this.vertexBufferDescriptors[o];a===ne.VERTEX?this.vertexBufferDatas[o]=new Float32Array(n/Float32Array.BYTES_PER_ELEMENT*t):this.vertexBufferDatas[o]=e[o]}let r=0;const i=new Uint32Array(t);for(let o=0;o<t;o++){const n=this.indexBufferData[o];for(let a=0;a<this.vertexBufferDatas.length;a++){const{arrayStride:l,stepMode:c}=this.vertexBufferDescriptors[a];if(c===ne.VERTEX){const h=l/Float32Array.BYTES_PER_ELEMENT;for(let u=0;u<h;u++)this.vertexBufferDatas[a][r*h+u]=e[a][n*h+u]}}i[o]=r,r++}for(let o=0;o<this.vertexBuffers.length;o++)this.vertexBuffers[o].destroy(),this.vertexBuffers[o]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[o],usage:dt.VERTEX,hint:Et.DYNAMIC});const s=new Float32Array(t*3);for(let o=0;o<t;)for(let n=0;n<3;n++){const a=i[o++];s[a*3+n]=1}this.barycentricBuffer=this.device.createBuffer({viewOrSize:s,usage:dt.VERTEX,hint:Et.DYNAMIC}),this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=this.device.createBuffer({viewOrSize:i,usage:dt.INDEX,hint:Et.STATIC})}};var Rn;(function(t){t[t.BARYCENTRIC=0]="BARYCENTRIC",t[t.FRAG_COORD=1]="FRAG_COORD",t[t.ABCD=2]="ABCD",t[t.TXTY=3]="TXTY",t[t.POSITION=4]="POSITION",t[t.SIZE=5]="SIZE",t[t.FILL_COLOR=6]="FILL_COLOR",t[t.STROKE_COLOR=7]="STROKE_COLOR",t[t.ZINDEX_STROKE_WIDTH=8]="ZINDEX_STROKE_WIDTH",t[t.OPACITY=9]="OPACITY",t[t.INNER_SHADOW_COLOR=10]="INNER_SHADOW_COLOR",t[t.INNER_SHADOW=11]="INNER_SHADOW"})(Rn||(Rn={}));const RNt=` 603#define SHIFT_RIGHT23 1.0 / 8388608.0 604#define SHIFT_LEFT23 8388608.0 605#define SHIFT_RIGHT22 1.0 / 4194304.0 606#define SHIFT_LEFT22 4194304.0 607 608layout(std140) uniform SceneUniforms { 609 mat3 u_ProjectionMatrix; 610 mat3 u_ViewMatrix; 611 mat3 u_ViewProjectionInvMatrix; 612 vec4 u_BackgroundColor; 613 vec4 u_GridColor; 614 float u_ZoomScale; 615 float u_CheckboardStyle; 616}; 617 618${PI} 619layout(location = ${Rn.FRAG_COORD}) in vec2 a_FragCoord; 620 621#ifdef USE_INSTANCES 622 layout(location = ${Rn.ABCD}) in vec4 a_Abcd; 623 layout(location = ${Rn.TXTY}) in vec2 a_Txty; 624 layout(location = ${Rn.POSITION}) in vec4 a_Position; 625 layout(location = ${Rn.SIZE}) in vec4 a_Size; 626 layout(location = ${Rn.FILL_COLOR}) in vec4 a_FillColor; 627 layout(location = ${Rn.STROKE_COLOR}) in vec4 a_StrokeColor; 628 layout(location = ${Rn.ZINDEX_STROKE_WIDTH}) in vec4 a_ZIndexStrokeWidth; 629 layout(location = ${Rn.OPACITY}) in vec4 a_Opacity; 630 layout(location = ${Rn.INNER_SHADOW_COLOR}) in vec4 a_InnerShadowColor; 631 layout(location = ${Rn.INNER_SHADOW}) in vec4 a_InnerShadow; 632#else 633 layout(std140) uniform ShapeUniforms { 634 mat3 u_ModelMatrix; 635 vec4 u_Position; 636 vec4 u_Size; 637 vec4 u_FillColor; 638 vec4 u_StrokeColor; 639 vec4 u_ZIndexStrokeWidth; 640 vec4 u_Opacity; 641 vec4 u_InnerShadowColor; 642 vec4 u_InnerShadow; 643 }; 644#endif 645 646out vec2 v_FragCoord; 647#ifdef USE_INSTANCES 648 out vec4 v_FillColor; 649 out vec4 v_StrokeColor; 650 out float v_StrokeWidth; 651 out vec4 v_Opacity; 652 out float v_CornerRadius; 653 out float v_StrokeAlignment; 654 out vec4 v_InnerShadowColor; 655 out vec4 v_InnerShadow; 656#else 657#endif 658out vec2 v_Radius; 659 660#ifdef USE_FILLIMAGE 661 out vec2 v_Uv; 662#endif 663 664void main() { 665 ${DI} 666 667 mat3 model; 668 vec3 position; 669 vec2 size; 670 vec4 fillColor; 671 vec4 strokeColor; 672 float zIndex; 673 float strokeWidth; 674 float strokeAlignment; 675 float shapeSizeAttenuation; 676 677 #ifdef USE_INSTANCES 678 model = mat3(a_Abcd.x, a_Abcd.y, 0, a_Abcd.z, a_Abcd.w, 0, a_Txty.x, a_Txty.y, 1); 679 position = a_Position.xyz; 680 size = a_Size.xy; 681 fillColor = a_FillColor; 682 strokeColor = a_StrokeColor; 683 zIndex = a_ZIndexStrokeWidth.x; 684 strokeWidth = a_ZIndexStrokeWidth.y; 685 strokeAlignment = a_ZIndexStrokeWidth.w; 686 shapeSizeAttenuation = a_Opacity.w; 687 688 v_FillColor = fillColor; 689 v_StrokeColor = strokeColor; 690 v_StrokeWidth = strokeWidth; 691 v_Opacity = a_Opacity; 692 v_CornerRadius = a_ZIndexStrokeWidth.z; 693 v_StrokeAlignment = a_ZIndexStrokeWidth.w; 694 v_InnerShadowColor = a_InnerShadowColor; 695 v_InnerShadow = a_InnerShadow; 696 #else 697 model = u_ModelMatrix; 698 position = u_Position.xyz; 699 size = u_Size.xy; 700 fillColor = u_FillColor; 701 strokeColor = u_StrokeColor; 702 zIndex = u_ZIndexStrokeWidth.x; 703 strokeWidth = u_ZIndexStrokeWidth.y; 704 strokeAlignment = u_ZIndexStrokeWidth.w; 705 shapeSizeAttenuation = u_Opacity.w; 706 #endif 707 708 709 float compressed = shapeSizeAttenuation; 710 float sizeAttenuation = floor(compressed * SHIFT_RIGHT23); 711 compressed -= sizeAttenuation * SHIFT_LEFT23; 712 float strokeAttenuation = floor(compressed * SHIFT_RIGHT22); 713 714 float scale = 1.0; 715 if (sizeAttenuation > 0.5) { 716 scale = 1.0 / u_ZoomScale; 717 } 718 if (strokeAttenuation > 0.5) { 719 strokeWidth = strokeWidth / u_ZoomScale; 720 } 721 722 float strokeOffset; 723 if (strokeAlignment < 0.5) { 724 strokeOffset = strokeWidth / 2.0; 725 } else if (strokeAlignment < 1.5) { 726 strokeOffset = 0.0; 727 } else if (strokeAlignment < 2.5) { 728 strokeOffset = strokeWidth; 729 } 730 731 vec2 radius = size + vec2(strokeOffset); 732 v_FragCoord = vec2(a_FragCoord * radius); 733 v_Radius = abs(radius); 734 735 #ifdef USE_FILLIMAGE 736 v_Uv = (a_FragCoord * radius / size + 1.0) / 2.0; 737 #endif 738 739 gl_Position = vec4((u_ProjectionMatrix
740 * u_ViewMatrix 741 * model 742 * vec3(position.xy + v_FragCoord * scale, 1)).xy, position.z, 1); 743} 744`,CNt=` 745#define SHIFT_RIGHT23 1.0 / 8388608.0 746#define SHIFT_LEFT23 8388608.0 747 748layout(std140) uniform SceneUniforms { 749 mat3 u_ProjectionMatrix; 750 mat3 u_ViewMatrix; 751 mat3 u_ViewProjectionInvMatrix; 752 vec4 u_BackgroundColor; 753 vec4 u_GridColor; 754 float u_ZoomScale; 755 float u_CheckboardStyle; 756}; 757 758#ifdef USE_INSTANCES 759#else 760 layout(std140) uniform ShapeUniforms { 761 mat3 u_ModelMatrix; 762 vec4 u_Position; 763 vec4 u_Size; 764 vec4 u_FillColor; 765 vec4 u_StrokeColor; 766 vec4 u_ZIndexStrokeWidth; 767 vec4 u_Opacity; 768 vec4 u_InnerShadowColor; 769 vec4 u_InnerShadow; 770 }; 771#endif 772 773out vec4 outputColor; 774 775${sR} 776in vec2 v_FragCoord; 777 778#ifdef USE_INSTANCES 779 in vec4 v_FillColor; 780 in vec4 v_StrokeColor; 781 in float v_StrokeWidth; 782 in vec4 v_Opacity; 783 in float v_CornerRadius; 784 in float v_StrokeAlignment; 785 in vec4 v_InnerShadowColor; 786 in vec4 v_InnerShadow; 787#else 788#endif 789in vec2 v_Radius; 790 791#ifdef USE_FILLIMAGE 792 in vec2 v_Uv; 793 uniform sampler2D u_Texture; 794#endif 795 796float epsilon = 0.000001; 797 798float sdf_circle(vec2 p, float r) { 799 return length(p) - r; 800} 801 802float sdf_ellipse(vec2 p, vec2 r) { 803 float k0 = length(p / r); 804 float k1 = length(p / (r * r)); 805 return k0 * (k0 - 1.0) / k1; 806 807 // V1 808 // float k1 = length(p/r); 809 // return (k1-1.0)*min(r.x,r.y); 810 811 // V3 812 // float k1 = length(p/r); 813 // return length(p)*(1.0-1.0/k1); 814} 815 816float sdf_rounded_box(vec2 p, vec2 b, float r) { 817 vec2 q = abs(p) - b + r; 818 return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r; 819} 820 821vec4 over(vec4 below, vec4 above) { 822 vec4 result; 823 float alpha = above.a + below.a * (1.0 - above.a); 824 result.rgb = 825 (above.rgb * above.a + below.rgb * below.a * (1.0 - above.a)) / alpha; 826 result.a = alpha; 827 return result; 828} 829 830float antialias(float distance) { 831 return clamp(distance / -fwidth(distance), 0.0, 1.0); 832} 833 834vec4 mix_border_inside(vec4 border, vec4 inside, float distance) { 835 // Blend the border on top of the background and then linearly interpolate 836 // between the two as we slide inside the background. 837 return mix(border, inside, clamp(1.0 - distance, 0.0, 1.0) * antialias(distance)); 838} 839 840float sigmoid(float t) { 841 return 1.0 / (1.0 + exp(-t)); 842} 843 844float make_shadow(vec2 pos, vec2 halfSize, float cornerRd, float blurRd, float distMul, float shape) { 845 float distance; 846 if (shape < 0.5) { 847 distance = sdf_circle(pos, halfSize.x); 848 } else if (shape < 1.5) { 849 distance = sdf_ellipse(pos, halfSize); 850 } else if (shape < 2.5) { 851 distance = sdf_rounded_box(pos, halfSize, cornerRd + blurRd); 852 } 853 float dist = sigmoid(distMul * distance / blurRd); 854 return clamp(dist, 0.0, 1.0); 855} 856 857void main() { 858 float strokeWidth; 859 vec4 fillColor; 860 vec4 strokeColor; 861 float opacity; 862 float fillOpacity; 863 float strokeOpacity; 864 float shapeSizeAttenuation; 865 float cornerRadius; 866 vec4 innerShadowColor; 867 vec4 innerShadow; 868 float strokeAlignment; 869 870 #ifdef USE_INSTANCES 871 fillColor = v_FillColor; 872 strokeColor = v_StrokeColor; 873 strokeWidth = v_StrokeWidth; 874 opacity = v_Opacity.x; 875 fillOpacity = v_Opacity.y; 876 strokeOpacity = v_Opacity.z; 877 shapeSizeAttenuation = v_Opacity.w; 878 cornerRadius = v_CornerRadius; 879 strokeAlignment = v_StrokeAlignment; 880 innerShadowColor = v_InnerShadowColor; 881 innerShadow = v_InnerShadow; 882 #else 883 fillColor = u_FillColor; 884 strokeColor = u_StrokeColor; 885 strokeWidth = u_ZIndexStrokeWidth.y; 886 opacity = u_Opacity.x; 887 fillOpacity = u_Opacity.y; 888 strokeOpacity = u_Opacity.z; 889 shapeSizeAttenuation = u_Opacity.w; 890 cornerRadius = u_ZIndexStrokeWidth.z; 891 strokeAlignment = u_ZIndexStrokeWidth.w; 892 innerShadowColor = u_InnerShadowColor; 893 innerShadow = u_InnerShadow; 894 #endif 895 896 #ifdef USE_FILLIMAGE 897 fillColor = texture(SAMPLER_2D(u_Texture), v_Uv); 898 #endif 899 900 float compressed = shapeSizeAttenuation; 901 float sizeAttenuation = floor(compressed * SHIFT_RIGHT23); 902 compressed -= sizeAttenuation * SHIFT_LEFT23; 903 float shape = compressed; 904 905 float distance; 906 // 'circle', 'ellipse', 'rect' 907 if (shape < 0.5) { 908 distance = sdf_circle(v_FragCoord, v_Radius.x); 909 } else if (shape < 1.5) { 910 distance = sdf_ellipse(v_FragCoord, v_Radius); 911 } else if (shape < 2.5) {
912 distance = sdf_rounded_box(v_FragCoord, v_Radius, cornerRadius); 913 // TODO: Fast path when the quad is not rounded and doesn't have any border. 914 } 915 916 // based on the target alpha compositing mode. 917 fillColor.a *= fillOpacity; 918 strokeColor.a *= strokeOpacity; 919 920 vec4 color = fillColor; 921 float d1; 922 float d2; 923 if (strokeAlignment < 0.5) { 924 d1 = distance + strokeWidth; 925 d2 = distance + strokeWidth / 2.0; 926 color = mix_border_inside(over(fillColor, strokeColor), fillColor, d1); 927 color = mix_border_inside(strokeColor, color, d2); 928 } else if (strokeAlignment < 1.5) { 929 d1 = distance + strokeWidth; 930 d2 = distance; 931 color = mix_border_inside(over(fillColor, strokeColor), fillColor, d1); 932 color = mix_border_inside(strokeColor, color, d2); 933 } else if (strokeAlignment < 2.5) { 934 d2 = distance + strokeWidth; 935 color = mix_border_inside(strokeColor, color, d2); 936 } 937 outputColor = color; 938 939 float innerShadowBlurRadius = innerShadow.z / 2.0; 940 if (innerShadowBlurRadius > 0.0) { 941 vec2 shadowOffset = -innerShadow.xy; 942 float blurRadius = innerShadow.z; 943 float distMul = -1.0; 944 float lowerShadow = make_shadow(v_FragCoord + shadowOffset, v_Radius, cornerRadius, blurRadius, distMul, shape); 945 946 vec3 lowerShadowColor = innerShadowColor.rgb * innerShadowColor.a; 947 outputColor = over(vec4(color.xyz, 1.0), vec4(lowerShadowColor, 1.0 - lowerShadow)); 948 outputColor = over(outputColor, vec4(color.xyz, clamp(distance, 0.0, 1.0))); 949 } 950 951 float antialiasedBlur = -fwidth(length(v_FragCoord)); 952 float opacity_t = clamp(distance / antialiasedBlur, 0.0, 1.0); 953 outputColor.a *= clamp(1.0 - distance, 0.0, 1.0) * opacity * opacity_t; 954 955 ${iR} 956 957 if (outputColor.a < epsilon) 958 discard; 959} 960`;var DE=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},B5=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},PE,e_;const MNt={center:0,inner:1,outer:2};let NH=class eY extends oR{constructor(){super(...arguments),PE.set(this,void 0),e_.set(this,void 0)}static useDash(e){const{strokeDasharray:r}=e;return r.length>0&&r.some(i=>i>0)}validate(e){var r,i;if(!super.validate(e))return!1;if(this.shapes.length===0)return!0;const s=!gl(this.shapes[0].fill),o=!gl(e.fill),n=((r=this.shapes[0].fillGradient)===null||r===void 0?void 0:r.length)>0,a=((i=e.fillGradient)===null||i===void 0?void 0:i.length)>0;return s!==o||n!==a?!1:s&&o||n&&a?this.shapes[0].fill===e.fill:eY.useDash(e)===eY.useDash(this.shapes[0])}createGeometry(){this.indexBufferData=new Uint32Array([0,1,2,0,2,3]),this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=this.device.createBuffer({viewOrSize:this.indexBufferData,usage:dt.INDEX,hint:Et.STATIC}),this.vertexBufferDatas[0]=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.vertexBuffers[0]&&this.vertexBuffers[0].destroy(),this.vertexBuffers[0]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[0],usage:dt.VERTEX,hint:Et.STATIC}),this.instanced&&(this.vertexBuffers[1]&&(this.vertexBuffers[1].destroy(),this.vertexBuffers[2].destroy()),this.vertexBufferDatas[1]=new Float32Array(new Array(32*this.shapes.length).fill(0)),this.vertexBuffers[1]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[1],usage:dt.VERTEX,hint:Et.DYNAMIC}),this.vertexBufferDatas[2]=new Float32Array(new Array(6*this.shapes.length).fill(0)),this.vertexBuffers[2]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[2],usage:dt.VERTEX,hint:Et.DYNAMIC})),this.vertexBufferDescriptors=[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:Rn.FRAG_COORD,offset:0,format:I.F32_RG}]}
960],this.instanced&&this.vertexBufferDescriptors.push({arrayStride:128,stepMode:ne.INSTANCE,attributes:[{shaderLocation:Rn.POSITION,offset:0,format:I.F32_RGBA},{shaderLocation:Rn.SIZE,offset:16,format:I.F32_RGBA},{shaderLocation:Rn.FILL_COLOR,offset:32,format:I.F32_RGBA},{shaderLocation:Rn.STROKE_COLOR,offset:48,format:I.F32_RGBA},{shaderLocation:Rn.ZINDEX_STROKE_WIDTH,offset:64,format:I.F32_RGBA},{shaderLocation:Rn.OPACITY,offset:80,format:I.F32_RGBA},{shaderLocation:Rn.INNER_SHADOW_COLOR,offset:96,format:I.F32_RGBA},{shaderLocation:Rn.INNER_SHADOW,offset:112,format:I.F32_RGBA}]},{arrayStride:24,stepMode:ne.INSTANCE,attributes:[{shaderLocation:Rn.ABCD,offset:0,format:I.F32_RGBA},{shaderLocation:Rn.TXTY,offset:16,format:I.F32_RG}]})}createMaterial(e,r){this.createProgram(RNt,CNt,e),!this.instanced&&!DE(this,PE,"f")&&B5(this,PE,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*48,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),this.pipeline=this.renderCache.createRenderPipeline({inputLayout:this.inputLayout,program:this.program,colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],blendConstant:kn,depthWrite:!0,depthCompare:qe.GREATER,stencilWrite:!1,stencilFront:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP},stencilBack:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP}}}),this.device.setResourceName(this.pipeline,"SDFPipeline");const i={pipeline:this.pipeline,uniformBufferBindings:[{buffer:r}]};if(this.instanced||i.uniformBufferBindings.push({buffer:DE(this,PE,"f")}),this.useFillImage){const s=this.shapes[0].fill;if(this.bindings&&this.bindings.destroy(),gl(s)||Rv(s)){const{minX:n,minY:a,maxX:l,maxY:c}=this.shapes[0].getGeometryBounds(),h=l-n,u=c-a,d=Rv(s)?this.texturePool.getOrCreatePattern({pattern:s,width:h,height:u}):this.texturePool.getOrCreateGradient({gradients:this.shapes[0].fillGradient,min:[n,a],width:h,height:u}),f=this.device.createTexture({format:I.U8_RGBA_NORM,width:128,height:128,usage:xr.SAMPLED});f.setImageData([d]),B5(this,e_,f,"f")}else if(s.texture)B5(this,e_,s.texture,"f");else{const n=this.device.createTexture({format:I.U8_RGBA_NORM,width:s.width,height:s.height,usage:xr.SAMPLED});n.setImageData([s]),B5(this,e_,n,"f")}const o=this.renderCache.createSampler({addressModeU:Zn.CLAMP_TO_EDGE,addressModeV:Zn.CLAMP_TO_EDGE,minFilter:io.POINT,magFilter:io.BILINEAR,mipmapFilter:xn.LINEAR,lodMinClamp:0,lodMaxClamp:0});i.samplerBindings=[{texture:DE(this,e_,"f"),sampler:o}]}this.bindings=this.renderCache.createBindings(i)}render(e,r){if(this.shapes.some(s=>s.renderDirtyFlag)||this.geometryDirty){if(this.instanced){const s=[];this.shapes.forEach((o,n,a)=>{const[l]=this.generateBuffer(o,n,a.length);s.push(...l)}),this.vertexBufferDatas[1]=new Float32Array(s),this.vertexBuffers[1].setSubData(0,new Uint8Array(this.vertexBufferDatas[1].buffer)),this.vertexBufferDatas[2]=new Float32Array(this.shapes.map(o=>[o.worldTransform.a,o.worldTransform.b,o.worldTransform.c,o.worldTransform.d,o.worldTransform.tx,o.worldTransform.ty]).flat()),this.vertexBuffers[2].setSubData(0,new Uint8Array(this.vertexBufferDatas[2].buffer))}else{const{worldTransform:s}=this.shapes[0],[o,n]=this.generateBuffer(this.shapes[0],0,1),a=s.toArray(!0);DE(this,PE,"f").setSubData(0,new Uint8Array(new Float32Array([...Hv(a),...o]).buffer));const l=Object.assign({u_ModelMatrix:a},n);this.useFillImage&&(l.u_FillImage=DE(this,e_,"f")),this.program.setUniformsLegacy(l)}this.useWireframe&&this.geometryDirty&&this.generateWireframe()}this.program.setUniformsLegacy(r),e.setPipeline(this.pipeline);const i=this.vertexBuffers.map(s=>({buffer:s}));this.useWireframe&&i.push({buffer:this.barycentricBuffer}),e.setVertexInput(this.inputLayout,i,{buffer:this.indexBuffer}),e.setBindings(this.bindings),e.drawIndexed(6,this.shapes.length)}destroy(){var e,r,i;super.destroy(),this.program&&((e=DE(this,PE,"f"))===null||e===void 0||e.destroy(),(i=(r=DE(this,e_,"f"))===null||r===void 0?void 0:r.destroy)===null||i===void 0||i.call(r))}generateBuffer(e,r,i){const{fillRGB:s,strokeRGB:{r:o,g:n,b:a,opacity:l},strokeWidth:c,strokeAlignment:h,opacity:u,fillOpacity:d,strokeOpacity:f,innerShadowColorRGB:{r:g,g:p,b:m,opacity:v},innerShadowOffsetX:b,innerShadowOffsetY:y,innerShadowBlurRadius:_,sizeAttenuation:w,strokeAttenuation:E}=e;let A=[0,0,0,0],x=[0,0,0,0],S=0,T=0;const R=(e.globalRenderOrder+1/i*r)/IE;if(e instanceof Gl){const{cx:bt,cy:ct,r:Xt}=e;A=[bt,ct,R,0],x=[Xt,Xt,0,0],S=0}else if(e instanceof $h){const{cx:bt,cy:ct,rx:Xt,ry:It}=e;A=[bt,ct,R,0],x=[Xt,It,0,0],S=1}else if(e instanceof ed){const{x:bt,y:ct,width:Xt,height:It,cornerRadius:zt}=e;A=[bt+Xt/2,ct+It/2,R,0],x=[Xt/2,It/2,0,0],S=2,T=zt}
960const{r:B,g:O,b:C,opacity:F}=s||{},U=A,H=x,N=[B/255,O/255,C/255,F],G=[o/255,n/255,a/255,l],Y=[e.globalRenderOrder/IE,eY.useDash(e)?0:c,T,MNt[h]],q=(w?1:0)*8388608+(E?1:0)*4194304+S,L=[u,d,f,q],J=[g/255,p/255,m/255,v],tt=[b,y,_,0];return[[...U,...H,...N,...G,...Y,...L,...J,...tt],{u_Position:U,u_Size:H,u_FillColor:N,u_StrokeColor:G,u_ZIndexStrokeWidth:Y,u_Opacity:L,u_InnerShadowColor:J,u_InnerShadow:tt}]}};PE=new WeakMap,e_=new WeakMap;var Hc;(function(t){t[t.BARYCENTRIC=0]="BARYCENTRIC",t[t.FRAG_COORD=1]="FRAG_COORD",t[t.ABCD=2]="ABCD",t[t.TXTY=3]="TXTY",t[t.POSITION_SIZE=4]="POSITION_SIZE",t[t.ZINDEX_STROKE_WIDTH=5]="ZINDEX_STROKE_WIDTH",t[t.DROP_SHADOW_COLOR=6]="DROP_SHADOW_COLOR",t[t.DROP_SHADOW=7]="DROP_SHADOW"})(Hc||(Hc={}));const BNt=` 961layout(std140) uniform SceneUniforms { 962 mat3 u_ProjectionMatrix; 963 mat3 u_ViewMatrix; 964 mat3 u_ViewProjectionInvMatrix; 965 vec4 u_BackgroundColor; 966 vec4 u_GridColor; 967 float u_ZoomScale; 968 float u_CheckboardStyle; 969}; 970 971${PI} 972layout(location = ${Hc.FRAG_COORD}) in vec2 a_FragCoord; 973 974#ifdef USE_INSTANCES 975 layout(location = ${Hc.ABCD}) in vec4 a_Abcd; 976 layout(location = ${Hc.TXTY}) in vec2 a_Txty; 977 layout(location = ${Hc.POSITION_SIZE}) in vec4 a_PositionSize; 978 layout(location = ${Hc.ZINDEX_STROKE_WIDTH}) in vec4 a_ZIndexStrokeWidth; 979 layout(location = ${Hc.DROP_SHADOW_COLOR}) in vec4 a_DropShadowColor; 980 layout(location = ${Hc.DROP_SHADOW}) in vec4 a_DropShadow; 981#else 982 layout(std140) uniform ShapeUniforms { 983 mat3 u_ModelMatrix; 984 vec4 u_PositionSize; 985 vec4 u_ZIndexStrokeWidth; 986 vec4 u_DropShadowColor; 987 vec4 u_DropShadow; 988 }; 989#endif 990 991out vec2 v_Origin; 992#ifdef USE_INSTANCES 993 out float v_CornerRadius; 994 out vec4 v_DropShadowColor; 995 out vec4 v_DropShadow; 996#else 997#endif 998out vec2 v_Size; 999out vec2 v_Point; 1000 1001void main() { 1002 ${DI} 1003 1004 mat3 model; 1005 vec2 origin; 1006 vec2 size; 1007 float zIndex; 1008 vec4 dropShadow; 1009 float sizeAttenuation; 1010 1011 #ifdef USE_INSTANCES 1012 model = mat3(a_Abcd.x, a_Abcd.y, 0, a_Abcd.z, a_Abcd.w, 0, a_Txty.x, a_Txty.y, 1); 1013 origin = a_PositionSize.xy; 1014 size = a_PositionSize.zw; 1015 zIndex = a_ZIndexStrokeWidth.x; 1016 dropShadow = a_DropShadow; 1017 sizeAttenuation = a_ZIndexStrokeWidth.w; 1018 v_CornerRadius = a_ZIndexStrokeWidth.z; 1019 v_DropShadowColor = a_DropShadowColor; 1020 v_DropShadow = dropShadow; 1021 #else 1022 model = u_ModelMatrix; 1023 origin = u_PositionSize.xy; 1024 size = u_PositionSize.zw; 1025 zIndex = u_ZIndexStrokeWidth.x; 1026 dropShadow = u_DropShadow; 1027 sizeAttenuation = u_ZIndexStrokeWidth.w; 1028 #endif 1029 1030 float scale = 1.0; 1031 if (sizeAttenuation > 0.5) { 1032 scale = 1.0 / u_ZoomScale; 1033 } 1034 1035 // Set the bounds of the shadow and adjust its size based on the shadow's 1036 // spread radius to achieve the spreading effect 1037 float margin = 3.0 * dropShadow.z; 1038 1039 vec2 center = origin + size / 2.0; 1040 vec2 sizeSign = sign(size); 1041 size = abs(size); 1042 1043 // Recalculate the origin since the size could be negative 1044 origin = center - size / 2.0 + dropShadow.xy * sizeSign; 1045 v_Size = size; 1046 v_Origin = origin; 1047 1048 origin -= margin; 1049 size += 2.0 * margin; 1050 1051 v_Point = center + a_FragCoord * (size / 2.0); 1052 1053 gl_Position = vec4((u_ProjectionMatrix 1054 * u_ViewMatrix 1055 * model 1056 * vec3(center + a_FragCoord * (size / 2.0) * scale, 1)).xy, zIndex, 1); 1057} 1058`,ONt=` 1059layout(std140) uniform SceneUniforms { 1060 mat3 u_ProjectionMatrix; 1061 mat3 u_ViewMatrix; 1062 mat3 u_ViewProjectionInvMatrix; 1063 vec4 u_BackgroundColor; 1064 vec4 u_GridColor; 1065 float u_ZoomScale; 1066 float u_CheckboardStyle; 1067}; 1068 1069#ifdef USE_INSTANCES 1070#else 1071 layout(std140) uniform ShapeUniforms { 1072 mat3 u_ModelMatrix; 1073 vec4 u_PositionSize; 1074 vec4 u_ZIndexStrokeWidth; 1075 vec4 u_DropShadowColor; 1076 vec4 u_DropShadow; 1077 }; 1078#endif 1079 1080out vec4 outputColor; 1081 1082${sR} 1083in vec2 v_Origin; 1084#ifdef USE_INSTANCES 1085 in float v_CornerRadius; 1086 in vec4 v_DropShadowColor; 1087 in vec4 v_DropShadow; 1088#else 1089#endif 1090in vec2 v_Size; 1091in vec2 v_Point; 1092 1093float epsilon = 0.000001; 1094float PI = 3.1415926; 1095 1096// A standard gaussian function, used for weighting samples 1097float gaussian(float x, float sigma) { 1098 return exp(-(x * x) / (2. * sigma * sigma)) / (sqrt(2. * PI) * sigma); 1099} 1100 1101// This approximates the error function, needed for the gaussian integral 1102vec2 erf(vec2 x) { 1103 vec2 s = sign(x), a = abs(x); 1104 x = 1.0 + (0.278393 + (0.230389 + 0.078108 * (a * a)) * a) * a; 1105 x *= x; 1106 return s - s / (x * x); 1107} 1108
1109// @see https://raphlinus.github.io/graphics/2020/04/21/blurred-rounded-rects.html 1110// vec2 erf7(vec2 x) { 1111// x = x * sqrt(2. * PI); 1112// vec2 xx = x * x; 1113// x = x + (0.24295 + (0.03395 + 0.0104 * xx) * xx) * (x * xx); 1114// return x / sqrt(1.0 + x * x); 1115// } 1116 1117float rect_shadow(vec2 pixel_position, vec2 origin, vec2 size, float sigma) { 1118 vec2 bottom_right = origin + size; 1119 vec2 x_distance = vec2(pixel_position.x - origin.x, pixel_position.x - bottom_right.x); 1120 vec2 y_distance = vec2(pixel_position.y - origin.y, pixel_position.y - bottom_right.y); 1121 vec2 integral_x = 0.5 + 0.5 * erf(x_distance * (sqrt(0.5) / sigma)); 1122 vec2 integral_y = 0.5 + 0.5 * erf(y_distance * (sqrt(0.5) / sigma)); 1123 return (integral_x.x - integral_x.y) * (integral_y.x - integral_y.y); 1124} 1125 1126float blur_along_x(float x, float y, float sigma, float corner, vec2 half_size) { 1127 float delta = min(half_size.y - corner - abs(y), 0.0); 1128 float curved = half_size.x - corner + sqrt(max(0., corner * corner - delta * delta)); 1129 vec2 integral = 0.5 + 0.5 * erf((x + vec2(-curved, curved)) * (sqrt(0.5) / sigma)); 1130 return integral.y - integral.x; 1131} 1132 1133void main() { 1134 float cornerRadius; 1135 vec4 dropShadow; 1136 vec4 dropShadowColor; 1137 1138 #ifdef USE_INSTANCES 1139 cornerRadius = v_CornerRadius; 1140 dropShadowColor = v_DropShadowColor; 1141 dropShadow = v_DropShadow; 1142 #else 1143 cornerRadius = u_ZIndexStrokeWidth.z; 1144 dropShadowColor = u_DropShadowColor; 1145 dropShadow = u_DropShadow; 1146 #endif 1147 1148 float blur_radius = dropShadow.z; 1149 if (blur_radius > 0.0) { 1150 float alpha = 0.; 1151 vec2 point = v_Point; 1152 1153 if (cornerRadius > 0.0) { 1154 vec2 half_size = v_Size / 2.0; 1155 vec2 center = v_Origin + half_size; 1156 vec2 center_to_point = point - center; 1157 1158 // The signal is only non-zero in a limited range, so don't waste samples 1159 float low = center_to_point.y - half_size.y; 1160 float high = center_to_point.y + half_size.y; 1161 float start = clamp(-3. * blur_radius, low, high); 1162 float end = clamp(3. * blur_radius, low, high); 1163 1164 // Accumulate samples (we can get away with surprisingly few samples) 1165 float step = (end - start) / 4.; 1166 float y = start + step * 0.5; 1167 1168 for (int i = 0; i < 4; i++) { 1169 alpha += blur_along_x(center_to_point.x, center_to_point.y - y, blur_radius, 1170 cornerRadius, half_size) * 1171 gaussian(y, blur_radius) * step; 1172 y += step; 1173 } 1174 } else { 1175 alpha = rect_shadow(point, v_Origin, v_Size, blur_radius); 1176 } 1177 1178 outputColor = dropShadowColor; 1179 outputColor.a = alpha; 1180 1181 ${iR} 1182 } else { 1183 discard; 1184 } 1185} 1186`;var O5=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},INt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},FE;let kat=class extends oR{constructor(){super(...arguments),FE.set(this,void 0)}static check(t){return(t instanceof ed||t instanceof au)&&t.dropShadowBlurRadius>0}createGeometry(){this.indexBufferData=new Uint32Array([0,1,2,0,2,3]),this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=this.device.createBuffer({viewOrSize:this.indexBufferData,usage:dt.INDEX,hint:Et.STATIC}),this.vertexBufferDatas[0]=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.vertexBuffers[0]&&this.vertexBuffers[0].destroy(),this.vertexBuffers[0]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[0],usage:dt.VERTEX,hint:Et.STATIC}),this.instanced&&(this.vertexBuffers[1]&&(this.vertexBuffers[1].destroy(),this.vertexBuffers[2].destroy()),this.vertexBufferDatas[1]=new Float32Array(new Array(16*this.shapes.length).fill(0)),this.vertexBuffers[1]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[1],usage:dt.VERTEX,hint:Et.DYNAMIC}),this.vertexBufferDatas[2]=new Float32Array(new Array(6*this.shapes.length).fill(0)),this.vertexBuffers[2]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[2],usage:dt.VERTEX,hint:Et.DYNAMIC}
1186)),this.vertexBufferDescriptors=[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:Hc.FRAG_COORD,offset:0,format:I.F32_RG}]}],this.instanced&&this.vertexBufferDescriptors.push({arrayStride:64,stepMode:ne.INSTANCE,attributes:[{shaderLocation:Hc.POSITION_SIZE,offset:0,format:I.F32_RGBA},{shaderLocation:Hc.ZINDEX_STROKE_WIDTH,offset:16,format:I.F32_RGBA},{shaderLocation:Hc.DROP_SHADOW_COLOR,offset:32,format:I.F32_RGBA},{shaderLocation:Hc.DROP_SHADOW,offset:48,format:I.F32_RGBA}]},{arrayStride:24,stepMode:ne.INSTANCE,attributes:[{shaderLocation:Hc.ABCD,offset:0,format:I.F32_RGBA},{shaderLocation:Hc.TXTY,offset:16,format:I.F32_RG}]})}createMaterial(t,e){this.createProgram(BNt,ONt,t),!this.instanced&&!O5(this,FE,"f")&&INt(this,FE,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*32,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),this.inputLayout=this.renderCache.createInputLayout({vertexBufferDescriptors:this.vertexBufferDescriptors,indexBufferFormat:I.U32_R,program:this.program}),this.pipeline=this.renderCache.createRenderPipeline({inputLayout:this.inputLayout,program:this.program,colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],blendConstant:kn,depthWrite:!1,depthCompare:qe.GREATER,stencilWrite:!1,stencilFront:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP},stencilBack:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP}}}),this.instanced?this.bindings=this.renderCache.createBindings({pipeline:this.pipeline,uniformBufferBindings:[{buffer:e}]}):this.bindings=this.device.createBindings({pipeline:this.pipeline,uniformBufferBindings:[{buffer:e},{buffer:O5(this,FE,"f")}]})}render(t,e){if(this.shapes.some(i=>i.renderDirtyFlag)||this.geometryDirty){if(this.instanced){const i=[];this.shapes.forEach(s=>{const[o]=this.generateBuffer(s);i.push(...o)}),this.vertexBufferDatas[1]=new Float32Array(i),this.vertexBuffers[1].setSubData(0,new Uint8Array(this.vertexBufferDatas[1].buffer)),this.vertexBufferDatas[2]=new Float32Array(this.shapes.map(s=>[s.worldTransform.a,s.worldTransform.b,s.worldTransform.c,s.worldTransform.d,s.worldTransform.tx,s.worldTransform.ty]).flat()),this.vertexBuffers[2].setSubData(0,new Uint8Array(this.vertexBufferDatas[2].buffer))}else{const{worldTransform:i}=this.shapes[0],[s,o]=this.generateBuffer(this.shapes[0]),n=i.toArray(!0);O5(this,FE,"f").setSubData(0,new Uint8Array(new Float32Array([...Hv(n),...s]).buffer));const a=Object.assign({u_ModelMatrix:n},o);this.program.setUniformsLegacy(a)}this.useWireframe&&this.geometryDirty&&this.generateWireframe()}this.program.setUniformsLegacy(e),t.setPipeline(this.pipeline);const r=this.vertexBuffers.map(i=>({buffer:i}));this.useWireframe&&r.push({buffer:this.barycentricBuffer}),t.setVertexInput(this.inputLayout,r,{buffer:this.indexBuffer}),t.setBindings(this.bindings),t.drawIndexed(6,this.shapes.length)}destroy(){var t;super.destroy(),this.program&&((t=O5(this,FE,"f"))===null||t===void 0||t.destroy())}generateBuffer(t){const{x:e,y:r,width:i,height:s,strokeWidth:o,cornerRadius:n,dropShadowColorRGB:{r:a,g:l,b:c,opacity:h},dropShadowOffsetX:u,dropShadowOffsetY:d,dropShadowBlurRadius:f,sizeAttenuation:g}=t,p=[e,r,i,s],m=[t.globalRenderOrder/IE,o,n,g?1:0],v=[a/255,l/255,c/255,h],b=[u,d,f,0];return[[...p,...m,...v,...b],{u_PositionSize:p,u_ZIndexStrokeWidth:m,u_DropShadowColor:v,u_DropShadow:b}]}};FE=new WeakMap;var Kc;(function(t){t[t.BARYCENTRIC=0]="BARYCENTRIC",t[t.PREV=1]="PREV",t[t.POINTA=2]="POINTA",t[t.POINTB=3]="POINTB",t[t.NEXT=4]="NEXT",t[t.VERTEX_JOINT=5]="VERTEX_JOINT",t[t.VERTEX_NUM=6]="VERTEX_NUM",t[t.TRAVEL=7]="TRAVEL"})(Kc||(Kc={}));var on;(function(t){t[t.NONE=0]="NONE",t[t.FILL=1]="FILL",t[t.JOINT_BEVEL=4]="JOINT_BEVEL",t[t.JOINT_MITER=8]="JOINT_MITER",t[t.JOINT_ROUND=12]="JOINT_ROUND",t[t.JOINT_CAP_BUTT=16]="JOINT_CAP_BUTT",t[t.JOINT_CAP_SQUARE=18]="JOINT_CAP_SQUARE",t[t.JOINT_CAP_ROUND=20]="JOINT_CAP_ROUND",t[t.FILL_EXPAND=24]="FILL_EXPAND",t[t.CAP_BUTT=32]="CAP_BUTT",t[t.CAP_SQUARE=64]="CAP_SQUARE",t[t.CAP_ROUND=96]="CAP_ROUND",t[t.CAP_BUTT2=128]="CAP_BUTT2"})(on||(on={}));const DNt=` 1187layout(std140) uniform SceneUniforms { 1188 mat3 u_ProjectionMatrix; 1189 mat3 u_ViewMatrix; 1190 mat3 u_ViewProjectionInvMatrix;
1191 vec4 u_BackgroundColor; 1192 vec4 u_GridColor; 1193 float u_ZoomScale; 1194 float u_CheckboardStyle; 1195 vec2 u_Viewport; 1196}; 1197 1198${PI} 1199layout(location = ${Kc.PREV}) in vec2 a_Prev; 1200layout(location = ${Kc.POINTA}) in vec2 a_PointA; 1201layout(location = ${Kc.POINTB}) in vec2 a_PointB; 1202layout(location = ${Kc.NEXT}) in vec2 a_Next; 1203layout(location = ${Kc.VERTEX_JOINT}) in float a_VertexJoint; 1204layout(location = ${Kc.VERTEX_NUM}) in float a_VertexNum; 1205layout(location = ${Kc.TRAVEL}) in float a_Travel; 1206 1207layout(std140) uniform ShapeUniforms { 1208 mat3 u_ModelMatrix; 1209 vec4 u_StrokeColor; 1210 vec4 u_ZIndexStrokeWidth; 1211 vec4 u_Opacity; 1212 vec4 u_StrokeDash; 1213}; 1214 1215const float FILL = ${on.FILL}.0; 1216const float BEVEL = ${on.JOINT_BEVEL}.0; 1217const float MITER = ${on.JOINT_MITER}.0; 1218const float ROUND = ${on.JOINT_ROUND}.0; 1219const float JOINT_CAP_BUTT = ${on.JOINT_CAP_BUTT}.0; 1220const float JOINT_CAP_SQUARE = ${on.JOINT_CAP_SQUARE}.0; 1221const float JOINT_CAP_ROUND = ${on.JOINT_CAP_ROUND}.0; 1222const float FILL_EXPAND = ${on.FILL_EXPAND}.0; 1223const float CAP_BUTT = 1.0; 1224const float CAP_SQUARE = 2.0; 1225const float CAP_ROUND = 3.0; 1226const float CAP_BUTT2 = 4.0; 1227 1228const float expand = 1.0; 1229const float dpr = 2.0; 1230 1231out vec4 v_Distance; 1232out vec4 v_Arc; 1233out float v_Type; 1234out float v_Travel; 1235out float v_ScalingFactor; 1236#ifdef USE_INSTANCES 1237 out vec4 v_StrokeColor; 1238 out vec4 v_Opacity; 1239 out float v_StrokeAlignment; 1240#else 1241#endif 1242 1243vec2 doBisect( 1244 vec2 norm, float len, vec2 norm2, float len2, float dy, float inner 1245) { 1246 vec2 bisect = (norm + norm2) / 2.0; 1247 bisect /= dot(norm, bisect); 1248 if (inner > 0.5) { 1249 if (len < len2) { 1250 if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) { 1251 return dy * norm; 1252 } 1253 } else { 1254 if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) { 1255 return dy * norm; 1256 } 1257 } 1258 } 1259 return dy * bisect; 1260} 1261 1262// vec2 clip2ScreenSpace(vec4 clip) { 1263// return u_Viewport * (0.5 * clip.xy / clip.w + 0.5); 1264// } 1265 1266void main() { 1267 ${DI} 1268 1269 mat3 model = u_ModelMatrix; 1270 vec4 strokeColor = u_StrokeColor; 1271 float zIndex = u_ZIndexStrokeWidth.x; 1272 float strokeWidth = u_ZIndexStrokeWidth.y; 1273 float strokeMiterlimit = u_ZIndexStrokeWidth.z; 1274 float strokeAlignment = u_ZIndexStrokeWidth.w; 1275 bool sizeAttenuation = u_Opacity.w > 0.5; 1276 1277 if (sizeAttenuation) { 1278 strokeWidth /= u_ZoomScale; 1279 } 1280 1281 vec2 pointA; 1282 vec2 pointB; 1283 // vec4 clip0 = vec4((u_ProjectionMatrix 1284 // * u_ViewMatrix 1285 // * model 1286 // * vec3(a_PointA, 1)).xy, zIndex, 1);; 1287 // vec4 clip1 = vec4((u_ProjectionMatrix 1288 // * u_ViewMatrix 1289 // * model 1290 // * vec3(a_PointB, 1)).xy, zIndex, 1);; 1291 1292 // if (sizeAttenuation) { 1293 // pointA = clip2ScreenSpace(clip0); 1294 // pointB = clip2ScreenSpace(clip1); 1295 // } else { 1296 pointA = (model * vec3(a_PointA, 1.0)).xy; 1297 pointB = (model * vec3(a_PointB, 1.0)).xy; 1298 // } 1299 1300 vec2 xBasis = pointB - pointA; 1301 float len = length(xBasis); 1302 vec2 forward = xBasis / len; 1303 vec2 norm = vec2(forward.y, -forward.x); 1304 1305 float type = a_VertexJoint; 1306 float vertexNum = a_VertexNum; 1307 1308 float capType = floor(type / 32.0); 1309 type -= capType * 32.0; 1310 v_Arc = vec4(0.0); 1311 strokeWidth *= 0.5; 1312 float strokeAlignmentFactor = 2.0 * strokeAlignment - 1.0; 1313 1314 vec2 pos; 1315 1316 if (capType == CAP_ROUND) { 1317 if (vertexNum < 3.5) { 1318 gl_Position = vec4(0.0, 0.0, 0.0, 1.0); 1319 return; 1320 } 1321 type = JOINT_CAP_ROUND; 1322 capType = 0.0; 1323 } 1324 1325 if (type >= BEVEL) { 1326 float dy = strokeWidth + expand; 1327 float inner = 0.0; 1328 if (vertexNum >= 1.5) { 1329 dy = -dy; 1330 inner = 1.0; 1331 } 1332 1333 vec2 base, next, xBasis2, bisect; 1334 float flag = 0.0; 1335 float sign2 = 1.0; 1336 if (vertexNum < 0.5 || vertexNum > 2.5 && vertexNum < 3.5) { 1337 // if (sizeAttenuation) { 1338 // next = clip2ScreenSpace(vec4((u_ProjectionMatrix 1339 // * u_ViewMatrix 1340 // * model 1341 // * vec3(a_Prev, 1)).xy, zIndex, 1)); 1342 // } else { 1343 next = (model * vec3(a_Prev, 1.0)).xy; 1344 // } 1345 1346 base = pointA; 1347 flag = type - floor(type / 2.0) * 2.0; 1348 sign2 = -1.0; 1349 } else { 1350 // if (sizeAttenuation) { 1351 // next = clip2ScreenSpace(vec4((u_ProjectionMatrix
1352 // * u_ViewMatrix 1353 // * model 1354 // * vec3(a_Next, 1)).xy, zIndex, 1)); 1355 // } else { 1356 next = (model * vec3(a_Next, 1.0)).xy; 1357 // } 1358 1359 base = pointB; 1360 if (type >= MITER && type < MITER + 3.5) { 1361 flag = step(MITER + 1.5, type); 1362 // check miter limit here? 1363 } 1364 } 1365 1366 xBasis2 = next - base; 1367 float len2 = length(xBasis2); 1368 vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2; 1369 float D = norm.x * norm2.y - norm.y * norm2.x; 1370 if (D < 0.0) { 1371 inner = 1.0 - inner; 1372 } 1373 norm2 *= sign2; 1374 1375 if (abs(strokeAlignmentFactor) > 0.01) { 1376 float shift = strokeWidth * strokeAlignmentFactor; 1377 pointA += norm * shift; 1378 pointB += norm * shift; 1379 if (abs(D) < 0.01) { 1380 base += norm * shift; 1381 } else { 1382 base += doBisect(norm, len, norm2, len2, shift, 0.0); 1383 } 1384 } 1385 1386 float collinear = step(0.0, dot(norm, norm2)); 1387 v_Type = 0.0; 1388 float dy2 = -1000.0; 1389 float dy3 = -1000.0; 1390 if (abs(D) < 0.01 && collinear < 0.5) { 1391 if (type >= ROUND && type < ROUND + 1.5) { 1392 type = JOINT_CAP_ROUND; 1393 } 1394 // TODO: BUTT here too 1395 } 1396 1397 if (vertexNum < 3.5) { 1398 if (abs(D) < 0.01) { 1399 pos = dy * norm; 1400 } else { 1401 if (flag < 0.5 && inner < 0.5) { 1402 pos = dy * norm; 1403 } else { 1404 pos = doBisect(norm, len, norm2, len2, dy, inner); 1405 } 1406 } 1407 if (capType >= CAP_BUTT && capType < CAP_ROUND) { 1408 float extra = step(CAP_SQUARE, capType) * strokeWidth; 1409 vec2 back = -forward; 1410 if (vertexNum < 0.5 || vertexNum > 2.5) { 1411 pos += back * (expand + extra); 1412 dy2 = expand; 1413 } else { 1414 dy2 = dot(pos + base - pointA, back) - extra; 1415 } 1416 } 1417 if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) { 1418 float extra = step(JOINT_CAP_SQUARE, type) * strokeWidth; 1419 if (vertexNum < 0.5 || vertexNum > 2.5) { 1420 dy3 = dot(pos + base - pointB, forward) - extra; 1421 } else { 1422 pos += forward * (expand + extra); 1423 dy3 = expand; 1424 if (capType >= CAP_BUTT) { 1425 dy2 -= expand + extra; 1426 } 1427 } 1428 } 1429 } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) { 1430 if (inner > 0.5) { 1431 dy = -dy; 1432 inner = 0.0; 1433 } 1434 vec2 d2 = abs(dy) * forward; 1435 if (vertexNum < 4.5) { 1436 dy = -dy; 1437 pos = dy * norm; 1438 } else if (vertexNum < 5.5) { 1439 pos = dy * norm; 1440 } else if (vertexNum < 6.5) { 1441 pos = dy * norm + d2; 1442 v_Arc.x = abs(dy); 1443 } else { 1444 dy = -dy; 1445 pos = dy * norm + d2; 1446 v_Arc.x = abs(dy); 1447 } 1448 dy2 = 0.0; 1449 v_Arc.y = dy; 1450 v_Arc.z = 0.0; 1451 v_Arc.w = strokeWidth; 1452 v_Type = 3.0; 1453 } else if (abs(D) < 0.01) { 1454 pos = dy * norm; 1455 } else { 1456 if (type >= ROUND && type < ROUND + 1.5) { 1457 if (inner > 0.5) { 1458 dy = -dy; 1459 inner = 0.0; 1460 } 1461 if (vertexNum < 4.5) { 1462 pos = doBisect(norm, len, norm2, len2, -dy, 1.0); 1463 } else if (vertexNum < 5.5) { 1464 pos = dy * norm; 1465 } else if (vertexNum > 7.5) { 1466 pos = dy * norm2; 1467 } else { 1468 pos = doBisect(norm, len, norm2, len2, dy, 0.0); 1469 float d2 = abs(dy); 1470 if (length(pos) > abs(dy) * 1.5) { 1471 if (vertexNum < 6.5) { 1472 pos.x = dy * norm.x - d2 * norm.y; 1473 pos.y = dy * norm.y + d2 * norm.x; 1474 } else { 1475 pos.x = dy * norm2.x + d2 * norm2.y; 1476 pos.y = dy * norm2.y - d2 * norm2.x; 1477 } 1478 } 1479 } 1480 vec2 norm3 = normalize(norm + norm2); 1481 1482 float sign = step(0.0, dy) * 2.0 - 1.0; 1483 v_Arc.x = sign * dot(pos, norm3); 1484 v_Arc.y = pos.x * norm3.y - pos.y * norm3.x; 1485 v_Arc.z = dot(norm, norm3) * strokeWidth; 1486 v_Arc.w = strokeWidth; 1487 1488 dy = -sign * dot(pos, norm); 1489 dy2 = -sign * dot(pos, norm2); 1490 dy3 = v_Arc.z - v_Arc.x; 1491 v_Type = 3.0; 1492 } else { 1493 float hit = 0.0; 1494 if (type >= BEVEL && type < BEVEL + 1.5) { 1495 if (dot(norm, norm2) > 0.0) { 1496 type = MITER; 1497 } 1498 } 1499 if (type >= MITER && type < MITER + 3.5) { 1500 if (inner > 0.5) { 1501 dy = -dy; 1502 inner = 0.0; 1503 } 1504 float sign = step(0.0, dy) * 2.0 - 1.0; 1505 pos = doBisect(norm, len, norm2, len2, dy, 0.0); 1506 if (length(pos) > abs(dy) * strokeMiterlimit) { 1507 type = BEVEL; 1508 } else { 1509 if (vertexNum < 4.5) { 1510 dy = -dy; 1511 pos = doBisect(norm, len, norm2, len2, dy, 1.0); 1512 } else if (vertexNum < 5.5) { 1513 pos = dy * norm; 1514 } else if (vertexNum > 6.5) { 1515 pos = dy * norm2; 1516 } 1517 v_Type = 1.0; 1518 dy = -sign * dot(pos, norm); 1519 dy2 = -sign * dot(pos, norm2); 1520 hit = 1.0; 1521 } 1522 } 1523 if (type >= BEVEL && type < BEVEL + 1.5) { 1524 if (inner > 0.5) { 1525 dy = -dy; 1526 inner = 0.0; 1527 } 1528 float d2 = abs(dy); 1529 vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x); 1530 vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x); 1531 if (vertexNum < 4.5) { 1532 pos = doBisect(norm, len, norm2, len2, -dy, 1.0); 1533 } else if (vertexNum < 5.5) { 1534 pos = dy * norm; 1535 } else if (vertexNum > 7.5) { 1536 pos = dy * norm2; 1537 } else { 1538 if (vertexNum < 6.5) { 1539 pos = pos3; 1540 } else { 1541 pos = pos4; 1542 } 1543 } 1544 vec2 norm3 = normalize(norm + norm2); 1545 float sign = step(0.0, dy) * 2.0 - 1.0; 1546 dy = -sign * dot(pos, norm); 1547 dy2 = -sign * dot(pos, norm2); 1548 dy3 = (-sign * dot(pos, norm3)) + strokeWidth; 1549 v_Type = 4.0; 1550 hit = 1.0; 1551 } 1552 if (hit < 0.5) { 1553 gl_Position = vec4(0.0, 0.0, 0.0, 1.0); 1554 return; 1555 } 1556 } 1557 } 1558 pos += base; 1559 v_Distance = vec4(dy, dy2, dy3, strokeWidth) * dpr; 1560 v_Arc *= dpr; 1561 v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x)); 1562 } 1563 1564 // v_ScalingFactor = sqrt(model[0][0] * model[0][0] + model[0][1] * model[0][1] + model[0][2] * model[0][2]); 1565 v_ScalingFactor = 1.0; 1566 1567 // if (sizeAttenuation) { 1568 // vec4 clip = mix(clip0, clip1, 0.5); 1569 // gl_Position = vec4(clip.w * (2.0 * pos / u_Viewport - 1.0), clip.z, clip.w); 1570 // } else { 1571 gl_Position = vec4((u_ProjectionMatrix
1572 * u_ViewMatrix 1573 * vec3(pos, 1)).xy, zIndex, 1); 1574 // } 1575} 1576`,PNt=` 1577layout(std140) uniform SceneUniforms { 1578 mat3 u_ProjectionMatrix; 1579 mat3 u_ViewMatrix; 1580 mat3 u_ViewProjectionInvMatrix; 1581 vec4 u_BackgroundColor; 1582 vec4 u_GridColor; 1583 float u_ZoomScale; 1584 float u_CheckboardStyle; 1585 vec2 u_Viewport; 1586}; 1587 1588layout(std140) uniform ShapeUniforms { 1589 mat3 u_ModelMatrix; 1590 vec4 u_StrokeColor; 1591 vec4 u_ZIndexStrokeWidth; 1592 vec4 u_Opacity; 1593 vec4 u_StrokeDash; 1594}; 1595 1596out vec4 outputColor; 1597 1598${sR} 1599in vec4 v_Distance; 1600in vec4 v_Arc; 1601in float v_Type; 1602in float v_Travel; 1603in float v_ScalingFactor; 1604 1605float epsilon = 0.000001; 1606 1607float antialias(float distance) { 1608 return clamp(distance / fwidth(distance), 0.0, 1.0); 1609} 1610 1611float pixelLine(float x) { 1612 return clamp(x + 0.5, 0.0, 1.0); 1613} 1614// float pixelLine(float x, float A, float B) { 1615// float y = abs(x), s = sign(x); 1616// if (y * 2.0 < A - B) { 1617// return 0.5 + s * y / A; 1618// } 1619// y -= (A - B) * 0.5; 1620// y = max(1.0 - y / B, 0.0); 1621// return (1.0 + s * (1.0 - y * y)) * 0.5; 1622// //return clamp(x + 0.5, 0.0, 1.0); 1623// } 1624 1625void main() { 1626 vec4 strokeColor = u_StrokeColor; 1627 float opacity = u_Opacity.x; 1628 float strokeOpacity = u_Opacity.z; 1629 float strokeAlignment = u_ZIndexStrokeWidth.w; 1630 float alpha = 1.0; 1631 1632 float d1 = v_Distance.x; 1633 float d2 = v_Distance.y; 1634 float d3 = v_Distance.z; 1635 float w = v_Distance.w; 1636 1637 if (v_Type < 0.5) { 1638 float left = max(d1 - 0.5, -w); 1639 float right = min(d1 + 0.5, w); 1640 float near = d2 - 0.5; 1641 float far = min(d2 + 0.5, 0.0); 1642 float top = d3 - 0.5; 1643 float bottom = min(d3 + 0.5, 0.0); 1644 alpha = max(antialias(right - left), 0.0) * max(bottom - top, 0.0) * max(far - near, 0.0); 1645 } else if (v_Type < 1.5) { 1646 float a1 = pixelLine(d1 - w); 1647 float a2 = pixelLine(d1 + w); 1648 float b1 = pixelLine(d2 - w); 1649 float b2 = pixelLine(d2 + w); 1650 1651 float left = max(d1 - 0.5, -w); 1652 float right = min(d1 + 0.5, w); 1653 1654 alpha = antialias(a2 * b2 - a1 * b1); 1655 } else if (v_Type < 2.5) { 1656 alpha *= max(min(d1 + 0.5, 1.0), 0.0); 1657 alpha *= max(min(d2 + 0.5, 1.0), 0.0); 1658 alpha *= max(min(d3 + 0.5, 1.0), 0.0); 1659 } else if (v_Type < 3.5) { 1660 float a1 = pixelLine(d1 - w); 1661 float a2 = pixelLine(d1 + w); 1662 float b1 = pixelLine(d2 - w); 1663 float b2 = pixelLine(d2 + w); 1664 float alpha_miter = a2 * b2 - a1 * b1; 1665 float alpha_bevel = pixelLine(d3); 1666 1667 float r = length(v_Arc.xy); 1668 float circle_hor = pixelLine(w + r) - pixelLine(-w + r); 1669 float circle_vert = min(w * 2.0, 1.0); 1670 float alpha_circle = circle_hor * circle_vert;
1671 alpha = min(alpha_miter, max(alpha_circle, alpha_bevel)); 1672 } else { 1673 float a1 = pixelLine(d1 - w); 1674 float a2 = pixelLine(d1 + w); 1675 float b1 = pixelLine(d2 - w); 1676 float b2 = pixelLine(d2 + w); 1677 alpha = antialias(a2 * b2 - a1 * b1); 1678 alpha *= pixelLine(d3); 1679 } 1680 1681 float u_Dash = u_StrokeDash.x; 1682 float u_Gap = u_StrokeDash.y; 1683 float u_DashOffset = u_StrokeDash.z; 1684 if (u_Dash + u_Gap > 1.0) { 1685 float travel = mod(v_Travel + u_Gap * v_ScalingFactor * 0.5 + u_DashOffset, u_Dash * v_ScalingFactor + u_Gap * v_ScalingFactor) - (u_Gap * v_ScalingFactor * 0.5); 1686 float left = max(travel - 0.5, -0.5); 1687 float right = min(travel + 0.5, u_Gap * v_ScalingFactor + 0.5); 1688 alpha *= antialias(max(0.0, right - left)); 1689 } 1690 1691 outputColor = strokeColor; 1692 outputColor.a *= alpha * opacity * strokeOpacity; 1693 1694 ${iR} 1695 1696 if (outputColor.a < epsilon) { 1697 discard; 1698 } 1699} 1700`;var yl=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},I5=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},nR,NE,Ep,kE;const kH=1e-4,FI=64,r_=2,Lat=3,FNt={inner:0,center:.5,outer:1};let Ch=class extends oR{constructor(){super(...arguments),nR.set(this,void 0),NE.set(this,void 0),Ep.set(this,void 0),kE.set(this,void 0),this.instanced=!1,this.pointsBuffer=[],this.travelBuffer=[]}static check(t){return t instanceof sp||t instanceof Zh||t instanceof Qh||t instanceof au||t instanceof ky||t instanceof tp||(t instanceof ed||t instanceof Gl||t instanceof $h)&&t.strokeDasharray.length>0&&t.strokeDasharray.some(e=>e>0)||t instanceof Wc&&_nt(t.stroke,t.strokeWidth)||t instanceof Ny&&bnt(t)}validate(t){return!1}get instanceCount(){const t=this.shapes[0];return t instanceof sp||t instanceof Wc||t instanceof Zh||t instanceof Qh||t instanceof au||t instanceof ky||t instanceof tp||t instanceof Ny?this.pointsBuffer.length/Lat-3:t instanceof ed?6:t instanceof Gl||t instanceof $h?FI+1:0}createGeometry(){const t=[],e=[],r=[];let i=0;this.shapes.forEach(s=>{const{pointsBuffer:o,travelBuffer:n}=LNt(s,(s instanceof Zh||s instanceof Qh||s instanceof tp)&&this.index===2||s instanceof au&&this.index!==2||s instanceof ky);e.push(...o),r.push(...n),t.push(0+i,1+i,2+i,0+i,2+i,3+i,4+i,5+i,6+i,4+i,6+i,7+i,4+i,7+i,8+i),i+=9}),this.indexBufferData=new Uint32Array(t),this.pointsBuffer=e,this.travelBuffer=r,!(this.instanceCount<=0)&&(yl(this,Ep,"f")&&yl(this,Ep,"f").destroy(),I5(this,Ep,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*15*this.instanceCount*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),yl(this,nR,"f")&&yl(this,nR,"f").destroy(),I5(this,nR,this.device.createBuffer({viewOrSize:new Float32Array([0,1,2,3,4,5,6,7,8]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),yl(this,NE,"f")&&yl(this,NE,"f").destroy(),I5(this,NE,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*this.instanceCount,usage:dt.VERTEX,hint:Et.STATIC}),"f"),yl(this,Ep,"f").setSubData(0,new Uint8Array(new Float32Array(this.pointsBuffer).buffer)),yl(this,NE,"f").setSubData(0,new Uint8Array(new Float32Array(this.travelBuffer).buffer)),this.vertexBufferOffsets=[0,12,20,24,36,0,0],this.vertexBuffers=[yl(this,Ep,"f"),yl(this,Ep,"f"),yl(this,Ep,"f"),yl(this,Ep,"f"),yl(this,Ep,"f"),yl(this,nR,"f"),yl(this,NE,"f")],this.vertexBufferDatas=[new Float32Array(this.pointsBuffer),new Float32Array(this.pointsBuffer),new Float32Array(this.pointsBuffer),new Float32Array(this.pointsBuffer),new Float32Array(this.pointsBuffer),new Float32Array([0,1,2,3,4,5,6,7,8]),new Float32Array(this.travelBuffer)],this.vertexBufferDescriptors=[{arrayStri
1700de:12,stepMode:ne.INSTANCE,attributes:[{format:I.F32_RG,offset:0,shaderLocation:Kc.PREV}]},{arrayStride:12,stepMode:ne.INSTANCE,attributes:[{format:I.F32_RG,offset:0,shaderLocation:Kc.POINTA}]},{arrayStride:12,stepMode:ne.INSTANCE,attributes:[{format:I.F32_R,offset:0,shaderLocation:Kc.VERTEX_JOINT}]},{arrayStride:12,stepMode:ne.INSTANCE,attributes:[{format:I.F32_RG,offset:0,shaderLocation:Kc.POINTB}]},{arrayStride:12,stepMode:ne.INSTANCE,attributes:[{format:I.F32_RG,offset:0,shaderLocation:Kc.NEXT}]},{arrayStride:4,stepMode:ne.VERTEX,attributes:[{format:I.F32_R,offset:0,shaderLocation:Kc.VERTEX_NUM}]},{arrayStride:4,stepMode:ne.INSTANCE,attributes:[{format:I.F32_R,offset:0,shaderLocation:Kc.TRAVEL}]}],this.indexBuffer||(this.indexBuffer=this.device.createBuffer({viewOrSize:this.indexBufferData,usage:dt.INDEX,hint:Et.STATIC})))}createMaterial(t,e){this.instanceCount<=0||(this.createProgram(DNt,PNt,t),yl(this,kE,"f")||I5(this,kE,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*32,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),this.inputLayout=this.renderCache.createInputLayout({vertexBufferDescriptors:this.vertexBufferDescriptors,indexBufferFormat:I.U32_R,program:this.program}),this.pipeline=this.renderCache.createRenderPipeline({inputLayout:this.inputLayout,program:this.program,colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],blendConstant:kn,depthWrite:!1,depthCompare:qe.GREATER,stencilWrite:!1,stencilFront:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP},stencilBack:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP}}}),this.bindings=this.device.createBindings({pipeline:this.pipeline,uniformBufferBindings:[{buffer:e},{buffer:yl(this,kE,"f")}]}))}render(t,e){if(this.instanceCount<=0)return;if(this.shapes.some(i=>i.renderDirtyFlag)||this.geometryDirty){const{worldTransform:i}=this.shapes[0],[s,o]=this.generateBuffer(this.shapes[0]),n=i.toArray(!0);yl(this,kE,"f").setSubData(0,new Uint8Array(new Float32Array([...Hv(n),...s]).buffer));const a=Object.assign({u_ModelMatrix:n},o);this.program.setUniformsLegacy(a),this.useWireframe&&this.geometryDirty&&this.generateWireframe()}this.program.setUniformsLegacy(e),t.setPipeline(this.pipeline);const r=this.vertexBuffers.map((i,s)=>({buffer:i,offset:this.vertexBufferOffsets[s]}));this.useWireframe&&r.push({buffer:this.barycentricBuffer,offset:0}),t.setVertexInput(this.inputLayout,r,{buffer:this.indexBuffer}),t.setBindings(this.bindings),t.drawIndexed(15,this.instanceCount)}destroy(){var t;super.destroy(),this.program&&((t=yl(this,kE,"f"))===null||t===void 0||t.destroy())}generateBuffer(t){const{fillRGB:{r:e,g:r,b:i,opacity:s},strokeRGB:{r:o,g:n,b:a,opacity:l},strokeWidth:c,opacity:h,fillOpacity:u,strokeOpacity:d,strokeAlignment:f,strokeMiterlimit:g,strokeDasharray:p,strokeDashoffset:m,sizeAttenuation:v}=t,b=this.shapes[0];let y=[o/255,n/255,a/255,l];const _=[(t.globalRenderOrder+.1)/IE,c,g,FNt[f]],w=[h,u,d,v?1:0],E=[p&&p[0]||0,p&&p[1]||0,m||0,0];if((b instanceof Zh||b instanceof Qh||b instanceof tp)&&this.index===1||b instanceof au&&this.index===2)y=[e/255,r/255,i/255,s],w[2]=u;else if(b instanceof Ny){const{decorationColorRGB:A,decorationThickness:x,decorationStyle:S,metrics:T}=b;y=[A.r/255,A.g/255,A.b/255,s],_[1]=x;const R=T.fontMetrics.fontSize/14;S==="dotted"?(E[0]=R*1.5,E[1]=R):S==="dashed"&&(E[0]=R*4,E[1]=R*2)}return[[...y,..._,...w,...E],{u_StrokeColor:y,u_ZIndexStrokeWidth:_,u_Opacity:w,u_StrokeDash:E}]}};nR=new WeakMap,NE=new WeakMap,Ep=new WeakMap,kE=new WeakMap;function NNt(t){let e;switch(t){case"bevel":e=on.JOINT_BEVEL;break;case"round":e=on.JOINT_ROUND;break;default:e=on.JOINT_MITER;break}return e}function kNt(t){let e;switch(t){case"square":e=on.CAP_SQUARE;break;case"round":e=on.CAP_ROUND;break;default:e=on.CAP_BUTT;break}return e}function LNt(t,e=!0){const{strokeLinecap:r,strokeLinejoin:i}=t;let s=[];if(t instanceof Zh||t instanceof Qh||t instanceof au||t instanceof ky||t instanceof tp){const{strokePoints:d,fillPoints:f}=t;s=(e?d:f).map((g,p)=>[...g].concat(p!==d.length-1?[NaN,NaN]:[])).flat(2)}else if(t instanceof sp)s=t.points.reduce((d,f)=>(d.push(f[0],f[1]),d),[]);else if(t instanceof Wc)s=t.points.map((d,f)=>[...d].concat(f!==t.points.length-1?[NaN,NaN]:[])).flat(2);else if(t instanceof ed){const{x:d,y:f,width:g,height:p}=t;s=[d,f,d+g,f,d+g,f+p,d,f+p,d,f,d+kH,f]}else if(t instanceof Gl){const{cx:d,cy:f,r:g}=t;for(let p=0;p<FI;p++){const m=p/FI*Math.PI*2;s.push(d+g*Math.cos(m),f+g*Math.sin(m))}s.push(d+g,f)}else if(t instanceof $h){const{cx:d,cy:f,rx:g,ry:p}=t;for(let m=0;m<FI;m++){const v=m/FI*Math.PI*2;s.push(d+g*Math.cos(v),f+p*Math.sin(v))}s.push(d+g,f)}else if(t instanceof Ny){const{decorationLine:d,decorationStyle:f,decorationThickness:g,x:p,y:m,metrics:v}=t;v.lineMetrics.forEach((b,y)=>{const _=[];let w=0,E=0;const A=g;if(f==="wavy"){let S="M 0 0";for(;E+A*2<b.width;)S+=` Q ${E+A} ${w%2!=0?A:-A} ${E+A*2} 0`,E+=A*2,++w;const{subPaths:T}=TI(S),R=T.map(B=>B.getPoints().map(O=>[O[0],O[1]]));_.push(...R.flat(2))}else _.push(0,0,b.width,0);let x=0;d==="underline"||d==="overline"?x=v.height:d==="line-through"&&(x=v.height/2),_.forEach((S,T)=>{T%2===0?_[T]+=p+b.x:_[T]+=m+b.y+x}),y!==v.lineMetrics.length-1&&_.push(NaN,NaN),s.push(..._)})}const o=NNt(i),n=kNt(r);let a=n;n===on.CAP_ROUND&&(a=on.JOINT_CAP_ROUND),n===on.CAP_BUTT&&(a=on.JOINT_CAP_BUTT),n===on.CAP_SQUARE&&(a=on.JOINT_CAP_SQUARE);const l=[];let c=0;for(let d=0;d<s.length;d+=r_)(isNaN(s[d])||isNaN(s[d+1]))&&(l.push(s.slice(c,d)),c=d+2);l.push(s.slice(c));const h=[],u=[];return l.forEach(d=>{const f=[],g=[0];let p=(Math.round(0/r_)+2)*Lat,m=0,v=!1;if(d.length>=6&&d[0]===d[d.length-2]&&d[1]===d[d.length-1]){const b=[d[2]-d[0],d[3]-d[1]];d.push(d[0]+kH*b[0],d[1]+kH*b[1]),v=!0}for(let b=0;b<d.length;b+=r_)b>1&&(v&&b>=d.length-r_||(m+=Math.sqrt(Math.pow(d[b]-d[b-r_],2)+Math.pow(d[b+1]-d[b+1-r_],2)),g.push(m))),f[p++]=d[b],f[p++]=d[b+1],f[p]=o,b==0?n!==on.CAP_ROUND&&(f[p]+=n):(isNaN(d[b-2])||isNaN(d[b-1]))&&(f[p]+=on.CAP_BUTT),b+r_*2>=d.length||isNaN(d[b+4])||isNaN(d[b+5])?f[p]+=a-o:(b+r_>=d.length||isNaN(d[b+2])||isNaN(d[b+3]))&&(f[p]=0),p++;f[p++]=d[d.length-4],f[p++]=d[d.length-3],f[p++]=0,f[0]=d[0],f[1]=d[1],f[2]=0,f[3]=d[2],f[4]=d[3],f[5]=n===on.CAP_ROUND?n:0,h.push(...f),u.push(...g)}),{pointsBuffer:h,travelBuffer:u}}var D5;(function(t){t[t.BARYCENTRIC=0]="BARYCENTRIC",t[t.POSITION=1]="POSITION"})(D5||(D5={}));const UNt=` 1701layout(std140) uniform SceneUniforms { 1702 mat3 u_ProjectionMatrix; 1703 mat3 u_ViewMatrix; 1704 mat3 u_ViewProjectionInvMatrix;
1705 vec4 u_BackgroundColor; 1706 vec4 u_GridColor; 1707 float u_ZoomScale; 1708 float u_CheckboardStyle; 1709}; 1710 1711${PI} 1712layout(location = ${D5.POSITION}) in vec2 a_Position; 1713 1714layout(std140) uniform ShapeUniforms { 1715 mat3 u_ModelMatrix; 1716 vec4 u_FillColor; 1717 vec4 u_StrokeColor; 1718 vec4 u_ZIndexStrokeWidth; 1719 vec4 u_Opacity; 1720}; 1721 1722void main() { 1723 ${DI} 1724 1725 mat3 model; 1726 vec4 fillColor; 1727 vec4 strokeColor; 1728 float zIndex; 1729 float strokeWidth; 1730 float strokeAlignment; 1731 float sizeAttenuation; 1732 model = u_ModelMatrix; 1733 fillColor = u_FillColor; 1734 strokeColor = u_StrokeColor; 1735 zIndex = u_ZIndexStrokeWidth.x; 1736 strokeWidth = u_ZIndexStrokeWidth.y; 1737 strokeAlignment = u_ZIndexStrokeWidth.w; 1738 sizeAttenuation = u_Opacity.w; 1739 1740 float scale = 1.0; 1741 if (sizeAttenuation > 0.5) { 1742 scale = 1.0 / u_ZoomScale; 1743 } 1744 1745 gl_Position = vec4((u_ProjectionMatrix 1746 * u_ViewMatrix 1747 * model 1748 * vec3(a_Position * scale, 1)).xy, zIndex, 1); 1749} 1750`,GNt=` 1751layout(std140) uniform SceneUniforms { 1752 mat3 u_ProjectionMatrix; 1753 mat3 u_ViewMatrix; 1754 mat3 u_ViewProjectionInvMatrix; 1755 vec4 u_BackgroundColor; 1756 vec4 u_GridColor; 1757 float u_ZoomScale; 1758 float u_CheckboardStyle; 1759}; 1760 1761layout(std140) uniform ShapeUniforms { 1762 mat3 u_ModelMatrix; 1763 vec4 u_FillColor; 1764 vec4 u_StrokeColor; 1765 vec4 u_ZIndexStrokeWidth; 1766 vec4 u_Opacity; 1767}; 1768 1769${sR} 1770 1771out vec4 outputColor; 1772 1773float epsilon = 0.000001; 1774 1775void main() { 1776 float strokeWidth; 1777 vec4 fillColor; 1778 vec4 strokeColor; 1779 float opacity; 1780 float fillOpacity; 1781 float strokeOpacity; 1782 float cornerRadius; 1783 float strokeAlignment; 1784 1785 fillColor = u_FillColor; 1786 strokeColor = u_StrokeColor; 1787 strokeWidth = u_ZIndexStrokeWidth.y; 1788 opacity = u_Opacity.x; 1789 fillOpacity = u_Opacity.y; 1790 strokeOpacity = u_Opacity.z; 1791 cornerRadius = u_ZIndexStrokeWidth.z; 1792 strokeAlignment = u_ZIndexStrokeWidth.w; 1793 1794 // based on the target alpha compositing mode. 1795 fillColor.a *= fillOpacity; 1796 strokeColor.a *= strokeOpacity; 1797 1798 outputColor = fillColor; 1799 outputColor.a *= opacity; 1800 1801 ${iR} 1802 1803 if (outputColor.a < epsilon) 1804 discard; 1805} 1806`;rT=function(t,e,r=2){const i=e&&e.length,s=i?e[0]*r:t.length;let o=Uat(t,0,s,r,!0);const n=[];if(!o||o.next===o.prev)return n;let a,l,c;if(i&&(o=VNt(t,e,o,r)),t.length>80*r){a=1/0,l=1/0;let h=-1/0,u=-1/0;for(let d=r;d<s;d+=r){const f=t[d],g=t[d+1];f<a&&(a=f),g<l&&(l=g),f>h&&(h=f),g>u&&(u=g)}c=Math.max(h-a,u-l),c=c!==0?32767/c:0}return NI(o,n,r,a,l,c,0),n};function Uat(t,e,r,i,s){let o;if(s===rkt(t,e,r,i)>0)for(let n=e;n<r;n+=i)o=jat(n/i|0,t[n],t[n+1],o);else for(let n=r-i;n>=e;n-=i)o=jat(n/i|0,t[n],t[n+1],o);return o&&P5(o,o.next)&&(LI(o),o=o.next),o}function LE(t,e){if(!t)return t;e||(e=t);let r=t,i;do if(i=!1,!r.steiner&&(P5(r,r.next)||Gn(r.prev,r,r.next)===0)){if(LI(r),r=e=r.prev,r===r.next)break;i=!0}else r=r.next;while(i||r!==e);return e}function NI(t,e,r,i,s,o,n){if(!t)return;!n&&o&&qNt(t,i,s,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?jNt(t,i,s,o):WNt(t)){e.push(l.i,t.i,c.i),LI(t),t=c.next,a=c.next;continue}if(t=c,t===a){n?n===1?(t=XNt(LE(t),e),NI(t,e,r,i,s,o,2)):n===2&&zNt(t,e,r,i,s,o):NI(LE(t),e,r,i,s,o,1);break}}}function WNt(t){const e=t.prev,r=t,i=t.next;if(Gn(e,r,i)>=0)return!1;const s=e.x,o=r.x,n=i.x,a=e.y,l=r.y,c=i.y,h=s<o?s<n?s:n:o<n?o:n,u=a<l?a<c?a:c:l<c?l:c,d=s>o?s>n?s:n:o>n?o:n,f=a>l?a>c?a:c:l>c?l:c;let g=i.next;for(;g!==e;){if(g.x>=h&&g.x<=d&&g.y>=u&&g.y<=f&&aR(s,a,o,l,n,c,g.x,g.y)&&Gn(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function jNt(t,e,r,i){const s=t.prev,o=t,n=t.next;if(Gn(s,o,n)>=0)return!1;const a=s.x,l=o.x,c=n.x,h=s.y,u=o.y,d=n.y,f=a<l?a<c?a:c:l<c?l:c,g=h<u?h<d?h:d:u<d?u:d,p=a>l?a>c?a:c:l>c?l:c,m=h>u?h>d?h:d:u>d?u:d,v=LH(f,g,e,r,i),b=LH(p,m,e,r,i);let y=t.prevZ,_=t.nextZ;for(;y&&y.z>=v&&_&&_.z<=b;){if(y.x>=f&&y.x<=p&&y.y>=g&&y.y<=m&&y!==s&&y!==n&&aR(a,h,l,u,c,d,y.x,y.y)&&Gn(y.prev,y,y.next)>=0||(y=y.prevZ,_.x>=f&&_.x<=p&&_.y>=g&&_.y<=m&&_!==s&&_!==n&&aR(a,h,l,u,c,d,_.x,_.y)&&Gn(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;y&&y.z>=v;){if(y.x>=f&&y.x<=p&&y.y>=g&&y.y<=m&&y!==s&&y!==n&&aR(a,h,l,u,c,d,y.x,y.y)&&Gn(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;_&&_.z<=b;){if(_.x>=f&&_.x<=p&&_.y>=g&&_.y<=m&&_!==s&&_!==n&&aR(a,h,l,u,c,d,_.x,_.y)&&Gn(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function XNt(t,e){let r=t;do{const i=r.prev,s=r.next.next;!P5(i,s)&&Gat(i,r,r.next,s)&&kI(i,s)&&kI(s,i)&&(e.push(i.i,r.i,s.i),LI(r),LI(r.next),r=t=s),r=r.next}
vendor: 1,446 bytes, line 1806
1806while(r!==t);return LE(r)}function zNt(t,e,r,i,s,o){let n=t;do{let a=n.next.next;for(;a!==n.prev;){if(n.i!==a.i&&QNt(n,a)){let l=Wat(n,a);n=LE(n,n.next),l=LE(l,l.next),NI(n,e,r,i,s,o,0),NI(l,e,r,i,s,o,0);return}a=a.next}n=n.next}while(n!==t)}function VNt(t,e,r,i){const s=[];for(let o=0,n=e.length;o<n;o++){const a=e[o]*i,l=o<n-1?e[o+1]*i:t.length,c=Uat(t,a,l,i,!1);c===c.next&&(c.steiner=!0),s.push(JNt(c))}s.sort(YNt);for(let o=0;o<s.length;o++)r=$Nt(s[o],r);return r}function YNt(t,e){return t.x-e.x}function $Nt(t,e){const r=HNt(t,e);if(!r)return e;const i=Wat(r,t);return LE(i,i.next),LE(r,r.next)}function HNt(t,e){let r=e;const i=t.x,s=t.y;let o=-1/0,n;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){const u=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(u<=i&&u>o&&(o=u,n=r.x<r.next.x?r:r.next,u===i))return n}r=r.next}while(r!==e);if(!n)return null;const a=n,l=n.x,c=n.y;let h=1/0;r=n;do{if(i>=r.x&&r.x>=l&&i!==r.x&&aR(s<c?i:o,s,l,c,s<c?o:i,s,r.x,r.y)){const u=Math.abs(s-r.y)/(i-r.x);kI(r,t)&&(u<h||u===h&&(r.x>n.x||r.x===n.x&&KNt(n,r)))&&(n=r,h=u)}r=r.next}while(r!==a);return n}function KNt(t,e){return Gn(t.prev,t,e.prev)<0&&Gn(e.next,t,t.next)<0}function qNt(t,e,r,i){let s=t;do s.z===0&&(s.z=LH(s.x,s.y,e,r,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,ZNt(s)}function ZNt(t){let e,r=1;do{let i=t,s;t=null;let o=null;for(e=0;i;){e++;let n=i,a=0;for(let c=0;c<r&&(a++,n=n.nextZ,!!n);c++);let l=r;
vendor: 1,590 bytes, line 1806
1806for(;a>0||l>0&&n;)a!==0&&(l===0||!n||i.z<=n.z)?(s=i,i=i.nextZ,a--):(s=n,n=n.nextZ,l--),o?o.nextZ=s:t=s,s.prevZ=o,o=s;i=n}o.nextZ=null,r*=2}while(e>1);return t}function LH(t,e,r,i,s){return t=(t-r)*s|0,e=(e-i)*s|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function JNt(t){let e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function aR(t,e,r,i,s,o,n,a){return(s-n)*(e-a)>=(t-n)*(o-a)&&(t-n)*(i-a)>=(r-n)*(e-a)&&(r-n)*(o-a)>=(s-n)*(i-a)}function QNt(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!tkt(t,e)&&(kI(t,e)&&kI(e,t)&&ekt(t,e)&&(Gn(t.prev,t,e.prev)||Gn(t,e.prev,e))||P5(t,e)&&Gn(t.prev,t,t.next)>0&&Gn(e.prev,e,e.next)>0)}function Gn(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function P5(t,e){return t.x===e.x&&t.y===e.y}function Gat(t,e,r,i){const s=N5(Gn(t,e,r)),o=N5(Gn(t,e,i)),n=N5(Gn(r,i,t)),a=N5(Gn(r,i,e));return!!(s!==o&&n!==a||s===0&&F5(t,r,e)||o===0&&F5(t,i,e)||n===0&&F5(r,t,i)||a===0&&F5(r,e,i))}function F5(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function N5(t){return t>0?1:t<0?-1:0}function tkt(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&Gat(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function kI(t,e){return Gn(t.prev,t,t.next)<0?Gn(t,e,t.next)>=0&&Gn(t,t.prev,e)>=0:Gn(t,e,t.prev)<0||Gn(t,t.next,e)<0}function ekt(t,e){let r=t,i=!1;const s=(t.x+e.x)/2,o=(t.y+e.y)/2;do r.y>o!=r.next.y>
1806o&&r.next.y!==r.y&&s<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next;while(r!==t);return i}function Wat(t,e){const r=UH(t.i,t.x,t.y),i=UH(e.i,e.x,e.y),s=t.next,o=e.prev;return t.next=e,e.prev=t,r.next=s,s.prev=r,i.next=r,r.prev=i,o.next=i,i.prev=o,i}function jat(t,e,r,i){const s=UH(t,e,r);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function LI(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function UH(t,e,r){return{i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function rkt(t,e,r,i){let s=0;for(let o=e,n=r-i;o<r;o+=i)s+=(t[n]-t[o])*(t[o+1]+t[n+1]),n=o;return s}function ikt(t){const e=[],r=[],i=t[0][0].length;let s=0,o=0;for(const n of t){for(const a of n)for(let l=0;l<i;l++)e.push(a[l]);o&&(s+=o,r.push(s)),o=n.length}return{vertices:e,holes:r,dimensions:i}}var lR=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},skt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},UE,k5;const okt={center:0,inner:1,outer:2};let UI=class l1t extends oR{constructor(){super(...arguments),UE.set(this,void 0),k5.set(this,void 0),this.points=[],this.instanced=!1}static useDash(e){const{strokeDasharray:r}=e;return r.length>0&&r.some(i=>i>0)}validate(e){if(!super.validate(e))return!1;if(this.shapes.length===0)return!0;if(this.shapes[0].d!==e.d)return!1;const r=!gl(this.shapes[0].fill),i=!gl(e.fill);return r!==i?!1:r&&i?this.shapes[0].fill===e.fill:!0}createGeometry(){const e=this.shapes[0];let r,i;e instanceof Wc?(r=e.points,i=e.tessellationMethod):(e instanceof Zh||e instanceof Qh||e instanceof au||e instanceof tp)&&(r=e.fillPathPoints,i=cE.EARCUT);const s=r.flat(2);if(s.length!==0){if(i===cE.EARCUT){let o=[],n=[];const a=[];let l=0,c=DH(r[0]);r.forEach(h=>{DH(h)!==c?o.push(n.length):(c=DH(h),o.length>0&&(a.push(...rT(n.flat(),o).map(u=>u+l)),l+=n.length,o=[],n=[])),n.push(...h)}),n.length&&a.push(...rT(n.flat(),o).map(h=>h+l)),this.indexBufferData=new Uint32Array(a),this.points=s}else if(i===cE.LIBTESS){const o=oNt(r,e.fillRule);this.indexBufferData=new Uint32Array(new Array(o.length/2).fill(void 0).map((n,a)=>a)),this.points=o}this.vertexBuffers[0]&&this.vertexBuffers[0].destroy(),this.vertexBufferDatas[0]=new Float32Array(this.points),this.vertexBuffers[0]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[0],usage:dt.VERTEX,hint:Et.STATIC}),this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=this.device.createBuffer({viewOrSize:this.indexBufferData,usage:dt.INDEX,hint:Et.STATIC}),this.vertexBufferDescriptors=[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:D5.POSITION,offset:0,format:I.F32_RG}]}]}}createMaterial(e,r){if(this.points.length===0)return;this.createProgram(UNt,GNt,e),lR(this,UE,"f")||skt(this,UE,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*36,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),this.pipeline=this.renderCache.createRenderPipeline({inputLayout:this.inputLayout,program:this.program,colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,topology:Go.TRIANGLES,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],blendConstant:kn,depthWrite:!0,depthCompare:qe.GREATER,stencilWrite:!1,stencilFront:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP},stencilBack:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP}}}),this.device.setResourceName(this.pipeline,"MeshPipeline");const i={pipeline:this.pipeline,uniformBufferBindings:[{buffer:r},{buffer:lR(this,UE,"f")}]};this.bindings=this.renderCache.createBindings(i)}render(e,r){if(this.points.length===0)return;if(this.shapes.some(s=>s.renderDirtyFlag)||this.geometryDirty){const{worldTransform:s}=this.shapes[0],[o,n]=this.generateBuffer(this.shapes[0]),a=s.toArray(!0);lR(this,UE,"f").setSubData(0,new Uint8Array(new Float32Array([...Hv(a),...o]).buffer));const l=Object.assign({u_ModelMatrix:a},n);this.useFillImage&&(l.u_FillImage=lR(this,k5,"f")),this.program.setUniformsLegacy(l),this.useWireframe&&this.geometryDirty&&this.generateWireframe()}this.program.setUniformsLegacy(r),e.setPipeline(this.pipeline);const i=this.vertexBuffers.map(s=>({buffer:s}));this.useWireframe&&i.push({buffer:this.barycentricBuffer}),e.setVertexInput(this.inputLayout,i,{buffer:this.indexBuffer}),e.setBindings(this.bindings),e.drawIndexed(this.indexBufferData.length,this.shapes.length)}destroy(){var e,r;super.destroy(),this.program&&((e=lR(this,UE,"f"))===null||e===void 0||e.destroy(),(r=lR(this,k5,"f"))===null||r===void 0||r.destroy())}generateBuffer(e){const{fillRGB:r,strokeRGB:{r:i,g:s,b:o,opacity:n},strokeWidth:a,strokeAlignment:l,opacity:c,fillOpacity:h,strokeOpacity:u,sizeAttenuation:d}=e,{r:f,g,b:p,opacity:m}=r||{},v=[f/255,g/255,p/255,m],b=[i/255,s/255,o/255,n],y=[e.globalRenderOrder/IE,l1t.useDash(e)?0:a,0,okt[l]],_=[c,h,u,d?1:0];return[[...v,...b,...y,..._],{u_FillColor:v,u_StrokeColor:b,u_ZIndexStrokeWidth:y,u_Opacity:_}]}};UE=new WeakMap,k5=new WeakMap;
1806class nkt extends oR{validate(){return!1}createGeometry(){}createMaterial(e,r){}render(e,r){const i=this.shapes[0];i&&i.render(e,r)}}function Ss(t,e=0){return t+=e,t+=t<<10,t+=t>>>6,t>>>0}function Xat(t){return t+=t<<3,t^=t>>>11,t+=t<<15,t>>>0}function GH(){return 0}let akt=class{constructor(){this.keys=[],this.values=[]}},GI=class{constructor(t,e){this.keyEqualFunc=t,this.keyHashFunc=e,this.buckets=new Map}findBucketIndex(t,e){for(let r=0;r<t.keys.length;r++)if(this.keyEqualFunc(e,t.keys[r]))return r;return-1}findBucket(t){const e=this.keyHashFunc(t);return this.buckets.get(e)}get(t){const e=this.findBucket(t);if(e===void 0)return null;const r=this.findBucketIndex(e,t);return r<0?null:e.values[r]}add(t,e){const r=this.keyHashFunc(t);this.buckets.get(r)===void 0&&this.buckets.set(r,new akt);const i=this.buckets.get(r);i.keys.push(t),i.values.push(e)}delete(t){const e=this.findBucket(t);if(e===void 0)return;const r=this.findBucketIndex(e,t);r!==-1&&(e.keys.splice(r,1),e.values.splice(r,1))}clear(){this.buckets.clear()}size(){let t=0;for(const e of this.buckets.values())t+=e.values.length;return t}*values(){for(const t of this.buckets.values())for(let e=t.values.length-1;e>=0;e--)yield t.values[e]}};function zat(t,e){return t=Ss(t,e.blendMode),t=Ss(t,e.blendSrcFactor),t=Ss(t,e.blendDstFactor),t}function lkt(t,e){return t=zat(t,e.rgbBlendState),t=zat(t,e.alphaBlendState),t=Ss(t,e.channelWriteMask),t}function ckt(t,e){return t=Ss(t,e.r<<24|e.g<<16|e.b<<8|e.a),t}function hkt(t,e){var r,i,s,o,n,a,l,c;for(let h=0;h<e.attachmentsState.length;h++)t=lkt(t,e.attachmentsState[h]);return t=ckt(t,e.blendConstant||kn),t=Ss(t,e.depthCompare),t=Ss(t,e.depthWrite?1:0),t=Ss(t,(r=e.stencilFront)===null||r===void 0?void 0:r.compare),t=Ss(t,(i=e.stencilFront)===null||i===void 0?void 0:i.passOp),t=Ss(t,(s=e.stencilFront)===null||s===void 0?void 0:s.failOp),t=Ss(t,(o=e.stencilFront)===null||o===void 0?void 0:o.depthFailOp),t=Ss(t,(n=e.stencilBack)===null||n===void 0?void 0:n.compare),t=Ss(t,(a=e.stencilBack)===null||a===void 0?void 0:a.passOp),t=Ss(t,(l=e.stencilBack)===null||l===void 0?void 0:l.failOp),t=Ss(t,(c=e.stencilBack)===null||c===void 0?void 0:c.depthFailOp),t=Ss(t,e.stencilWrite?1:0),t=Ss(t,e.cullMode),t=Ss(t,e.frontFace?1:0),t=Ss(t,e.polygonOffset?1:0),t}function ukt(t){let e=0;e=Ss(e,t.program.id),t.inputLayout!==null&&(e=Ss(e,t.inputLayout.id)),e=hkt(e,t.megaStateDescriptor);for(let r=0;r<t.colorAttachmentFormats.length;r++)e=Ss(e,t.colorAttachmentFormats[r]||0);return e=Ss(e,t.depthStencilAttachmentFormat||0),Xat(e)}function dkt(t){let e=0;if(t.pipeline&&(e=Ss(e,t.pipeline.id)),t.samplerBindings)for(let r=0;r<t.samplerBindings.length;r++){const i=t.samplerBindings[r];i!==null&&i.texture!==null&&(e=Ss(e,i.texture.id))}if(t.uniformBufferBindings)for(let r=0;r<t.uniformBufferBindings.length;r++){const i=t.uniformBufferBindings[r];i!==null&&i.buffer!==null&&(e=Ss(e,i.buffer.id),e=Ss(e,i.binding),e=Ss(e,i.offset),e=Ss(e,i.size))}if(t.storageBufferBindings)for(let r=0;r<t.storageBufferBindings.length;r++){const i=t.storageBufferBindings[r];i!==null&&i.buffer!==null&&(e=Ss(e,i.buffer.id),e=Ss(e,i.binding),e=Ss(e,i.offset),e=Ss(e,i.size))}if(t.storageTextureBindings)for(let r=0;r<t.storageTextureBindings.length;r++){const i=t.storageTextureBindings[r];i!==null&&i.texture!==null&&(e=Ss(e,i.texture.id),e=Ss(e,i.binding))}return Xat(e)}function fkt(t,e){var r,i,s,o;return((r=t.vertex)===null||r===void 0?void 0:r.glsl)===((i=e.vertex)===null||i===void 0?void 0:i.glsl)&&((s=t.fragment)===null||s===void 0?void 0:s.glsl)===((o=e.fragment)===null||o===void 0?void 0:o.glsl)}function pkt(t){var e,r;return{vertex:{glsl:(e=t.vertex)===null||e===void 0?void 0:e.glsl},fragment:{glsl:(r=t.fragment)===null||r===void 0?void 0:r.glsl}}}let gkt=class{constructor(t){this.device=t,this.bindingsCache=new GI(L4,dkt),this.renderPipelinesCache=new GI(G4,ukt),this.inputLayoutsCache=new GI(W4,GH),this.programCache=new GI(fkt,GH),this.samplerCache=new GI(j4,GH)}createBindings(t){let e=this.bindingsCache.get(t);if(e===null){const r=X4(t);e=this.device.createBindings(r),this.bindingsCache.add(r,e)}return e}createRenderPipeline(t){let e=this.renderPipelinesCache.get(t);if(e===null){const r=z4(t);r.colorAttachmentFormats=r.colorAttachmentFormats.filter(i=>i),e=this.device.createRenderPipeline(r),this.renderPipelinesCache.add(r,e)}return e}createInputLayout(t){t.vertexBufferDescriptors=t.vertexBufferDescriptors.filter(r=>!!r);let e=this.inputLayoutsCache.get(t);if(e===null){const r=V4(t);e=this.device.createInputLayout(r),this.inputLayoutsCache.add(r,e)}return e}createProgram(t){let e=this.programCache.get(t);if(e===null){const r=pkt(t);e=this.device.createProgram(t),this.programCache.add(r,e)}return e}createSampler(t){let e=this.samplerCache.get(t);return e===null&&(e=this.device.createSampler(t),this.samplerCache.add(t,e)),e}
1806destroy(){for(const t of this.bindingsCache.values())t.destroy();for(const t of this.renderPipelinesCache.values())t.destroy();for(const t of this.inputLayoutsCache.values())t.destroy();for(const t of this.programCache.values())t.destroy();for(const t of this.samplerCache.values())t.destroy();this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()}};const mkt=` 1807 vec3 mod289(vec3 x) { 1808 return x - floor(x * (1.0 / 289.0)) * 289.0; 1809 } 1810 1811 vec2 mod289(vec2 x) { 1812 return x - floor(x * (1.0 / 289.0)) * 289.0; 1813 } 1814 1815 vec3 permute(vec3 x) { 1816 return mod289(((x*34.0)+1.0)*x); 1817 } 1818 1819 float snoise(vec2 v) 1820 { 1821 const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0 1822 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) 1823 -0.577350269189626, // -1.0 + 2.0 * C.x 1824 0.024390243902439); // 1.0 / 41.0 1825 // First corner 1826 vec2 i = floor(v + dot(v, C.yy) ); 1827 vec2 x0 = v - i + dot(i, C.xx); 1828 1829 // Other corners 1830 vec2 i1; 1831 //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 1832 //i1.y = 1.0 - i1.x; 1833 i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); 1834 // x0 = x0 - 0.0 + 0.0 * C.xx ; 1835 // x1 = x0 - i1 + 1.0 * C.xx ; 1836 // x2 = x0 - 1.0 + 2.0 * C.xx ; 1837 vec4 x12 = x0.xyxy + C.xxzz; 1838 x12.xy -= i1; 1839 1840 // Permutations 1841 i = mod289(i); // Avoid truncation effects in permutation 1842 vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) 1843 + i.x + vec3(0.0, i1.x, 1.0 )); 1844 1845 vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); 1846 m = m*m ; 1847 m = m*m ; 1848 1849 // Gradients: 41 points uniformly over a line, mapped onto a diamond. 1850 // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) 1851 1852 vec3 x = 2.0 * fract(p * C.www) - 1.0; 1853 vec3 h = abs(x) - 0.5; 1854 vec3 ox = floor(x + 0.5); 1855 vec3 a0 = x - ox; 1856 1857 // Normalise gradients implicitly by scaling m 1858 // Approximation of: m *= inversesqrt( a0*a0 + h*h ); 1859 m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); 1860 1861 // Compute final noise value at P 1862 vec3 g; 1863 g.x = a0.x * x0.x + h.x * x0.y; 1864 g.yz = a0.yz * x12.xz + h.yz * x12.yw; 1865 return 130.0 * dot(m, g); 1866 }`,ykt=` 1867 float aastep(float threshold, float value) { 1868 float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757; 1869 return smoothstep(threshold - afwidth, threshold + afwidth, value); 1870 } 1871`,vkt=` 1872 ${ykt} 1873 ${mkt} 1874 float absorb(float sdf, vec2 uv, float scale, float falloff) { 1875 float distort = sdf + snoise(uv * scale) * falloff; 1876 return aastep(0.5, distort); 1877 } 1878`,_kt=` 1879 ${vkt} 1880 1881 // float ink(float sdf, vec2 uv) { 1882 // float alpha = 0.0; 1883 // alpha += absorb(sdf, uv, 1000.0, 0.1) * 0.3; 1884 // alpha += absorb(sdf, uv, 50.0, 0.2) * 0.3; 1885 // alpha += absorb(sdf, uv, 500.0, 0.2) * 0.3; 1886 // return alpha; 1887 // } 1888 1889 // float ink(float sdf, vec2 uv) { 1890 // float alpha = 0.0; 1891 // alpha += absorb(sdf, uv, 80.0, 0.02) * 0.1; 1892 // alpha += absorb(sdf, uv, 50.0, 0.02) * 0.1; 1893 // alpha += absorb(sdf, uv, 500.0, 0.05) * 0.2; 1894 // alpha += absorb(sdf, uv, 1000.0, 0.05) * 0.2; 1895 // alpha += absorb(sdf, uv, 3000.0, 0.1) * 0.2; 1896 // alpha += absorb(sdf, uv, 1000.0, 0.3) * 0.15; 1897 // return alpha; 1898 // } 1899 1900 float ink(float sdf, vec2 uv) { 1901 float alpha = 0.0; 1902 alpha += absorb(sdf, uv, 600.0, 0.1) * 0.2;
1903 alpha += absorb(sdf, uv, 300.0, 0.1) * 0.2; 1904 alpha += absorb(sdf, uv, 20.0, 0.05) * 0.2; 1905 alpha += absorb(sdf, uv, 400.0, 0.05) * 0.2; 1906 alpha += absorb(sdf, uv, 100.0, 0.2) * 0.2; 1907 return alpha; 1908 } 1909`;var cR;(function(t){t[t.BARYCENTRIC=0]="BARYCENTRIC",t[t.POSITION=1]="POSITION",t[t.UV_OFFSET=2]="UV_OFFSET"})(cR||(cR={}));const bkt=` 1910layout(std140) uniform SceneUniforms { 1911 mat3 u_ProjectionMatrix; 1912 mat3 u_ViewMatrix; 1913 mat3 u_ViewProjectionInvMatrix; 1914 vec4 u_BackgroundColor; 1915 vec4 u_GridColor; 1916 float u_ZoomScale; 1917 float u_CheckboardStyle; 1918}; 1919 1920layout(std140) uniform ShapeUniforms { 1921 mat3 u_ModelMatrix; 1922 vec4 u_FillColor; 1923 vec4 u_StrokeColor; 1924 vec4 u_ZIndexStrokeWidth; 1925 vec4 u_Opacity; 1926 vec4 u_DropShadowColor; 1927 vec4 u_DropShadow; 1928 vec2 u_AtlasSize; 1929}; 1930 1931${PI} 1932layout(location = ${cR.POSITION}) in vec3 a_Position; 1933layout(location = ${cR.UV_OFFSET}) in vec4 a_UvOffset; 1934 1935out vec2 v_Uv; 1936 1937void main() { 1938 ${DI} 1939 1940 float zIndex = u_ZIndexStrokeWidth.x; 1941 float strokeWidth = u_ZIndexStrokeWidth.y; 1942 float fontSize = u_ZIndexStrokeWidth.z; 1943 float sizeAttenuation = u_Opacity.w; 1944 1945 float scale = 1.0; 1946 if (sizeAttenuation > 0.5) { 1947 scale = 1.0 / u_ZoomScale; 1948 } 1949 1950 v_Uv = a_UvOffset.xy / u_AtlasSize; 1951 vec2 offset = a_UvOffset.zw; 1952 1953 gl_Position = vec4((u_ProjectionMatrix 1954 * u_ViewMatrix 1955 * u_ModelMatrix 1956 * vec3(a_Position.xy + offset, 1)).xy, a_Position.z, 1); 1957} 1958`,wkt=` 1959layout(std140) uniform SceneUniforms { 1960 mat3 u_ProjectionMatrix; 1961 mat3 u_ViewMatrix; 1962 mat3 u_ViewProjectionInvMatrix; 1963 vec4 u_BackgroundColor; 1964 vec4 u_GridColor; 1965 float u_ZoomScale; 1966 float u_CheckboardStyle; 1967}; 1968 1969layout(std140) uniform ShapeUniforms { 1970 mat3 u_ModelMatrix; 1971 vec4 u_FillColor; 1972 vec4 u_StrokeColor; 1973 vec4 u_ZIndexStrokeWidth; 1974 vec4 u_Opacity; 1975 vec4 u_DropShadowColor; 1976 vec4 u_DropShadow; 1977 vec2 u_AtlasSize; 1978}; 1979 1980out vec4 outputColor; 1981 1982${sR} 1983in vec2 v_Uv; 1984uniform sampler2D u_Texture; 1985 1986float epsilon = 0.000001; 1987 1988float median(float r, float g, float b) { 1989 return max(min(r, g), min(max(r, g), b)); 1990} 1991 1992#define SDF_PX 8.0 1993 1994void main() { 1995 float strokeWidth = u_ZIndexStrokeWidth.y; 1996 vec4 fillColor = u_FillColor; 1997 vec4 strokeColor = u_StrokeColor; 1998 float opacity = u_Opacity.x; 1999 float fillOpacity = u_Opacity.y; 2000 float strokeOpacity = u_Opacity.z; 2001 float shapeSizeAttenuation = u_Opacity.w; 2002 vec4 dropShadow = u_DropShadow; 2003 vec4 dropShadowColor = u_DropShadowColor; 2004 float shadowDist; 2005 float shadowBlurRadius = u_DropShadow.z; 2006 2007 #ifdef USE_SDF_NONE 2008 outputColor = texture(SAMPLER_2D(u_Texture), v_Uv); 2009 #else 2010 float dist; 2011 lowp float buff; 2012 vec2 shadowOffset = u_DropShadow.xy / u_AtlasSize; 2013 2014 #ifdef USE_SDF 2015 #ifdef USE_EMOJI 2016 fillColor = texture(SAMPLER_2D(u_Texture), v_Uv); 2017 #endif 2018 dist = texture(SAMPLER_2D(u_Texture), v_Uv).a; 2019 buff = (256.0 - 64.0) / 256.0; 2020 2021 #ifdef USE_SHADOW 2022 shadowDist = texture(SAMPLER_2D(u_Texture), v_Uv - shadowOffset).a; 2023 #endif 2024 #endif 2025 2026 #ifdef USE_MSDF 2027 vec3 s = texture(SAMPLER_2D(u_Texture), v_Uv).rgb; 2028 dist = median(s.r, s.g, s.b); 2029 buff = 0.5; 2030 2031 #ifdef USE_SHADOW 2032 vec3 shadowSample = texture(SAMPLER_2D(u_Texture), v_Uv - shadowOffset).rgb; 2033 shadowDist = median(shadowSample.r, shadowSample.g, shadowSample.b); 2034 #endif 2035 #endif 2036 2037 float fontSize = u_ZIndexStrokeWidth.z; 2038 fillColor.a *= fillOpacity; 2039 strokeColor.a *= strokeOpacity; 2040 2041 highp float gamma_scaled = fwidth(dist); 2042 if (strokeWidth > 0.0 && strokeColor.a > 0.0) { 2043 float fillAlpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); 2044 float strokeThreshold = buff - strokeWidth / fontSize; 2045 float strokeAlpha = smoothstep(strokeThreshold - gamma_scaled, strokeThreshold + gamma_scaled, dist); 2046 2047 vec4 finalColor = mix(strokeColor, fillColor, fillAlpha); 2048 outputColor = finalColor; 2049 opacity *= strokeAlpha; 2050 } else { 2051 highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); 2052 opacity *= alpha; 2053 outputColor = fillColor; 2054 } 2055 #endif 2056 2057 outputColor.a *= opacity; 2058 2059 #ifdef USE_SHADOW 2060 // gamma_scaled = fwidth(shadowDist) * 128.0 / shadowBlurRadius; 2061 gamma_scaled = shadowBlurRadius / 128.0; 2062 highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, shadowDist); 2063 dropShadowColor.a *= alpha; 2064 outputColor = mix(dropShadowColor, outputColor, outputColor.a); 2065 #endif 2066 2067 ${iR} 2068 2069 if (outputColor.a < epsilon) 2070 discard; 2071} 2072`,Ekt=` 2073layout(std140) uniform SceneUniforms { 2074 mat3 u_ProjectionMatrix; 2075 mat3 u_ViewMatrix; 2076 mat3 u_ViewProjectionInvMatrix;
2077 vec4 u_BackgroundColor; 2078 vec4 u_GridColor; 2079 float u_ZoomScale; 2080 float u_CheckboardStyle; 2081}; 2082 2083layout(std140) uniform ShapeUniforms { 2084 mat3 u_ModelMatrix; 2085 vec4 u_FillColor; 2086 vec4 u_StrokeColor; 2087 vec4 u_ZIndexStrokeWidth; 2088 vec4 u_Opacity; 2089 vec4 u_DropShadowColor; 2090 vec4 u_DropShadow; 2091 vec2 u_AtlasSize; 2092}; 2093 2094out vec4 outputColor; 2095 2096${sR} 2097in vec2 v_Uv; 2098uniform sampler2D u_Texture; 2099 2100float epsilon = 0.000001; 2101 2102float median(float r, float g, float b) { 2103 return max(min(r, g), min(max(r, g), b)); 2104} 2105 2106${_kt} 2107 2108#define SDF_PX 8.0 2109 2110void main() { 2111 float strokeWidth = u_ZIndexStrokeWidth.y; 2112 vec4 fillColor = u_FillColor; 2113 vec4 strokeColor = u_StrokeColor; 2114 float opacity = u_Opacity.x; 2115 float fillOpacity = u_Opacity.y; 2116 float strokeOpacity = u_Opacity.z; 2117 float shapeSizeAttenuation = u_Opacity.w; 2118 vec4 dropShadow = u_DropShadow; 2119 vec4 dropShadowColor = u_DropShadowColor; 2120 float shadowDist; 2121 float shadowBlurRadius = u_DropShadow.z; 2122 2123 #ifdef USE_SDF_NONE 2124 outputColor = texture(SAMPLER_2D(u_Texture), v_Uv); 2125 #else 2126 float dist; 2127 lowp float buff; 2128 vec2 shadowOffset = u_DropShadow.xy / u_AtlasSize; 2129 2130 #ifdef USE_SDF 2131 #ifdef USE_EMOJI 2132 fillColor = texture(SAMPLER_2D(u_Texture), v_Uv); 2133 #endif 2134 dist = texture(SAMPLER_2D(u_Texture), v_Uv).a; 2135 buff = (256.0 - 64.0) / 256.0; 2136 2137 #ifdef USE_SHADOW 2138 shadowDist = texture(SAMPLER_2D(u_Texture), v_Uv - shadowOffset).a; 2139 #endif 2140 #endif 2141 2142 #ifdef USE_MSDF 2143 vec3 s = texture(SAMPLER_2D(u_Texture), v_Uv).rgb; 2144 dist = median(s.r, s.g, s.b); 2145 buff = 0.5; 2146 2147 #ifdef USE_SHADOW 2148 vec3 shadowSample = texture(SAMPLER_2D(u_Texture), v_Uv - shadowOffset).rgb; 2149 shadowDist = median(shadowSample.r, shadowSample.g, shadowSample.b); 2150 #endif 2151 #endif 2152 2153 float fontSize = u_ZIndexStrokeWidth.z; 2154 2155 highp float gamma_scaled; 2156 highp float alpha = ink(dist - 0.2, v_Uv); 2157 2158 opacity *= alpha; 2159 2160 outputColor = fillColor; 2161 #endif 2162 2163 outputColor.a *= opacity; 2164 2165 #ifdef USE_SHADOW 2166 // gamma_scaled = fwidth(shadowDist) * 128.0 / shadowBlurRadius; 2167 gamma_scaled = shadowBlurRadius / 128.0; 2168 alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, shadowDist); 2169 dropShadowColor.a *= alpha; 2170 outputColor = mix(dropShadowColor, outputColor, outputColor.a); 2171 #endif 2172 2173 ${iR} 2174 2175 if (outputColor.a < epsilon) 2176 discard; 2177} 2178`;var Ap=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Akt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},i_,GE,WH;let xkt=class extends oR{constructor(){super(...arguments),i_.set(this,new wNt),GE.set(this,void 0),WH.set(this,void 0)}validate(t){return super.validate(t)?this.shapes.length===0?!0:this.hash(this.shapes[0])===this.hash(t):!1}hash(t){const{metrics:e,bitmapFont:r,physical:i,dropShadowBlurRadius:s}=t;return`${e==null?void 0:e.font}-${r==null?void 0:r.fontFamily}-${i}-${s}`}get useBitmapFont(){var t;return!!(!((t=this.shapes[0])===null||t===void 0)&&t.bitmapFont)}createGeometry(){const{metrics:t,fontSize:e,fontFamily:r,fontWeight:i,fontStyle:s,bitmapFont:o,esdt:n,content:a,fill:l}=this.shapes[0],c=Pat(a),h=[],u=[],d=[];let f=0,g;if(this.useBitmapFont)g=t.fontMetrics.fontSize/o.baseMeasurementFontSize;else{g=Number(e)/(Tat/fd);const p=this.shapes.map(m=>m.bidiChars).join("");Ap(this,i_,"f").generateAtlas(t.font,r,i.toString(),s,p,this.device,n,c?l:"")}this.shapes.forEach(p=>{const{metrics:m,letterSpacing:v,bitmapFont:b}=p,{font:y,lines:_,lineHeight:w}=m,{indicesOffset:E,indexBuffer:A,charUVOffsetBuffer:x,charPositionsBuffer:S}=this.buildTextBuffers({object:p,lines:_,fontStack:y,lineHeight:w,letterSpacing:v,indicesOffset:f,bitmapFont:b,fontScale:g});f=E,d.push(...x),u.push(...S),h.push(...A)}),this.indexBufferData=new Uint32Array(h),this.vertexBuffers[0]&&this.vertexBuffers[0].destroy(),this.vertexBufferDatas[0]=new Float32Array(u),this.vertexBuffers[0]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[0],usage:dt.VERTEX,hint:Et.STATIC}),this.vertexBuffers[1]&&this.vertexBuffers[1].destroy(),this.vertexBufferDatas[1]=new Float32Array(d),this.vertexBuffers[1]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[1],usage:dt.VERTEX,hint:Et.STATIC}),this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=this.device.createBuffer({viewOrSize:this.indexBufferData,usage:dt.INDEX,hint:Et.STATIC}
2178),this.vertexBufferDescriptors=[{arrayStride:12,stepMode:ne.VERTEX,attributes:[{shaderLocation:cR.POSITION,offset:0,format:I.F32_RGB}]},{arrayStride:16,stepMode:ne.VERTEX,attributes:[{shaderLocation:cR.UV_OFFSET,offset:0,format:I.F32_RGBA}]}]}createMaterial(t,e){const{content:r,dropShadowBlurRadius:i,physical:s}=this.shapes[0];let o;if(this.useBitmapFont){const{bitmapFont:l}=this.shapes[0];l.createTexture(this.device),o=l.pages[0].texture;const{distanceField:c}=l;c.type==="msdf"?t+=`#define USE_MSDF 2179`:c.type==="sdf"?t+=`#define USE_SDF 2180`:t+=`#define USE_SDF_NONE 2181`}else t+=`#define USE_SDF 2182`,Pat(r)&&(t+=`#define USE_EMOJI 2183`),o=Ap(this,i_,"f").getAtlasTexture();i>0&&(t+=`#define USE_SHADOW 2184`),this.device.setResourceName(o,"SDFText Texture"),this.createProgram(bkt,s?Ekt:wkt,t),Ap(this,GE,"f")||Akt(this,GE,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*48,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),this.pipeline=this.renderCache.createRenderPipeline({inputLayout:this.inputLayout,program:this.program,colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],blendConstant:kn,depthWrite:!0,depthCompare:qe.GREATER,stencilWrite:!1,stencilFront:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP},stencilBack:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP}}}),this.device.setResourceName(this.pipeline,"SDFTextPipeline");const n=this.renderCache.createSampler({addressModeU:Zn.CLAMP_TO_EDGE,addressModeV:Zn.CLAMP_TO_EDGE,minFilter:io.POINT,magFilter:io.BILINEAR,mipmapFilter:xn.LINEAR,lodMinClamp:0,lodMaxClamp:0}),a={pipeline:this.pipeline,uniformBufferBindings:[{buffer:e},{buffer:Ap(this,GE,"f")}],samplerBindings:[{texture:o,sampler:n}]};this.bindings=this.renderCache.createBindings(a)}render(t,e){if(this.shapes.some(i=>i.renderDirtyFlag)||this.geometryDirty){const{worldTransform:i}=this.shapes[0],[s,o]=this.generateBuffer(this.shapes[0],this.useBitmapFont?this.shapes[0].bitmapFont.pages[0]:Ap(this,i_,"f").getAtlas().image),n=i.toArray(!0);Ap(this,GE,"f").setSubData(0,new Uint8Array(new Float32Array([...Hv(n),...s]).buffer));const a=Object.assign({u_ModelMatrix:n},o);this.program.setUniformsLegacy(a),this.useWireframe&&this.geometryDirty&&this.generateWireframe()}this.program.setUniformsLegacy(e),t.setPipeline(this.pipeline);const r=this.vertexBuffers.map(i=>({buffer:i}));this.useWireframe&&r.push({buffer:this.barycentricBuffer}),t.setVertexInput(this.inputLayout,r,{buffer:this.indexBuffer}),t.setBindings(this.bindings),t.drawIndexed(this.indexBufferData.length)}destroy(){var t,e;super.destroy(),this.program&&((t=Ap(this,GE,"f"))===null||t===void 0||t.destroy(),(e=Ap(this,WH,"f"))===null||e===void 0||e.destroy()),Ap(this,i_,"f").destroy()}generateBuffer(t,e){const{fillRGB:r,strokeRGB:{r:i,g:s,b:o,opacity:n},strokeWidth:a,opacity:l,fillOpacity:c,strokeOpacity:h,sizeAttenuation:u,fontSize:d,dropShadowColorRGB:{r:f,g,b:p,opacity:m},dropShadowOffsetX:v,dropShadowOffsetY:b,dropShadowBlurRadius:y}=t,{width:_,height:w}=e,{r:E,g:A,b:x,opacity:S}=r||{},T=[E/255,A/255,x/255,S],R=[i/255,s/255,o/255,n],B=[t.globalRenderOrder/IE,a,d,0],O=[l,c,h,u?1:0],C=[f/255,g/255,p/255,m],F=[v,b,y,0],U=[_,w];return[[...T,...R,...B,...O,...C,...F,...U],{u_FillColor:T,u_StrokeColor:R,u_ZIndexStrokeWidth:B,u_Opacity:O,u_DropShadowColor:C,u_DropShadow:F,u_AtlasSize:U}]}buildTextBuffers({object:t,lines:e,fontStack:r,lineHeight:i,letterSpacing:s,indicesOffset:o,bitmapFont:n,fontScale:a}){const{textAlign:l,textBaseline:c,x:h=0,y:u=0,bitmapFontKerning:d,metrics:f,path:g,side:p,startOffset:m}=t,v=[],b=[],y=[];let _=o;const w=Knt(c,f.fontMetrics)+f.fontMetrics.fontBoundingBoxAscent||0,E=Ap(this,i_,"f").layout(e,r,i,l,s,n,a,d,0,w,g,p,m);let A;return n?A={[r]:Object.keys(n.chars).reduce((x,S)=>{const{xAdvance:T,xOffset:R,yOffset:B,rect:O}=n.chars[S];return x[S]={rect:O,metrics:{width:T,height:n.lineHeight,left:R,top:-B+n.lineHeight,advance:T}},x},{})}
2184:A=Ap(this,i_,"f").getAtlas().positions,ANt(E,A,this.useBitmapFont).forEach((x,S,T)=>{const R=x.rotation,B=Be(x.tl.x,x.tl.y),O=Be(x.tr.x,x.tr.y),C=Be(x.bl.x,x.bl.y),F=Be(x.br.x,x.br.y);if(R!==0){const H=x.width,N=x.br.y-x.tl.y,G=Be(B[0]+H/2,B[1]+N);s5(B,R,G),s5(O,R,G),s5(C,R,G),s5(F,R,G)}v.push(x.tex.x,x.tex.y,B[0],B[1]),v.push(x.tex.x+x.tex.w,x.tex.y,O[0],O[1]),v.push(x.tex.x+x.tex.w,x.tex.y+x.tex.h,F[0],F[1]),v.push(x.tex.x,x.tex.y+x.tex.h,C[0],C[1]);const U=(t.globalRenderOrder+1/T.length*S)/IE;b.push(h,u,U,h,u,U,h,u,U,h,u,U),y.push(0+_,2+_,1+_),y.push(2+_,0+_,3+_),_+=4}),{indexBuffer:y,charUVOffsetBuffer:v,charPositionsBuffer:b,indicesOffset:_}}};i_=new WeakMap,GE=new WeakMap,WH=new WeakMap;var jH=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},ra=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},y0,WE,jE,L5,WI,jI;const pd=new WeakMap;pd.set(Gl,[NH,Ch]),pd.set($h,[NH,Ch]),pd.set(ed,[kat,NH,Ch]),pd.set(sp,[Ch]),pd.set(Wc,[UI,Ch]),pd.set(Zh,[UI,Ch,Ch]),pd.set(Qh,[UI,Ch,Ch]),pd.set(au,[kat,UI,Ch,Ch]),pd.set(ky,[Ch]),pd.set(tp,[UI,Ch,Ch]),pd.set(Ny,[Ch,xkt]),pd.set(pH,[nkt]);let Skt=class{constructor(t){this.device=t,y0.set(this,[]),WE.set(this,Object.create(null)),jE.set(this,Object.create(null)),L5.set(this,new WeakMap),WI.set(this,void 0),jI.set(this,void 0),jH(this,WI,new gkt(t),"f"),jH(this,jI,new EFt,"f")}collectDrawcallCtors(t){var e;return(e=pd.get(t.constructor))===null||e===void 0?void 0:e.map(r=>{if(!r.check||r.check&&r.check(t))return r}).filter(r=>!!r)}createDrawcalls(t,e=!1){return this.collectDrawcallCtors(t).map((r,i)=>{const s=new r(this.device,ra(this,WI,"f"),ra(this,jI,"f"),e,i);return s.add(t),s})}getOrCreateNonBatchableDrawcalls(t){let e=ra(this,WE,"f")[t.uid];return e||(e=this.createDrawcalls(t)||[],ra(this,WE,"f")[t.uid]=e),e}getOrCreateBatchableDrawcalls(t){let e=ra(this,jE,"f")[t.uid];if(!e){const r=t.constructor;let i=ra(this,L5,"f").get(r);i||(i=[]);const s=this.collectDrawcallCtors(t);e=i.find(o=>o.length===s.length&&o.every(n=>n.validate(t))),e||(e=this.createDrawcalls(t,!0)||[],i.push(e),ra(this,L5,"f").set(r,i)),e.forEach(o=>{o.add(t)}),ra(this,jE,"f")[t.uid]=e}return e}add(t){if(t.batchable){const e=this.getOrCreateBatchableDrawcalls(t);ra(this,y0,"f").indexOf(e[0])===-1&&ra(this,y0,"f").push(...e)}else ra(this,y0,"f").push(...this.getOrCreateNonBatchableDrawcalls(t))}remove(t){t.batchable?(this.getOrCreateBatchableDrawcalls(t).forEach(e=>{e.remove(t)}),delete ra(this,jE,"f")[t.uid]):delete ra(this,WE,"f")[t.uid]}destroy(){for(const t in ra(this,WE,"f"))ra(this,WE,"f")[t].forEach(e=>{e.destroyed||e.destroy()});for(const t in ra(this,jE,"f"))ra(this,jE,"f")[t].forEach(e=>{e.destroyed||e.destroy()});ra(this,WI,"f").destroy(),ra(this,jI,"f").destroy()}clear(){jH(this,y0,[],"f")}flush(t,e,r){const i=[],s=[],o=[],n=[];ra(this,y0,"f").forEach(a=>{a.shapes.forEach(l=>{l.geometryDirtyFlag&&(o.push(l),i.push(a)),l.materialDirtyFlag&&(n.push(l),s.push(a))})}
2184),i.forEach(a=>a.geometryDirty=!0),s.forEach(a=>a.materialDirty=!0),o.forEach(a=>{var l;a.geometryDirtyFlag&&((l=a.preCreateGeometry)===null||l===void 0||l.call(a),a.geometryDirtyFlag=!1)}),n.forEach(a=>a.materialDirtyFlag=!1),ra(this,y0,"f").forEach(a=>{a.submit(t,e,r)})}stats(){return{drawcallCount:ra(this,y0,"f").length}}};y0=new WeakMap,WE=new WeakMap,jE=new WeakMap,L5=new WeakMap,WI=new WeakMap,jI=new WeakMap;var Vat=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Je=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Wn=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},XE,Ba,s_,zE,VE,YE,hR,XI,uR,zI,o_,VI,$E,dR,U5,fR,HE;(function(t){t[t.NONE=0]="NONE",t[t.GRID=1]="GRID",t[t.DOTS=2]="DOTS"})(HE||(HE={})),(function(t){t[t.LIGHT=0]="LIGHT",t[t.DARK=1]="DARK"})(iE||(iE={}));let Tkt=class{constructor(){XE.set(this,void 0),Ba.set(this,void 0),s_.set(this,void 0),zE.set(this,void 0),VE.set(this,void 0),YE.set(this,void 0),hR.set(this,void 0),XI.set(this,HE.GRID),uR.set(this,iE.LIGHT),zI.set(this,void 0),o_.set(this,void 0),VI.set(this,1),$E.set(this,void 0),dR.set(this,void 0),U5.set(this,void 0),fR.set(this,void 0)}apply(t){const{hooks:e,canvas:r,renderer:i,shaderCompilerPath:s,devicePixelRatio:o,camera:n,themeColors:a}=t,l=c=>{var h,u;const d=a[Je(this,uR,"f")].background,f=a[Je(this,uR,"f")].grid,{r:g,g:p,b:m,opacity:v}=((h=sr.rgb(d))===null||h===void 0?void 0:h.rgb())||sr.rgb(0,0,0,1),{r:b,g:y,b:_,opacity:w}=((u=sr.rgb(f))===null||u===void 0?void 0:u.rgb())||sr.rgb(0,0,0,1),E=n.projectionMatrix,A=n.viewMatrix,x=n.viewProjectionMatrixInv,S=[g/255,p/255,m/255,v],T=[b/255,y/255,_/255,w],R=n.zoom,B=c?Je(this,XI,"f"):0,O=[r.width,r.height];return[new Float32Array([...Hv(E),...Hv(A),...Hv(x),...S,...T,R,B,...O]),{u_ProjectionMatrix:E,u_ViewMatrix:A,u_ViewProjectionInvMatrix:x,u_BackgroundColor:S,u_GridColor:T,u_ZoomScale:R,u_CheckboardStyle:B,u_Viewport:O}]};e.initAsync.tapPromise(()=>Vat(this,void 0,void 0,function*(){let c;i==="webgl"?c=new hd({targets:["webgl2","webgl1"],antialias:!0,shaderDebug:!0,trackResources:!1,onContextCreationError:()=>{},onContextLost:()=>{},onContextRestored(p){}}):c=new ud({shaderCompilerPath:s,onContextLost:()=>{}});const{width:h,height:u}=r,d=yield c.createSwapChain(r);d.configureSwapChain(h,u),Wn(this,XE,d,"f"),Wn(this,Ba,d.getDevice(),"f"),Wn(this,o_,new Skt(Je(this,Ba,"f")),"f"),Wn(this,s_,Je(this,Ba,"f").createRenderTargetFromTexture(Je(this,Ba,"f").createTexture({format:I.U8_RGBA_RT,width:h,height:u,usage:xr.RENDER_TARGET})),"f"),Wn(this,zE,Je(this,Ba,"f").createRenderTargetFromTexture(Je(this,Ba,"f").createTexture({format:I.D24_S8,width:h,height:u,usage:xr.RENDER_TARGET})),"f");const[f,g]=l(!0);Wn(this,YE,Je(this,Ba,"f").createBuffer({viewOrSize:f,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),Wn(this,hR,g,"f"),Wn(this,zI,new Rnt,"f")})),e.resize.tap((c,h)=>{Je(this,XE,"f").configureSwapChain(c*o,h*o),Je(this,s_,"f")&&(Je(this,s_,"f").destroy(),Wn(this,s_,Je(this,Ba,"f").createRenderTargetFromTexture(Je(this,Ba,"f").createTexture({format:I.U8_RGBA_RT,width:c*o,height:h*o,usage:xr.RENDER_TARGET})),"f"),Je(this,zE,"f").destroy(),Wn(this,zE,Je(this,Ba,"f").createRenderTargetFromTexture(Je(this,Ba,"f").createTexture({format:I.D24_S8,width:c*o,height:h*o,usage:xr.RENDER_TARGET})),"f"))}),e.destroy.tap(()=>{Je(this,o_,"f").destroy(),Je(this,YE,"f").destroy(),Je(this,zI,"f").destroy(),Je(this,s_,"f").destroy(),Je(this,zE,"f").destroy(),Je(this,Ba,"f").destroy(),Je(this,Ba,"f").checkForLeaks()}),e.beginFrame.tap(()=>{var c;const{width:h,height:u}=Je(this,XE,"f").getCanvas(),d=Je(this,XE,"f").getOnscreenTexture(),f=!Je(this,$E,"f")||Je(this,$E,"f")&&((c=Je(this,dR,"f"))===null||c===void 0?void 0:c.grid),[g,p]=l(f);Je(this,YE,"f").setSubData(0,new Uint8Array(g.buffer)),Wn(this,hR,p,"f"),Je(this,Ba,"f").beginFrame(),Wn(this,VE,Je(this,Ba,"f").createRenderPass({colorAttachment:[Je(this,s_,"f")],colorResolveTo:[d],c
2184olorClearColor:[kn],depthStencilAttachment:Je(this,zE,"f"),depthClearValue:1}),"f"),Je(this,VE,"f").setViewport(0,0,h,u),Je(this,zI,"f").render(Je(this,Ba,"f"),Je(this,VE,"f"),Je(this,YE,"f"),Je(this,hR,"f")),Je(this,o_,"f").clear(),Wn(this,VI,1,"f")}),e.endFrame.tap(({all:c,removed:h})=>{if([...c.filter(u=>u.culled),...h].forEach(u=>{u.renderable&&Je(this,o_,"f").remove(u)}),Je(this,o_,"f").flush(Je(this,VE,"f"),Je(this,YE,"f"),Je(this,hR,"f")),Je(this,Ba,"f").submitPass(Je(this,VE,"f")),Je(this,Ba,"f").endFrame(),Je(this,$E,"f")&&Je(this,fR,"f")){const{type:u,encoderOptions:d}=Je(this,dR,"f")||{},f=Je(this,XE,"f").getCanvas().toDataURL(u,d);Je(this,fR,"f").call(this,f),Wn(this,$E,!1,"f"),Wn(this,dR,void 0,"f"),Wn(this,fR,void 0,"f")}}),e.render.tap(c=>{var h,u;c.renderable&&(c.globalRenderOrder=(Wn(this,VI,(u=Je(this,VI,"f"),h=u++,u),"f"),h),Je(this,o_,"f").add(c))})}get checkboardStyle(){return Je(this,XI,"f")}set checkboardStyle(t){Wn(this,XI,t,"f")}get theme(){return Je(this,uR,"f")}set theme(t){Wn(this,uR,t,"f")}get device(){return Je(this,Ba,"f")}toDataURL(t,e){return Vat(this,void 0,void 0,function*(){return Wn(this,$E,!0,"f"),Wn(this,dR,t,"f"),Wn(this,U5,new Promise(r=>{Wn(this,fR,i=>{r(i)},"f")}),"f"),e(),Je(this,U5,"f")})}};XE=new WeakMap,Ba=new WeakMap,s_=new WeakMap,zE=new WeakMap,VE=new WeakMap,YE=new WeakMap,hR=new WeakMap,XI=new WeakMap,uR=new WeakMap,zI=new WeakMap,o_=new WeakMap,VI=new WeakMap,$E=new WeakMap,dR=new WeakMap,U5=new WeakMap,fR=new WeakMap;var xp=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},KE=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},YI,qE,n_,pR;const Rkt=.02,Ckt=4,Mkt=100,$I=[.02,.05,.1,.15,.2,.33,.5,.75,1,1.25,1.5,2,2.5,3,4],Bkt=t=>$I.find(e=>e>t)||$I[$I.length-1],Okt=t=>[...$I].reverse().find(e=>e<t)||$I[0];let Ikt=class{constructor(){YI.set(this,void 0),qE.set(this,{}),n_.set(this,void 0),pR.set(this,!1)}apply(t){const{canvas:e,camera:r,root:i,devicePixelRatio:s,api:{client2Viewport:o,getCanvasMode:n,setCursor:a}}=t;i.draggable=!0;const l=Bt();let c,h,u;const d=it();let f,g=!1;function p(E){const A=e.getBoundingClientRect(),x=E.nativeEvent.clientX-A.left,S=E.nativeEvent.clientY-A.top,T=x/(e.clientWidth||e.width/s),R=S/(e.clientHeight||e.height/s),B=T*2-1,O=R*-2+1;return[B,O]}function m(E){const A=Qt(it(),p(E),l);r.x=c+d[0]-A[0],r.y=h+d[1]-A[1]}function v(E){const A=(E.nativeEvent.clientX-f[0])/100,x=Bt();bi(x,x,[d[0],d[1]]),Mo(x,x,A),bi(x,x,[-d[0],-d[1]]),r.x=c,r.y=h,r.rotation=u,us(x,x,r.matrix),r.rotation=u+A,r.x=x[6],r.y=x[7]}i.addEventListener("dragstart",E=>{xp(this,n_,"f")||n()===Fa.HAND&&(a("grabbing"),g=E.shiftKey,fp(l,r.viewProjectionMatrixInv),c=r.x,h=r.y,u=r.rotation,Qt(d,p(E),l),f=[E.nativeEvent.clientX,E.nativeEvent.clientY])}),i.addEventListener("drag",E=>{xp(this,n_,"f")||n()===Fa.HAND&&(a("grabbing"),g?v(E):m(E))}),i.addEventListener("dragend",E=>{xp(this,n_,"f")||n()===Fa.HAND&&(a("grab"),g=!1)});const b=(E,A)=>{const x=Math.max(Rkt,Math.min(Ckt,r.zoom*Math.pow(2,A*-.01))),S=o(E);r.gotoLandmark(r.createLandmark({viewportX:S.x,viewportY:S.y,zoom:x}),{duration:0})};i.addEventListener("wheel",E=>{E.preventDefault(),E.metaKey||E.ctrlKey?b({x:E.nativeEvent.clientX,y:E.nativeEvent.clientY},E.deltaY):(r.x+=E.deltaX/r.zoom,r.y+=E.deltaY/r.zoom)});const y=E=>{E.pointerType==="mouse"?KE(this,YI,!0,"f"):xp(this,qE,"f")[E.pointerId]||(xp(this,qE,"f")[E.pointerId]={last:null}),this.touchCount>=2?KE(this,n_,!0,"f"):KE(this,n_,!1,"f")},_=E=>{if(E.pointerType==="mouse"&&KE(this,YI,!1,"f"),E.pointerType!=="mouse"&&delete xp(this,qE,"f")[E.pointerId],xp(this,pR,"f")&&this.touchCount<=1)return KE(this,pR,!1,"f"),KE(this,n_,!1,"f"),!0},w=E=>{if(this.touchCount>=2){const A=E.global.x,x=E.global.y,S=xp(this,qE,"f"),T=Object.keys(S),R=Number(T[0]),B=Number(T[1]),O=S[R],C=S[B],F=O.last&&C.last?Math.sqrt(Math.pow(C.last.x-O.last.x,2)+Math.pow(C.last.y-O.last.y,2)):null;if(R===E.pointerId?O.last={x:A,y:x}:B===E.pointerId&&(C.last={x:A,y:x}),F){const U=new ye(O.last.x+(C.last.x-O.last.x)/2,O.last.y+(C.last.y-O.last.y)/2),H=Math.sqrt(Math.pow(C.last.x-O.last.x,2)+Math.pow(C.last.y-O.last.y,2));b(U,(F/H-1)*Mkt)}else xp(this,pR,"f")||KE(this,pR,!0,"f")}};i.addEventListener("pointerdown",y),i.addEventListener("pointermove",w),i.addEventListener("pointerup",_),i.addEventListener("pointerupoutside",_),i.addEventListener("pointercancel",_)}
2184get touchCount(){return(xp(this,YI,"f")?1:0)+Object.keys(xp(this,qE,"f")).length}};YI=new WeakMap,qE=new WeakMap,n_=new WeakMap,pR=new WeakMap;let Dkt=class{apply(t){const{canvas:e,hooks:r,globalThis:i,supportsPointerEvents:s,supportsTouchEvents:o}=t,n=y=>{y.preventDefault(),r.pointerMove.call(y)},a=y=>{r.pointerUp.call(y)},l=y=>{r.pointerDown.call(y)},c=y=>{r.pointerOver.call(y)},h=y=>{r.pointerOut.call(y)},u=y=>{r.pointerCancel.call(y)},d=y=>{r.pointerWheel.call(y)},f=y=>{i.addEventListener("pointermove",n,!0),y.addEventListener("pointerdown",l,!0),y.addEventListener("pointerleave",h,!0),y.addEventListener("pointerover",c,!0),i.addEventListener("pointerup",a,!0),i.addEventListener("pointercancel",u,!0)},g=y=>{y.addEventListener("touchstart",l,!0),y.addEventListener("touchend",a,!0),y.addEventListener("touchmove",n,!0),y.addEventListener("touchcancel",u,!0)},p=y=>{i.addEventListener("mousemove",n,!0),y.addEventListener("mousedown",l,!0),y.addEventListener("mouseout",h,!0),y.addEventListener("mouseover",c,!0),i.addEventListener("mouseup",a,!0)},m=y=>{i.removeEventListener("pointermove",n,!0),y.removeEventListener("pointerdown",l,!0),y.removeEventListener("pointerleave",h,!0),y.removeEventListener("pointerover",c,!0),i.removeEventListener("pointerup",a,!0)},v=y=>{y.removeEventListener("touchstart",l,!0),y.removeEventListener("touchend",a,!0),y.removeEventListener("touchmove",n,!0),y.removeEventListener("touchcancel",u,!0)},b=y=>{i.removeEventListener("mousemove",n,!0),y.removeEventListener("mousedown",l,!0),y.removeEventListener("mouseout",h,!0),y.removeEventListener("mouseover",c,!0),i.removeEventListener("mouseup",a,!0)};"addEventListener"in i&&(r.init.tap(()=>{s?f(e):(p(e),o&&g(e)),e.addEventListener("wheel",d,{capture:!0})}),r.destroy.tap(()=>{s?m(e):(b(e),o&&v(e)),e.removeEventListener("wheel",d,!0)}))}};var Ya=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Yat=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},XH,HI,zH,af,v0;const Pkt=1,Fkt={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};let Nkt=class{constructor(){XH.set(this,!0),HI.set(this,new mp(null)),zH.set(this,new sH(null)),af.set(this,void 0),v0.set(this,void 0),this.onPointerMove=t=>{const e=this.normalizeToPointerEvent(t);for(const r of e){const i=this.bootstrapEvent(Ya(this,HI,"f"),r);Ya(this,af,"f").mapEvent(i)}this.setCursor(Ya(this,af,"f").cursor)}}get rootBoundary(){return Ya(this,af,"f")}apply(t){const{hooks:e,root:r}=t;Yat(this,v0,t,"f"),Yat(this,af,new APt(r),"f"),Ya(this,af,"f").setPickHandler((i,s)=>{const{picked:o}=e.pickSync.call({position:{x:i,y:s},picked:[],topmost:!0});return o[0]||null}),e.pointerWheel.tap(i=>{const s=this.normalizeWheelEvent(i);Ya(this,af,"f").mapEvent(s)}),e.pointerDown.tap(i=>{const s=this.normalizeToPointerEvent(i);Ya(this,XH,"f")&&s[0].isNormalized&&(i.cancelable||!("cancelable"in i))&&i.preventDefault();for(let o=0,n=s.length;o<n;o++){const a=s[o],l=this.bootstrapEvent(Ya(this,HI,"f"),a);Ya(this,af,"f").mapEvent(l)}this.setCursor(Ya(this,af,"f").cursor)}),e.pointerUp.tap(i=>{let s=i.target;i.composedPath&&i.composedPath().length>0&&(s=i.composedPath()[0]);const o=s!==Ya(this,v0,"f").canvas?"outside":"",n=this.normalizeToPointerEvent(i);for(let a=0,l=n.length;a<l;a++){const c=this.bootstrapEvent(Ya(this,HI,"f"),n[a]);c.type+=o,Ya(this,af,"f").mapEvent(c)}this.setCursor(Ya(this,af,"f").cursor)}),e.pointerMove.tap(this.onPointerMove),e.pointerOver.tap(this.onPointerMove),e.pointerOut.tap(this.onPointerMove),e.pointerCancel.tap(this.onPointerMove)}normalizeWheelEvent(t){const e=Ya(this,zH,"f");this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode;const{x:r,y:i}=this.getViewportXY(t);e.client.x=r,e.client.y=i;const{x:s,y:o}=Ya(this,v0,"f").api.viewport2Canvas(e.client);return e.screen.x=s,e.screen.y=o,e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null}
2184setCursor(t){var e,r;(r=(e=Ya(this,v0,"f").api).setCursor)===null||r===void 0||r.call(e,t)}normalizeToPointerEvent(t){const{supportsTouchEvents:e,supportsPointerEvents:r}=Ya(this,v0,"f"),i=[];if(e&&t instanceof TouchEvent)for(let s=0;s<t.changedTouches.length;s++){const o=t.changedTouches[s];Xo(o.button)&&(o.button=0),Xo(o.buttons)&&(o.buttons=1),Xo(o.isPrimary)&&(o.isPrimary=t.touches.length===1&&t.type==="touchstart"),Xo(o.width)&&(o.width=o.radiusX||1),Xo(o.height)&&(o.height=o.radiusY||1),Xo(o.tiltX)&&(o.tiltX=0),Xo(o.tiltY)&&(o.tiltY=0),Xo(o.pointerType)&&(o.pointerType="touch"),Xo(o.pointerId)&&(o.pointerId=o.identifier||0),Xo(o.pressure)&&(o.pressure=o.force||.5),Xo(o.twist)&&(o.twist=0),Xo(o.tangentialPressure)&&(o.tangentialPressure=0),o.isNormalized=!0,o.type=t.type,i.push(o)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!r||!(t instanceof globalThis.PointerEvent))){const s=t;Xo(s.isPrimary)&&(s.isPrimary=!0),Xo(s.width)&&(s.width=1),Xo(s.height)&&(s.height=1),Xo(s.tiltX)&&(s.tiltX=0),Xo(s.tiltY)&&(s.tiltY=0),Xo(s.pointerType)&&(s.pointerType="mouse"),Xo(s.pointerId)&&(s.pointerId=Pkt),Xo(s.pressure)&&(s.pressure=.5),Xo(s.twist)&&(s.twist=0),Xo(s.tangentialPressure)&&(s.tangentialPressure=0),s.isNormalized=!0,i.push(s)}else i.push(t);return i}bootstrapEvent(t,e){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);const{x:r,y:i}=this.getViewportXY(e);t.client.x=r,t.client.y=i;const{x:s,y:o}=Ya(this,v0,"f").api.viewport2Canvas(t.client);return t.screen.x=s,t.screen.y=o,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=Fkt[t.type]||t.type),t}getViewportXY(t){let e,r;const{offsetX:i,offsetY:s,clientX:o,clientY:n}=t;if(!J$(i)&&!J$(s))e=i,r=s;else{const a=Ya(this,v0,"f").api.client2Viewport({x:o,y:n});e=a.x,r=a.y}return{x:e,y:r}}};XH=new WeakMap,HI=new WeakMap,zH=new WeakMap,af=new WeakMap,v0=new WeakMap;var kkt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Lkt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},G5;const $at=new ye;let Ukt=class{constructor(){G5.set(this,void 0)}apply(t){const{hooks:e,root:r,api:{elementsFromBBox:i}}=t,s=Bo.get().createCanvas(1,1);s&&kkt(this,G5,s.getContext("2d"),"f"),e.pickSync.tap(o=>{const{position:{x:n,y:a}}=o,l=[r];return i(n,a,n,a).forEach(c=>{this.hitTest(c,n,a)&&l.unshift(c)}),o.picked=l,o})}hitTest(t,e,r){if(t.hitArea||t.renderable){t.worldTransform.applyInverse({x:e,y:r},$at);const{x:i,y:s}=$at;return t.hitArea?t.hitArea.contains(i,s):t.containsPoint(i,s,Lkt(this,G5,"f"))}return!1}};G5=new WeakMap;var Gkt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Hat=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},KI;function Kat(t,e){do{if(t&&e(t))return t;t=t==null?void 0:t.parent}while(t!=null);return null}let Wkt=class{constructor(t){KI.set(this,void 0),Gkt(this,KI,t,"f")}apply(t){const{root:e,hooks:r,api:{elementsFromPoint:i}}=t,s=o=>{const n=o.target,a=Kat(n,l=>l.draggable===!0);if(a){let l=!1;const c=o.timeStamp,h=[o.clientX,o.clientY];let u=null,d=[o.clientX,o.clientY];const f=p=>
2184{if(!l){const y=p.timeStamp-c,_=int(p.clientX,p.clientY,...h);if(y<=Hat(this,KI,"f").dragstartTimeThreshold||_<=Hat(this,KI,"f").dragstartDistanceThreshold)return;p.type="dragstart",a.dispatchEvent(p),l=!0}p.type="drag",p.dx=p.clientX-d[0],p.dy=p.clientY-d[1],a.dispatchEvent(p),d=[p.clientX,p.clientY];const m=[p.globalX,p.globalY],v=i(m[0],m[1]),b=v[v.indexOf(n)+1];if(b){const y=Kat(b,_=>_.droppable===!0);u!==y&&(u&&(p.type="dragleave",p.target=u,u.dispatchEvent(p)),y&&(p.type="dragenter",p.target=y,y.dispatchEvent(p)),u=y,u&&(p.type="dragover",p.target=u,u.dispatchEvent(p)))}};e.addEventListener("pointermove",f);const g=function(p){if(l){p.detail={preventClick:!0};const m=p;u&&(m.type="drop",m.target=u,u.dispatchEvent(m)),m.type="dragend",a.dispatchEvent(m),l=!1}e.removeEventListener("pointermove",f)};n.addEventListener("pointerup",g,{once:!0}),n.addEventListener("pointerupoutside",g,{once:!0})}};r.init.tap(()=>{e.addEventListener("pointerdown",s)}),r.destroy.tap(()=>{e.removeEventListener("pointerdown",s)})}};KI=new WeakMap;var jkt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},gR=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},W5,ZE;let Xkt=class{constructor(){W5.set(this,void 0),ZE.set(this,new ea)}apply(t){const{hooks:e,rBushRoot:r}=t;jkt(this,W5,t,"f"),e.cameraChange.tap(this.updateViewport.bind(this)),this.updateViewport(),e.beginFrame.tap(({all:i,removed:s,modified:o})=>{const{minX:n,minY:a,maxX:l,maxY:c}=gR(this,ZE,"f");[...s,...o].forEach(d=>{d.renderable&&r.remove({shape:d,minX:0,minY:0,maxX:0,maxY:0},(f,g)=>f.shape===g.shape)});const h=[];o.forEach(d=>{if(d.renderable){const f=d.getBounds();h.push({minX:f.minX,minY:f.minY,maxX:f.maxX,maxY:f.maxY,shape:d})}}),r.load(h);const u=r.search({minX:n,minY:a,maxX:l,maxY:c}).map(d=>d.shape);i.forEach(d=>{d.renderable&&d.cullable&&(d.culled=!u.includes(d))})})}updateViewport(){const{camera:t,api:{viewport2Canvas:e}}=gR(this,W5,"f"),{width:r,height:i}=t,s=e({x:0,y:0}),o=e({x:r,y:0}),n=e({x:r,y:i}),a=e({x:0,y:i});gR(this,ZE,"f").minX=Math.min(s.x,o.x,n.x,a.x),gR(this,ZE,"f").minY=Math.min(s.y,o.y,n.y,a.y),gR(this,ZE,"f").maxX=Math.max(s.x,o.x,n.x,a.x),gR(this,ZE,"f").maxY=Math.max(s.y,o.y,n.y,a.y)}};W5=new WeakMap,ZE=new WeakMap;var Io;(function(t){t.START="start",t.MOVE="move",t.MODIFIED="modified",t.CANCEL="cancel",t.COMPLETE="complete"})(Io||(Io={}));function zkt(t){const[e,r]=t,i=r.y-e.y,s=r.x-e.x;return Math.sqrt(i*i+s*s)}function Vkt(t){const[,e,r]=t,i=r.y-e.y,s=r.x-e.x;return Math.sqrt(i*i+s*s)}function qat(t){const{points:e}=t,[r]=e,{x:i,y:s}=r,o=zkt(e),n=Vkt(e);return{minX:i,minY:s,maxX:i+o,maxY:s+n}}class Ykt extends Uo{constructor(e,r){super(),this.api=e,this.layer=r,this.points=[],this.isDrawing=!1}reset(){this.id=void 0,this.isDrawing=!1,this.points=[]}}var jn=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},JE=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},gd,md,xm;const $kt=t=>{const[e,r,i,s]=t.concat().sort((a,l)=>l.y-a.y),o=[i,s].sort((a,l)=>a.x-l.x),n=[e,r].sort((a,l)=>l.x-a.x);return o.concat(n)};function Hkt(t,e,r){return Math.abs(t.x-e.x)<r||Math.abs(t.y-e.y)<r}class Zat extends Ykt{constructor(){super(...arguments),gd.set(this,void 0),md.set(this,void 0),xm.set(this,void 0)}get start(){return jn(this,gd,"f")}get end(){return jn(this,md,"f")}get state(){if(!jn(this,gd,"f")||!jn(this,md,"f"))return null;const e={canvas:this.api.viewport2Canvas({x:jn(this,md,"f").client.x,y:jn(this,gd,"f").client.y}),client:{x:jn(this,md,"f").client.x,y:jn(this,gd,"f").client.y}},r={canvas:this.api.viewport2Canvas({x:jn(this,gd,"f").client.x,y:jn(this,md,"f").client.y}),client:{x:jn(this,gd,"f").client.x,y:jn(this,md,"f").client.y}};return{points:$kt([jn(this,gd,"f").canvas,e.canvas,jn(this,md,"f").canvas,r.canvas]),id:this.id,isDrawing:this.isDrawing}}onMouseDown(e){if(jn(this,gd,"f")){this.onMouseUp(e);return}this.isDrawing=!0,JE(this,gd,{canvas:{x:e.global.x,y:e.global.y},client:{x:e.client.x,y:e.client.y}},"f"),JE(this,md,{canvas:{x:e.global.x,y:e.global.y},client:{x:e.client.x,y:e.client.y}}
2184,"f"),this.id=eH("pen"),this.emit(Io.START,this.state)}onMouseMove(e){this.isDrawing&&(JE(this,md,{canvas:{x:e.global.x,y:e.global.y},client:{x:e.client.x,y:e.client.y}},"f"),this.emit(Io.MODIFIED,this.state))}onMouseUp(e){if(this.isDrawing){if(Hkt(jn(this,gd,"f").client,jn(this,md,"f").client,2)){this.emit(Io.CANCEL,this.state),this.reset();return}this.isDrawing=!1,this.emit(Io.COMPLETE,this.state),this.reset()}}onMouseDbClick(){}onKeyDown(e){e.code==="Escape"&&(this.emit(Io.CANCEL,this.state),this.reset(),e.stopPropagation())}reset(){super.reset(),JE(this,gd,void 0,"f"),JE(this,md,void 0,"f")}render(e,r){const{points:i}=e,[s,o,n,a]=i;jn(this,xm,"f")||(JE(this,xm,new Wc(Object.assign({d:`M${s.x},${s.y}L${o.x},${o.y}L${n.x},${n.y}L${a.x},${a.y}Z`,selectable:!1},r)),"f"),this.layer.appendChild(jn(this,xm,"f"))),jn(this,xm,"f").d=`M${s.x},${s.y}L${o.x},${o.y}L${n.x},${n.y}L${a.x},${a.y}Z`,jn(this,xm,"f").visible=!0}hide(){jn(this,xm,"f")&&(jn(this,xm,"f").visible=!1)}destroy(){JE(this,xm,void 0,"f")}}gd=new WeakMap,md=new WeakMap,xm=new WeakMap;var zo=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},yd=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},qI,ZI,JI,QI,tD,eD,rD,iD,sD,mR,oD,nD,j5,_u;(function(t){t.SELECTED="selected",t.DESELECTED="deselected",t.RESIZING="resizing",t.RESIZED="resized",t.MOVED="moved",t.MOVING="moving",t.DELETED="deleted"})(_u||(_u={}));class Kkt extends Tv{constructor(e){super(e),qI.set(this,void 0),ZI.set(this,void 0),JI.set(this,void 0),QI.set(this,void 0),tD.set(this,void 0),eD.set(this,void 0),rD.set(this,void 0),iD.set(this,void 0),sD.set(this,void 0),mR.set(this,void 0),oD.set(this,void 0),nD.set(this,void 0),j5.set(this,void 0);const{target:r,maskFill:i,maskFillOpacity:s,maskStroke:o,maskStrokeOpacity:n,maskStrokeWidth:a,maskOpacity:l,anchorSize:c,anchorStroke:h,anchorFill:u,anchorFillOpacity:d,anchorStrokeOpacity:f,anchorStrokeWidth:g,anchorOpacity:p}=e;this.target=r,this.maskFill=i??"transparent",this.maskFillOpacity=s??1,this.maskStroke=o??"black",this.maskStrokeOpacity=n??1,this.maskStrokeWidth=a??1,this.maskOpacity=l??1,this.anchorSize=c??4,this.anchorStroke=h??"black",this.anchorFill=u??"transparent",this.anchorFillOpacity=d??1,this.anchorStrokeOpacity=f??1,this.anchorStrokeWidth=g??1,this.anchorOpacity=p??1,this.init()}get anchorSize(){return zo(this,rD,"f")}set anchorSize(e){zo(this,rD,"f")!==e&&yd(this,rD,e,"f")}get anchorStroke(){return zo(this,iD,"f")}set anchorStroke(e){zo(this,iD,"f")!==e&&yd(this,iD,e,"f")}get anchorFill(){return zo(this,sD,"f")}set anchorFill(e){zo(this,sD,"f")!==e&&yd(this,sD,e,"f")}get anchorFillOpacity(){return zo(this,mR,"f")}set anchorFillOpacity(e){zo(this,mR,"f")!==e&&yd(this,mR,e,"f")}get anchorStrokeOpacity(){return zo(this,oD,"f")}set anchorStrokeOpacity(e){zo(this,oD,"f")!==e&&yd(this,oD,e,"f")}get anchorStrokeWidth(){return zo(this,nD,"f")}set anchorStrokeWidth(e){zo(this,nD,"f")!==e&&yd(this,nD,e,"f")}get anchorOpacity(){return zo(this,mR,"f")}set anchorOpacity(e){zo(this,j5,"f")!==e&&yd(this,j5,e,"f")}get maskFill(){return zo(this,qI,"f")}set maskFill(e){zo(this,qI,"f")!==e&&yd(this,qI,e,"f")}get maskFillOpacity(){return zo(this,ZI,"f")}set maskFillOpacity(e){zo(this,ZI,"f")!==e&&yd(this,ZI,e,"f")}get maskStroke(){return zo(this,JI,"f")}set maskStroke(e){zo(this,JI,"f")!==e&&yd(this,JI,e,"f")}get maskStrokeOpacity(){return zo(this,QI,"f")}set maskStrokeOpacity(e){zo(this,QI,"f")!==e&&yd(this,QI,e,"f")}get maskStrokeWidth(){return zo(this,tD,"f")}set maskStrokeWidth(e){zo(this,tD,"f")!==e&&yd(this,tD,e,"f")}get maskOpacity(){return zo(this,eD,"f")}set maskOpacity(e){zo(this,eD,"f")!==e&&yd(this,eD,e,"f")}}qI=new WeakMap,ZI=new WeakMap,JI=new WeakMap,QI=new WeakMap,tD=new WeakMap,eD=new WeakMap,rD=new WeakMap,iD=new WeakMap,sD=new WeakMap,mR=new WeakMap,oD=new WeakMap,nD=new WeakMap,j5=new WeakMap;class qkt extends Kkt{init(){const e=new ea;e.addBounds(this.target.getGeometryBounds(),this.target.worldTransform);const{minX:r,minY:i,maxX:s,maxY:o}=e;this.mask=new Wc({d:`M${r} ${i}L${s} ${i}L${s} ${o}L${r} ${o}
2184Z`,fill:this.maskFill,fillOpacity:this.maskFillOpacity,stroke:this.maskStroke,strokeOpacity:this.maskStrokeOpacity,strokeWidth:this.maskStrokeWidth,opacity:this.maskOpacity,cursor:"move",batchable:!1,cullable:!1,draggable:!0,sizeAttenuation:!0,selectable:!1}),this.appendChild(this.mask);const n={r:this.anchorSize,draggable:!0,sizeAttenuation:!0,stroke:this.anchorStroke,fill:this.anchorFill,fillOpacity:this.anchorFillOpacity,strokeOpacity:this.anchorStrokeOpacity,strokeWidth:this.anchorStrokeWidth,opacity:this.anchorOpacity,batchable:!1,cullable:!1,selectable:!1};this.tlAnchor=new Gl(Object.assign({cx:r,cy:i,cursor:"nwse-resize"},n)),this.trAnchor=new Gl(Object.assign({cx:s,cy:i,cursor:"nesw-resize"},n)),this.blAnchor=new Gl(Object.assign({cx:r,cy:o,cursor:"nesw-resize"},n)),this.brAnchor=new Gl(Object.assign({cx:s,cy:o,cursor:"nwse-resize"},n)),this.mask.appendChild(this.tlAnchor),this.mask.appendChild(this.trAnchor),this.mask.appendChild(this.blAnchor),this.mask.appendChild(this.brAnchor),this.bindEventListeners()}triggerMovingEvent(e,r){this.plugin.movingEvent.detail={dx:e,dy:r},this.target.dispatchEvent(this.plugin.movingEvent)}triggerMovedEvent(){this.target.dispatchEvent(this.plugin.movingEvent)}bindEventListeners(){let e=0,r=0;const i=(s,o)=>{const{x:n,y:a}=this.mask.position,l=s-e-n,c=o-r-a;this.plugin.selected.forEach(h=>{this.plugin.getOrCreateSelectable(h).triggerMovingEvent(l,c)}),this.mask.position.x=s-e,this.mask.position.y=o-r};this.addEventListener("dragstart",s=>{s.target===this.mask&&(e=s.screen.x,r=s.screen.y)}),this.addEventListener("drag",s=>{const o=s.target,{x:n,y:a}=s.screen;o===this.mask?i(n,a):(o===this.tlAnchor||o===this.trAnchor||o===this.blAnchor||o===this.brAnchor)&&(o===this.tlAnchor?(this.tlAnchor.position.x=n-this.tlAnchor.cx,this.tlAnchor.position.y=a-this.tlAnchor.cy,this.trAnchor.position.y=this.tlAnchor.position.y,this.blAnchor.position.x=this.tlAnchor.position.x):o===this.trAnchor?(this.trAnchor.position.x=n-this.trAnchor.cx,this.trAnchor.position.y=a-this.trAnchor.cy,this.tlAnchor.position.y=a-this.tlAnchor.cy,this.brAnchor.position.x=n-this.brAnchor.cx):o===this.blAnchor?(this.blAnchor.position.x=n-this.blAnchor.cx,this.blAnchor.position.y=a-this.blAnchor.cy,this.brAnchor.position.y=a-this.brAnchor.cy,this.tlAnchor.position.x=n-this.tlAnchor.cx):o===this.brAnchor&&(this.brAnchor.position.x=n-this.brAnchor.cx,this.brAnchor.position.y=a-this.brAnchor.cy,this.blAnchor.position.y=a-this.blAnchor.cy,this.trAnchor.position.x=n-this.trAnchor.cx),this.mask.d=`M${this.tlAnchor.cx+this.tlAnchor.position.x} ${this.tlAnchor.cy+this.tlAnchor.position.y}L${this.trAnchor.cx+this.trAnchor.position.x} ${this.trAnchor.cy+this.trAnchor.position.y}L${this.brAnchor.cx+this.brAnchor.position.x} ${this.brAnchor.cy+this.brAnchor.position.y}L${this.blAnchor.cx+this.blAnchor.position.x} ${this.blAnchor.cy+this.blAnchor.position.y}Z`,this.plugin.resizingEvent.detail={tlX:this.tlAnchor.cx+this.tlAnchor.position.x,tlY:this.tlAnchor.cy+this.tlAnchor.position.y,brX:this.brAnchor.cx+this.brAnchor.position.x,brY:this.brAnchor.cy+this.brAnchor.position.y},this.target.dispatchEvent(this.plugin.resizingEvent))}),this.addEventListener("dragend",s=>{const o=s.target;o===this.mask?(this.plugin.selected.forEach(g=>{this.plugin.getOrCreateSelectable(g).triggerMovedEvent()}),this.tlAnchor.cx+=this.mask.position.x,this.tlAnchor.cy+=this.mask.position.y,this.trAnchor.cx+=this.mask.position.x,this.trAnchor.cy+=this.mask.position.y,this.blAnchor.cx+=this.mask.position.x,this.blAnchor.cy+=this.mask.position.y,this.brAnchor.cx+=this.mask.position.x,this.brAnchor.cy+=this.mask.position.y,this.mask.position.x=0,this.mask.position.y=0,this.target.dispatchEvent(this.plugin.movedEvent)):(o===this.tlAnchor||o===this.trAnchor||o===this.blAnchor||o===this.brAnchor)&&(this.tlAnchor.cx=this.tlAnchor.position.x+this.tlAnchor.cx,this.tlAnchor.cy=this.tlAnchor.position.y+this.tlAnchor.cy,this.tlAnchor.position.x=0,this.tlAnchor.position.y=0,this.trAnchor.cx=this.trAnchor.position.x+this.trAnchor.cx,this.trAnchor.cy=this.trAnchor.position.y+this.trAnchor.cy,this.trAnchor.position.x=0,this.trAnchor.position.y=0,this.blAnchor.cx=this.blAnchor.position.x+this.blAnchor.cx,this.blAnchor.cy=this.blAnchor.position.y+this.blAnchor.cy,this.blAnchor.position.x=0,this.blAnchor.position.y=0,this.brAnchor.cx=this.brAnchor.position.x+this.brAnchor.cx,this.brAnchor.cy=this.brAnchor.position.y+this.brAnchor.cy,this.brAnchor.position.x=0,this.brAnchor.position.y=0,this.plugin.resizedEvent.detail={tlX:this.tlAnchor.cx,tlY:this.tlAnchor.cy,brX:this.brAnchor.cx,brY:this.brAnchor.cy},this.target.dispatchEvent(this.plugin.resizedEvent));const{cx:n,cy:a}=this.tlAnchor,{cx:l,cy:c}=this.trAnchor,{cx:h,cy:u}=this.brAnchor,{cx:d,cy:f}=this.blAnchor;this.mask.d=`M${n} ${a}L${l} ${c}L${h} ${u}L${d} ${f}Z`})}}var yR=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
2184return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},ps=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},X5,Sm,vR,QE,ia,aD;class Zkt{constructor(e){X5.set(this,void 0),Sm.set(this,[]),vR.set(this,{}),QE.set(this,void 0),ia.set(this,void 0),aD.set(this,new Tv({zIndex:Number.MAX_SAFE_INTEGER,serializable:!1})),yR(this,X5,e,"f")}apply(e){const{root:r,api:{createCustomEvent:i,getCanvasMode:s},hooks:o}=e;function n(a){return l=>{s()===Fa.SELECT&&a(l)}}yR(this,QE,e,"f"),yR(this,ia,new Zat(e.api,ps(this,aD,"f")),"f"),this.movingEvent=i(_u.MOVING),this.movedEvent=i(_u.MOVED),this.resizingEvent=i(_u.RESIZING),this.resizedEvent=i(_u.RESIZED),r.appendChild(ps(this,aD,"f")),this.register=()=>{const a=this.bindSelectableEvents(n),l=this.bindSelectionBrush(n);this.unregister=()=>{a(),l(),this.deselectAllShapes(),yR(this,Sm,[],"f"),yR(this,vR,{},"f")}},o.modeChange.tap((a,l)=>{a===Fa.SELECT&&this.unregister(),l===Fa.SELECT&&this.register()})}bindSelectableEvents(e){const{root:r}=ps(this,QE,"f"),i=e(l=>{const c=l.target;c===r?l.shiftKey||(this.deselectAllShapes(),yR(this,Sm,[],"f")):c.selectable?(l.shiftKey||this.deselectAllShapes(),this.selectShape(c)):l.shiftKey}),s=l=>{const c=l.target,{dx:h,dy:u}=l.detail;c.position.x+=h,c.position.y+=u},o=l=>{const c=l.target;if(c instanceof Gl||c instanceof $h||c instanceof Zh||c instanceof Qh){const{x:h,y:u}=c.worldTransform.apply({x:c.cx,y:c.cy});c.cx=h,c.cy=u,c.position.x=0,c.position.y=0}},n=l=>{const c=l.target,{tlX:h,tlY:u,brX:d,brY:f}=l.detail,g=d-h,p=f-u;c instanceof Gl||c instanceof Zh?(c.cx=h+g/2,c.cy=u+p/2,c.r=g/2):c instanceof $h||c instanceof Qh?(c.cx=h+g/2,c.cy=u+p/2,c.rx=g/2,c.ry=p/2):(c instanceof ed||c instanceof au)&&(c.x=h,c.y=u,c.width=g,c.height=p)},a=l=>{const c=l.target,{tlX:h,tlY:u,brX:d,brY:f}=l.detail,g=d-h,p=f-u;c instanceof Gl||c instanceof Zh?(c.cx=h+g/2,c.cy=u+p/2,c.r=g/2):c instanceof $h||c instanceof Qh?(c.cx=h+g/2,c.cy=u+p/2,c.rx=g/2,c.ry=p/2):(c instanceof ed||c instanceof au)&&(c.x=h,c.y=u,c.width=g,c.height=p)};return r.addEventListener("pointerdown",i),r.addEventListener(_u.MOVING,s),r.addEventListener(_u.MOVED,o),r.addEventListener(_u.RESIZING,n),r.addEventListener(_u.RESIZED,a),()=>{r.removeEventListener("pointerdown",i),r.removeEventListener(_u.MOVING,s),r.removeEventListener(_u.MOVED,o),r.removeEventListener(_u.RESIZING,n),r.removeEventListener(_u.RESIZED,a)}}bindSelectionBrush(e){const{root:r,api:i,themeColors:s}=ps(this,QE,"f"),{selectionBrushSortMode:o,selectionBrushStyle:n}=ps(this,X5,"f");let a=[];const l=y=>i.elementsFromBBox(y.minX,y.minY,y.maxX,y.maxY).filter(_=>{if(!_.selectable)return!1;const{minX:w,minY:E,maxX:A,maxY:x}=_.getBounds();return y.minX<w&&y.minY<E&&y.maxX>A&&y.maxY>x}),c=(y,_)=>y.length===0&&_.length===0?!0:y.length!==_.length?!1:y.every((w,E)=>w===_[E]),h=y=>{for(let _=0;_<y.length;_++){const w=y[_-1];w&&y[_].sort((E,A)=>{const x=w.indexOf(E),S=w.indexOf(A);return(x===-1?1/0:x)-(S===-1?1/0:S)})}},u=e(y=>{var _;y.button===0&&this.selected.length===0&&((_=ps(this,ia,"f"))===null||_===void 0||_.onMouseDown(y))}),d=e(y=>{var _;(_=ps(this,ia,"f"))===null||_===void 0||_.onMouseMove(y)}),f=e(y=>{var _;y.button===0&&this.selected.length===0&&((_=ps(this,ia,"f"))===null||_===void 0||_.onMouseUp(y))});r.addEventListener("pointerdown",u),r.addEventListener("pointermove",d),r.addEventListener("pointerup",f);const g=y=>{a=[];const{selectionBrushFill:_,selectionBrushStroke:w}=s[i.getTheme()];ps(this,ia,"f").render(y,Object.assign(Object.assign({},n),{fill:_,stroke:w,fillOpacity:.5}))},p=y=>{const{selectionBrushFill:_,selectionBrushStroke:w}=s[i.getTheme()];ps(this,ia,"f").render(y,Object.assign(Object.assign({},n),{fill:_,stroke:w,fillOpacity:.5}))},m=y=>{if(o==="behavior"){const E=qat(y),A=l(E),x=a[a.length-1];(!x||!c(A,x))&&a.push(A)}const{selectionBrushFill:_,selectionBrushStroke:w}=s[i.getTheme()];ps(this,ia,"f").render(y,Object.assign(Object.assign({},n),{fill:_,stroke:w,fillOpacity:.5}))},v=y=>{if(ps(this,ia,"f").hide(),o==="behavior")h(a),a[a.length-1].forEac
2184h(_=>{this.selectShape(_)});else if(o==="directional"){const _=qat(y),{start:w,end:E}=ps(this,ia,"f"),A=_.maxX-_.minX>_.maxY-_.minY?"h":"v";let x;w.canvas.x<E.canvas.x&&w.canvas.y<E.canvas.y?A==="h"?x="lr":x="tb":w.canvas.x>E.canvas.x&&w.canvas.y>E.canvas.y?A==="h"?x="rl":x="bt":w.canvas.x<E.canvas.x&&w.canvas.y>E.canvas.y?A==="h"?x="lr":x="bt":w.canvas.x>E.canvas.x&&w.canvas.y<E.canvas.y&&(A==="h"?x="rl":x="tb"),l(_).sort((S,T)=>{const R=S.getBounds(),B=T.getBounds();return x==="lr"?R.minX-B.minX:x==="rl"?B.maxX-R.maxX:x==="tb"?R.minY-B.minY:x==="bt"?B.maxY-R.maxY:null}).filter(S=>S!==null).forEach(S=>{this.selectShape(S)})}},b=()=>{ps(this,ia,"f").hide()};return ps(this,ia,"f").on(Io.START,g),ps(this,ia,"f").on(Io.MODIFIED,m),ps(this,ia,"f").on(Io.MOVE,p),ps(this,ia,"f").on(Io.COMPLETE,v),ps(this,ia,"f").on(Io.CANCEL,b),()=>{ps(this,ia,"f").off(Io.START,g),ps(this,ia,"f").off(Io.MODIFIED,m),ps(this,ia,"f").off(Io.MOVE,p),ps(this,ia,"f").off(Io.COMPLETE,v),ps(this,ia,"f").off(Io.CANCEL,b),r.removeEventListener("pointerdown",u),r.removeEventListener("pointermove",d),r.removeEventListener("pointerup",f)}}get selected(){return ps(this,Sm,"f")}getOrCreateSelectable(e){if(!ps(this,vR,"f")[e.uid]){const r=new qkt({target:e});r&&(r.plugin=this,ps(this,vR,"f")[e.uid]=r,ps(this,aD,"f").appendChild(r))}return ps(this,vR,"f")[e.uid]}selectShape(e){const r=this.getOrCreateSelectable(e);if(r&&ps(this,Sm,"f").indexOf(e)===-1){r.visible=!0,ps(this,Sm,"f").push(e);const{root:i,api:{createCustomEvent:s}}=ps(this,QE,"f");i.dispatchEvent(s("selected",e))}}deselectShape(e){const r=ps(this,Sm,"f").indexOf(e);if(r>-1){const i=this.getOrCreateSelectable(e);i&&(i.visible=!1),ps(this,Sm,"f").splice(r,1);const{root:s,api:{createCustomEvent:o}}=ps(this,QE,"f");s.dispatchEvent(o("deselected",e))}}deselectAllShapes(){[...ps(this,Sm,"f")].forEach(e=>{this.deselectShape(e)})}}X5=new WeakMap,Sm=new WeakMap,vR=new WeakMap,QE=new WeakMap,ia=new WeakMap,aD=new WeakMap;var a_=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Do=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},lD,uc,z5,cD,hD,uD,dD,fD;class Jkt{constructor(e){lD.set(this,void 0),uc.set(this,void 0),z5.set(this,new Tv({zIndex:Number.MAX_SAFE_INTEGER,serializable:!1})),cD.set(this,void 0),hD.set(this,void 0),uD.set(this,void 0),dD.set(this,void 0),fD.set(this,void 0)}apply(e){const{root:r,api:{getCanvasMode:i,createCustomEvent:s},hooks:o}=e;a_(this,lD,e,"f"),r.appendChild(Do(this,z5,"f")),a_(this,cD,s(Io.START),"f"),a_(this,hD,s(Io.MOVE),"f"),a_(this,uD,s(Io.MODIFIED),"f"),a_(this,dD,s(Io.COMPLETE),"f"),a_(this,fD,s(Io.CANCEL),"f");function n(d){return f=>{i()===Fa.DRAW_RECT&&d(f)}}const a=n(d=>{d.detail===2&&d.button===0&&Do(this,uc,"f").onMouseDbClick(d)}),l=n(d=>{d.button===0&&Do(this,uc,"f").onMouseDown(d)}),c=n(d=>{Do(this,uc,"f").onMouseMove(d)}),h=n(d=>{d.button===0&&Do(this,uc,"f").onMouseUp(d)}),u=n(d=>{Do(this,uc,"f").onKeyDown(d)});this.register=()=>{r.addEventListener("click",a),r.addEventListener("pointerdown",l),r.addEventListener("pointermove",c),r.addEventListener("pointerup",h),window.addEventListener("keydown",u)},this.unregister=()=>{r.removeEventListener("click",a),r.removeEventListener("pointerdown",l),r.removeEventListener("pointermove",c),r.removeEventListener("pointerup",h),window.removeEventListener("keydown",u)},o.modeChange.tap((d,f)=>{var g,p;d===Fa.DRAW_RECT&&(this.unregister(),(p=(g=Do(this,uc,"f")).destroy)===null||p===void 0||p.call(g),a_(this,uc,void 0,"f")),f===Fa.DRAW_RECT&&(this.register(),this.setPen(f))})}setPen(e){const{root:r}=Do(this,lD,"f");e===Fa.DRAW_RECT&&a_(this,uc,new Zat(Do(this,lD,"f").api,Do(this,z5,"f")),"f");let i;const s=c=>{this.renderPen(c),Do(this,cD,"f").detail=c,r.dispatchEvent(Do(this,cD,"f")),e===Fa.DRAW_RECT&&(i=new Wc({d:`M${c.points[0].x},${c.points[0].y}L${c.points[1].x},${c.points[1].y}L${c.points[2].x},${c.points[2].y}L${c.points[3].x},${c.points[3].y}Z`,fill:"transparent",stroke:"black",selectable:!0,sizeAttenuation:!0})),r.appendChild(i)},o=c=>{this.renderPen(c),Do(this,hD,"f").detail=c,r.dispatchEvent(Do(this,hD,"f"))},n=c=>{this.renderPen(c),Do(this,uD,"f").detail=c,r.dispatchEvent(Do(this,uD,"f")),e===Fa.DRAW_RECT&&(i.d=`M${c.points[0].x},${c.points[0].y}L${c.points[1].x},${c.points[1].y}L${c.points[2].x},${c.points[2].y}L${c.points[3].x},${c.points[3].y}Z`)},a=c=>{this.hidePen(c),Do(this,dD,"f").detail=c,r.dispatchEvent(Do(this,dD,"f"))},l=c=>{this.hidePen(c),Do(this,fD,"f").detail=c,r.dispatchEvent(Do(this,fD,"f")),r.removeChild(i)};Do(this,uc,"f").on(Io.START,s),Do(this,uc,"f").on(Io.MODIFIED,n),Do(this,uc,"f").on(Io.MOVE,o),Do(this,uc,"f").on(Io.COMPLETE,a),Do(this,uc,"f").on(Io.CANCEL,l)}hidePen(e){Do(this,uc,"f").hide()}renderPen(e){Do(this,uc,"f").render(e,{fill:"none",stroke:"black",sizeAttenuation:!0})}}lD=new WeakMap,uc=new WeakMap,z5=new WeakMap,cD=new WeakMap,hD=new WeakMap,uD=new WeakMap,dD=new WeakMap,fD=new WeakMap;let VH,Yr,vl,V5,Vl,Tm,pD,_R,Y5,l_,gD,lf,$5,t1,e1;VH=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Yr=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},vl=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
2184return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},(function(t){t.SELECT="select",t.HAND="hand",t.DRAW_RECT="draw-rect"})(Fa||(Fa={}));const Jat=()=>({mode:Fa.HAND,zoom:1});QQ=class{get pluginContext(){return Yr(this,Vl,"f")}get root(){return Yr(this,l_,"f")}get camera(){return Yr(this,gD,"f")}constructor(t){V5.set(this,void 0),Vl.set(this,void 0),Tm.set(this,void 0),pD.set(this,void 0),_R.set(this,void 0),Y5.set(this,void 0),l_.set(this,new Tv),gD.set(this,void 0),lf.set(this,!0),$5.set(this,new Set),t1.set(this,new Set),e1.set(this,void 0);const{canvas:e,renderer:r="webgl",shaderCompilerPath:i="",devicePixelRatio:s,mode:o=Fa.HAND,checkboardStyle:n=HE.GRID,theme:a=iE.LIGHT,themeColors:l={[iE.LIGHT]:{background:"#fbfbfb",grid:"#dedede",selectionBrushFill:"#dedede",selectionBrushStroke:"#dedede"},[iE.DARK]:{background:"#121212",grid:"#242424",selectionBrushFill:"#242424",selectionBrushStroke:"#242424"}},plugins:c}=t,h=oPt(),u=(s??h.devicePixelRatio)||1,d=!!h.PointerEvent,f="ontouchstart"in h,{width:g,height:p}=e,m=new Nat(g/u,p/u);m.onchange=()=>{Yr(this,Vl,"f").hooks.cameraChange.call(),vl(this,lf,!0,"f")},vl(this,gD,m,"f"),vl(this,Vl,{globalThis:h,canvas:e,renderer:r,shaderCompilerPath:i,devicePixelRatio:u,themeColors:l,supportsPointerEvents:d,supportsTouchEvents:f,hooks:{init:new Rh,initAsync:new rPt,beginFrame:new Rh,render:new Rh,endFrame:new Rh,destroy:new Rh,resize:new Rh,pointerDown:new Rh,pointerUp:new Rh,pointerMove:new Rh,pointerOut:new Rh,pointerOver:new Rh,pointerWheel:new Rh,pointerCancel:new Rh,pickSync:new iPt,cameraChange:new Rh,modeChange:new Rh},camera:m,root:Yr(this,l_,"f"),rBushRoot:new TE,api:{elementsFromPoint:this.elementsFromPoint.bind(this),elementFromPoint:this.elementFromPoint.bind(this),elementsFromBBox:this.elementsFromBBox.bind(this),client2Viewport:this.client2Viewport.bind(this),viewport2Canvas:m.viewport2Canvas.bind(m),viewport2Client:this.viewport2Client.bind(this),canvas2Viewport:m.canvas2Viewport.bind(m),createCustomEvent:this.createCustomEvent.bind(this),getCanvasMode:()=>Yr(this,e1,"f"),getTheme:()=>this.theme,setCursor:b=>{Bo.get().setCursor(this,b)}}},"f"),vl(this,Tm,new Tkt,"f"),vl(this,pD,new Nkt,"f"),vl(this,_R,new Zkt(Object.assign({selectionBrushSortMode:"directional",selectionBrushStyle:{strokeWidth:1}},c==null?void 0:c.selector)),"f"),vl(this,Y5,new Jkt({}),"f"),this.theme=a,this.checkboardStyle=n;const v=[new Dkt,Yr(this,pD,"f"),new Ukt,new Ikt,Yr(this,_R,"f"),Yr(this,Y5,"f"),new Xkt,Yr(this,Tm,"f"),new Wkt(Object.assign({overlap:"pointer",dragstartTimeThreshold:100,dragstartDistanceThreshold:10},c==null?void 0:c.dragndrop))];vl(this,V5,VH(this,void 0,void 0,function*(){const{hooks:b}=Yr(this,Vl,"f");return v.forEach(y=>{y==null||y.apply(Yr(this,Vl,"f"))}),b.init.call(),yield b.initAsync.promise(),this}),"f"),this.mode=o}get initialized(){return Yr(this,V5,"f").then(()=>this)}render(){const{hooks:t}=Yr(this,Vl,"f");Yr(this,t1,"f").clear();const e=[];if($$(Yr(this,l_,"f"),r=>{r.sortDirtyFlag&&(r.sorted=r.children.slice().sort(wnt),r.sortDirtyFlag=!1),Yr(this,t1,"f").add(r),r.transformDirtyFlag&&(r.boundsDirtyFlag=!0,r.renderDirtyFlag=!0),r.renderDirtyFlag&&(e.push(r),vl(this,lf,!0,"f")),r.transform.updateTransform(r.parent?r.parent.transform:mnt)}),Yr(this,lf,"f")){const r=Array.from(Yr(this,t1,"f")),i=[...Yr(this,$5,"f")].filter(s=>!Yr(this,t1,"f").has(s));t.beginFrame.call({all:r,modified:e,removed:i}),$$(Yr(this,l_,"f"),s=>{if(s.culled||!s.visible)return!0;s.renderable&&t.render.call(s)}),t.endFrame.call({all:r,modified:e,removed:i}),[...r,...i].forEach(s=>{s.renderDirtyFlag=!1}),vl(this,$5,new Set(Yr(this,t1,"f")),"f"),vl(this,lf,!1,"f")}}resize(t,e){const{hooks:r}=Yr(this,Vl,"f");Yr(this,gD,"f").projection(t,e),r.resize.call(t,e)}destroy(){const{hooks:t}=Yr(this,Vl,"f");t.destroy.call()}getDOM(){return Yr(this,Vl,"f").canvas}getDPR(){return Yr(this,Vl,"f").devicePixelRatio}getDevice(){return Yr(this,Tm,"f").device}toDataURL(){return VH(this,arguments,void 0,function*(t={}){const e=yield Yr(this,Tm,"f").toDataURL(t,()=>{vl(this,lf,!0,"f"),this.render()});return t.grid||(vl(this,lf,!0,"f"),this.render()),e})}appendChild(t){vl(this,lf,!0,"f"),Yr(this,l_,"f").appendChild(t)}removeChild(t){return vl(this,lf,!0,"f"),Yr(this,l_,"f").removeChild(t)}get checkboardStyle(){return Yr(this,Tm,"f").checkboardStyle}set checkboardStyle(t){vl(this,lf,!0,"f"),Yr(this,Tm,"f").checkboardStyle=t}get theme(){return Yr(this,Tm,"f").theme}set theme(t){vl(this,lf,!0,"f"),Yr(this,Tm,"f").theme=t}get mode(){return Yr(this,e1,"f")}set mode(t){if(Yr(this,e1,"f")!==t){Yr(this,Vl,"f").hooks.modeChange.call(Yr(this,e1,"f"),t),vl(this,e1,t,"f");let e;t===Fa.HAND?e="grab":t===Fa.SELECT?e="default":t===Fa.DRAW_RECT&&(e="crosshair"),Bo.get().setCursor(this,e)}}selectShape(t){Yr(this,_R,"f").selectShape(t)}deselectShape(t){Yr(this,_R,"f").deselectShape(t)}elementsFromBBox(t,e,r,i){const{rBushRoot:s}=Yr(this,Vl,"f"),o=s.search({minX:t,minY:e,maxX:r,maxY:i}),n=[];return o.forEach(({shape:a})=>{const{pointerEvents:l="auto",visible:c,culled:h}=a;let u=c;if(u){let f=a.parent;for(;f;){if(!f.visible){u=!1;break}f=f.parent}}const d=["auto","visiblepainted","visiblefill","visiblestroke","visible"].includes(l);(!d||d&&u)&&!h&&l!=="none"&&n.push(a)}),n.sort((a,l)=>a.globalRenderOrder-l.globalRenderOrder),n}elementsFromPoint(t,e){const{picked:r}=Yr(this,Vl,"f").hooks.pickSync.call({topmost:!1,position:{x:t,y:e},picked:[]});return r}elementFromPoint(t,e){const{picked:r}=Yr(this,Vl,"f").hooks.pickSync.call({topmost:!0,position:{x:t,y:e},picked:[]});return r[0]}client2Viewport({x:t,y:e}){const{left:r,top:i}=Yr(this,Vl,"f").canvas.getBoundingClientRect();return{x:t-r,y:e-i}}viewport2Client({x:t,y:e}){const{left:r,top:i}=Yr(this,Vl,"f").canvas.getBoundingClientRect();return{x:t+r,y:e+i}}zoomIn(){const{camera:t}=this;t.cancelLandmarkAnimation();const e=t.createLandmark({viewportX:t.width/2,viewportY:t.height/2,zoom:Bkt(t.zoom)});t.gotoLandmark(e,{duration:300,easing:"ease"})}zoomOut(){const{camera:t}=this;t.cancelLandmarkAnimation();const e=t.createLandmark({viewportX:t.width/2,viewportY:t.height/2,zoom:Okt(t.zoom)});t.gotoLandmark(e,{duration:300,easing:"ease"})}createCustomEvent(t,e){const r=Yr(this,pD,"f").rootBoundary;return new xPt(r,t,e)}},V5=new WeakMap,Vl=new WeakMap,Tm=new WeakMap,pD=new WeakMap,_R=new WeakMap,Y5=new WeakMap,l_=new WeakMap,gD=new WeakMap,lf=new WeakMap,$5=new WeakMap,t1=new WeakMap,e1=new WeakMap;var Qkt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},tLt=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};ett=class{constructor(t){this.options=t}toCanvas(){return Qkt(this,arguments,void 0,function*(t={}){const{canvas:e}=this.options,{width:r,height:i}=e.getDOM(),s=e.getDPR(),{clippingRegion:o=new Ua(0,0,r,i),beforeDrawImage:n,afterDrawImage:a}=t,l=tLt(t,["clippingRegion","beforeDrawImage","afterDrawImage"]),c=yield e.toDataURL(l),h=yield this.getOrCreateImage(c),{x:u,y:d,width:f,height:g}=o,p=document.createElement("canvas");p.width=f*s,p.height=g*s;const m=p.getContext("2d");m.scale(s,s),n&&n(m);const v=h.width>r?s:1;return m.drawImage(h,u*v,d*v,f*v,g*v,0,0,f,g),a&&a(m),p})}toSVG(t={}){const{grid:e}=t,{canvas:r}=this.options,{width:i,height:s}=r.getDOM(),{grid:o,background:n}=r.pluginContext.themeColors[r.theme],a=Qr("svg");return a.setAttribute("width",`${i}`),a.setAttribute("height",`${s}`),a.setAttribute("style",`background-color: ${n}`),e&&(r.checkboardStyle===HE.GRID?this.drawLinesGrid(a,o):r.checkboardStyle===HE.DOTS&&this.drawDotsGrid(a,o)),a.appendChild(OH(BH(r.root))),a}toSVGDataURL(t={}){const e=this.toSVG(t),r=Bo.get().getDocument().implementation.createDocumentType("svg","-//W3C//DTD SVG 1.1//EN","http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"),i=Bo.get().getDocument().implementation.createDocument("http://www.w3.org/2000/svg","svg",r);return i.replaceChild(e,i.documentElement),`data:image/svg+xml;charset=utf8,${encodeURIComponent(Bo.get().getXMLSerializer().serializeToString(i))}`}downloadImage(t){const{defaultFilename:e}=this.options,{dataURL:r,name:i=e||"g"}=t,s=r.substring(r.indexOf(":")+1,r.indexOf(";")).split("/")[1],o=r.startsWith("data:image/svg"),n=`${i}.${o?"svg":s}`,a=Bo.get().getDocument().createElement("a");if(o)a.addEventListener("click",()=>{a.download=n,a.href=r});else if(window.Blob&&window.URL){const l=r.split(",");let c="";if(l&&l.length>0){const g=l[0].match(/:(.*?);/);g&&g.length>=2&&(c=g[1])}const h=atob(l[1]);let u=h.length;const d=new Uint8Array(u);for(;u--;
2184)d[u]=h.charCodeAt(u);const f=new Blob([d],{type:c});navigator.msSaveBlob?navigator.msSaveBlob(f,n):a.addEventListener("click",()=>{a.download=n,a.href=window.URL.createObjectURL(f)})}if(a.click)a.click();else{const l=Bo.get().getDocument().createEvent("MouseEvents");l.initEvent("click",!1,!1),a.dispatchEvent(l)}}getOrCreateImage(t){return new Promise((e,r)=>{const i=new window.Image;i&&(i.onload=()=>{e(i)},i.onerror=s=>{r(s)},i.crossOrigin="Anonymous",i.src=t)})}drawLinesGrid(t,e){const r=Qr("defs");t.appendChild(r);const i=Qr("pattern");i.setAttribute("id","small-grid"),i.setAttribute("width","10"),i.setAttribute("height","10"),i.setAttribute("patternUnits","userSpaceOnUse");const s=Qr("path");s.setAttribute("d","M 10 0 L 0 0 0 10"),s.setAttribute("fill","none"),s.setAttribute("stroke",e),s.setAttribute("stroke-width","1"),i.appendChild(s);const o=Qr("pattern");o.setAttribute("id","grid"),o.setAttribute("width","100"),o.setAttribute("height","100"),o.setAttribute("patternUnits","userSpaceOnUse");const n=Qr("rect");n.setAttribute("width","100"),n.setAttribute("height","100"),n.setAttribute("fill","url(#small-grid)"),o.appendChild(n);const a=Qr("path");a.setAttribute("d","M 100 0 L 0 0 0 100"),a.setAttribute("fill","none"),a.setAttribute("stroke",e),a.setAttribute("stroke-width","2"),o.appendChild(a),r.appendChild(i),r.appendChild(o);const l=Qr("rect");l.setAttribute("width","100%"),l.setAttribute("height","100%"),l.setAttribute("fill","url(#grid)"),t.appendChild(l)}drawDotsGrid(t,e){const r=Qr("defs");t.appendChild(r);const i=Qr("circle");i.setAttribute("id","dot-tl"),i.setAttribute("cx","0"),i.setAttribute("cy","0"),i.setAttribute("r","2"),i.setAttribute("fill",e);const s=i.cloneNode(),o=i.cloneNode(),n=i.cloneNode();s.setAttribute("id","dot-tr"),s.setAttribute("cx","20"),o.setAttribute("id","dot-bl"),o.setAttribute("cy","20"),n.setAttribute("id","dot-br"),n.setAttribute("cx","20"),n.setAttribute("cy","20"),r.appendChild(i),r.appendChild(s),r.appendChild(o),r.appendChild(n);const a=Qr("pattern");a.setAttribute("id","dots-grid"),a.setAttribute("width","20"),a.setAttribute("height","20"),a.setAttribute("patternUnits","userSpaceOnUse");const l=Qr("use");l.setAttribute("xlink:href","#dot-bl");const c=Qr("use");c.setAttribute("xlink:href","#dot-br");const h=Qr("use");h.setAttribute("xlink:href","#dot-tl");const u=Qr("use");u.setAttribute("xlink:href","#dot-tr"),a.appendChild(l),a.appendChild(c),a.appendChild(h),a.appendChild(u),r.appendChild(a);const d=Qr("rect");d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.setAttribute("fill","url(#dots-grid)"),t.appendChild(d)}};var c_=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},bR,wR;let eLt=class rY{constructor(e,r){this.appStateChange=e,this.elementsChange=r}static create(e,r){return new rY(e,r)}inverse(){return new rY(this.appStateChange.inverse(),this.elementsChange.inverse())}applyTo(e,r,i){const[s,o]=this.elementsChange.applyTo(e,i.elements),[n,a]=this.appStateChange.applyTo(r,s);return[s,n,o||a]}applyLatestChanges(e){const r=this.elementsChange.applyLatestChanges(e);return rY.create(this.appStateChange,r)}isEmpty(){return this.appStateChange.isEmpty()&&this.elementsChange.isEmpty()}},rLt=class IG{constructor(){bR.set(this,[]),wR.set(this,[])}static pop(e){if(!e.length)return null;const r=e.pop();return r!==void 0?r:null}static push(e,r,i){const s=r.inverse().applyLatestChanges(i);return e.push(s)}get undoStack(){return c_(this,bR,"f")}get redoStack(){return c_(this,wR,"f")}clear(){c_(this,bR,"f").length=0,c_(this,wR,"f").length=0}undo(e,r,i){return this.perform(e,r,i,()=>IG.pop(c_(this,bR,"f")),s=>IG.push(c_(this,wR,"f"),s,e))}redo(e,r,i){return this.perform(e,r,i,()=>IG.pop(c_(this,wR,"f")),s=>IG.push(c_(this,bR,"f"),s,e))}perform(e,r,i,s,o){try{let n=s();if(n===null)return;let a=e,l=r,c=!1;for(;n;){try{[a,l,c]=n.applyTo(a,l,i)}finally{o(n)}if(c)break;n=s()}return[a,l]}finally{}}};bR=new WeakMap,wR=new WeakMap;let vd=class Qy{constructor(e,r){this.deleted=e,this.inserted=r}static create(e,r,i,s){const o=i&&s!=="inserted"?i(e):e,n=i&&s!=="deleted"?i(r):r;return new Qy(o,n)}static calculate(e,r,i,s){if(e===r)return Qy.empty();const o={},n={};for(const c of this.distinctKeysIterator("full",e,r))o[c]=e[c],n[c]=r[c];const[a,l]=s?s(o,n):[o,n];return Qy.create(a,l,i)}static empty(){return new Qy({},{})}static isEmpty(e){return!Object.keys(e.deleted).length&&!Object.keys(e.inserted).length}static mergeObjects(e,r,i){const s=Object.assign({},e);for(const o of Object.keys(i))delete s[o];return Object.assign(Object.assign({},s),r)}static mergeArrays(e,r,i,s){return Object.values(Qy.mergeObjects(m0(e??[],s),m0(r??[],s),m0(i??[],s)))}static diffObjects(e,r,i,s){var o,n;if(!(!e[i]&&!r[i])&&(typeof e[i]=="object"||typeof r[i]=="object")){const a=(o=e[i])!==null&&o!==void 0?o:{},l=(n=r[i])!==null&&n!==void 0?n:{},c=Qy.getLeftDifferences(a,l).reduce((u,d)=>(u[d]=s(a[d]),u),{}),h=Qy.getRightDifferences(a,l).reduce((u,d)=>(u[d]=s(l[d]),u),{});Object.keys(c).length||Object.keys(h).length?(Reflect.set(e,i,c),Reflect.set(r,i,h)):(Reflect.deleteProperty(e,i),Reflect.deleteProperty(r,i))}}static diffArrays(e,r,i,s){if(!(!e[i]&&!r[i])&&(Array.isArray(e[i])||Array.isArray(r[i]))){const o=Array.isArray(e[i])?e[i]:[],n=Array.isArray(r[i])?r[i]:[],a=m0(Qy.getLeftDifferences(m0(o,s),m0(n,s))),l=m0(Qy.getRightDifferences(m0(o,s),m0(n,s)));if(Object.keys(a).length||Object.keys(l).length){const c=o.filter(u=>a[s?s(u):String(u)]),h=n.filter(u=>l[s?s(u):String(u)]);Reflect.set(e,i,c),Reflect.set(r,i,h)}else Reflect.deleteProperty(e,i),Reflect.deleteProperty(r,i)}}static isLeftDifferent(e,r,i=!1){return!!this.distinctKeysIterator("left",e,r,i).next().value}static isRightDifferent(e,r,i=!1){return!!this.distinctKeysIterator("right",e,r,i).next().value}static getLeftDifferences(e,r,i=!1){return Array.from(this.distinctKeysIterator("left",e,r,i))}static getRightDifferences(e,r,i=!1){return Array.from(this.distinctKeysIterator("right",e,r,i))}static*distinctKeysIterator(e,r,i,s=!1){if(r===i)return;let o=[];e==="left"?o=Object.keys(r):e==="right"?o=Object.keys(i):e==="full"?o=Array.from(new Set([...Object.keys(r),...Object.keys(i)])):vPt(e,`Unknown distinctKeysIterator's join param "${e}"`);for(const n of o){const a=r[n],l=i[n];if(a!==l){if(!s&&typeof a=="object"&&typeof l=="object"&&a!==null&&l!==null&&cnt(a,l))continue;yield n}}}};var YH=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};let iLt=class gE{constructor(e){this.delta=e}static calculate(e,r){const i=vd.calculate(e,r,void 0);return new gE(i)}static empty(){return new gE(vd.create({},{}))}inverse(){const e=vd.create(this.delta.inserted,this.delta.deleted);return new gE(e)}applyTo(e,r){try{const i=YH(this.delta.inserted,[]),s=Object.assign(Object.assign({},e),i),o=this.filterInvisibleChanges(e,s,r);return[s,o]}catch(i){return console.error("Couldn't apply appstate change",i
2184),[e,!1]}}isEmpty(){return vd.isEmpty(this.delta)}static stripElementsProps(e){return YH(e,[])}static stripStandaloneProps(e){return YH(e,[])}filterInvisibleChanges(e,r,i){const s=e,o=r,n=vd.isRightDifferent(gE.stripElementsProps(s),gE.stripElementsProps(o)),a=vd.isRightDifferent(gE.stripStandaloneProps(s),gE.stripStandaloneProps(o));return!n&&!a?!1:n}};var $H=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};const Qat=t=>t;let h_=class od{constructor(e,r,i){this.added=e,this.removed=r,this.updated=i}static create(e,r,i,s={shouldRedistribute:!1}){let o;if(s.shouldRedistribute){const n=new Map,a=new Map,l=new Map,c=[...e,...r,...i];for(const[h,u]of c)this.satisfiesAddition(u)?n.set(h,u):this.satisfiesRemoval(u)?a.set(h,u):l.set(h,u);o=new od(n,a,l)}else o=new od(e,r,i);return o}static checkForVisibleDifference(e,r){return e.isDeleted&&r.isDeleted!==!1?!1:e.isDeleted&&r.isDeleted===!1||e.isDeleted===!1&&r.isDeleted?!0:vd.isRightDifferent(e,r)}inverse(){const e=o=>{const n=new Map;for(const[a,l]of o.entries())n.set(a,vd.create(l.inserted,l.deleted));return n},r=e(this.added),i=e(this.removed),s=e(this.updated);return od.create(i,r,s)}isEmpty(){return this.added.size===0&&this.removed.size===0&&this.updated.size===0}applyTo(e,r){let i=Qat(new Map(e));const s={containsVisibleDifference:!1,containsZindexDifference:!1};try{const o=od.createApplier(i,r,s);o(this.added),o(this.removed),o(this.updated),this.resolveConflicts(e,i)}catch(o){return console.error("Couldn't apply elements change",o),[e,!0]}return[i,s.containsVisibleDifference]}applyLatestChanges(e){const r=a=>l=>{const c={};for(const h of Object.keys(l))c[h]=a[h];return c},i=a=>{const l=new Map;for(const[c,h]of a.entries()){const u=e.get(c);if(u){const d=vd.create(h.deleted,h.inserted,r(u),"inserted");l.set(c,d)}else l.set(c,h)}return l},s=i(this.added),o=i(this.removed),n=i(this.updated);return od.create(s,o,n,{shouldRedistribute:!0})}static applyDelta(e,r,i={containsVisibleDifference:!0,containsZindexDifference:!0}){const s=$H(r.inserted,[]);if(!i.containsVisibleDifference){const{index:o}=s,n=$H(s,["index"]),a=od.checkForVisibleDifference(e,n);i.containsVisibleDifference=a}return i.containsZindexDifference||(i.containsZindexDifference=r.deleted.index!==r.inserted.index),fat(e,s)}resolveConflicts(e,r){const i=new Map,s=new Map(Array.from(e).filter(([l])=>i.has(l))),{added:o,removed:n,updated:a}=od.calculate(s,i);for(const[l,c]of o)this.added.set(l,c);for(const[l,c]of n)this.removed.set(l,c);for(const[l,c]of a)this.updated.set(l,c);return i}static calculate(e,r){if(e===r)return od.empty();const i=new Map,s=new Map,o=new Map;for(const n of e.values())if(!r.get(n.uid)){const a=Object.assign(Object.assign({},n),{isDeleted:!1}),l={isDeleted:!0},c=vd.create(a,l,od.stripIrrelevantProps);s.set(n.uid,c)}for(const n of r.values()){const a=e.get(n.uid);if(!a){const l={isDeleted:!0},c=Object.assign(Object.assign({},n),{isDeleted:!1}),h=vd.create(l,c,od.stripIrrelevantProps);i.set(n.uid,h);continue}if(a.versionNonce!==n.versionNonce){const l=vd.calculate(a,n,od.stripIrrelevantProps);if(typeof a.isDeleted=="boolean"&&typeof n.isDeleted=="boolean"&&a.isDeleted!==n.isDeleted){a.isDeleted&&!n.isDeleted?i.set(n.uid,l):s.set(n.uid,l);continue}vd.isEmpty(l)||o.set(n.uid,l)}}return od.create(i,s,o)}static empty(){return od.create(new Map,new Map,new Map)}static stripIrrelevantProps(e){const{uid:r,updated:i,version:s,versionNonce:o}=e;return $H(e,["uid","updated","version","versionNonce"])}};h_.satisfiesAddition=({deleted:t,inserted:e})=>t.isDeleted===!0&&!e.isDeleted,h_.satisfiesRemoval=({deleted:t,inserted:e})=>!t.isDeleted&&e.isDeleted===!0,h_.satisfiesUpdate=({deleted:t,inserted:e})=>!!t.isDeleted==!!e.isDeleted,h_.createApplier=(t,e,r)=>{const i=h_.createGetter(t,e,r);return s=>Array.from(s.entries()).reduce((o,[n,a])=>{const l=i(n,a.inserted);if(l){const c=h_.applyDelta(l,a,r);t.set(c.uid,c),o.set(c.uid,c)}return o},new Map)},h_.createGetter=(t,e,r)=>(i,s)=>{let o=t.get(i);return o||(o=e.get(i),o&&(r.containsZindexDifference=!0,(s.isDeleted===!1||s.isDeleted!==!0&&o.isDeleted===!1)&&(r.containsVisibleDifference=!0))),o};const sLt=Object.freeze(Object.defineProperty({__proto__:null,AABB:ea,AppStateChange:iLt,BrowserAdapter
2184:ent,Camera:Nat,Canvas:QQ,get CanvasMode(){return Fa},get CheckboardStyle(){return HE},Circle:Gl,CircleWrapper:aH,Custom:pH,CustomWrapper:Cnt,DOMAdapter:Bo,ElementsChange:h_,Ellipse:$h,EllipseWrapper:lH,Grid:Rnt,Group:Tv,History:rLt,HistoryEntry:eLt,IDENTITY_TRANSFORM:mnt,ImageExporter:ett,Path:Wc,PathWrapper:fH,Polyline:sp,PolylineWrapper:hH,Rect:ed,RectWrapper:cH,Rectangle:Ua,RoughCircle:Zh,RoughEllipse:Qh,RoughPath:tp,RoughPolyline:ky,RoughRect:au,Shape:du,Snapshot:class uet{constructor(e,r,i={didElementsChange:!1,didAppStateChange:!1,isEmpty:!1}){this.elements=e,this.appState=r,this.meta=i}static empty(){return new uet(new Map,Jat(),{didElementsChange:!1,didAppStateChange:!1,isEmpty:!0})}isEmpty(){return this.meta.isEmpty}maybeClone(e,r){const i=this.maybeCreateElementsSnapshot(e),s=this.maybeCreateAppStateSnapshot(r);let o=!1,n=!1;return this.elements!==i&&(o=!0),this.appState!==s&&(n=!0),!o&&!n?this:new uet(i,s,{didElementsChange:o,didAppStateChange:n})}detectChangedElements(e){if(this.elements===e)return!1;if(this.elements.size!==e.size)return!0;const r=Array.from(e.keys());for(let i=r.length-1;i>=0;i--){const s=this.elements.get(r[i]),o=e.get(r[i]);if(!s||!o||s.uid!==o.uid||s.versionNonce!==o.versionNonce)return!0}return!1}createElementsSnapshot(e){const r=new Map;for(const[i,s]of this.elements.entries())e.get(i)?r.set(i,s):r.set(i,fat(s,{isDeleted:!0}));for(const[i,s]of e.entries()){const o=r.get(i);(!o||o&&o.versionNonce!==s.versionNonce)&&r.set(i,dat(s))}return r}maybeCreateElementsSnapshot(e){return e?this.detectChangedElements(e)?this.createElementsSnapshot(e):this.elements:this.elements}detectChangedAppState(e){return!cnt(this.appState,e)}maybeCreateAppStateSnapshot(e){if(!e)return this.appState;const r=e;return this.detectChangedAppState(r)?r:this.appState}},get TesselationMethod(){return cE},Text:Ny,TextWrapper:Tnt,get Theme(){return iE},WebWorkerAdapter:wFt,deepClone:dat,deserializeNode:FV,fromSVGElement:yG,getBounds:oH,getDefaultAppState:Jat,hasValidDecoration:bnt,hasValidStroke:_nt,inLine:Ant,inPolyline:xnt,isColor:rtt,isFillOrStrokeAffected:ZT,isGradient:QB,isPattern:Rv,isString:gl,loadBitmapFont:net,parseGradient:qU,parsePath:TI,parseTransform:fG,serializeNode:BH,shiftPoints:uH,sortByZIndex:wnt,strokeOffset:Kv,toBrandedType:Qat,toSVGElement:OH},Symbol.toStringTag,{value:"Module"}));var oLt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},tlt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},H5=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},K5,ER;let nLt=class{constructor(){K5.set(this,void 0),ER.set(this,void 0)}apply(t){const{hooks:e,canvas:r,renderer:i,shaderCompilerPath:s,devicePixelRatio:o}=t;e.initAsync.tapPromise(()=>oLt(this,void 0,void 0,function*(){let n;i==="webgl"?n=new hd({targets:["webgl2","webgl1"],antialias:!0,shaderDebug:!0,trackResources:!0,onContextCreationError:()=>{},onContextLost:()=>{},onContextRestored(h){}}):n=new ud({shaderCompilerPath:s,onContextLost:()=>{}});const{width:a,height:l}=r,c=yield n.createSwapChain(r);c.configureSwapChain(a,l),tlt(this,K5,c,"f"),tlt(this,ER,c.getDevice(),"f")})),e.resize.tap((n,a)=>{H5(this,K5,"f").configureSwapChain(n*o,a*o)}),e.destroy.tap(()=>{H5(this,ER,"f").destroy()}),e.beginFrame.tap(()=>{H5(this,ER,"f").beginFrame()}),e.endFrame.tap(()=>{H5(this,ER,"f").endFrame()})}};K5=new WeakMap,ER=new WeakMap;var HH=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},mD;let aLt=class{constructor(){mD.set(this,[])}getCallbacksNum(){return HH(this,mD,"f").length}tapPromise(t){HH(this,mD,"f").push(t)}promise(...t){return Promise.all(HH(this,mD,"f").map(e=>e(...t)))}};mD=new WeakMap;var elt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},q5;let yD=class{constructor(){q5.set(this,[])}tap(t){elt(this,q5,"f").push(t)}call(...t){elt(this,q5,"f").forEach(function(e){e.apply(void 0,t)})}};q5=new WeakMap;const lLt=()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};var cLt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},rlt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
2184return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},r1=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Z5,_0;let hLt=class{constructor(t){Z5.set(this,void 0),_0.set(this,void 0);const{canvas:e,renderer:r="webgl",shaderCompilerPath:i="",devicePixelRatio:s}=t,o=lLt();rlt(this,_0,{globalThis:o,canvas:e,renderer:r,shaderCompilerPath:i,devicePixelRatio:s??o.devicePixelRatio,hooks:{init:new yD,initAsync:new aLt,beginFrame:new yD,endFrame:new yD,destroy:new yD,resize:new yD}},"f"),rlt(this,Z5,cLt(this,void 0,void 0,function*(){const{hooks:n}=r1(this,_0,"f");return[new nLt].forEach(a=>{a.apply(r1(this,_0,"f"))}),n.init.call(),yield n.initAsync.promise(),this}),"f")}get initialized(){return r1(this,Z5,"f").then(()=>this)}render(){const{hooks:t}=r1(this,_0,"f");t.beginFrame.call(),t.endFrame.call()}resize(t,e){const{hooks:r}=r1(this,_0,"f");r.resize.call(t,e)}destroy(){const{hooks:t}=r1(this,_0,"f");t.destroy.call()}getDOM(){return r1(this,_0,"f").canvas}};Z5=new WeakMap,_0=new WeakMap;const uLt=Object.freeze(Object.defineProperty({__proto__:null,Canvas:hLt},Symbol.toStringTag,{value:"Module"}));var dLt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},AR=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},nn=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},xR,Mh,u_,SR,TR;let fLt=class{constructor(){xR.set(this,void 0),Mh.set(this,void 0),u_.set(this,void 0),SR.set(this,void 0),TR.set(this,void 0)}apply(t){const{hooks:e,canvas:r,renderer:i,shaderCompilerPath:s,devicePixelRatio:o}=t;e.initAsync.tapPromise(()=>dLt(this,void 0,void 0,function*(){let n;i==="webgl"?n=new hd({targets:["webgl2","webgl1"],antialias:!0,shaderDebug:!0,trackResources:!0,onContextCreationError:()=>{},onContextLost:()=>{},onContextRestored(h){}}):n=new ud({shaderCompilerPath:s,onContextLost:()=>{}});const{width:a,height:l}=r,c=yield n.createSwapChain(r);c.configureSwapChain(a,l),AR(this,xR,c,"f"),AR(this,Mh,c.getDevice(),"f"),AR(this,u_,nn(this,Mh,"f").createRenderTargetFromTexture(nn(this,Mh,"f").createTexture({format:I.U8_RGBA_RT,width:a,height:l,usage:xr.RENDER_TARGET})),"f"),AR(this,TR,nn(this,Mh,"f").createBuffer({viewOrSize:new Float32Array([a/o,l/o]),usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f")})),e.resize.tap((n,a)=>{nn(this,xR,"f").configureSwapChain(n*o,a*o),nn(this,u_,"f")&&(nn(this,u_,"f").destroy(),AR(this,u_,nn(this,Mh,"f").createRenderTargetFromTexture(nn(this,Mh,"f").createTexture({format:I.U8_RGBA_RT,width:n*o,height:a*o,usage:xr.RENDER_TARGET})),"f"))}),e.destroy.tap(()=>{nn(this,u_,"f").destroy(),nn(this,TR,"f").destroy(),nn(this,Mh,"f").destroy(),nn(this,Mh,"f").checkForLeaks()}),e.beginFrame.tap(()=>{const{width:n,height:a}=nn(this,xR,"f").getCanvas(),l=nn(this,xR,"f").getOnscreenTexture();nn(this,TR,"f").setSubData(0,new Uint8Array(new Float32Array([n/o,a/o]).buffer)),nn(this,Mh,"f").beginFrame(),AR(this,SR,nn(this,Mh,"f").createRenderPass({colorAttachment:[nn(this,u_,"f")],colorResolveTo:[l],colorClearColor:[op]}),"f"),nn(this,SR,"f").setViewport(0,0,n,a)}),e.endFrame.tap(()=>{nn(this,Mh,"f").submitPass(nn(this,SR,"f")),nn(this,Mh,"f").endFrame()}),e.render.tap(n=>
2184{n.render(nn(this,Mh,"f"),nn(this,SR,"f"),nn(this,TR,"f"))})}};xR=new WeakMap,Mh=new WeakMap,u_=new WeakMap,SR=new WeakMap,TR=new WeakMap;var KH=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},vD;let pLt=class{constructor(){vD.set(this,[])}getCallbacksNum(){return KH(this,vD,"f").length}tapPromise(t){KH(this,vD,"f").push(t)}promise(...t){return Promise.all(KH(this,vD,"f").map(e=>e(...t)))}};vD=new WeakMap;var ilt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},J5;let RR=class{constructor(){J5.set(this,[])}tap(t){ilt(this,J5,"f").push(t)}call(...t){ilt(this,J5,"f").forEach(function(e){e.apply(void 0,t)})}};J5=new WeakMap;const gLt=()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};var mLt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},slt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},cf=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Q5,b0,i1;let yLt=class{constructor(t){Q5.set(this,void 0),b0.set(this,void 0),i1.set(this,[]);const{canvas:e,renderer:r="webgl",shaderCompilerPath:i="",devicePixelRatio:s}=t,o=gLt();slt(this,b0,{globalThis:o,canvas:e,renderer:r,shaderCompilerPath:i,devicePixelRatio:s??o.devicePixelRatio,hooks:{init:new RR,initAsync:new pLt,beginFrame:new RR,render:new RR,endFrame:new RR,destroy:new RR,resize:new RR}},"f"),slt(this,Q5,mLt(this,void 0,void 0,function*(){const{hooks:n}=cf(this,b0,"f");return[new fLt].forEach(a=>{a.apply(cf(this,b0,"f"))}),n.init.call(),yield n.initAsync.promise(),this}),"f")}get initialized(){return cf(this,Q5,"f").then(()=>this)}render(){const{hooks:t}=cf(this,b0,"f");t.beginFrame.call(),cf(this,i1,"f").forEach(e=>{t.render.call(e)}),t.endFrame.call()}resize(t,e){const{hooks:r}=cf(this,b0,"f");r.resize.call(t,e)}destroy(){const{hooks:t}=cf(this,b0,"f");cf(this,i1,"f").forEach(e=>e.destroy()),t.destroy.call()}getDOM(){return cf(this,b0,"f").canvas}appendChild(t){cf(this,i1,"f").push(t)}removeChild(t){const e=cf(this,i1,"f").indexOf(t);e!==-1&&cf(this,i1,"f").splice(e,1)}};Q5=new WeakMap,b0=new WeakMap,i1=new WeakMap;let olt=class{constructor(){this.renderDirtyFlag=!0}};const vLt=` 2185layout(std140) uniform SceneUniforms { 2186 vec2 u_Resolution; 2187}; 2188 2189layout(std140) uniform ShapeUniforms { 2190 float u_AntiAliasingType; 2191}; 2192 2193layout(location = 0) in vec2 a_FragCoord; 2194layout(location = 1) in vec2 a_Position; 2195layout(location = 2) in vec2 a_Size; 2196layout(location = 3) in vec4 a_FillColor; 2197 2198out vec2 v_FragCoord; 2199out vec4 v_FillColor; 2200 2201void main() { 2202 v_FragCoord = a_FragCoord; 2203 v_FillColor = a_FillColor; 2204 2205 // Pixel space to [0, 1] (Screen space) 2206 vec2 zeroToOne = (a_Position + a_Size * a_FragCoord) / u_Resolution; 2207 2208 // Convert from [0, 1] to [0, 2] 2209 vec2 zeroToTwo = zeroToOne * 2.0; 2210 2211 // Convert from [0, 2] to [-1, 1] (NDC/clip space) 2212 vec2 clipSpace = zeroToTwo - 1.0; 2213 2214 // Flip Y axis 2215 gl_Position = vec4(clipSpace * vec2(1, -1), 0.0, 1.0); 2216} 2217`,_Lt=` 2218layout(std140) uniform SceneUniforms { 2219 vec2 u_Resolution; 2220}; 2221 2222layout(std140) uniform ShapeUniforms { 2223 float u_AntiAliasingType; 2224}; 2225 2226out vec4 outputColor; 2227 2228in vec2 v_FragCoord; 2229in vec4 v_FillColor; 2230 2231float sdf_circle(vec2 p, float r) { 2232 return length(p) - r; 2233} 2234 2235void main() { 2236 float distance = sdf_circle(v_FragCoord, 1.0); 2237 2238 if (distance > 0.0) { 2239 discard; 2240 } 2241 2242 int antiAliasingType = int(floor(u_AntiAliasingType + 0.5)); 2243 2244 float alpha; 2245 if (antiAliasingType == 0) { 2246 // Non Anti-aliasing
2247 alpha = 1.0; 2248 } else if (antiAliasingType == 1) { 2249 // Use Smoothstep 2250 alpha = smoothstep(0.0, 0.01, -distance); 2251 } else if (antiAliasingType == 2) { 2252 // Use Divide Fixed 2253 alpha = clamp(-distance / 0.01, 0.0, 1.0); 2254 } else if (antiAliasingType == 3) { 2255 // Use fwidth 2256 alpha = clamp(-distance / fwidth(-distance), 0.0, 1.0); 2257 } 2258 2259 outputColor = v_FillColor; 2260 outputColor.a *= alpha; 2261} 2262`;var bu=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},ji=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},s1,_D,CR,bD,MR,BR,wD,OR,IR,o1,ED,n1,tW,AD,eW;(function(t){t[t.NONE=0]="NONE",t[t.SMOOTHSTEP=1]="SMOOTHSTEP",t[t.DIVIDE=2]="DIVIDE",t[t.FWIDTH=3]="FWIDTH"})(eW||(eW={}));let bLt=class extends olt{constructor(t={}){super(),s1.set(this,void 0),_D.set(this,void 0),CR.set(this,void 0),bD.set(this,void 0),MR.set(this,void 0),BR.set(this,void 0),wD.set(this,void 0),OR.set(this,void 0),IR.set(this,void 0),o1.set(this,void 0),ED.set(this,void 0),n1.set(this,void 0),tW.set(this,eW.NONE),AD.set(this,void 0);const{cx:e,cy:r,r:i,fill:s,antiAliasingType:o}=t;this.cx=e??0,this.cy=r??0,this.r=i??0,this.fill=s??"black",bu(this,tW,o,"f")}get cx(){return ji(this,OR,"f")}set cx(t){ji(this,OR,"f")!==t&&(bu(this,OR,t,"f"),this.renderDirtyFlag=!0)}get cy(){return ji(this,IR,"f")}set cy(t){ji(this,IR,"f")!==t&&(bu(this,IR,t,"f"),this.renderDirtyFlag=!0)}get r(){return ji(this,o1,"f")}set r(t){ji(this,o1,"f")!==t&&(bu(this,o1,t,"f"),this.renderDirtyFlag=!0)}get fill(){return ji(this,ED,"f")}set fill(t){ji(this,ED,"f")!==t&&(bu(this,ED,t,"f"),bu(this,n1,sr.rgb(t),"f"),this.renderDirtyFlag=!0)}render(t,e,r){ji(this,s1,"f")||(bu(this,AD,t.createBuffer({viewOrSize:new Float32Array([ji(this,tW,"f")]),usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),bu(this,s1,t.createProgram({vertex:{glsl:vLt},fragment:{glsl:_Lt}}),"f"),bu(this,CR,t.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*8,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),bu(this,_D,t.createBuffer({viewOrSize:new Float32Array([-1,-1,1,-1,1,1,-1,1]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),bu(this,bD,t.createBuffer({viewOrSize:new Uint32Array([0,1,2,0,2,3]),usage:dt.INDEX,hint:Et.STATIC}),"f"),bu(this,BR,t.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:0,offset:0,format:I.F32_RG}]},{arrayStride:32,stepMode:ne.INSTANCE,attributes:[{shaderLocation:1,offset:0,format:I.F32_RG},{shaderLocation:2,offset:8,format:I.F32_RG},{shaderLocation:3,offset:16,format:I.F32_RGBA}]}],indexBufferFormat:I.U32_R,program:ji(this,s1,"f")}),"f"),bu(this,MR,t.createRenderPipeline({inputLayout:ji(this,BR,"f"),program:ji(this,s1,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}]}}),"f"),bu(this,wD,t.createBindings({pipeline:ji(this,MR,"f"),uniformBufferBindings:[{buffer:r},{buffer:ji(this,AD,"f")}]}),"f")),this.renderDirtyFlag&&ji(this,CR,"f").setSubData(0,new Uint8Array(new Float32Array([ji(this,OR,"f"),ji(this,IR,"f"),ji(this,o1,"f"),ji(this,o1,"f"),ji(this,n1,"f").r/255,ji(this,n1,"f").g/255,ji(this,n1,"f").b/255,ji(this,n1,"f").opacity]).buffer)),e.setPipeline(ji(this,MR,"f")),e.setVertexInput(ji(this,BR,"f"),[{buffer:ji(this,_D,"f")},{buffer:ji(this,CR,"f")}],{buffer:ji(this,bD,"f")}),e.setBindings(ji(this,wD,"f")),e.drawIndexed(6,1),this.renderDirtyFlag=!1}destroy(){ji(this,s1,"f").destroy(),ji(this,CR,"f").destroy(),ji(this,_D,"f").destroy(),ji(this,bD,"f").destroy(),ji(this,AD,"f").destroy(),ji(this,MR,"f").destroy(),ji(this,BR,"f").destroy(),ji(this,wD,"f").destroy()}};
2262s1=new WeakMap,_D=new WeakMap,CR=new WeakMap,bD=new WeakMap,MR=new WeakMap,BR=new WeakMap,wD=new WeakMap,OR=new WeakMap,IR=new WeakMap,o1=new WeakMap,ED=new WeakMap,n1=new WeakMap,tW=new WeakMap,AD=new WeakMap;const wLt=Object.freeze(Object.defineProperty({__proto__:null,get AntiAliasingType(){return eW},Canvas:yLt,Circle:bLt,Shape:olt},Symbol.toStringTag,{value:"Module"})),nlt=new wn,rW=0;let qH=class{constructor(){this.renderDirtyFlag=!0,this.transform=new wn,this.children=[]}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*id}set angle(t){this.transform.rotation=t*eu}appendChild(t){return t.parent&&t.parent.removeChild(t),t.parent=this,t.transform._parentID=-1,this.children.push(t),t}removeChild(t){const e=this.children.indexOf(t);return e===-1?null:(t.parent=void 0,t.transform._parentID=-1,this.children.splice(e,1),t)}};const ELt=` 2263layout(std140) uniform SceneUniforms { 2264 vec2 u_Resolution; 2265}; 2266 2267layout(std140) uniform ShapeUniforms { 2268 mat3 u_ModelMatrix; 2269}; 2270 2271layout(location = 0) in vec2 a_FragCoord; 2272layout(location = 1) in vec2 a_Position; 2273layout(location = 2) in vec2 a_Size; 2274layout(location = 3) in vec4 a_FillColor; 2275 2276out vec2 v_FragCoord; 2277out vec4 v_FillColor; 2278 2279void main() { 2280 v_FragCoord = a_FragCoord; 2281 v_FillColor = a_FillColor; 2282 2283 vec2 position = (u_ModelMatrix * vec3(a_Position + a_Size * a_FragCoord, 1)).xy; 2284 2285 // Pixel space to [0, 1] (Screen space) 2286 vec2 zeroToOne = position / u_Resolution; 2287 2288 // Convert from [0, 1] to [0, 2] 2289 vec2 zeroToTwo = zeroToOne * 2.0; 2290 2291 // Convert from [0, 2] to [-1, 1] (NDC/clip space) 2292 vec2 clipSpace = zeroToTwo - 1.0; 2293 2294 // Flip Y axis 2295 gl_Position = vec4(clipSpace * vec2(1, -1), 0.0, 1.0); 2296} 2297`,ALt=` 2298layout(std140) uniform SceneUniforms { 2299 vec2 u_Resolution; 2300}; 2301 2302out vec4 outputColor; 2303 2304in vec2 v_FragCoord; 2305in vec4 v_FillColor; 2306 2307float sdf_circle(vec2 p, float r) { 2308 return length(p) - r; 2309} 2310 2311void main() { 2312 float distance = sdf_circle(v_FragCoord, 1.0); 2313 2314 if (distance > 0.0) { 2315 discard; 2316 } 2317 2318 float alpha = clamp(-distance / fwidth(-distance), 0.0, 1.0); 2319 2320 outputColor = v_FillColor; 2321 outputColor.a *= alpha; 2322} 2323`;var Xi=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},_d=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},DR,PR,a1,xD,l1,c1,SD,FR,TD,NR,kR,LR,RD;let xLt=class extends qH{constructor(t={}){super(),DR.set(this,void 0),PR.set(this,void 0),a1.set(this,void 0),xD.set(this,void 0),l1.set(this,void 0),c1.set(this,void 0),SD.set(this,void 0),FR.set(this,void 0),TD.set(this,void 0),NR.set(this,void 0),kR.set(this,void 0),LR.set(this,void 0),RD.set(this,void 0);const{cx:e,cy:r,r:i,fill:s}=t;this.cx=e??0,this.cy=r??0,this.r=i??0,this.fill=s??"black"}get cx(){return Xi(this,DR,"f")}set cx(t){Xi(this,DR,"f")!==t&&(_d(this,DR,t,"f"),this.renderDirtyFlag=!0)}get cy(){return Xi(this,PR,"f")}set cy(t){Xi(this,PR,"f")!==t&&(_d(this,PR,t,"f"),this.renderDirtyFlag=!0)}get r(){return Xi(this,a1,"f")}set r(t){Xi(this,a1,"f")!==t&&(_d(this,a1,t,"f"),this.renderDirtyFlag=!0)}get fill(){return Xi(this,xD,"f")}set fill(t){Xi(this,xD,"f")!==t&&(_d(this,xD,t,"f"),_d(this,l1,sr.rgb(t),"f"),this.renderDirtyFlag=!0)}render(t,e,r){Xi(this,c1,"f")||(_d(this,c1,t.createProgram({vertex:{glsl:ELt},fragment:{glsl:ALt}}),"f"),_d(this,NR,t.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*12,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),_d(this,FR,t.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*8,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),_d(this,SD,t.createBuffer({viewOrSize:new Float32Array([-1,-1,1,-1,1,1,-1,1]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),_d(this,TD,t.createBuffer({viewOrSize:new Uint32Array([0,1,2,0,2,3]),usage:dt.INDEX,hint:Et.STATIC}),"f"),_d(this,LR,t.createInputLayout({vertexBufferDescriptors:[{arrayStri
2323de:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:0,offset:0,format:I.F32_RG}]},{arrayStride:32,stepMode:ne.INSTANCE,attributes:[{shaderLocation:1,offset:0,format:I.F32_RG},{shaderLocation:2,offset:8,format:I.F32_RG},{shaderLocation:3,offset:16,format:I.F32_RGBA}]}],indexBufferFormat:I.U32_R,program:Xi(this,c1,"f")}),"f"),_d(this,kR,t.createRenderPipeline({inputLayout:Xi(this,LR,"f"),program:Xi(this,c1,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}]}}),"f"),_d(this,RD,t.createBindings({pipeline:Xi(this,kR,"f"),uniformBufferBindings:[{buffer:r},{buffer:Xi(this,NR,"f")}]}),"f"));const{a:i,b:s,c:o,d:n,tx:a,ty:l}=this.worldTransform;Xi(this,NR,"f").setSubData(0,new Uint8Array(new Float32Array([i,s,0,rW,o,n,0,rW,a,l,1,rW]).buffer)),this.renderDirtyFlag&&Xi(this,FR,"f").setSubData(0,new Uint8Array(new Float32Array([Xi(this,DR,"f"),Xi(this,PR,"f"),Xi(this,a1,"f"),Xi(this,a1,"f"),Xi(this,l1,"f").r/255,Xi(this,l1,"f").g/255,Xi(this,l1,"f").b/255,Xi(this,l1,"f").opacity]).buffer)),e.setPipeline(Xi(this,kR,"f")),e.setVertexInput(Xi(this,LR,"f"),[{buffer:Xi(this,SD,"f")},{buffer:Xi(this,FR,"f")}],{buffer:Xi(this,TD,"f")}),e.setBindings(Xi(this,RD,"f")),e.drawIndexed(6,1),this.renderDirtyFlag=!1}destroy(){Xi(this,c1,"f").destroy(),Xi(this,FR,"f").destroy(),Xi(this,SD,"f").destroy(),Xi(this,TD,"f").destroy(),Xi(this,NR,"f").destroy(),Xi(this,kR,"f").destroy(),Xi(this,LR,"f").destroy(),Xi(this,RD,"f").destroy()}};DR=new WeakMap,PR=new WeakMap,a1=new WeakMap,xD=new WeakMap,l1=new WeakMap,c1=new WeakMap,SD=new WeakMap,FR=new WeakMap,TD=new WeakMap,NR=new WeakMap,kR=new WeakMap,LR=new WeakMap,RD=new WeakMap;let SLt=class extends qH{render(t,e,r){}destroy(){}};var TLt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},UR=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},an=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},GR,Bh,d_,WR,jR;let RLt=class{constructor(){GR.set(this,void 0),Bh.set(this,void 0),d_.set(this,void 0),WR.set(this,void 0),jR.set(this,void 0)}apply(t){const{hooks:e,canvas:r,renderer:i,shaderCompilerPath:s,devicePixelRatio:o}=t;e.initAsync.tapPromise(()=>TLt(this,void 0,void 0,function*(){let n;i==="webgl"?n=new hd({targets:["webgl2","webgl1"],antialias:!0,shaderDebug:!0,trackResources:!0,onContextCreationError:()=>{},onContextLost:()=>{},onContextRestored(h){}}):n=new ud({shaderCompilerPath:s,onContextLost:()=>{}});const{width:a,height:l}=r,c=yield n.createSwapChain(r);c.configureSwapChain(a,l),UR(this,GR,c,"f"),UR(this,Bh,c.getDevice(),"f"),UR(this,d_,an(this,Bh,"f").createRenderTargetFromTexture(an(this,Bh,"f").createTexture({format:I.U8_RGBA_RT,width:a,height:l,usage:xr.RENDER_TARGET})),"f"),UR(this,jR,an(this,Bh,"f").createBuffer({viewOrSize:new Float32Array([a/o,l/o]),usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f")})),e.resize.tap((n,a)=>{an(this,GR,"f").configureSwapChain(n*o,a*o),an(this,d_,"f")&&(an(this,d_,"f").destroy(),UR(this,d_,an(this,Bh,"f").createRenderTargetFromTexture(an(this,Bh,"f").createTexture({format:I.U8_RGBA_RT,width:n*o,height:a*o,usage:xr.RENDER_TARGET})),"f"))}),e.destroy.tap(()=>{an(this,d_,"f").destroy(),an(this,jR,"f").destroy(),an(this,Bh,"f").destroy(),an(this,Bh,"f").checkForLeaks()}),e.beginFrame.tap(()=>{const{width:n,height:a}=an(this,GR,"f").getCanvas(),l=an(this,GR,"f").getOnscreenTexture();an(this,jR,"f").setSubData(0,new Uint8Array(new Float32Array([n/
2323o,a/o]).buffer)),an(this,Bh,"f").beginFrame(),UR(this,WR,an(this,Bh,"f").createRenderPass({colorAttachment:[an(this,d_,"f")],colorResolveTo:[l],colorClearColor:[op]}),"f"),an(this,WR,"f").setViewport(0,0,n,a)}),e.endFrame.tap(()=>{an(this,Bh,"f").submitPass(an(this,WR,"f")),an(this,Bh,"f").endFrame()}),e.render.tap(n=>{n.transform.updateTransform(n.parent?n.parent.transform:nlt),n.render(an(this,Bh,"f"),an(this,WR,"f"),an(this,jR,"f"))})}};GR=new WeakMap,Bh=new WeakMap,d_=new WeakMap,WR=new WeakMap,jR=new WeakMap;var ZH=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},CD;let CLt=class{constructor(){CD.set(this,[])}getCallbacksNum(){return ZH(this,CD,"f").length}tapPromise(t){ZH(this,CD,"f").push(t)}promise(...t){return Promise.all(ZH(this,CD,"f").map(e=>e(...t)))}};CD=new WeakMap;var alt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},iW;let XR=class{constructor(){iW.set(this,[])}tap(t){alt(this,iW,"f").push(t)}call(...t){alt(this,iW,"f").forEach(function(e){e.apply(void 0,t)})}};iW=new WeakMap;const MLt=()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};function JH(t,e){e(t),t.children.forEach(r=>{JH(r,e)})}var BLt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},llt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},hf=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},sW,w0,h1;let OLt=class{constructor(t){sW.set(this,void 0),w0.set(this,void 0),h1.set(this,[]);const{canvas:e,renderer:r="webgl",shaderCompilerPath:i="",devicePixelRatio:s}=t,o=MLt();llt(this,w0,{globalThis:o,canvas:e,renderer:r,shaderCompilerPath:i,devicePixelRatio:s??o.devicePixelRatio,hooks:{init:new XR,initAsync:new CLt,beginFrame:new XR,render:new XR,endFrame:new XR,destroy:new XR,resize:new XR}},"f"),llt(this,sW,BLt(this,void 0,void 0,function*(){const{hooks:n}=hf(this,w0,"f");return[new RLt].forEach(a=>{a.apply(hf(this,w0,"f"))}),n.init.call(),yield n.initAsync.promise(),this}),"f")}get initialized(){return hf(this,sW,"f").then(()=>this)}render(){const{hooks:t}=hf(this,w0,"f");t.beginFrame.call(),hf(this,h1,"f").forEach(e=>{JH(e,r=>{t.render.call(r)})}),t.endFrame.call()}resize(t,e){const{hooks:r}=hf(this,w0,"f");r.resize.call(t,e)}destroy(){const{hooks:t}=hf(this,w0,"f");hf(this,h1,"f").forEach(e=>{JH(e,r=>{r.destroy()})}),t.destroy.call()}getDOM(){return hf(this,w0,"f").canvas}appendChild(t){hf(this,h1,"f").push(t)}removeChild(t){const e=hf(this,h1,"f").indexOf(t);e!==-1&&hf(this,h1,"f").splice(e,1)}};sW=new WeakMap,w0=new WeakMap,h1=new WeakMap;const ILt=Object.freeze(Object.defineProperty({__proto__:null,Canvas:OLt,Circle:xLt,Group:SLt,IDENTITY_TRANSFORM:nlt,PADDING:rW,Shape:qH},Symbol.toStringTag,{value:"Module"}));var QH=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},MD;let DLt=class{constructor(){MD.set(this,[])}getCallbacksNum(){return QH(this,MD,"f").length}tapPromise(t){QH(this,MD,"f").push(t)}promise(...t){return Promise.all(QH(this,MD,"f").map(e=>e(...t)))}};MD=new WeakMap;var clt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},oW;let zR=class{constructor(){oW.set(this,[])}tap(t){clt(this,oW,"f").push(t)}call(...t){clt(this,oW,"f").forEach(function(e){e.apply(void 0,t)})}};oW=new WeakMap;const PLt=()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};
2323function t9(t,e){e(t),t.children.forEach(r=>{t9(r,e)})}const e9=0;function BD(t){return[t[0],t[1],t[2],e9,t[3],t[4],t[5],e9,t[6],t[7],t[8],e9]}const FLt={linear:cr(0,0,1,1),ease:cr(.25,.1,.25,1),"ease-in":cr(.42,0,1,1),"ease-out":cr(0,0,.58,1),"ease-in-out":cr(.42,0,.58,1)};var Ti=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},bd=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},E0,Rm,Cm,Mm,Sp,OD,ID,DD,nW,PD;const NLt=.01;let hlt=class{constructor(t,e){this.clipSpaceNearZ=Sh.NEGATIVE_ONE,E0.set(this,1),Rm.set(this,0),Cm.set(this,0),Mm.set(this,0),Sp.set(this,Bt()),OD.set(this,Bt()),ID.set(this,Bt()),DD.set(this,Bt()),nW.set(this,Bt()),PD.set(this,void 0),this.projection(t,e),this.updateMatrix()}projection(t,e){ld(Ti(this,OD,"f"),t,e),this.updateViewProjectionMatrix()}updateMatrix(){const t=1/Ti(this,E0,"f");Yc(Ti(this,Sp,"f")),bi(Ti(this,Sp,"f"),Ti(this,Sp,"f"),[Ti(this,Rm,"f"),Ti(this,Cm,"f")]),Mo(Ti(this,Sp,"f"),Ti(this,Sp,"f"),Ti(this,Mm,"f")),xh(Ti(this,Sp,"f"),Ti(this,Sp,"f"),[t,t]),_i(Ti(this,ID,"f"),Ti(this,Sp,"f")),this.updateViewProjectionMatrix()}updateViewProjectionMatrix(){us(Ti(this,DD,"f"),Ti(this,OD,"f"),Ti(this,ID,"f")),_i(Ti(this,nW,"f"),Ti(this,DD,"f"))}get projectionMatrix(){return Ti(this,OD,"f")}get viewMatrix(){return Ti(this,ID,"f")}get viewProjectionMatrix(){return Ti(this,DD,"f")}get viewProjectionMatrixInv(){return Ti(this,nW,"f")}get matrix(){return Ti(this,Sp,"f")}get zoom(){return Ti(this,E0,"f")}set zoom(t){Ti(this,E0,"f")!==t&&(bd(this,E0,t,"f"),this.updateMatrix())}get x(){return Ti(this,Rm,"f")}set x(t){Ti(this,Rm,"f")!==t&&(bd(this,Rm,t,"f"),this.updateMatrix())}get y(){return Ti(this,Cm,"f")}set y(t){Ti(this,Cm,"f")!==t&&(bd(this,Cm,t,"f"),this.updateMatrix())}get rotation(){return Ti(this,Mm,"f")}set rotation(t){Ti(this,Mm,"f")!==t&&(bd(this,Mm,t,"f"),this.updateMatrix())}createLandmark(t={}){return Object.assign({zoom:Ti(this,E0,"f"),x:Ti(this,Rm,"f"),y:Ti(this,Cm,"f"),rotation:Ti(this,Mm,"f")},t)}gotoLandmark(t,e={}){const{easing:r="linear",duration:i=100,onframe:s=void 0,onfinish:o=void 0}=e,{zoom:n,x:a,y:l,rotation:c}=t,h=()=>{bd(this,E0,n,"f"),bd(this,Rm,a,"f"),bd(this,Cm,l,"f"),bd(this,Mm,c,"f"),this.updateMatrix(),o&&o()};if(i===0){h();return}this.cancelLandmarkAnimation();let u;const d=[a,l],f=[n,c],g=p=>{u===void 0&&(u=p);const m=p-u;if(m>i){h();return}const v=FLt[r](m/i),b=it(),y=Be(1,0);if(ta(b,[Ti(this,Rm,"f"),Ti(this,Cm,"f")],d,v),ta(y,[this.zoom,Ti(this,Mm,"f")],f,v),bd(this,Rm,b[0],"f"),bd(this,Cm,b[1],"f"),bd(this,E0,y[0],"f"),bd(this,Mm,y[1],"f"),this.updateMatrix(),za(b,d)<=NLt){h();return}m<i&&(s&&s(v),bd(this,PD,requestAnimationFrame(g),"f"))};requestAnimationFrame(g)}cancelLandmarkAnimation(){Ti(this,PD,"f")!==void 0&&cancelAnimationFrame(Ti(this,PD,"f"))}};E0=new WeakMap,Rm=new WeakMap,Cm=new WeakMap,Mm=new WeakMap,Sp=new WeakMap,OD=new WeakMap,ID=new WeakMap,DD=new WeakMap,nW=new WeakMap,PD=new WeakMap;const ult=new wn;let r9=class{constructor(){this.renderDirtyFlag=!0,this.transform=new wn,this.children=[]}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*id}set angle(t){this.transform.rotation=t*eu}appendChild(t){return t.parent&&t.parent.removeChild(t),t.parent=this,t.transform._parentID=-1,this.children.push(t),t}removeChild(t){const e=this.children.indexOf(t);return e===-1?null:(t.parent=void 0,t.transform._parentID=-1,this.children.splice(e,1),t)}};const kLt=` 2324layout(std140) uniform SceneUniforms { 2325 mat3 u_ProjectionMatrix; 2326 mat3 u_ViewMatrix; 2327}; 2328 2329layout(std140) uniform ShapeUniforms { 2330 mat3 u_ModelMatrix; 2331}; 2332 2333layout(location = 0) in vec2 a_FragCoord; 2334layout(location = 1) in vec2 a_Position; 2335layout(location = 2) in vec2 a_Size; 2336layout(location = 3) in vec4 a_FillColor; 2337 2338out vec2 v_FragCoord; 2339out vec4 v_FillColor; 2340 2341void main() { 2342 v_FragCoord = a_FragCoord; 2343 v_FillColor = a_FillColor; 2344 2345 gl_Position = vec4((u_ProjectionMatrix
2346 * u_ViewMatrix 2347 * u_ModelMatrix 2348 * vec3(a_Position + a_Size * a_FragCoord, 1)).xy, 0, 1); 2349} 2350`,LLt=` 2351layout(std140) uniform SceneUniforms { 2352 mat3 u_ProjectionMatrix; 2353 mat3 u_ViewMatrix; 2354}; 2355 2356layout(std140) uniform ShapeUniforms { 2357 mat3 u_ModelMatrix; 2358}; 2359 2360out vec4 outputColor; 2361 2362in vec2 v_FragCoord; 2363in vec4 v_FillColor; 2364 2365float sdf_circle(vec2 p, float r) { 2366 return length(p) - r; 2367} 2368 2369void main() { 2370 float distance = sdf_circle(v_FragCoord, 1.0); 2371 2372 if (distance > 0.0) { 2373 discard; 2374 } 2375 2376 float alpha = clamp(-distance / fwidth(-distance), 0.0, 1.0); 2377 2378 outputColor = v_FillColor; 2379 outputColor.a *= alpha; 2380} 2381`;var zi=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},wd=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},VR,YR,u1,FD,d1,f1,ND,$R,kD,HR,KR,qR,LD;let ULt=class extends r9{constructor(t={}){super(),VR.set(this,void 0),YR.set(this,void 0),u1.set(this,void 0),FD.set(this,void 0),d1.set(this,void 0),f1.set(this,void 0),ND.set(this,void 0),$R.set(this,void 0),kD.set(this,void 0),HR.set(this,void 0),KR.set(this,void 0),qR.set(this,void 0),LD.set(this,void 0);const{cx:e,cy:r,r:i,fill:s}=t;this.cx=e??0,this.cy=r??0,this.r=i??0,this.fill=s??"black"}get cx(){return zi(this,VR,"f")}set cx(t){zi(this,VR,"f")!==t&&(wd(this,VR,t,"f"),this.renderDirtyFlag=!0)}get cy(){return zi(this,YR,"f")}set cy(t){zi(this,YR,"f")!==t&&(wd(this,YR,t,"f"),this.renderDirtyFlag=!0)}get r(){return zi(this,u1,"f")}set r(t){zi(this,u1,"f")!==t&&(wd(this,u1,t,"f"),this.renderDirtyFlag=!0)}get fill(){return zi(this,FD,"f")}set fill(t){zi(this,FD,"f")!==t&&(wd(this,FD,t,"f"),wd(this,d1,sr.rgb(t),"f"),this.renderDirtyFlag=!0)}render(t,e,r){zi(this,f1,"f")||(wd(this,f1,t.createProgram({vertex:{glsl:kLt},fragment:{glsl:LLt}}),"f"),wd(this,HR,t.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*16,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),wd(this,$R,t.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*8,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),wd(this,ND,t.createBuffer({viewOrSize:new Float32Array([-1,-1,1,-1,1,1,-1,1]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),wd(this,kD,t.createBuffer({viewOrSize:new Uint32Array([0,1,2,0,2,3]),usage:dt.INDEX,hint:Et.STATIC}),"f"),wd(this,qR,t.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:0,offset:0,format:I.F32_RG}]},{arrayStride:32,stepMode:ne.INSTANCE,attributes:[{shaderLocation:1,offset:0,format:I.F32_RG},{shaderLocation:2,offset:8,format:I.F32_RG},{shaderLocation:3,offset:16,format:I.F32_RGBA}]}],indexBufferFormat:I.U32_R,program:zi(this,f1,"f")}),"f"),wd(this,KR,t.createRenderPipeline({inputLayout:zi(this,qR,"f"),program:zi(this,f1,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}]}}),"f"),wd(this,LD,t.createBindings({pipeline:zi(this,KR,"f"),uniformBufferBindings:[{buffer:r},{buffer:zi(this,HR,"f")}]}),"f")),zi(this,HR,"f").setSubData(0,new Uint8Array(new Float32Array(BD(this.worldTransform.toArray(!0))).buffer)),this.renderDirtyFlag&&zi(this,$R,"f").setSubData(0,new Uint8Array(new Float32Array([zi(this,VR,"f"),zi(this,YR,"f"),zi(this,u1,"f"),zi(this,u1,"f"),zi(this,d1,"f").r/255,zi(this,d1,"f").g/255,zi(this,d1,"f").b/255,zi(this,d1,"f").opacity]).buffer)),e.setPipeline(zi(this,KR,"f")),e.setVertexInput(zi(this,qR,"f"),[{buffer:zi(this,ND,"f")},{buffer:zi(this,$R,"f")}],{buffer:zi(this,kD,"f")}),e.setBindings(zi(this,LD,"f")),e.drawIndexed(6,1),this.renderDirtyFlag=!1}destroy(){zi(this,f1,"f").destroy(),zi(this,$R,"f").destroy(),zi(this,ND,"f").destroy(),zi(this,kD,"f").destroy(),zi(this,HR,"f").destroy(),zi(this,KR,"f").destroy(),zi(this,qR,"f").destroy(),zi(this,LD,"f").destroy()}};VR=new WeakMap,YR=new WeakMap,u1=new WeakMap,FD=new WeakMap,d1=new WeakMap,f1=new WeakMap,ND=new WeakMap,$R=new WeakMap,kD=new WeakMap,HR=new WeakMap,KR=new WeakMap,qR=new WeakMap,LD=new WeakMap;let GLt=class extends r9{render(t,e,r){}destroy(){}};var WLt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},ZR=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
2381return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},ln=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},JR,Oh,f_,QR,tC;let jLt=class{constructor(){JR.set(this,void 0),Oh.set(this,void 0),f_.set(this,void 0),QR.set(this,void 0),tC.set(this,void 0)}apply(t){const{hooks:e,canvas:r,renderer:i,shaderCompilerPath:s,devicePixelRatio:o,camera:n}=t;e.initAsync.tapPromise(()=>WLt(this,void 0,void 0,function*(){let a;i==="webgl"?a=new hd({targets:["webgl2","webgl1"],antialias:!0,shaderDebug:!0,trackResources:!0,onContextCreationError:()=>{},onContextLost:()=>{},onContextRestored(u){}}):a=new ud({shaderCompilerPath:s,onContextLost:()=>{}});const{width:l,height:c}=r,h=yield a.createSwapChain(r);h.configureSwapChain(l,c),ZR(this,JR,h,"f"),ZR(this,Oh,h.getDevice(),"f"),ZR(this,f_,ln(this,Oh,"f").createRenderTargetFromTexture(ln(this,Oh,"f").createTexture({format:I.U8_RGBA_RT,width:l,height:c,usage:xr.RENDER_TARGET})),"f"),ZR(this,tC,ln(this,Oh,"f").createBuffer({viewOrSize:new Float32Array([...BD(n.projectionMatrix),...BD(n.viewMatrix),l/o,c/o]),usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f")})),e.resize.tap((a,l)=>{ln(this,JR,"f").configureSwapChain(a*o,l*o),ln(this,f_,"f")&&(ln(this,f_,"f").destroy(),ZR(this,f_,ln(this,Oh,"f").createRenderTargetFromTexture(ln(this,Oh,"f").createTexture({format:I.U8_RGBA_RT,width:a*o,height:l*o,usage:xr.RENDER_TARGET})),"f"))}),e.destroy.tap(()=>{ln(this,f_,"f").destroy(),ln(this,tC,"f").destroy(),ln(this,Oh,"f").destroy(),ln(this,Oh,"f").checkForLeaks()}),e.beginFrame.tap(()=>{const{width:a,height:l}=ln(this,JR,"f").getCanvas(),c=ln(this,JR,"f").getOnscreenTexture();ln(this,tC,"f").setSubData(0,new Uint8Array(new Float32Array([...BD(n.projectionMatrix),...BD(n.viewMatrix),a/o,l/o]).buffer)),ln(this,Oh,"f").beginFrame(),ZR(this,QR,ln(this,Oh,"f").createRenderPass({colorAttachment:[ln(this,f_,"f")],colorResolveTo:[c],colorClearColor:[op]}),"f"),ln(this,QR,"f").setViewport(0,0,a,l)}),e.endFrame.tap(()=>{ln(this,Oh,"f").submitPass(ln(this,QR,"f")),ln(this,Oh,"f").endFrame()}),e.render.tap(a=>{a.transform.updateTransform(a.parent?a.parent.transform:ult),a.render(ln(this,Oh,"f"),ln(this,QR,"f"),ln(this,tC,"f"))})}};JR=new WeakMap,Oh=new WeakMap,f_=new WeakMap,QR=new WeakMap,tC=new WeakMap;const XLt=.02,zLt=100;let VLt=class{apply(t){const{canvas:e,camera:r}=t,i=Bt();let s,o,n;const a=it();let l,c=!1;function h(p){const m=e.getBoundingClientRect(),v=p.clientX-m.left,b=p.clientY-m.top,y=v/e.clientWidth,_=b/e.clientHeight,w=y*2-1,E=_*-2+1;return[w,E]}function u(p){const m=Qt(it(),h(p),i);r.x=s+a[0]-m[0],r.y=o+a[1]-m[1]}function d(p){const m=(p.clientX-l[0])/100,v=Bt();bi(v,v,[a[0],a[1]]),Mo(v,v,m),bi(v,v,[-a[0],-a[1]]),r.x=s,r.y=o,r.rotation=n,us(v,v,r.matrix),r.rotation=n+m,r.x=v[6],r.y=v[7]}function f(p){c?d(p):u(p)}function g(p){c=!1,window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",g)}e.addEventListener("mousedown",p=>{p.preventDefault(),window.addEventListener("mousemove",f),window.addEventListener("mouseup",g),c=p.shiftKey,fp(i,r.viewProjectionMatrixInv),s=r.x,o=r.y,n=r.rotation,Qt(a,h(p),i),l=[p.clientX,p.clientY]}),e.addEventListener("wheel",p=>{p.preventDefault();const m=h(p),[v,b]=Qt(it(),m,r.viewProjectionMatrixInv),y=r.zoom*Math.pow(2,p.deltaY*-.01);r.zoom=Math.max(XLt,Math.min(zLt,y));const[_,w]=Qt(it(),m,r.viewProjectionMatrixInv);r.x+=v-_,r.y+=b-w})}};var YLt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},wu=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},i9=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
2381return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},aW,A0,p1,UD;let $Lt=class{get camera(){return wu(this,UD,"f")}constructor(t){aW.set(this,void 0),A0.set(this,void 0),p1.set(this,[]),UD.set(this,void 0);const{canvas:e,renderer:r="webgl",shaderCompilerPath:i="",devicePixelRatio:s}=t,o=PLt(),n=s??o.devicePixelRatio,{width:a,height:l}=e,c=new hlt(a/n,l/n);i9(this,UD,c,"f"),i9(this,A0,{globalThis:o,canvas:e,renderer:r,shaderCompilerPath:i,devicePixelRatio:n,hooks:{init:new zR,initAsync:new DLt,beginFrame:new zR,render:new zR,endFrame:new zR,destroy:new zR,resize:new zR},camera:c},"f"),i9(this,aW,YLt(this,void 0,void 0,function*(){const{hooks:h}=wu(this,A0,"f");return[new VLt,new jLt].forEach(u=>{u.apply(wu(this,A0,"f"))}),h.init.call(),yield h.initAsync.promise(),this}),"f")}get initialized(){return wu(this,aW,"f").then(()=>this)}render(){const{hooks:t}=wu(this,A0,"f");t.beginFrame.call(),wu(this,p1,"f").forEach(e=>{t9(e,r=>{t.render.call(r)})}),t.endFrame.call()}resize(t,e){const{hooks:r}=wu(this,A0,"f");wu(this,UD,"f").projection(t,e),r.resize.call(t,e)}destroy(){const{hooks:t}=wu(this,A0,"f");wu(this,p1,"f").forEach(e=>{t9(e,r=>{r.destroy()})}),t.destroy.call()}getDOM(){return wu(this,A0,"f").canvas}appendChild(t){wu(this,p1,"f").push(t)}removeChild(t){const e=wu(this,p1,"f").indexOf(t);e!==-1&&wu(this,p1,"f").splice(e,1)}};aW=new WeakMap,A0=new WeakMap,p1=new WeakMap,UD=new WeakMap;const HLt=Object.freeze(Object.defineProperty({__proto__:null,Camera:hlt,Canvas:$Lt,Circle:ULt,Group:GLt,IDENTITY_TRANSFORM:ult,Shape:r9},Symbol.toStringTag,{value:"Module"}));var s9=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},GD;let KLt=class{constructor(){GD.set(this,[])}getCallbacksNum(){return s9(this,GD,"f").length}tapPromise(t){s9(this,GD,"f").push(t)}promise(...t){return Promise.all(s9(this,GD,"f").map(e=>e(...t)))}};GD=new WeakMap;var dlt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},lW;let eC=class{constructor(){lW.set(this,[])}tap(t){dlt(this,lW,"f").push(t)}call(...t){dlt(this,lW,"f").forEach(function(e){e.apply(void 0,t)})}};lW=new WeakMap;const qLt=()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};function o9(t,e){e(t),t.children.forEach(r=>{o9(r,e)})}const n9=0;function g1(t){return[t[0],t[1],t[2],n9,t[3],t[4],t[5],n9,t[6],t[7],t[8],n9]}const ZLt={linear:cr(0,0,1,1),ease:cr(.25,.1,.25,1),"ease-in":cr(.42,0,1,1),"ease-out":cr(0,0,.58,1),"ease-in-out":cr(.42,0,.58,1)};var p_;(function(t){t._bytes4=new Uint8Array(4),t._float=new Float32Array(t._bytes4.buffer),t._int=new Int32Array(t._bytes4.buffer),t._bytes2=new Uint8Array(2),t._short=new Int16Array(t._bytes2.buffer);function e(c){return t._float[0]=c,t._int[0]}t.floatToInt=e;function r(c){return t._int[0]=c,t._float[0]}t.intToFloat=r;function i(c){return t._float[0]=c,t._bytes4}t.floatToBytes=i;function s(c,h,u,d){return t._bytes4[0]=c,t._bytes4[1]=h,t._bytes4[2]=u,t._bytes4[3]=d,t._float[0]}t.bytesToFloat=s;function o(c){return t._int[0]=c,t._bytes4}t.intToBytes=o;function n(c,h,u,d){return t._bytes4[0]=c,t._bytes4[1]=h,t._bytes4[2]=u,t._bytes4[3]=d,t._int[0]}t.bytesToInt=n;function a(c){return t._short[0]=c,t._bytes2}t.shortToBytes=a;function l(c,h){return t._bytes2[0]=c,t._bytes2[1]=h,t._short[0]}t.bytesToShort=l})(p_||(p_={}));const flt=256;let plt=class{constructor(t=new Uint8Array(flt)){this._bytes=t,this.count=0,this.readOffset=0,this.capacity=flt,this.count=this.capacity=t.length}clear(){this.count=0,this.readOffset=0}byteCount(){return this.count}bytes(){return this._bytes.subarray(0,this.count)}grow(){this.capacity*=2;const t=new Uint8Array(this.capacity);t.set(this._bytes),this._bytes=t}hasMoreToRead(){return this.readOffset<this.count}seekTo(t){this.readOffset=t}skipBytes(t){this.readOffset+=t}appendBytes(t){const e=t.length;return this.count+e>this.capacity&&this.grow(),this._bytes.set(t,this.count),this.count+=e,this}byteAt(t){return this._bytes[t]}appendByte(t){return this.count+1>this.capacity&&this.grow(),this._bytes[this.count]=t,this.count++,this}readByte(){const t=this.byteAt(this.readOffset);return this.readOffset++,t}shortAt(t){return p_.bytesToShort(this._bytes[t],this._bytes[t+1])}appendShort(t){return this.appendBytes(p_.shortToBytes(t)),this}appendShorts(t){for(const e of t)this.appendShort(e);return this}readShort(){const t=this.shortAt(this.readOffset);return this.readOffset+=2,t}intAt(t){return p_.bytesToInt(this._bytes[t],this._bytes[t+1],this._bytes[t+2],this._bytes[t+3])}appendInt(t){return this.appendBytes(p_.intToBytes(t)),this}appendInts(t){for(const e of t)this.appendInt(e);return this}readInt(){const t=this.intAt(this.readOffset);return this.readOffset+=4,t}
2381floatAt(t){return p_.bytesToFloat(this._bytes[t],this._bytes[t+1],this._bytes[t+2],this._bytes[t+3])}appendFloat(t){return this.appendBytes(p_.floatToBytes(t)),this}appendFloats(t){for(const e of t)this.appendFloat(e);return this}readFloat(){const t=this.floatAt(this.readOffset);return this.readOffset+=4,t}isEmpty(){return this.count==0}};var Ih=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},fi=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},x0,Bm,Om,Im,cW,hW,Tp,WD,jD,XD,uW,zD;const JLt=.01;let glt=class{constructor(t,e){this.clipSpaceNearZ=Sh.NEGATIVE_ONE,x0.set(this,1),Bm.set(this,0),Om.set(this,0),Im.set(this,0),cW.set(this,0),hW.set(this,0),Tp.set(this,Bt()),WD.set(this,Bt()),jD.set(this,Bt()),XD.set(this,Bt()),uW.set(this,Bt()),zD.set(this,void 0),this.projection(t,e),this.updateMatrix()}projection(t,e){Ih(this,cW,t,"f"),Ih(this,hW,e,"f"),ld(fi(this,WD,"f"),t,e),this.updateViewProjectionMatrix()}updateMatrix(){const t=1/fi(this,x0,"f");Yc(fi(this,Tp,"f")),bi(fi(this,Tp,"f"),fi(this,Tp,"f"),[fi(this,Bm,"f"),fi(this,Om,"f")]),Mo(fi(this,Tp,"f"),fi(this,Tp,"f"),fi(this,Im,"f")),xh(fi(this,Tp,"f"),fi(this,Tp,"f"),[t,t]),_i(fi(this,jD,"f"),fi(this,Tp,"f")),this.updateViewProjectionMatrix()}updateViewProjectionMatrix(){us(fi(this,XD,"f"),fi(this,WD,"f"),fi(this,jD,"f")),_i(fi(this,uW,"f"),fi(this,XD,"f"))}get projectionMatrix(){return fi(this,WD,"f")}get viewMatrix(){return fi(this,jD,"f")}get viewProjectionMatrix(){return fi(this,XD,"f")}get viewProjectionMatrixInv(){return fi(this,uW,"f")}get matrix(){return fi(this,Tp,"f")}get zoom(){return fi(this,x0,"f")}set zoom(t){fi(this,x0,"f")!==t&&(Ih(this,x0,t,"f"),this.updateMatrix())}get x(){return fi(this,Bm,"f")}set x(t){fi(this,Bm,"f")!==t&&(Ih(this,Bm,t,"f"),this.updateMatrix())}get y(){return fi(this,Om,"f")}set y(t){fi(this,Om,"f")!==t&&(Ih(this,Om,t,"f"),this.updateMatrix())}get rotation(){return fi(this,Im,"f")}set rotation(t){fi(this,Im,"f")!==t&&(Ih(this,Im,t,"f"),this.updateMatrix())}get width(){return fi(this,cW,"f")}get height(){return fi(this,hW,"f")}createLandmark(t={}){return Object.assign({zoom:fi(this,x0,"f"),x:fi(this,Bm,"f"),y:fi(this,Om,"f"),rotation:fi(this,Im,"f")},t)}gotoLandmark(t,e={}){const{easing:r="linear",duration:i=100,onframe:s=void 0,onfinish:o=void 0}=e,{zoom:n,x:a,y:l,rotation:c}=t,h=()=>{Ih(this,x0,n,"f"),Ih(this,Bm,a,"f"),Ih(this,Om,l,"f"),Ih(this,Im,c,"f"),this.updateMatrix(),o&&o()};if(i===0){h();return}this.cancelLandmarkAnimation();let u;const d=[a,l],f=[n,c],g=p=>{u===void 0&&(u=p);const m=p-u;if(m>i){h();return}const v=ZLt[r](m/i),b=it(),y=Be(1,0);if(ta(b,[fi(this,Bm,"f"),fi(this,Om,"f")],d,v),ta(y,[this.zoom,fi(this,Im,"f")],f,v),Ih(this,Bm,b[0],"f"),Ih(this,Om,b[1],"f"),Ih(this,x0,y[0],"f"),Ih(this,Im,y[1],"f"),this.updateMatrix(),za(b,d)<=JLt){h();return}m<i&&(s&&s(v),Ih(this,zD,requestAnimationFrame(g),"f"))};requestAnimationFrame(g)}cancelLandmarkAnimation(){fi(this,zD,"f")!==void 0&&cancelAnimationFrame(fi(this,zD,"f"))}};x0=new WeakMap,Bm=new WeakMap,Om=new WeakMap,Im=new WeakMap,cW=ne
2381w WeakMap,hW=new WeakMap,Tp=new WeakMap,WD=new WeakMap,jD=new WeakMap,XD=new WeakMap,uW=new WeakMap,zD=new WeakMap;const mlt=new wn;let a9=class{constructor(){this.renderDirtyFlag=!0,this.transform=new wn,this.children=[]}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*id}set angle(t){this.transform.rotation=t*eu}appendChild(t){return t.parent&&t.parent.removeChild(t),t.parent=this,t.transform._parentID=-1,this.children.push(t),t}removeChild(t){const e=this.children.indexOf(t);return e===-1?null:(t.parent=void 0,t.transform._parentID=-1,this.children.splice(e,1),t)}};const QLt=` 2382layout(std140) uniform SceneUniforms { 2383 mat3 u_ProjectionMatrix; 2384 mat3 u_ViewMatrix; 2385}; 2386 2387layout(std140) uniform ShapeUniforms { 2388 mat3 u_ModelMatrix; 2389}; 2390 2391layout(location = 0) in vec2 a_FragCoord; 2392layout(location = 1) in vec2 a_Position; 2393layout(location = 2) in vec2 a_Size; 2394layout(location = 3) in vec4 a_FillColor; 2395 2396out vec2 v_FragCoord; 2397out vec4 v_FillColor; 2398 2399void main() { 2400 v_FragCoord = a_FragCoord; 2401 v_FillColor = a_FillColor; 2402 2403 gl_Position = vec4((u_ProjectionMatrix 2404 * u_ViewMatrix 2405 * u_ModelMatrix 2406 * vec3(a_Position + a_Size * a_FragCoord, 1)).xy, 0, 1); 2407} 2408`,t3t=` 2409layout(std140) uniform SceneUniforms { 2410 mat3 u_ProjectionMatrix; 2411 mat3 u_ViewMatrix; 2412}; 2413 2414layout(std140) uniform ShapeUniforms { 2415 mat3 u_ModelMatrix; 2416}; 2417 2418out vec4 outputColor; 2419 2420in vec2 v_FragCoord; 2421in vec4 v_FillColor; 2422 2423float sdf_circle(vec2 p, float r) { 2424 return length(p) - r; 2425} 2426 2427void main() { 2428 float distance = sdf_circle(v_FragCoord, 1.0); 2429 2430 if (distance > 0.0) { 2431 discard; 2432 } 2433 2434 float alpha = clamp(-distance / fwidth(-distance), 0.0, 1.0); 2435 2436 outputColor = v_FillColor; 2437 outputColor.a *= alpha; 2438} 2439`;var Vi=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Ed=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},rC,iC,m1,VD,y1,v1,YD,sC,$D,oC,nC,aC,HD;let e3t=class extends a9{constructor(t={}){super(),rC.set(this,void 0),iC.set(this,void 0),m1.set(this,void 0),VD.set(this,void 0),y1.set(this,void 0),v1.set(this,void 0),YD.set(this,void 0),sC.set(this,void 0),$D.set(this,void 0),oC.set(this,void 0),nC.set(this,void 0),aC.set(this,void 0),HD.set(this,void 0);const{cx:e,cy:r,r:i,fill:s}=t;this.cx=e??0,this.cy=r??0,this.r=i??0,this.fill=s??"black"}get cx(){return Vi(this,rC,"f")}set cx(t){Vi(this,rC,"f")!==t&&(Ed(this,rC,t,"f"),this.renderDirtyFlag=!0)}get cy(){return Vi(this,iC,"f")}set cy(t){Vi(this,iC,"f")!==t&&(Ed(this,iC,t,"f"),this.renderDirtyFlag=!0)}get r(){return Vi(this,m1,"f")}set r(t){Vi(this,m1,"f")!==t&&(Ed(this,m1,t,"f"),this.renderDirtyFlag=!0)}get fill(){return Vi(this,VD,"f")}set fill(t){Vi(this,VD,"f")!==t&&(Ed(this,VD,t,"f"),Ed(this,y1,sr.rgb(t),"f"),this.renderDirtyFlag=!0)}render(t,e,r){Vi(this,v1,"f")||(Ed(this,v1,t.createProgram({vertex:{glsl:QLt},fragment:{glsl:t3t}}),"f"),Ed(this,oC,t.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*16,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),Ed(this,sC,t.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*8,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),Ed(this,YD,t.createBuffer({viewOrSize:new Float32Array([-1,-1,1,-1,1,1,-1,1]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),Ed(this,$D,t.createBuffer({viewOrSize:new Uint32Array([0,1,2,0,2,3]),usage:dt.INDEX,hint:Et.STATIC}),"f"),Ed(this,aC,t.createInputLayout({vertexBufferDescriptors:[{arrayStri
2439de:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:0,offset:0,format:I.F32_RG}]},{arrayStride:32,stepMode:ne.INSTANCE,attributes:[{shaderLocation:1,offset:0,format:I.F32_RG},{shaderLocation:2,offset:8,format:I.F32_RG},{shaderLocation:3,offset:16,format:I.F32_RGBA}]}],indexBufferFormat:I.U32_R,program:Vi(this,v1,"f")}),"f"),Ed(this,nC,t.createRenderPipeline({inputLayout:Vi(this,aC,"f"),program:Vi(this,v1,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}]}}),"f"),Ed(this,HD,t.createBindings({pipeline:Vi(this,nC,"f"),uniformBufferBindings:[{buffer:r},{buffer:Vi(this,oC,"f")}]}),"f")),Vi(this,oC,"f").setSubData(0,new Uint8Array(new Float32Array(g1(this.worldTransform.toArray(!0))).buffer)),this.renderDirtyFlag&&Vi(this,sC,"f").setSubData(0,new Uint8Array(new Float32Array([Vi(this,rC,"f"),Vi(this,iC,"f"),Vi(this,m1,"f"),Vi(this,m1,"f"),Vi(this,y1,"f").r/255,Vi(this,y1,"f").g/255,Vi(this,y1,"f").b/255,Vi(this,y1,"f").opacity]).buffer)),e.setPipeline(Vi(this,nC,"f")),e.setVertexInput(Vi(this,aC,"f"),[{buffer:Vi(this,YD,"f")},{buffer:Vi(this,sC,"f")}],{buffer:Vi(this,$D,"f")}),e.setBindings(Vi(this,HD,"f")),e.drawIndexed(6,1),this.renderDirtyFlag=!1}destroy(){Vi(this,v1,"f").destroy(),Vi(this,sC,"f").destroy(),Vi(this,YD,"f").destroy(),Vi(this,$D,"f").destroy(),Vi(this,oC,"f").destroy(),Vi(this,nC,"f").destroy(),Vi(this,aC,"f").destroy(),Vi(this,HD,"f").destroy()}};rC=new WeakMap,iC=new WeakMap,m1=new WeakMap,VD=new WeakMap,y1=new WeakMap,v1=new WeakMap,YD=new WeakMap,sC=new WeakMap,$D=new WeakMap,oC=new WeakMap,nC=new WeakMap,aC=new WeakMap,HD=new WeakMap;let r3t=class extends a9{render(t,e,r){}destroy(){}};var KD;(function(t){t.TRANSPARENT=0,t.BLACK=0|255<<24,t.WHITE=65535|255<<16|255<<24,t.RED=255|255<<24;function e(i){return i&255|(i>>8&255)<<8|(i>>16&255)<<16|255<<24}t.opaque=e;function r(i){const s=(i>>>24)/255;return dW((i&255)/255*s)|dW((i>>8&255)/255*s)<<8|dW((i>>16&255)/255*s)<<16|dW(s)<<24}t.premultiplied=r})(KD||(KD={}));function dW(t){return t<0?0:t>=1?255:t*256|0}const i3t=` 2440layout(std140) uniform SceneUniforms { 2441 mat3 u_ProjectionMatrix; 2442}; 2443 2444layout(location = 0) in vec4 a_Position; 2445layout(location = 1) in vec4 a_Color; 2446 2447out vec2 v_Uv; 2448out vec4 v_Color; 2449 2450void main() { 2451 v_Uv = a_Position.zw; 2452 v_Color = a_Color; 2453 vec2 position = (u_ProjectionMatrix * vec3(a_Position.xy, 1)).xy; 2454 gl_Position = vec4(position, 0, 1); 2455} 2456`,s3t=` 2457out vec4 outputColor; 2458 2459in vec2 v_Uv; 2460in vec4 v_Color; 2461 2462void main() { 2463 outputColor = v_Color * min(1.0, min(v_Uv.x, v_Uv.y)); 2464} 2465`;var Xn=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Dm=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},_1,lC,cC,qD,hC,ZD,fW,pW,gW,mW,yW;const JD=[it(),it()];let ylt=class{constructor(t){this.pixelScale=t,_1.set(this,void 0),lC.set(this,void 0),cC.set(this,void 0),qD.set(this,void 0),hC.set(this,void 0),ZD.set(this,new plt),fW.set(this,KD.TRANSPARENT),pW.set(this,0),gW.set(this,0),mW.set(this,0),yW.set(this,0)}render(t,e,r,i){Xn(this,_1,"f")||(Dm(this,_1,t.createProgram({vertex:{glsl:i3t},fragment:{glsl:s3t}}),"f"),Dm(this,cC,t.createInputLayout({vertexBufferDescriptors:[{arrayStride:20,stepMode:ne.VERTEX,attributes:[{format:I.F32_RGBA,offset:0,shaderLocation:0},{format:I.U8_RGBA_NORM,offset:16,shaderLocation:1}]}],indexBufferFormat:null,program:Xn(this,_1,"f")}
2465),"f"),Dm(this,lC,t.createRenderPipeline({inputLayout:Xn(this,cC,"f"),program:Xn(this,_1,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],topology:Go.TRIANGLE_STRIP}),"f"));const{height:s,width:o,zoom:n}=i,[a,l]=Qt(it(),[0,0],i.viewMatrix),c=Math.pow(10,Math.round(Math.log(n/32)/Math.log(10))),h=c/n,u=Math.ceil(-a*h),d=Math.ceil((s-l)*-h),f=Math.ceil((o-a)*h),g=Math.ceil(-l*-h);for(let v=u;v<f;v++){const b=a+v*n/c;this.strokeLine(b,0,b,s,v==0?KD.BLACK:v%10==0?0|127<<24:0|31<<24,v==0?2:1)}for(let v=d;v<g;v++){const b=l-v*n/c;this.strokeLine(0,b,o,b,v==0?KD.BLACK:v%10==0?0|127<<24:0|31<<24,v==0?2:1)}const p=Xn(this,ZD,"f").bytes();Xn(this,hC,"f")&&Xn(this,hC,"f").destroy();const m=t.createBuffer({viewOrSize:p.byteLength,usage:dt.VERTEX,hint:Et.DYNAMIC});Dm(this,hC,m,"f"),m.setSubData(0,p),Dm(this,qD,t.createBindings({pipeline:Xn(this,lC,"f"),uniformBufferBindings:[{buffer:r}]}),"f"),e.setBindings(Xn(this,qD,"f")),e.setPipeline(Xn(this,lC,"f")),e.setVertexInput(Xn(this,cC,"f"),[{buffer:m}],null),e.draw(p.length/20)}reset(){Xn(this,ZD,"f").clear()}destroy(){Xn(this,_1,"f").destroy(),Xn(this,hC,"f").destroy(),Xn(this,lC,"f").destroy(),Xn(this,cC,"f").destroy(),Xn(this,qD,"f").destroy()}appendVertex(t,e,r,i,s){Dm(this,mW,t,"f"),Dm(this,yW,e,"f"),Dm(this,pW,r,"f"),Dm(this,gW,i,"f"),Dm(this,fW,s,"f"),Xn(this,ZD,"f").appendFloat(t).appendFloat(e).appendFloat(r).appendFloat(i).appendByte(s&255).appendByte(s>>8&255).appendByte(s>>16&255).appendByte(s>>>24)}appendPreviousVertex(){this.appendVertex(Xn(this,mW,"f"),Xn(this,yW,"f"),Xn(this,pW,"f"),Xn(this,gW,"f"),Xn(this,fW,"f"))}strokeLine(t,e,r,i,s,o){JD[0][0]=t,JD[0][1]=e,JD[1][0]=r,JD[1][1]=i,this.strokeNonOverlappingPolyline(JD,s,o)}strokeNonOverlappingPolyline(t,e,r){const i=(r+this.pixelScale)/this.pixelScale,s=(r+this.pixelScale)/2,o=t.length;if(o<2)return;const n=t[0],a=t[1],l=a[0]-n[0],c=a[1]-n[1],h=P$([l,c]),u=s/h,d=-c*u,f=l*u;this.appendVertex(n[0]-d,n[1]-f,0,i,e),this.appendPreviousVertex(),this.appendVertex(n[0]+d,n[1]+f,i,0,e);const g=t[o-2|0],p=t[o-1|0],m=p[0]-g[0],v=p[1]-g[1],b=P$([m,v]),y=s/b,_=-v*y,w=m*y;this.appendVertex(p[0]-_,p[1]-w,0,i,e),this.appendVertex(p[0]+_,p[1]+w,i,0,e),this.appendPreviousVertex()}};_1=new WeakMap,lC=new WeakMap,cC=new WeakMap,qD=new WeakMap,hC=new WeakMap,ZD=new WeakMap,fW=new WeakMap,pW=new WeakMap,gW=new WeakMap,mW=new WeakMap,yW=new WeakMap;const o3t=` 2466layout(std140) uniform SceneUniforms { 2467 mat3 u_ProjectionMatrix; 2468 mat3 u_ViewMatrix; 2469 mat3 u_ViewProjectionInvMatrix; 2470 float u_ZoomScale; 2471 float u_CheckboardStyle; 2472}; 2473 2474layout(location = 0) in vec2 a_Position; 2475 2476out vec2 v_Position; 2477 2478vec2 project_clipspace_to_world(vec2 p) { 2479 return (u_ViewProjectionInvMatrix * vec3(p, 1)).xy; 2480} 2481 2482void main() { 2483 v_Position = project_clipspace_to_world(a_Position); 2484 gl_Position = vec4(a_Position, 0, 1); 2485} 2486`,n3t=` 2487layout(std140) uniform SceneUniforms { 2488 mat3 u_ProjectionMatrix; 2489 mat3 u_ViewMatrix; 2490 mat3 u_ViewProjectionInvMatrix; 2491 float u_ZoomScale; 2492 float u_CheckboardStyle; 2493}; 2494 2495out vec4 outputColor; 2496 2497in vec2 v_Position; 2498 2499const vec4 GRID_COLOR = vec4(0.87, 0.87, 0.87, 1.0); 2500const vec4 PAGE_COLOR = vec4(0.986, 0.986, 0.986, 1.0); 2501const int CHECKERBOARD_STYLE_NONE = 0; 2502const int CHECKERBOARD_STYLE_GRID = 1; 2503const int CHECKERBOARD_STYLE_DOTS = 2; 2504const float BASE_GRID_PIXEL_SIZE = 100.0; 2505const float BASE_DOT_SIZE = 8.0; 2506 2507vec2 scale_grid_size(float zoom) { 2508 if (zoom < 0.125) return vec2(BASE_GRID_PIXEL_SIZE * 125.0, 0.125); 2509 else if (zoom < 0.25) return vec2(BASE_GRID_PIXEL_SIZE * 25.0, 0.25); 2510 else if (zoom < 0.5) return vec2(BASE_GRID_PIXEL_SIZE * 5.0, 0.5); 2511 return vec2(BASE_GRID_PIXEL_SIZE, 4.0); 2512} 2513 2514vec4 render_grid_checkerboard(vec2 coord) { 2515 float alpha = 0.0; 2516 2517 vec2 size = scale_grid_size(u_ZoomScale); 2518 float gridSize1 = size.x; 2519 float gridSize2 = gridSize1 / 10.0; 2520 float zoomStep = size.y; 2521 int checkboardStyle = int(floor(u_CheckboardStyle + 0.5)); 2522 2523 if (checkboardStyle == CHECKERBOARD_STYLE_GRID) { 2524 vec2 grid1 = abs(fract(coord / gridSize1 - 0.5) - 0.5) / fwidth(coord) * gridSize1 / 2.0; 2525 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2; 2526 float v1 = 1.0 - min(min(grid1.x, grid1.y), 1.0); 2527 float v2 = 1.0 - min(min(grid2.x, grid2.y), 1.0); 2528 2529 if (v1 > 0.0) { 2530 alpha = v1; 2531 } else { 2532 alpha = v2 * clamp(u_ZoomScale / zoomStep, 0.0, 1.0); 2533 } 2534 } else if (checkboardStyle == CHECKERBOARD_STYLE_DOTS) { 2535 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2;
2536 alpha = 1.0 - smoothstep(0.0, 1.0, length(grid2) - BASE_DOT_SIZE * u_ZoomScale / zoomStep); 2537 } 2538 2539 return mix(PAGE_COLOR, GRID_COLOR, alpha); 2540} 2541 2542void main() { 2543 outputColor = render_grid_checkerboard(v_Position); 2544} 2545`;var _l=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},QD=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},b1,uC,dC,tP,w1,eP;class a3t{constructor(){b1.set(this,void 0),uC.set(this,void 0),dC.set(this,void 0),tP.set(this,void 0),w1.set(this,void 0),eP.set(this,new plt)}appendVertex(e,r){_l(this,eP,"f").appendFloat(e).appendFloat(r)}render(e,r,i){if(!_l(this,b1,"f")){QD(this,b1,e.createProgram({vertex:{glsl:o3t},fragment:{glsl:n3t}}),"f"),QD(this,dC,e.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{format:I.F32_RG,offset:0,shaderLocation:0}]}],indexBufferFormat:null,program:_l(this,b1,"f")}),"f"),QD(this,uC,e.createRenderPipeline({inputLayout:_l(this,dC,"f"),program:_l(this,b1,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],topology:Go.TRIANGLE_STRIP}),"f"),QD(this,tP,e.createBindings({pipeline:_l(this,uC,"f"),uniformBufferBindings:[{buffer:i}]}),"f"),_l(this,eP,"f").clear(),this.appendVertex(-1,-1),this.appendVertex(-1,1),this.appendVertex(1,-1),this.appendVertex(1,1);const s=_l(this,eP,"f").bytes();_l(this,w1,"f")&&_l(this,w1,"f").destroy();const o=e.createBuffer({viewOrSize:s.byteLength,usage:dt.VERTEX,hint:Et.DYNAMIC});QD(this,w1,o,"f"),o.setSubData(0,s)}r.setBindings(_l(this,tP,"f")),r.setPipeline(_l(this,uC,"f")),r.setVertexInput(_l(this,dC,"f"),[{buffer:_l(this,w1,"f")}],null),r.draw(4)}destroy(){_l(this,b1,"f").destroy(),_l(this,w1,"f").destroy(),_l(this,uC,"f").destroy(),_l(this,dC,"f").destroy(),_l(this,tP,"f").destroy()}}b1=new WeakMap,uC=new WeakMap,dC=new WeakMap,tP=new WeakMap,w1=new WeakMap,eP=new WeakMap;var l3t=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Rp=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},pi=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},fC,dc,g_,m_,y_,E1,rP,v_,iP,A1;(function(t){t[t.LINE_GEOMETRY=0]="LINE_GEOMETRY",t[t.SCREEN_SPACE=1]="SCREEN_SPACE"})(A1||(A1={}));var l9;(function(t){t[t.NONE=0]="NONE",t[t.GRID=1]="GRID",t[t.DOTS=2]="DOTS"})(l9||(l9={}));let c3t=class{constructor(){fC.set(this,void 0),dc.set(this,void 0),g_.set(this,void 0),m_.set(this,void 0),y_.set(this,void 0),E1.set(this,A1.SCREEN_SPACE),rP.set(this,l9.GRID),v_.set(this,void 0),iP.set(this,void 0)}apply(t){const{hooks:e,canvas:r,renderer:i,shaderCompilerPath:s,devicePixelRatio:o,camera:n}=t;e.initAsync.tapPromise(()=>l3t(this,void 0,void 0,function*(){let a;i==="webgl"?a=new hd({targets:["webgl2","webgl1"],antialias:!0,shaderDebug:!0,trackResources:!0,onContextCreationError:()=>{},onContextLost:()=>{},onContextRestored(u){}}):a=new ud({shaderCompilerPath:s,onContextLost:()=>{}});const{width:l,height:c}=r,h=yield a.createSwapChain(r);h.configureSwapChain(l,c),Rp(this,fC,h,"f"),Rp(this,dc,h.getDevice(),"f"),Rp(this,g_,pi(this,dc,"f").createRenderTargetFromTexture(pi(this,dc,"f").createTexture({format:I.U8_RGBA_RT,width:l,height:c,usage:xr.RENDER_TARGET})),"f"),Rp(this,y_,pi(this,dc,"f").createBuffer({viewOrSize:new Float32Array([...g1(n.projectionMatrix),...g1(n.viewMatrix),...g1(n.viewProjectionMatrixInv),n.zoom,pi(this,rP,"f"),0,0]),usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),pi(this,E1,"f")===A1.LINE_GEOMETRY?Rp(this,v_,new ylt(1/o),"f"):Rp(this,iP,new a3t,"f")})),e.resize.tap((a,l)=>{pi(this,fC,"f").configureSwapChain(a*o,l*o),pi(this,g_,"f")&&(pi(this,g_,"f").destroy(),Rp(this,g_,pi(this,dc,"f").createRenderTargetFromTexture(pi(this,dc,"f").createTexture({format:I.U8_RGBA_RT,width:a*o,height:l*o,usage:xr.RENDER_TARGET})),"f"))}),e.destroy.tap(()=>{pi(this,E1,"f")===A1.LINE_GEOMETRY?pi(this,v_,"f").destroy():pi(this,iP,"f").destroy(),pi(this,g_,"f").destroy(),pi(this,y_,"f").destroy(),pi(this,dc,"f").destroy(),pi(this,dc,"f").checkForLeaks()}),e.beginFrame.tap(()=>{const{width:a,height:l}=pi(this,fC,"f").getCanvas(),c=pi(this,fC,"f").getOnscreenTexture();pi(this,y_,"f").setSubData(0,new Uint8Array(new Float32Array([...g1(n.projectionMatrix),...g1(n.viewMatrix),...g1(n.viewProjectionMatrixInv),n.zoom,pi(this,rP,"f"),0,0]).buffer)),pi(this,dc,"f").beginFrame(),Rp(this,m_,pi(this,dc,"f").createRenderPass({colorAttachment:[pi(this,g_,"f")],colorResolveTo:[c],colorClearColor:[op]}),"f"),pi(this,m_,"f").setViewport(0,0,a,l),pi(this,E1,"f")===A1.LINE_GEOMETRY?(pi(this,v_,"f")||Rp(this,v_,new ylt(1/o),"f"),pi(this,v_,"f").render(pi(this,dc,"f"),pi(this,m_,"f"),pi(this,y_,"f"),n)):pi(this,iP,"f").render(pi(this,dc,"f"),pi(this,m_,"f"),pi(this,y_,"f"))}),e.endFrame.tap(()=>{pi(this,dc,"f").submitPass(pi(this,m_,"f")),pi(this,dc,"f").endFrame(),pi(this,E1,"f")===A1.LINE_GEOMETRY&&pi(this,v_,"f").reset()}),e.render.tap(a=>{a.transform.updateTransform(a.parent?a.parent.transform:mlt),a.render(pi(this,dc,"f"),pi(this,m_,"f"),pi(this,y_,"f"))})}setGridImplementation(t){Rp(this,E1,t,"f")}setCheckboardStyle(t){Rp(this,rP,t,"f")}};fC=new WeakMap,dc=new WeakMap,g_=new WeakMap,m_=new WeakMap,y_=new WeakMap,E1=new WeakMap,rP=new WeakMap,v_=new WeakMap,iP=ne
2545w WeakMap;const h3t=.02,u3t=4;let d3t=class{apply(t){const{canvas:e,camera:r}=t,i=Bt();let s,o,n;const a=it();let l,c=!1;function h(p){const m=e.getBoundingClientRect(),v=p.clientX-m.left,b=p.clientY-m.top,y=v/e.clientWidth,_=b/e.clientHeight,w=y*2-1,E=_*-2+1;return[w,E]}function u(p){const m=Qt(it(),h(p),i);r.x=s+a[0]-m[0],r.y=o+a[1]-m[1]}function d(p){const m=(p.clientX-l[0])/100,v=Bt();bi(v,v,[a[0],a[1]]),Mo(v,v,m),bi(v,v,[-a[0],-a[1]]),r.x=s,r.y=o,r.rotation=n,us(v,v,r.matrix),r.rotation=n+m,r.x=v[6],r.y=v[7]}function f(p){c?d(p):u(p)}function g(p){c=!1,window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",g)}e.addEventListener("mousedown",p=>{p.preventDefault(),window.addEventListener("mousemove",f),window.addEventListener("mouseup",g),c=p.shiftKey,fp(i,r.viewProjectionMatrixInv),s=r.x,o=r.y,n=r.rotation,Qt(a,h(p),i),l=[p.clientX,p.clientY]}),e.addEventListener("wheel",p=>{p.preventDefault();const m=h(p),[v,b]=Qt(it(),m,r.viewProjectionMatrixInv),y=r.zoom*Math.pow(2,p.deltaY*-.01);r.zoom=Math.max(h3t,Math.min(u3t,y));const[_,w]=Qt(it(),m,r.viewProjectionMatrixInv);r.x+=v-_,r.y+=b-w})}};var f3t=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},fc=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},vW=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},_W,S0,pC,x1,sP;let p3t=class{get camera(){return fc(this,sP,"f")}constructor(t){_W.set(this,void 0),S0.set(this,void 0),pC.set(this,void 0),x1.set(this,[]),sP.set(this,void 0);const{canvas:e,renderer:r="webgl",shaderCompilerPath:i="",devicePixelRatio:s}=t,o=qLt(),n=s??o.devicePixelRatio,{width:a,height:l}=e,c=new glt(a/n,l/n);vW(this,sP,c,"f"),vW(this,S0,{globalThis:o,canvas:e,renderer:r,shaderCompilerPath:i,devicePixelRatio:n,hooks:{init:new eC,initAsync:new KLt,beginFrame:new eC,render:new eC,endFrame:new eC,destroy:new eC,resize:new eC},camera:c},"f"),vW(this,_W,f3t(this,void 0,void 0,function*(){const{hooks:h}=fc(this,S0,"f");return vW(this,pC,new c3t,"f"),[new d3t,fc(this,pC,"f")].forEach(u=>{u.apply(fc(this,S0,"f"))}),h.init.call(),yield h.initAsync.promise(),this}),"f")}get initialized(){return fc(this,_W,"f").then(()=>this)}render(){const{hooks:t}=fc(this,S0,"f");t.beginFrame.call(),fc(this,x1,"f").forEach(e=>{o9(e,r=>{t.render.call(r)})}),t.endFrame.call()}resize(t,e){const{hooks:r}=fc(this,S0,"f");fc(this,sP,"f").projection(t,e),r.resize.call(t,e)}destroy(){const{hooks:t}=fc(this,S0,"f");fc(this,x1,"f").forEach(e=>{o9(e,r=>{r.destroy()})}),t.destroy.call()}getDOM(){return fc(this,S0,"f").canvas}appendChild(t){fc(this,x1,"f").push(t)}removeChild(t){const e=fc(this,x1,"f").indexOf(t);e!==-1&&fc(this,x1,"f").splice(e,1)}setGridImplementation(t){fc(this,pC,"f").setGridImplementation(t)}setCheckboardStyle(t){fc(this,pC,"f").setCheckboardStyle(t)}};_W=new WeakMap,S0=new WeakMap,pC=new WeakMap,x1=new WeakMap,sP=new WeakMap;const g3t=Object.freeze(Object.defineProperty({__proto__:null,Camera:glt,Canvas:p3t,Circle:e3t,Group:r3t,IDENTITY_TRANSFORM:mlt,Shape:a9},Symbol.toStringTag,{value:"Module"}));var c9=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},oP;let m3t=class{constructor(){oP.set(this,[])}getCallbacksNum(){return c9(this,oP,"f").length}tapPromise(t){c9(this,oP,"f").push(t)}promise(...t){return Promise.all(c9(this,oP,"f").map(e=>e(...t)))}};oP=new WeakMap;var vlt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},bW;let Ad=class{constructor(){bW.set(this,[])}tap(t){vlt(this,bW,"f").push(t)}call(...t){vlt(this,bW,"f").forEach(function(e){e.apply(void 0,t)})}};bW=new WeakMap;var nP=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},S1;let y3t=class{constructor(){S1.set(this,[])}tap(t){nP(this,S1,"f").push(t)}call(...t){if(nP(this,S1,"f").length){let e=nP(this,S1,"f")[0].apply(void 0,t);for(let r=0;r<nP(this,S1,"f").length-1;r++){const i=nP(this,S1,"f")[r];e=i(...e)}return e}return null}};S1=new WeakMap;const v3t=()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};
2545function wW(t,e){e(t)||t.children.forEach(r=>{wW(r,e)})}const h9=0;function T1(t){return[t[0],t[1],t[2],h9,t[3],t[4],t[5],h9,t[6],t[7],t[8],h9]}function _lt(t,e,r,i){var s=Math.sqrt(Math.pow(r-t,2)+Math.pow(i-e,2));return s}const _3t={linear:cr(0,0,1,1),ease:cr(.25,.1,.25,1),"ease-in":cr(.42,0,1,1),"ease-out":cr(0,0,.58,1),"ease-in-out":cr(.42,0,.58,1)};var __;(function(t){t._bytes4=new Uint8Array(4),t._float=new Float32Array(t._bytes4.buffer),t._int=new Int32Array(t._bytes4.buffer),t._bytes2=new Uint8Array(2),t._short=new Int16Array(t._bytes2.buffer);function e(c){return t._float[0]=c,t._int[0]}t.floatToInt=e;function r(c){return t._int[0]=c,t._float[0]}t.intToFloat=r;function i(c){return t._float[0]=c,t._bytes4}t.floatToBytes=i;function s(c,h,u,d){return t._bytes4[0]=c,t._bytes4[1]=h,t._bytes4[2]=u,t._bytes4[3]=d,t._float[0]}t.bytesToFloat=s;function o(c){return t._int[0]=c,t._bytes4}t.intToBytes=o;function n(c,h,u,d){return t._bytes4[0]=c,t._bytes4[1]=h,t._bytes4[2]=u,t._bytes4[3]=d,t._int[0]}t.bytesToInt=n;function a(c){return t._short[0]=c,t._bytes2}t.shortToBytes=a;function l(c,h){return t._bytes2[0]=c,t._bytes2[1]=h,t._short[0]}t.bytesToShort=l})(__||(__={}));const blt=256;let b3t=class{constructor(t=new Uint8Array(blt)){this._bytes=t,this.count=0,this.readOffset=0,this.capacity=blt,this.count=this.capacity=t.length}clear(){this.count=0,this.readOffset=0}byteCount(){return this.count}bytes(){return this._bytes.subarray(0,this.count)}grow(){this.capacity*=2;const t=new Uint8Array(this.capacity);t.set(this._bytes),this._bytes=t}hasMoreToRead(){return this.readOffset<this.count}seekTo(t){this.readOffset=t}skipBytes(t){this.readOffset+=t}appendBytes(t){const e=t.length;return this.count+e>this.capacity&&this.grow(),this._bytes.set(t,this.count),this.count+=e,this}byteAt(t){return this._bytes[t]}appendByte(t){return this.count+1>this.capacity&&this.grow(),this._bytes[this.count]=t,this.count++,this}readByte(){const t=this.byteAt(this.readOffset);return this.readOffset++,t}shortAt(t){return __.bytesToShort(this._bytes[t],this._bytes[t+1])}appendShort(t){return this.appendBytes(__.shortToBytes(t)),this}appendShorts(t){for(const e of t)this.appendShort(e);return this}readShort(){const t=this.shortAt(this.readOffset);return this.readOffset+=2,t}intAt(t){return __.bytesToInt(this._bytes[t],this._bytes[t+1],this._bytes[t+2],this._bytes[t+3])}appendInt(t){return this.appendBytes(__.intToBytes(t)),this}appendInts(t){for(const e of t)this.appendInt(e);return this}readInt(){const t=this.intAt(this.readOffset);return this.readOffset+=4,t}floatAt(t){return __.bytesToFloat(this._bytes[t],this._bytes[t+1],this._bytes[t+2],this._bytes[t+3])}appendFloat(t){return this.appendBytes(__.floatToBytes(t)),this}appendFloats(t){for(const e of t)this.appendFloat(e);return this}readFloat(){const t=this.floatAt(this.readOffset);return this.readOffset+=4,t}isEmpty(){return this.count==0}};const EW=t=>t instanceof Object,wlt=t=>t===!!t,AW=t=>typeof t=="function",sa=t=>t===void 0,Elt=t=>t==null;var Dh=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},gi=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},T0,Pm,Fm,Nm,xW,SW,Cp,aP,lP,cP,TW,hP;const w3t=.01;let Alt=class{constructor(t,e){this.clipSpaceNearZ=Sh.NEGATIVE_ONE,T0.set(this,1),Pm.set(this,0),Fm.set(this,0),Nm.set(this,0),xW.set(this,0),SW.set(this,0),Cp.set(this,Bt()),aP.set(this,Bt()),lP.set(this,Bt()),cP.set(this,Bt()),TW.set(this,Bt()),hP.set(this,void 0),this.projection(t,e),this.updateMatrix()}projection(t,e){Dh(this,xW,t,"f"),Dh(this,SW,e,"f"),ld(gi(this,aP,"f"),t,e),this.updateViewProjectionMatrix()}updateMatrix(){const t=1/gi(this,T0,"f");Yc(gi(this,Cp,"f")),bi(gi(this,Cp,"f"),gi(this,Cp,"f"),[gi(this,Pm,"f"),gi(this,Fm,"f")]),Mo(gi(this,Cp,"f"),gi(this,Cp,"f"),gi(this,Nm,"f")),xh(gi(this,Cp,"f"),gi(this,Cp,"f"),[t,t]),_i(gi(this,lP,"f"),gi(this,Cp,"f")),this.updateViewProjectionMatrix()}updateViewProjectionMatrix(){us(gi(this,cP,"f"),gi(this,aP,"f"),gi(this,lP,"f")),_i(gi(this,TW,"f"),gi(this,cP,"f"))}get projectionMatrix(){return gi(this,aP,"f")}get viewMatrix(){return gi(this,lP,"f")}get viewProjectionMatrix(){return gi(this,cP,"f")}get viewProjectionMatrixInv(){return gi(this,TW,"f")}get matrix(){return gi(this,Cp,"f")}get zoom(){return gi(this,T0,"f")}set zoom(t){gi(this,T0,"f")!==t&&(Dh(this,T0,t,"f"),this.updateMatrix())}get x(){return gi(this,Pm,"f")}set x(t){gi(this,Pm,"f")!==t&&(Dh(this,Pm,t,"f"),this.updateMatrix())}get y(){return gi(this,Fm,"f")}set y(t){gi(this,Fm,"f")!==t&&(Dh(this,Fm,t,"f"),this.updateMatrix())}get rotation(){return gi(this,Nm,"f")}set rotation(t){gi(this,Nm,"f")!==t&&(Dh(this,Nm,t,"f"),this.updateMatrix())}get width(){return gi(this,xW,"f")}get height(){return gi(this,SW,"f")}createLandmark(t={}){return Object.assign({zoom:gi(this,T0,"f"),x:gi(this,Pm,"f"),y:gi(this,Fm,"f"),rotation:gi(this,Nm,"f")},t)}gotoLandmark(t,e={}){const{easing:r="linear",duration:i=100,onframe:s=void 0,onfinish:o=void 0}=e,{zoom:n,x:a,y:l,rotation:c}=t,h=()=>{Dh(this,T0,n,"f"),Dh(this,Pm,a,"f"),Dh(this,Fm,l,"f"),Dh(this,Nm,c,"f"),this.updateMatrix(),o&&o()};if(i===0){h();return}this.cancelLandmarkAnimation();let u;const d=[a,l],f=[n,c],g=p=>{u===void 0&&(u=p);const m=p-u;if(m>i){h();return}const v=_3t[r](m/i),b=it(),y=Be(1,0);if(ta(b,[gi(this,Pm,"f"),gi(this,Fm,"f")],d,v),ta(y,[this.zoom,gi(this,Nm,"f")],f,v),Dh(this,Pm,b[0],"f"),Dh(this,Fm,b[1],"f"),Dh(this,T0,y[0],"f"),Dh(this,Nm,y[1],"f"),this.updateMatrix(),za(b,d)<=w3t){h();return}m<i&&(s&&s(v),Dh(this,hP,requestAnimationFrame(g),"f"))};requestAnimationFrame(g)}cancelLandmarkAnimation(){gi(this,hP,"f")!==void 0&&cancelAnimationFrame(gi(this,hP,"f"))}};T0=new WeakMap,Pm=new WeakMap,Fm=new WeakMap,Nm=new WeakMap,xW=new WeakMap,SW=new WeakMap,Cp=new WeakMap,aP=new WeakMap,lP=new WeakMap,cP=new WeakMap,TW=new WeakMap,hP=new WeakMap;let xlt=class c1t{get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=c1t.prototype.NONE,this.prop
2545agationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ye,this.page=new ye,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}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(e,r,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,r,i,s,o){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}},RW=class extends xlt{constructor(){super(...arguments),this.client=new ye,this.movement=new ye,this.offset=new ye,this.global=new ye,this.screen=new ye}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}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,r,i,s,o,n,a,l,c,h,u,d,f,g){throw new Error("Method not implemented.")}},Mp=class extends RW{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!")}},u9=class extends RW{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}};var E3t=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},A3t=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},CW;const x3t=2048;let S3t=class{constructor(t){this.dispatch=new Uo,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,CW.set(this,void 0),this.rootTarget=t,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)}setPickHandler(t){E3t(this,CW,t,"f")}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((r,i)=>r.priority-i.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.prop
vendor: 6,797 bytes, line 2545
2545agate(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 r=0,i=e.length;r<i;r++)e[r].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){return A3t(this,CW,"f").call(this,t,e)}propagate(t,e){if(!t.target)return;const r=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let i=0,s=r.length-1;i<s;i++)if(t.currentTarget=r[i],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 i=r.length-2;i>=0;i--)if(t.currentTarget=r[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,r=this._allInteractiveElements){if(r.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const i=Array.isArray(e)?e:[e];for(let s=r.length-1;s>=0;s--)i.forEach(o=>{t.currentTarget=r[s],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let r=0;r<x3t&&t!==this.rootTarget&&t.parent;r++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}notifyTarget(t,e){e=e??t.type;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 Mp)){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 i=e.button===2;this.dispatchEvent(e,i?"rightdown":"mousedown")}const r=this.trackingData(t.pointerId);r.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,r,i;if(!(t instanceof Mp)){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 s=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const o=s.pointerType==="mouse"||s.pointerType==="pen",n=this.trackingData(t.pointerId),a=this.findMountedTarget(n.overTargets);if(((e=n.overTargets)===null||e===void 0?void 0:e.length)>0&&a!==s.target){const h=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,h,a);if(this.dispatchEvent(u,"pointerout"),o&&this.dispatchEvent(u,"mouseout"),!s.composedPath().includes(a)){const d=this.createPointerEvent(t,"pointerleave",a);for(d.eventPhase=d.AT_TARGET;d.target&&!s.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),o&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(u)}if(a!==s.target){const h=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(s,h);this.dispatchEvent(u,"pointerover"),o&&this.dispatchEvent(u,"mouseover");let d=a==null?void 0:a.parent;for(;d&&d!==this.rootTarget.parent&&d!==s.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(s,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==a&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),o&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(u)}const l=[],c=(r=this.enableGlobalMoveEvents)!==null&&r!==void 0?r:!0;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(s,"pointermove"),c&&l.push("globalpointermove"),s.pointerType==="touch"&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(s,"touchmove"),c&&l.push("globaltouchmove")),o&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(s,"mousemove"),c&&l.push("globalmousemove"),this.cursor=(i=s.target)===null||i===void 0?void 0:i.cursor),l.length>0&&this.all(s,l),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=s.composedPath(),this.freeEvent(s)}mapPointerOver(t){var e;if(!(t instanceof Mp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(e=i.target)===null||e===void 0?void 0:e.cursor);const o=this.clonePointerEvent(i,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;r.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof Mp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const r=t.pointerType==="mouse"||t.pointerType==="pen",i=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",i);this.dispatchEvent(s),r&&this.dispatchEvent(s,"mouseout");const o=this.createPointerEvent(t,"pointerleave",i);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),r&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(s),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){var e;if(!(t instanceof Mp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=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 s=this.trackingData(t.pointerId),o=this.findMountedTarget(s.pressTargetsByButton[t.button]);let n=o;if(o&&!i.composedPath().includes(o)){let a=o;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 l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],n=a}if(n){const a=this.clonePointerEvent(i,"click");a.target=n,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:r});const l=s.clicksByButton[t.button];if(l.target===a.target&&r-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=r,a.detail=l.clickCount,!(!((e=i.detail)===null||e===void 0)&&e.preventClick)){if
2545(a.pointerType==="mouse"){const c=a.button===2;this.dispatchEvent(a,c?"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 Mp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),r=this.findMountedTarget(e.pressTargetsByButton[t.button]),i=this.createPointerEvent(t);if(r){let s=r;for(;s;)i.currentTarget=s,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch"?this.notifyTarget(i,"touchendoutside"):(i.pointerType==="mouse"||i.pointerType==="pen")&&this.notifyTarget(i,i.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(i)}mapWheel(t){if(!(t instanceof u9)){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 r=1;r<t.length&&t[r].parent===e;r++)e=t[r];return e}createPointerEvent(t,e,r){var i;const s=this.allocateEvent(Mp);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=(i=r??this.hitTest(s.global.x,s.global.y))!==null&&i!==void 0?i:this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(u9);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 r=this.allocateEvent(Mp);return r.nativeEvent=t.nativeEvent,r.originalEvent=t.originalEvent,this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.target=t.target,r.path=t.composedPath().slice(),r.type=e??r.type,r}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Mp&&e instanceof Mp&&(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.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof RW&&e instanceof RW&&(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 r=t.currentTarget._events[e];if(r)if("fn"in r)r.once&&t.currentTarget.removeListener(e,r.fn,void 0,!0),r.fn.call(r.context,t);else for(let i=0,s=r.length;i<s&&!t.propagationImmediatelyStopped;i++)r[i].once&&t.currentTarget.removeListener(e,r[i].fn,void 0,!0),r[i].fn.call(r[i].context,t)}};CW=new WeakMap;const Slt=new wn;let d9=class extends Uo{constructor(t={}){var e,r,i,s,o,n;super(),this.renderDirtyFlag=!0,this.transform=new wn,this.children=[],this.cursor=(e=t.cursor)!==null&&e!==void 0?e:"default",this.hitArea=t.hitArea,this.pointerEvents=(r=t.pointerEvents)!==null&&r!==void 0?r:"auto",this.visible=(i=t.visible)!==null&&i!==void 0?i:!0,this.renderable=(s=t.renderable)!==null&&s!==void 0?s:!0,this.draggable=(o=t.draggable)!==null&&o!==void 0?o:!1,this.droppable=(n=t.droppable)!==null&&n!==void 0?n:!1}addEventListener(t,e,r){const i=wlt(r)&&r||EW(r)&&r.capture,s=EW(r)?r.signal:void 0,o=EW(r)&&r.once,n=AW(e)?void 0:e;t=i?`${t}capture`:t;const a=AW(e)?e:e.handleEvent;s&&s.addEventListener("abort",()=>{this.off(t,a,n)}),o?this.once(t,a,n):this.on(t,a,n)}removeEventListener(t,e,r){const i=wlt(r)&&r||EW(r)&&r.capture,s=AW(e)?void 0:e;t=i?`${t}capture`:t,e=AW(e)?e:e==null?void 0:e.handleEvent,this.off(t,e,s)}dispatchEvent(t){if(!(t instanceof xlt))throw new Error("Container cannot propagate events outside of the Federated Events API");return t.defaultPrevented=!1,t.path=null,t.target=this,t.manager.dispatchEvent(t),!t.defaultPrevented}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*id}set angle(t){this.transform.rotation=t*eu}appendChild(t){return t.parent&&t.parent.removeChild(t),t.parent=this,t.transform._parentID=-1,this.children.push(t),t}removeChild(t){const e=this.children.indexOf(t);return e===-1?null:(t.parent=void 0,t.transform._parentID=-1,this.children.splice(e,1),t)}};function Tlt(t,e,r){let i=!1,s=!1;const o=!!e&&e!=="none",n=!!r&&r!=="none";return t==="visiblepainted"||t==="painted"||t==="auto"?(i=o,s=n):t==="visiblefill"||t==="fill"?i=!0:t==="visiblestroke"||t==="stroke"?s=!0:(t==="visible"||t==="all")&&(i=!0,s=!0),[i,s]}const T3t=` 2546layout(std140) uniform SceneUniforms { 2547 mat3 u_ProjectionMatrix; 2548 mat3 u_ViewMatrix; 2549}; 2550 2551layout(std140) uniform ShapeUniforms { 2552 mat3 u_ModelMatrix; 2553}; 2554 2555layout(location = 0) in vec2 a_FragCoord; 2556layout(location = 1) in vec2 a_Position; 2557layout(location = 2) in vec2 a_Size; 2558layout(location = 3) in vec4 a_FillColor; 2559 2560out vec2 v_FragCoord; 2561out vec4 v_FillColor; 2562 2563void main() { 2564 v_FragCoord = a_FragCoord; 2565 v_FillColor = a_FillColor; 2566 2567 gl_Position = vec4((u_ProjectionMatrix
2568 * u_ViewMatrix 2569 * u_ModelMatrix 2570 * vec3(a_Position + a_Size * a_FragCoord, 1)).xy, 0, 1); 2571} 2572`,R3t=` 2573layout(std140) uniform SceneUniforms { 2574 mat3 u_ProjectionMatrix; 2575 mat3 u_ViewMatrix; 2576}; 2577 2578layout(std140) uniform ShapeUniforms { 2579 mat3 u_ModelMatrix; 2580}; 2581 2582out vec4 outputColor; 2583 2584in vec2 v_FragCoord; 2585in vec4 v_FillColor; 2586 2587float sdf_circle(vec2 p, float r) { 2588 return length(p) - r; 2589} 2590 2591void main() { 2592 float distance = sdf_circle(v_FragCoord, 1.0); 2593 2594 if (distance > 0.0) { 2595 discard; 2596 } 2597 2598 float alpha = clamp(-distance / fwidth(-distance), 0.0, 1.0); 2599 2600 outputColor = v_FillColor; 2601 outputColor.a *= alpha; 2602} 2603`;var Lr=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Ph=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},R1,C1,km,gC,M1,mC,yC,B1,uP,vC,dP,_C,bC,wC,fP;let C3t=class extends d9{constructor(t={}){super(t),R1.set(this,void 0),C1.set(this,void 0),km.set(this,void 0),gC.set(this,void 0),M1.set(this,void 0),mC.set(this,void 0),yC.set(this,void 0),B1.set(this,void 0),uP.set(this,void 0),vC.set(this,void 0),dP.set(this,void 0),_C.set(this,void 0),bC.set(this,void 0),wC.set(this,void 0),fP.set(this,void 0);const{cx:e,cy:r,r:i,fill:s,stroke:o,strokeWidth:n}=t;this.cx=e??0,this.cy=r??0,this.r=i??0,this.fill=s??"black",this.stroke=o??"black",this.strokeWidth=n??0}get cx(){return Lr(this,R1,"f")}set cx(t){Lr(this,R1,"f")!==t&&(Ph(this,R1,t,"f"),this.renderDirtyFlag=!0)}get cy(){return Lr(this,C1,"f")}set cy(t){Lr(this,C1,"f")!==t&&(Ph(this,C1,t,"f"),this.renderDirtyFlag=!0)}get r(){return Lr(this,km,"f")}set r(t){Lr(this,km,"f")!==t&&(Ph(this,km,t,"f"),this.renderDirtyFlag=!0)}get fill(){return Lr(this,gC,"f")}set fill(t){Lr(this,gC,"f")!==t&&(Ph(this,gC,t,"f"),Ph(this,M1,sr.rgb(t),"f"),this.renderDirtyFlag=!0)}get stroke(){return Lr(this,mC,"f")}set stroke(t){Lr(this,mC,"f")!==t&&(Ph(this,mC,t,"f"),this.renderDirtyFlag=!0)}get strokeWidth(){return Lr(this,yC,"f")}set strokeWidth(t){Lr(this,yC,"f")!==t&&(Ph(this,yC,t,"f"),this.renderDirtyFlag=!0)}render(t,e,r){Lr(this,B1,"f")||(Ph(this,B1,t.createProgram({vertex:{glsl:T3t},fragment:{glsl:R3t}}),"f"),Ph(this,_C,t.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*16,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),Ph(this,vC,t.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*8,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),Ph(this,uP,t.createBuffer({viewOrSize:new Float32Array([-1,-1,1,-1,1,1,-1,1]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),Ph(this,dP,t.createBuffer({viewOrSize:new Uint32Array([0,1,2,0,2,3]),usage:dt.INDEX,hint:Et.STATIC}),"f"),Ph(this,wC,t.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:0,offset:0,format:I.F32_RG}]},{arrayStride:32,stepMode:ne.INSTANCE,attributes:[{shaderLocation:1,offset:0,format:I.F32_RG},{shaderLocation:2,offset:8,format:I.F32_RG},{shaderLocation:3,offset:16,format:I.F32_RGBA}]}],indexBufferFormat:I.U32_R,program:Lr(this,B1,"f")}),"f"),Ph(this,bC,t.createRenderPipeline({inputLayout:Lr(this,wC,"f"),program:Lr(this,B1,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}]}}),"f"),Ph(this,fP,t.createBindings({pipeline:Lr(this,bC,"f"),uniformBufferBindings:[{buffer:r},{buffer:Lr(this,_C,"f")}]}),"f")),Lr(this,_C,"f").setSubData(0,new Uint8Array(new Float32Array(T1(this.worldTransform.toArray(!0))).buffer)),this.renderDirtyFlag&&Lr(this,vC,"f").setSubData(0,new Uint8Array(new Float32Array([Lr(this,R1,"f"),Lr(this,C1,"f"),Lr(this,km,"f"),Lr(this,km,"f"),Lr(this,M1,"f").r/255,Lr(this,M1,"f").g/255,Lr(this,M1,"f").b/255,Lr(this,M1,"f").opacity]).buffer)),e.setP
2603ipeline(Lr(this,bC,"f")),e.setVertexInput(Lr(this,wC,"f"),[{buffer:Lr(this,uP,"f")},{buffer:Lr(this,vC,"f")}],{buffer:Lr(this,dP,"f")}),e.setBindings(Lr(this,fP,"f")),e.drawIndexed(6,1),this.renderDirtyFlag=!1}destroy(){Lr(this,B1,"f").destroy(),Lr(this,vC,"f").destroy(),Lr(this,uP,"f").destroy(),Lr(this,dP,"f").destroy(),Lr(this,_C,"f").destroy(),Lr(this,bC,"f").destroy(),Lr(this,wC,"f").destroy(),Lr(this,fP,"f").destroy()}containsPoint(t,e){const r=Lr(this,yC,"f")/2,i=_lt(Lr(this,R1,"f"),Lr(this,C1,"f"),t,e),[s,o]=Tlt(this.pointerEvents,Lr(this,gC,"f"),Lr(this,mC,"f"));return s?i<=Lr(this,km,"f"):o?i>=Lr(this,km,"f")-r&&i<=Lr(this,km,"f")+r:!1}};R1=new WeakMap,C1=new WeakMap,km=new WeakMap,gC=new WeakMap,M1=new WeakMap,mC=new WeakMap,yC=new WeakMap,B1=new WeakMap,uP=new WeakMap,vC=new WeakMap,dP=new WeakMap,_C=new WeakMap,bC=new WeakMap,wC=new WeakMap,fP=new WeakMap;const M3t=` 2604layout(std140) uniform SceneUniforms { 2605 mat3 u_ProjectionMatrix; 2606 mat3 u_ViewMatrix; 2607 mat3 u_ViewProjectionInvMatrix; 2608 float u_ZoomScale; 2609 float u_CheckboardStyle; 2610}; 2611 2612layout(location = 0) in vec2 a_Position; 2613 2614out vec2 v_Position; 2615 2616vec2 project_clipspace_to_world(vec2 p) { 2617 return (u_ViewProjectionInvMatrix * vec3(p, 1)).xy; 2618} 2619 2620void main() { 2621 v_Position = project_clipspace_to_world(a_Position); 2622 gl_Position = vec4(a_Position, 0, 1); 2623} 2624`,B3t=` 2625layout(std140) uniform SceneUniforms { 2626 mat3 u_ProjectionMatrix; 2627 mat3 u_ViewMatrix; 2628 mat3 u_ViewProjectionInvMatrix; 2629 float u_ZoomScale; 2630 float u_CheckboardStyle; 2631}; 2632 2633out vec4 outputColor; 2634 2635in vec2 v_Position; 2636 2637const vec4 GRID_COLOR = vec4(0.87, 0.87, 0.87, 1.0); 2638const vec4 PAGE_COLOR = vec4(0.986, 0.986, 0.986, 1.0); 2639const int CHECKERBOARD_STYLE_NONE = 0; 2640const int CHECKERBOARD_STYLE_GRID = 1; 2641const int CHECKERBOARD_STYLE_DOTS = 2; 2642const float BASE_GRID_PIXEL_SIZE = 100.0; 2643const float BASE_DOT_SIZE = 8.0; 2644 2645vec2 scale_grid_size(float zoom) { 2646 if (zoom < 0.125) return vec2(BASE_GRID_PIXEL_SIZE * 125.0, 0.125); 2647 else if (zoom < 0.25) return vec2(BASE_GRID_PIXEL_SIZE * 25.0, 0.25); 2648 else if (zoom < 0.5) return vec2(BASE_GRID_PIXEL_SIZE * 5.0, 0.5); 2649 return vec2(BASE_GRID_PIXEL_SIZE, 4.0); 2650} 2651 2652vec4 render_grid_checkerboard(vec2 coord) { 2653 float alpha = 0.0; 2654 2655 vec2 size = scale_grid_size(u_ZoomScale); 2656 float gridSize1 = size.x; 2657 float gridSize2 = gridSize1 / 10.0; 2658 float zoomStep = size.y; 2659 int checkboardStyle = int(floor(u_CheckboardStyle + 0.5)); 2660 2661 if (checkboardStyle == CHECKERBOARD_STYLE_GRID) { 2662 vec2 grid1 = abs(fract(coord / gridSize1 - 0.5) - 0.5) / fwidth(coord) * gridSize1 / 2.0; 2663 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2; 2664 float v1 = 1.0 - min(min(grid1.x, grid1.y), 1.0); 2665 float v2 = 1.0 - min(min(grid2.x, grid2.y), 1.0); 2666 2667 if (v1 > 0.0) { 2668 alpha = v1; 2669 } else { 2670 alpha = v2 * clamp(u_ZoomScale / zoomStep, 0.0, 1.0); 2671 } 2672 } else if (checkboardStyle == CHECKERBOARD_STYLE_DOTS) { 2673 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2;
2674 alpha = 1.0 - smoothstep(0.0, 1.0, length(grid2) - BASE_DOT_SIZE * u_ZoomScale / zoomStep); 2675 } 2676 2677 return mix(PAGE_COLOR, GRID_COLOR, alpha); 2678} 2679 2680void main() { 2681 outputColor = render_grid_checkerboard(v_Position); 2682} 2683`;var pc=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},pP=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},O1,EC,AC,gP,mP,yP;let Rlt=class{constructor(){O1.set(this,void 0),EC.set(this,void 0),AC.set(this,void 0),gP.set(this,void 0),mP.set(this,void 0),yP.set(this,new b3t)}appendVertex(t,e){pc(this,yP,"f").appendFloat(t).appendFloat(e)}render(t,e,r){if(!pc(this,O1,"f")){pP(this,O1,t.createProgram({vertex:{glsl:M3t},fragment:{glsl:B3t}}),"f"),pP(this,AC,t.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{format:I.F32_RG,offset:0,shaderLocation:0}]}],indexBufferFormat:null,program:pc(this,O1,"f")}),"f"),pP(this,EC,t.createRenderPipeline({inputLayout:pc(this,AC,"f"),program:pc(this,O1,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],topology:Go.TRIANGLE_STRIP}),"f"),pc(this,yP,"f").clear(),this.appendVertex(-1,-1),this.appendVertex(-1,1),this.appendVertex(1,-1),this.appendVertex(1,1);const i=pc(this,yP,"f").bytes(),s=t.createBuffer({viewOrSize:i.byteLength,usage:dt.VERTEX,hint:Et.DYNAMIC});pP(this,mP,s,"f"),s.setSubData(0,i),pP(this,gP,t.createBindings({pipeline:pc(this,EC,"f"),uniformBufferBindings:[{buffer:r}]}),"f")}
2683e.setBindings(pc(this,gP,"f")),e.setPipeline(pc(this,EC,"f")),e.setVertexInput(pc(this,AC,"f"),[{buffer:pc(this,mP,"f")}],null),e.draw(4)}destroy(){pc(this,O1,"f").destroy(),pc(this,mP,"f").destroy(),pc(this,EC,"f").destroy(),pc(this,AC,"f").destroy(),pc(this,gP,"f").destroy()}};O1=new WeakMap,EC=new WeakMap,AC=new WeakMap,gP=new WeakMap,mP=new WeakMap,yP=new WeakMap;let Clt=class extends d9{constructor(){super(...arguments),this.renderable=!1}containsPoint(t,e){throw new Error("Method not implemented.")}render(t,e,r){}destroy(){}};var O3t=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},b_=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Vs=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},xC,qc,w_,I1,D1,vP,_P,f9;(function(t){t[t.NONE=0]="NONE",t[t.GRID=1]="GRID",t[t.DOTS=2]="DOTS"})(f9||(f9={}));let I3t=class{constructor(){xC.set(this,void 0),qc.set(this,void 0),w_.set(this,void 0),I1.set(this,void 0),D1.set(this,void 0),vP.set(this,f9.GRID),_P.set(this,void 0)}apply(t){const{hooks:e,canvas:r,renderer:i,shaderCompilerPath:s,devicePixelRatio:o,camera:n}=t;e.initAsync.tapPromise(()=>O3t(this,void 0,void 0,function*(){let a;i==="webgl"?a=new hd({targets:["webgl2","webgl1"],antialias:!0,shaderDebug:!0,trackResources:!0,onContextCreationError:()=>{},onContextLost:()=>{},onContextRestored(u){}}):a=new ud({shaderCompilerPath:s,onContextLost:()=>{}});const{width:l,height:c}=r,h=yield a.createSwapChain(r);h.configureSwapChain(l,c),b_(this,xC,h,"f"),b_(this,qc,h.getDevice(),"f"),b_(this,w_,Vs(this,qc,"f").createRenderTargetFromTexture(Vs(this,qc,"f").createTexture({format:I.U8_RGBA_RT,width:l,height:c,usage:xr.RENDER_TARGET})),"f"),b_(this,D1,Vs(this,qc,"f").createBuffer({viewOrSize:new Float32Array([...T1(n.projectionMatrix),...T1(n.viewMatrix),...T1(n.viewProjectionMatrixInv),n.zoom,Vs(this,vP,"f"),0,0]),usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),b_(this,_P,new Rlt,"f")})),e.resize.tap((a,l)=>{Vs(this,xC,"f").configureSwapChain(a*o,l*o),Vs(this,w_,"f")&&(Vs(this,w_,"f").destroy(),b_(this,w_,Vs(this,qc,"f").createRenderTargetFromTexture(Vs(this,qc,"f").createTexture({format:I.U8_RGBA_RT,width:a*o,height:l*o,usage:xr.RENDER_TARGET})),"f"))}),e.destroy.tap(()=>{Vs(this,_P,"f").destroy(),Vs(this,w_,"f").destroy(),Vs(this,D1,"f").destroy(),Vs(this,qc,"f").destroy(),Vs(this,qc,"f").checkForLeaks()}),e.beginFrame.tap(()=>{const{width:a,height:l}=Vs(this,xC,"f").getCanvas(),c=Vs(this,xC,"f").getOnscreenTexture();Vs(this,D1,"f").setSubData(0,new Uint8Array(new Float32Array([...T1(n.projectionMatrix),...T1(n.viewMatrix),...T1(n.viewProjectionMatrixInv),n.zoom,Vs(this,vP,"f"),0,0]).buffer)),Vs(this,qc,"f").beginFrame(),b_(this,I1,Vs(this,qc,"f").createRenderPass({colorAttachment:[Vs(this,w_,"f")],colorResolveTo:[c],colorClearColor:[op]}),"f"),Vs(this,I1,"f").setViewport(0,0,a,l),Vs(this,_P,"f").render(Vs(this,qc,"f"),Vs(this,I1,"f"),Vs(this,D1,"f"))}),e.endFrame.tap(()=>{Vs(this,qc,"f").submitPass(Vs(this,I1,"f")),Vs(this,qc,"f").endFrame()}),e.render.tap(a=>{a.transform.updateTransform(a.parent?a.parent.transform:Slt),a.render(Vs(this,qc,"f"),Vs(this,I1,"f"),Vs(this,D1,"f"))})}setCheckboardStyle(t){b_(this,vP,t,"f")}};xC=new WeakMap,qc=new WeakMap,w_=new WeakMap,I1=new WeakMap,D1=new WeakMap,vP=new WeakMap,_P=new WeakMap;var Bp=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},P1=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
2683return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},bP,F1,E_,SC;const D3t=.02,P3t=4,F3t=100;let N3t=class{constructor(){bP.set(this,void 0),F1.set(this,{}),E_.set(this,void 0),SC.set(this,!1)}apply(t){const{canvas:e,camera:r,root:i,api:{client2Viewport:s,viewport2Canvas:o}}=t;i.hitArea=new Ua(-Number.MAX_VALUE,-Number.MAX_VALUE,1/0,1/0),i.draggable=!0;const n=Bt();let a,l,c;const h=it();let u,d=!1;function f(_){const w=e.getBoundingClientRect(),E=_.nativeEvent.clientX-w.left,A=_.nativeEvent.clientY-w.top,x=E/e.clientWidth,S=A/e.clientHeight,T=x*2-1,R=S*-2+1;return[T,R]}function g(_){const w=Qt(it(),f(_),n);r.x=a+h[0]-w[0],r.y=l+h[1]-w[1]}function p(_){const w=(_.nativeEvent.clientX-u[0])/100,E=Bt();bi(E,E,[h[0],h[1]]),Mo(E,E,w),bi(E,E,[-h[0],-h[1]]),r.x=a,r.y=l,r.rotation=c,us(E,E,r.matrix),r.rotation=c+w,r.x=E[6],r.y=E[7]}i.addEventListener("dragstart",_=>{Bp(this,E_,"f")||(d=_.shiftKey,fp(n,r.viewProjectionMatrixInv),a=r.x,l=r.y,c=r.rotation,Qt(h,f(_),n),u=[_.nativeEvent.clientX,_.nativeEvent.clientY])}),i.addEventListener("drag",_=>{Bp(this,E_,"f")||(d?p(_):g(_))}),i.addEventListener("dragend",_=>{Bp(this,E_,"f")||(d=!1)});const m=(_,w,E)=>{const{x:A,y:x}=o(s({x:_,y:w})),S=r.zoom*Math.pow(2,E*-.01);r.zoom=Math.max(D3t,Math.min(P3t,S));const{x:T,y:R}=o(s({x:_,y:w}));r.x+=A-T,r.y+=x-R};i.addEventListener("wheel",_=>{_.preventDefault(),m(_.nativeEvent.clientX,_.nativeEvent.clientY,_.deltaY)});const v=_=>{_.pointerType==="mouse"?P1(this,bP,!0,"f"):Bp(this,F1,"f")[_.pointerId]||(Bp(this,F1,"f")[_.pointerId]={last:null}),this.touchCount>=2?P1(this,E_,!0,"f"):P1(this,E_,!1,"f")},b=_=>{if(_.pointerType==="mouse"&&P1(this,bP,!1,"f"),_.pointerType!=="mouse"&&delete Bp(this,F1,"f")[_.pointerId],Bp(this,SC,"f")&&this.touchCount<=1)return P1(this,SC,!1,"f"),P1(this,E_,!1,"f"),!0},y=_=>{if(this.touchCount>=2){const w=_.global.x,E=_.global.y,A=Bp(this,F1,"f"),x=Object.keys(A),S=Number(x[0]),T=Number(x[1]),R=A[S],B=A[T],O=R.last&&B.last?Math.sqrt(Math.pow(B.last.x-R.last.x,2)+Math.pow(B.last.y-R.last.y,2)):null;if(S===_.pointerId?R.last={x:w,y:E}:T===_.pointerId&&(B.last={x:w,y:E}),O){const C=new ye(R.last.x+(B.last.x-R.last.x)/2,R.last.y+(B.last.y-R.last.y)/2),F=Math.sqrt(Math.pow(B.last.x-R.last.x,2)+Math.pow(B.last.y-R.last.y,2));m(C.x,C.y,(O/F-1)*F3t)}else Bp(this,SC,"f")||P1(this,SC,!0,"f")}};i.addEventListener("pointerdown",v),i.addEventListener("pointermove",y),i.addEventListener("pointerup",b),i.addEventListener("pointerupoutside",b),i.addEventListener("pointercancel",b)}get touchCount(){return(Bp(this,bP,"f")?1:0)+Object.keys(Bp(this,F1,"f")).length}};bP=new WeakMap,F1=new WeakMap,E_=new WeakMap,SC=new WeakMap;let k3t=class{apply(t){const{canvas:e,hooks:r,globalThis:i,supportsPointerEvents:s,supportsTouchEvents:o}=t,n=y=>{y.preventDefault(),r.pointerMove.call(y)},a=y=>{r.pointerUp.call(y)},l=y=>{r.pointerDown.call(y)},c=y=>{r.pointerOver.call(y)},h=y=>{r.pointerOut.call(y)},u=y=>{r.pointerCancel.call(y)},d=y=>{r.pointerWheel.call(y)},f=y=>{i.document.addEventListener("pointermove",n,!0),y.addEventListener("pointerdown",l,!0),y.addEventListener("pointerleave",h,!0),y.addEventListener("pointerover",c,!0),i.addEventListener("pointerup",a,!0),i.addEventListener("pointercancel",u,!0)},g=y=>{y.addEventListener("touchstart",l,!0),y.addEventListener("touchend",a,!0),y.addEventListener("touchmove",n,!0),y.addEventListener("touchcancel",u,!0)},p=y=>{i.document.addEventListener("mousemove",n,!0),y.addEventListener("mousedown",l,!0),y.addEventListener("mouseout",h,!0),y.addEventListener("mouseover",c,!0),i.addEventListener("mouseup",a,!0)},m=y=>{i.document.removeEventListener("pointermove",n,!0),y.removeEventListener("pointerdown",l,!0),y.removeEventListener("pointerleave",h,!0),y.removeEventListener("pointerover",c,!0),i.removeEventListener("pointerup",a,!0)},v=y=>{y.removeEventListener("touchstart",l,!0),y.removeEventListener("touchend",a,!0),y.removeEventListener("touchmove",n,!0),y.removeEventListener("touchcancel",u,!0)},b=y=>{i.document.removeEventListener("mousemove",n,!0),y.removeEventListener("mousedown",l,!0),y.removeEventListener("mouseout",h,!0),y.removeEventListener("mouseover",c,!0),i.removeEventListener("mouseup",a,!0)};r.init.tap(()=>{s?f(e):(p(e),o&&g(e)),e.addEventListener("wheel",d,{capture:!0})}),r.destroy.tap(()=>{s?m(e):(b(e),o&&v(e)),e.removeEventListener("wheel",d,!0)})}};var Mlt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
2683return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},bl=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},p9,wP,g9,Op,R0;const L3t=1,U3t={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};let G3t=class{constructor(){p9.set(this,!0),wP.set(this,new Mp(null)),g9.set(this,new u9(null)),Op.set(this,void 0),R0.set(this,void 0),this.onPointerMove=t=>{const e=this.normalizeToPointerEvent(t);for(const r of e){const i=this.bootstrapEvent(bl(this,wP,"f"),r);bl(this,Op,"f").mapEvent(i)}this.setCursor(bl(this,Op,"f").cursor)}}apply(t){const{hooks:e,root:r}=t;Mlt(this,R0,t,"f"),Mlt(this,Op,new S3t(r),"f"),bl(this,Op,"f").setPickHandler((i,s)=>{const{picked:o}=e.pickSync.call({position:{x:i,y:s},picked:[],topmost:!0});return o[0]||null}),e.pointerWheel.tap(i=>{const s=this.normalizeWheelEvent(i);bl(this,Op,"f").mapEvent(s)}),e.pointerDown.tap(i=>{const s=this.normalizeToPointerEvent(i);bl(this,p9,"f")&&s[0].isNormalized&&(i.cancelable||!("cancelable"in i))&&i.preventDefault();for(let o=0,n=s.length;o<n;o++){const a=s[o],l=this.bootstrapEvent(bl(this,wP,"f"),a);bl(this,Op,"f").mapEvent(l)}this.setCursor(bl(this,Op,"f").cursor)}),e.pointerUp.tap(i=>{let s=i.target;i.composedPath&&i.composedPath().length>0&&(s=i.composedPath()[0]);const o=s!==bl(this,R0,"f").canvas?"outside":"",n=this.normalizeToPointerEvent(i);for(let a=0,l=n.length;a<l;a++){const c=this.bootstrapEvent(bl(this,wP,"f"),n[a]);c.type+=o,bl(this,Op,"f").mapEvent(c)}this.setCursor(bl(this,Op,"f").cursor)}),e.pointerMove.tap(this.onPointerMove),e.pointerOver.tap(this.onPointerMove),e.pointerOut.tap(this.onPointerMove),e.pointerCancel.tap(this.onPointerMove)}normalizeWheelEvent(t){const e=bl(this,g9,"f");this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode;const{x:r,y:i}=this.getViewportXY(t);e.client.x=r,e.client.y=i;const{x:s,y:o}=bl(this,R0,"f").api.viewport2Canvas(e.client);return e.screen.x=s,e.screen.y=o,e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null}setCursor(t){bl(this,R0,"f").canvas.style.cursor=t}normalizeToPointerEvent(t){const{supportsTouchEvents:e,supportsPointerEvents:r}=bl(this,R0,"f"),i=[];if(e&&t instanceof TouchEvent)for(let s=0;s<t.changedTouches.length;s++){const o=t.changedTouches[s];sa(o.button)&&(o.button=0),sa(o.buttons)&&(o.buttons=1),sa(o.isPrimary)&&(o.isPrimary=t.touches.length===1&&t.type==="touchstart"),sa(o.width)&&(o.width=o.radiusX||1),sa(o.height)&&(o.height=o.radiusY||1),sa(o.tiltX)&&(o.tiltX=0),sa(o.tiltY)&&(o.tiltY=0),sa(o.pointerType)&&(o.pointerType="touch"),sa(o.pointerId)&&(o.pointerId=o.identifier||0),sa(o.pressure)&&(o.pressure=o.force||.5),sa(o.twist)&&(o.twist=0),sa(o.tangentialPressure)&&(o.tangentialPressure=0),o.isNormalized=!0,o.type=t.type,i.push(o)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!r||!(t instanceof globalThis.PointerEvent))){const s=t;sa(s.isPrimary)&&(s.isPrimary=!0),sa(s.width)&&(s.width=1),sa(s.height)&&(s.height=1),sa(s.tiltX)&&(s.tiltX=0),sa(s.tiltY)&&(s.tiltY=0),sa(s.pointerType)&&(s.pointerType="mouse"),sa(s.pointerId)&&(s.pointerId=L3t),sa(s.pressure)&&(s.pressure=.5),sa(s.twist)&&(s.twist=0),sa(s.tangentialPressure)&&(s.tangentialPressure=0),s.isNormalized=!0,i.push(s)}else i.push(t);return i}bootstrapEvent(t,e){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);const{x:r,y:i}=this.getViewportXY(e);t.client.x=r,t.client.y=i;const{x:s,y:o}=bl(this,R0,"f").api.viewport2Canvas(t.client);return t.screen.x=s,t.screen.y=o,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=U3t[t.type]||t.type),t}getViewportXY(t){let e,r;const{offsetX:i,offsetY:s,clientX:o,clientY:n}=t;if(!Elt(i)&&!Elt(s))e=i,r=s;else{const a=bl(this,R0,"f").api.client2Viewport({x:o,y:n});e=a.x,r=a.y}return{x:e,y:r}}};
2683p9=new WeakMap,wP=new WeakMap,g9=new WeakMap,Op=new WeakMap,R0=new WeakMap;const Blt=new ye;let W3t=class{apply(t){const{hooks:e,root:r}=t;e.pickSync.tap(i=>this.pick(i,r))}pick(t,e){const{position:{x:r,y:i}}=t,s=[];return wW(e,o=>{this.hitTest(o,r,i)&&s.unshift(o)}),t.picked=s,t}hitTest(t,e,r){if(t.pointerEvents==="none")return!1;if(t.hitArea||t.renderable){t.worldTransform.applyInverse({x:e,y:r},Blt);const{x:i,y:s}=Blt;return t.hitArea?t.hitArea.contains(i,s):t.containsPoint(i,s)}return!1}};var j3t=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Olt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},EP;function Ilt(t,e){do{if(t&&e(t))return t;t=t.parent}while(t!==void 0);return null}let X3t=class{constructor(t={}){EP.set(this,void 0),j3t(this,EP,Object.assign({overlap:"pointer",dragstartTimeThreshold:0,dragstartDistanceThreshold:0},t),"f")}apply(t){const{root:e,hooks:r,api:{elementsFromPoint:i}}=t,s=o=>{const n=o.target,a=Ilt(n,l=>l.draggable===!0);if(a){let l=!1;const c=o.timeStamp,h=[o.clientX,o.clientY];let u=null,d=[o.clientX,o.clientY];const f=p=>{if(!l){const y=p.timeStamp-c,_=_lt(p.clientX,p.clientY,...h);if(y<=Olt(this,EP,"f").dragstartTimeThreshold||_<=Olt(this,EP,"f").dragstartDistanceThreshold)return;p.type="dragstart",a.dispatchEvent(p),l=!0}p.type="drag",p.dx=p.clientX-d[0],p.dy=p.clientY-d[1],a.dispatchEvent(p),d=[p.clientX,p.clientY];const m=[p.globalX,p.globalY],v=i(m[0],m[1]),b=v[v.indexOf(n)+1];if(b){const y=Ilt(b,_=>_.droppable===!0);u!==y&&(u&&(p.type="dragleave",p.target=u,u.dispatchEvent(p)),y&&(p.type="dragenter",p.target=y,y.dispatchEvent(p)),u=y,u&&(p.type="dragover",p.target=u,u.dispatchEvent(p)))}};e.addEventListener("pointermove",f);const g=function(p){if(l){p.detail={preventClick:!0};const m=p;u&&(m.type="drop",m.target=u,u.dispatchEvent(m)),m.type="dragend",a.dispatchEvent(m),l=!1}e.removeEventListener("pointermove",f)};n.addEventListener("pointerup",g,{once:!0}),n.addEventListener("pointerupoutside",g,{once:!0})}};r.init.tap(()=>{e.addEventListener("pointerdown",s)}),r.destroy.tap(()=>{e.removeEventListener("pointerdown",s)})}};EP=new WeakMap;var z3t=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Cn=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},AP=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},MW,xd,xP,BW,A_,N1;let V3t=class{get root(){return Cn(this,A_,"f")}get camera(){return Cn(this,N1,"f")}constructor(t){MW.set(this,void 0),xd.set(this,void 0),xP.set(this,void 0),BW.set(this,void 0),A_.set(this,new Clt),N1.set(this,void 0);const{canvas:e,renderer:r="webgl",shaderCompilerPath:i="",devicePixelRatio:s}=t,o=v3t(),n=s??o.devicePixelRatio,a=!!o.PointerEvent,l="ontouchstart"in o,{width:c,height:h}
2683=e,u=new Alt(c/n,h/n);AP(this,N1,u,"f"),AP(this,xd,{globalThis:o,canvas:e,renderer:r,shaderCompilerPath:i,devicePixelRatio:n,supportsPointerEvents:a,supportsTouchEvents:l,hooks:{init:new Ad,initAsync:new m3t,beginFrame:new Ad,render:new Ad,endFrame:new Ad,destroy:new Ad,resize:new Ad,pointerDown:new Ad,pointerUp:new Ad,pointerMove:new Ad,pointerOut:new Ad,pointerOver:new Ad,pointerWheel:new Ad,pointerCancel:new Ad,pickSync:new y3t},camera:u,root:Cn(this,A_,"f"),api:{elementsFromPoint:this.elementsFromPoint.bind(this),elementFromPoint:this.elementFromPoint.bind(this),client2Viewport:this.client2Viewport.bind(this),viewport2Canvas:this.viewport2Canvas.bind(this),viewport2Client:this.viewport2Client.bind(this),canvas2Viewport:this.canvas2Viewport.bind(this)}},"f"),AP(this,xP,new I3t,"f"),AP(this,BW,new G3t,"f");const d=[new k3t,Cn(this,BW,"f"),new W3t,new N3t,Cn(this,xP,"f"),new X3t({dragstartTimeThreshold:100,dragstartDistanceThreshold:10})];AP(this,MW,z3t(this,void 0,void 0,function*(){const{hooks:f}=Cn(this,xd,"f");return d.forEach(g=>{g.apply(Cn(this,xd,"f"))}),f.init.call(),yield f.initAsync.promise(),this}),"f")}get initialized(){return Cn(this,MW,"f").then(()=>this)}render(){const{hooks:t}=Cn(this,xd,"f");t.beginFrame.call(),wW(Cn(this,A_,"f"),e=>{t.render.call(e)}),t.endFrame.call()}resize(t,e){const{hooks:r}=Cn(this,xd,"f");Cn(this,N1,"f").projection(t,e),r.resize.call(t,e)}destroy(){const{hooks:t}=Cn(this,xd,"f");wW(Cn(this,A_,"f"),e=>{e.destroy()}),t.destroy.call()}getDOM(){return Cn(this,xd,"f").canvas}appendChild(t){Cn(this,A_,"f").appendChild(t)}removeChild(t){Cn(this,A_,"f").removeChild(t)}setCheckboardStyle(t){Cn(this,xP,"f").setCheckboardStyle(t)}elementsFromPoint(t,e){const{picked:r}=Cn(this,xd,"f").hooks.pickSync.call({topmost:!1,position:{x:t,y:e},picked:[]});return r}elementFromPoint(t,e){const{picked:r}=Cn(this,xd,"f").hooks.pickSync.call({topmost:!0,position:{x:t,y:e},picked:[]});return r[0]}client2Viewport({x:t,y:e}){const{left:r,top:i}=Cn(this,xd,"f").canvas.getBoundingClientRect();return{x:t-r,y:e-i}}viewport2Client({x:t,y:e}){const{left:r,top:i}=Cn(this,xd,"f").canvas.getBoundingClientRect();return{x:t+r,y:e+i}}canvas2Viewport({x:t,y:e}){const{width:r,height:i,viewProjectionMatrix:s}=Cn(this,N1,"f"),o=Qt(it(),[t,e],s);return{x:(o[0]+1)/2*r,y:(1-(o[1]+1)/2)*i}}viewport2Canvas({x:t,y:e}){const{width:r,height:i,viewProjectionMatrixInv:s}=Cn(this,N1,"f"),o=Qt(it(),[t/r*2-1,(1-e/i)*2-1],s);return{x:o[0],y:o[1]}}};MW=new WeakMap,xd=new WeakMap,xP=new WeakMap,BW=new WeakMap,A_=new WeakMap,N1=new WeakMap;const Y3t=Object.freeze(Object.defineProperty({__proto__:null,Camera:Alt,Canvas:V3t,Circle:C3t,Grid:Rlt,Group:Clt,IDENTITY_TRANSFORM:Slt,Rectangle:Ua,Shape:d9,isFillOrStrokeAffected:Tlt},Symbol.toStringTag,{value:"Module"}));var m9=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},SP;let $3t=class{constructor(){SP.set(this,[])}getCallbacksNum(){return m9(this,SP,"f").length}tapPromise(t){m9(this,SP,"f").push(t)}promise(...t){return Promise.all(m9(this,SP,"f").map(e=>e(...t)))}};SP=new WeakMap;var Dlt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},OW;let Sd=class{constructor(){OW.set(this,[])}tap(t){Dlt(this,OW,"f").push(t)}call(...t){Dlt(this,OW,"f").forEach(function(e){e.apply(void 0,t)})}};OW=new WeakMap;var TP=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},k1;let H3t=class{constructor(){k1.set(this,[])}tap(t){TP(this,k1,"f").push(t)}call(...t){if(TP(this,k1,"f").length){let e=TP(this,k1,"f")[0].apply(void 0,t);for(let r=0;r<TP(this,k1,"f").length-1;r++){const i=TP(this,k1,"f")[r];e=i(...e)}return e}return null}};k1=new WeakMap;const K3t=()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};
2683function IW(t,e){e(t)||t.children.forEach(r=>{IW(r,e)})}const y9=0;function L1(t){return[t[0],t[1],t[2],y9,t[3],t[4],t[5],y9,t[6],t[7],t[8],y9]}function Plt(t,e,r,i){var s=Math.sqrt(Math.pow(r-t,2)+Math.pow(i-e,2));return s}const q3t={linear:cr(0,0,1,1),ease:cr(.25,.1,.25,1),"ease-in":cr(.42,0,1,1),"ease-out":cr(0,0,.58,1),"ease-in-out":cr(.42,0,.58,1)};var x_;(function(t){t._bytes4=new Uint8Array(4),t._float=new Float32Array(t._bytes4.buffer),t._int=new Int32Array(t._bytes4.buffer),t._bytes2=new Uint8Array(2),t._short=new Int16Array(t._bytes2.buffer);function e(c){return t._float[0]=c,t._int[0]}t.floatToInt=e;function r(c){return t._int[0]=c,t._float[0]}t.intToFloat=r;function i(c){return t._float[0]=c,t._bytes4}t.floatToBytes=i;function s(c,h,u,d){return t._bytes4[0]=c,t._bytes4[1]=h,t._bytes4[2]=u,t._bytes4[3]=d,t._float[0]}t.bytesToFloat=s;function o(c){return t._int[0]=c,t._bytes4}t.intToBytes=o;function n(c,h,u,d){return t._bytes4[0]=c,t._bytes4[1]=h,t._bytes4[2]=u,t._bytes4[3]=d,t._int[0]}t.bytesToInt=n;function a(c){return t._short[0]=c,t._bytes2}t.shortToBytes=a;function l(c,h){return t._bytes2[0]=c,t._bytes2[1]=h,t._short[0]}t.bytesToShort=l})(x_||(x_={}));const Flt=256;let Z3t=class{constructor(t=new Uint8Array(Flt)){this._bytes=t,this.count=0,this.readOffset=0,this.capacity=Flt,this.count=this.capacity=t.length}clear(){this.count=0,this.readOffset=0}byteCount(){return this.count}bytes(){return this._bytes.subarray(0,this.count)}grow(){this.capacity*=2;const t=new Uint8Array(this.capacity);t.set(this._bytes),this._bytes=t}hasMoreToRead(){return this.readOffset<this.count}seekTo(t){this.readOffset=t}skipBytes(t){this.readOffset+=t}appendBytes(t){const e=t.length;return this.count+e>this.capacity&&this.grow(),this._bytes.set(t,this.count),this.count+=e,this}byteAt(t){return this._bytes[t]}appendByte(t){return this.count+1>this.capacity&&this.grow(),this._bytes[this.count]=t,this.count++,this}readByte(){const t=this.byteAt(this.readOffset);return this.readOffset++,t}shortAt(t){return x_.bytesToShort(this._bytes[t],this._bytes[t+1])}appendShort(t){return this.appendBytes(x_.shortToBytes(t)),this}appendShorts(t){for(const e of t)this.appendShort(e);return this}readShort(){const t=this.shortAt(this.readOffset);return this.readOffset+=2,t}intAt(t){return x_.bytesToInt(this._bytes[t],this._bytes[t+1],this._bytes[t+2],this._bytes[t+3])}appendInt(t){return this.appendBytes(x_.intToBytes(t)),this}appendInts(t){for(const e of t)this.appendInt(e);return this}readInt(){const t=this.intAt(this.readOffset);return this.readOffset+=4,t}floatAt(t){return x_.bytesToFloat(this._bytes[t],this._bytes[t+1],this._bytes[t+2],this._bytes[t+3])}appendFloat(t){return this.appendBytes(x_.floatToBytes(t)),this}appendFloats(t){for(const e of t)this.appendFloat(e);return this}readFloat(){const t=this.floatAt(this.readOffset);return this.readOffset+=4,t}isEmpty(){return this.count==0}};const DW=t=>t instanceof Object,Nlt=t=>t===!!t,PW=t=>typeof t=="function",oa=t=>t===void 0,klt=t=>t==null;var gr=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},gc=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Ip,Eu,Au,uf,RP,CP,Dp,MP,BP,OP,FW,IP;const Llt=1e-4;let Ult=class h1t{constructor(e,r){this.clipSpaceNearZ=Sh.NEGATIVE_ONE,Ip.set(this,1),Eu.set(this,0),Au.set(this,0),uf.set(this,0),RP.set(this,0),CP.set(this,0),Dp.set(this,Bt()),MP.set(this,Bt()),BP.set(this,Bt()),OP.set(this,Bt()),FW.set(this,Bt()),IP.set(this,void 0),this.projection(e,r),this.updateMatrix()}clone(){const e=new h1t(gr(this,RP,"f"),gr(this,CP,"f"));return gc(e,Eu,gr(this,Eu,"f"),"f"),gc(e,Au,gr(this,Au,"f"),"f"),gc(e,Ip,gr(this,Ip,"f"),"f"),gc(e,uf,gr(this,uf,"f"),"f"),e.updateMatrix(),e}projection(e,r){gc(this,RP,e,"f"),gc(this,CP,r,"f"),ld(gr(this,MP,"f"),e,r),this.updateViewProjectionMatrix()}updateMatrix(){const e=1/gr(this,Ip,"f");Yc(gr(this,Dp,"f")),bi(gr(this,Dp,"f"),gr(this,Dp,"f"),[gr(this,Eu,"f"),gr(this,Au,"f")]),Mo(gr(this,Dp,"f"),gr(this,Dp,"f"),gr(this,uf,"f")),xh(gr(this,Dp,"f"),gr(this,Dp,"f"),[e,e]),_i(gr(this,BP,"f"),gr(this,Dp,"f")),this.updateViewProjectionMatrix()}updateViewProjectionMatrix(){us(gr(this,OP,"f"),gr(this,MP,"f"),gr(this,BP,"f")),_i(gr(this,FW,"f"),gr(this,OP,"f")),this.onchange&&this.onchange()}get projectionMatrix(){return gr(this,MP,"f")}get viewMatrix(){return gr(this,BP,"f")}get viewProjectionMatrix(){return gr(this,OP,"f")}get viewProjectionMatrixInv(){return gr(this,FW,"f")}get matrix(){return gr(this,Dp,"f")}get zoom(){return gr(this,Ip,"f")}set zoom(e){gr(this,Ip,"f")!==e&&(gc(this,Ip,e,"f"),this.updateMatrix())}get x(){return gr(this,Eu,"f")}set x(e){gr(this,Eu,"f")!==e&&(gc(this,Eu,e,"f"),this.updateMatrix())}get y(){return gr(this,Au,"f")}set y(e){gr(this,Au,"f")!==e&&(gc(this,Au,e,"f"),this.updateMatrix())}get rotation(){return gr(this,uf,"f")}set rotation(e){gr(this,uf,"f")!==e&&(gc(this,uf,e,"f"),this.updateMatrix())}get width(){return gr(this,RP,"f")}get height(){return gr(this,CP,"f")}createLandmark(e={}){return Object.assign({zoom:gr(this,Ip,"f"),x:gr(this,Eu,"f"),y:gr(this,Au,"f"),rotation:gr(this,uf,"f")},e)}gotoLandmark(e,r={}){const{easing:i="linear",duration:s=100,onframe:o=void 0,onfinish:n=void 0}=r,{zoom:a=gr(this,Ip,"f"),x:l=gr(this,Eu,"f"),y:c=gr(this,Au,"f"),rotation:h=gr(this,uf,"f"),viewportX:u
2683=0,viewportY:d=0}=e,f=u||d,g=()=>{this.applyLandmark({x:l,y:c,zoom:a,rotation:h,viewportX:u,viewportY:d}),n&&n()};if(s===0){g();return}this.cancelLandmarkAnimation();let p;const m=[l,c],v=[a,h],b=y=>{p===void 0&&(p=y);const _=y-p;if(_>s){g();return}const w=q3t[i](_/s),E=it(),A=Be(1,0);if(ta(E,[gr(this,Eu,"f"),gr(this,Au,"f")],m,w),ta(A,[this.zoom,gr(this,uf,"f")],v,w),this.applyLandmark({x:E[0],y:E[1],zoom:A[0],rotation:A[1],viewportX:u,viewportY:d}),f?za(A,v)<=Llt:za(E,m)<=Llt){g();return}_<s&&(o&&o(w),gc(this,IP,requestAnimationFrame(b),"f"))};requestAnimationFrame(b)}cancelLandmarkAnimation(){gr(this,IP,"f")!==void 0&&cancelAnimationFrame(gr(this,IP,"f"))}viewport2Canvas({x:e,y:r},i){const{width:s,height:o,viewProjectionMatrixInv:n}=i||this,a=Qt(it(),[e/s*2-1,(1-r/o)*2-1],n);return{x:a[0],y:a[1]}}canvas2Viewport({x:e,y:r},i){const{width:s,height:o,viewProjectionMatrix:n}=i||this,a=Qt(it(),[e,r],n);return{x:(a[0]+1)/2*s,y:(1-(a[1]+1)/2)*o}}applyLandmark(e){const{x:r,y:i,zoom:s,rotation:o,viewportX:n,viewportY:a}=e,l=n||a;let c=0,h=0;if(l){const u=this.viewport2Canvas({x:n,y:a});c=u.x,h=u.y}if(gc(this,Ip,s,"f"),gc(this,uf,o,"f"),gc(this,Eu,r,"f"),gc(this,Au,i,"f"),this.updateMatrix(),l){const{x:u,y:d}=this.viewport2Canvas({x:n,y:a});gc(this,Eu,gr(this,Eu,"f")+(c-u),"f"),gc(this,Au,gr(this,Au,"f")+(h-d),"f"),this.updateMatrix()}}};Ip=new WeakMap,Eu=new WeakMap,Au=new WeakMap,uf=new WeakMap,RP=new WeakMap,CP=new WeakMap,Dp=new WeakMap,MP=new WeakMap,BP=new WeakMap,OP=new WeakMap,FW=new WeakMap,IP=new WeakMap;let Glt=class u1t{get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=u1t.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ye,this.page=new ye,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}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(e,r,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,r,i,s,o){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}},NW=class extends Glt{constructor(){super(...arguments),this.client=new ye,this.movement=new ye,this.offset=new ye,this.global=new ye,this.screen=new ye}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}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,r,i,s,o,n,a,l,c,h,u,d,f,g){throw new Error("Method not implemented.")}},Pp=class extends NW{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!")}},v9=class extends NW{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}};var J3t=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
2683return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Q3t=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},kW;const tUt=2048;let eUt=class{constructor(t){this.dispatch=new Uo,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,kW.set(this,void 0),this.rootTarget=t,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)}setPickHandler(t){J3t(this,kW,t,"f")}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((r,i)=>r.priority-i.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(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 r=0,i=e.length;r<i;r++)e[r].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}
vendor: 6,556 bytes, line 2683
2683hitTest(t,e){return Q3t(this,kW,"f").call(this,t,e)}propagate(t,e){if(!t.target)return;const r=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let i=0,s=r.length-1;i<s;i++)if(t.currentTarget=r[i],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 i=r.length-2;i>=0;i--)if(t.currentTarget=r[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,r=this._allInteractiveElements){if(r.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const i=Array.isArray(e)?e:[e];for(let s=r.length-1;s>=0;s--)i.forEach(o=>{t.currentTarget=r[s],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let r=0;r<tUt&&t!==this.rootTarget&&t.parent;r++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}notifyTarget(t,e){e=e??t.type;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 Pp)){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 i=e.button===2;this.dispatchEvent(e,i?"rightdown":"mousedown")}const r=this.trackingData(t.pointerId);r.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,r,i;if(!(t instanceof Pp)){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 s=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const o=s.pointerType==="mouse"||s.pointerType==="pen",n=this.trackingData(t.pointerId),a=this.findMountedTarget(n.overTargets);if(((e=n.overTargets)===null||e===void 0?void 0:e.length)>0&&a!==s.target){const h=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,h,a);if(this.dispatchEvent(u,"pointerout"),o&&this.dispatchEvent(u,"mouseout"),!s.composedPath().includes(a)){const d=this.createPointerEvent(t,"pointerleave",a);for(d.eventPhase=d.AT_TARGET;d.target&&!s.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),o&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(u)}if(a!==s.target){const h=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(s,h);this.dispatchEvent(u,"pointerover"),o&&this.dispatchEvent(u,"mouseover");let d=a==null?void 0:a.parent;for(;d&&d!==this.rootTarget.parent&&d!==s.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(s,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==a&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),o&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(u)}const l=[],c=(r=this.enableGlobalMoveEvents)!==null&&r!==void 0?r:!0;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(s,"pointermove"),c&&l.push("globalpointermove"),s.pointerType==="touch"&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(s,"touchmove"),c&&l.push("globaltouchmove")),o&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(s,"mousemove"),c&&l.push("globalmousemove"),this.cursor=(i=s.target)===null||i===void 0?void 0:i.cursor),l.length>0&&this.all(s,l),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=s.composedPath(),this.freeEvent(s)}mapPointerOver(t){var e;if(!(t instanceof Pp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(e=i.target)===null||e===void 0?void 0:e.cursor);const o=this.clonePointerEvent(i,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;r.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof Pp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const r=t.pointerType==="mouse"||t.pointerType==="pen",i=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",i);this.dispatchEvent(s),r&&this.dispatchEvent(s,"mouseout");const o=this.createPointerEvent(t,"pointerleave",i);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),r&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(s),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){var e;if(!(t instanceof Pp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=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 s=this.trackingData(t.pointerId),o=this.findMountedTarget(s.pressTargetsByButton[t.button]);let n=o;if(o&&!i.composedPath().includes(o)){let a=o;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 l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],n=a}if(n){const a=this.clonePointerEvent(i,"click");a.target=n,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:r});const l=s.clicksByButton[t.button];if(l.target===a.target&&r-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=r,a.detail=l.clickCount,!(!((e=i.detail)===null||e===void 0)&&e.preventClick)){if
2683(a.pointerType==="mouse"){const c=a.button===2;this.dispatchEvent(a,c?"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 Pp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),r=this.findMountedTarget(e.pressTargetsByButton[t.button]),i=this.createPointerEvent(t);if(r){let s=r;for(;s;)i.currentTarget=s,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch"?this.notifyTarget(i,"touchendoutside"):(i.pointerType==="mouse"||i.pointerType==="pen")&&this.notifyTarget(i,i.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(i)}mapWheel(t){if(!(t instanceof v9)){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 r=1;r<t.length&&t[r].parent===e;r++)e=t[r];return e}createPointerEvent(t,e,r){var i;const s=this.allocateEvent(Pp);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=(i=r??this.hitTest(s.global.x,s.global.y))!==null&&i!==void 0?i:this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(v9);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 r=this.allocateEvent(Pp);return r.nativeEvent=t.nativeEvent,r.originalEvent=t.originalEvent,this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.target=t.target,r.path=t.composedPath().slice(),r.type=e??r.type,r}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Pp&&e instanceof Pp&&(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.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof NW&&e instanceof NW&&(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 r=t.currentTarget._events[e];if(r)if("fn"in r)r.once&&t.currentTarget.removeListener(e,r.fn,void 0,!0),r.fn.call(r.context,t);else for(let i=0,s=r.length;i<s&&!t.propagationImmediatelyStopped;i++)r[i].once&&t.currentTarget.removeListener(e,r[i].fn,void 0,!0),r[i].fn.call(r[i].context,t)}};kW=new WeakMap;const Wlt=new wn;let _9=class extends Uo{constructor(t={}){var e,r,i,s,o,n;super(),this.renderDirtyFlag=!0,this.transform=new wn,this.children=[],this.cursor=(e=t.cursor)!==null&&e!==void 0?e:"default",this.hitArea=t.hitArea,this.pointerEvents=(r=t.pointerEvents)!==null&&r!==void 0?r:"auto",this.visible=(i=t.visible)!==null&&i!==void 0?i:!0,this.renderable=(s=t.renderable)!==null&&s!==void 0?s:!0,this.draggable=(o=t.draggable)!==null&&o!==void 0?o:!1,this.droppable=(n=t.droppable)!==null&&n!==void 0?n:!1}addEventListener(t,e,r){const i=Nlt(r)&&r||DW(r)&&r.capture,s=DW(r)?r.signal:void 0,o=DW(r)&&r.once,n=PW(e)?void 0:e;t=i?`${t}capture`:t;const a=PW(e)?e:e.handleEvent;s&&s.addEventListener("abort",()=>{this.off(t,a,n)}),o?this.once(t,a,n):this.on(t,a,n)}removeEventListener(t,e,r){const i=Nlt(r)&&r||DW(r)&&r.capture,s=PW(e)?void 0:e;t=i?`${t}capture`:t,e=PW(e)?e:e==null?void 0:e.handleEvent,this.off(t,e,s)}dispatchEvent(t){if(!(t instanceof Glt))throw new Error("Container cannot propagate events outside of the Federated Events API");return t.defaultPrevented=!1,t.path=null,t.target=this,t.manager.dispatchEvent(t),!t.defaultPrevented}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*id}set angle(t){this.transform.rotation=t*eu}appendChild(t){return t.parent&&t.parent.removeChild(t),t.parent=this,t.transform._parentID=-1,this.children.push(t),t}removeChild(t){const e=this.children.indexOf(t);return e===-1?null:(t.parent=void 0,t.transform._parentID=-1,this.children.splice(e,1),t)}};function jlt(t,e,r){let i=!1,s=!1;const o=!!e&&e!=="none",n=!!r&&r!=="none";return t==="visiblepainted"||t==="painted"||t==="auto"?(i=o,s=n):t==="visiblefill"||t==="fill"?i=!0:t==="visiblestroke"||t==="stroke"?s=!0:(t==="visible"||t==="all")&&(i=!0,s=!0),[i,s]}const rUt=` 2684layout(std140) uniform SceneUniforms { 2685 mat3 u_ProjectionMatrix; 2686 mat3 u_ViewMatrix; 2687}; 2688 2689layout(std140) uniform ShapeUniforms { 2690 mat3 u_ModelMatrix; 2691}; 2692 2693layout(location = 0) in vec2 a_FragCoord; 2694layout(location = 1) in vec2 a_Position; 2695layout(location = 2) in vec2 a_Size; 2696layout(location = 3) in vec4 a_FillColor; 2697 2698out vec2 v_FragCoord; 2699out vec4 v_FillColor; 2700 2701void main() { 2702 v_FragCoord = a_FragCoord; 2703 v_FillColor = a_FillColor; 2704 2705 gl_Position = vec4((u_ProjectionMatrix
2706 * u_ViewMatrix 2707 * u_ModelMatrix 2708 * vec3(a_Position + a_Size * a_FragCoord, 1)).xy, 0, 1); 2709} 2710`,iUt=` 2711layout(std140) uniform SceneUniforms { 2712 mat3 u_ProjectionMatrix; 2713 mat3 u_ViewMatrix; 2714}; 2715 2716layout(std140) uniform ShapeUniforms { 2717 mat3 u_ModelMatrix; 2718}; 2719 2720out vec4 outputColor; 2721 2722in vec2 v_FragCoord; 2723in vec4 v_FillColor; 2724 2725float sdf_circle(vec2 p, float r) { 2726 return length(p) - r; 2727} 2728 2729void main() { 2730 float distance = sdf_circle(v_FragCoord, 1.0); 2731 2732 if (distance > 0.0) { 2733 discard; 2734 } 2735 2736 float alpha = clamp(-distance / fwidth(-distance), 0.0, 1.0); 2737 2738 outputColor = v_FillColor; 2739 outputColor.a *= alpha; 2740} 2741`;var Ur=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Fh=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},U1,G1,Lm,TC,W1,RC,CC,j1,DP,MC,PP,BC,OC,IC,FP;let sUt=class extends _9{constructor(t={}){super(t),U1.set(this,void 0),G1.set(this,void 0),Lm.set(this,void 0),TC.set(this,void 0),W1.set(this,void 0),RC.set(this,void 0),CC.set(this,void 0),j1.set(this,void 0),DP.set(this,void 0),MC.set(this,void 0),PP.set(this,void 0),BC.set(this,void 0),OC.set(this,void 0),IC.set(this,void 0),FP.set(this,void 0);const{cx:e,cy:r,r:i,fill:s,stroke:o,strokeWidth:n}=t;this.cx=e??0,this.cy=r??0,this.r=i??0,this.fill=s??"black",this.stroke=o??"black",this.strokeWidth=n??0}get cx(){return Ur(this,U1,"f")}set cx(t){Ur(this,U1,"f")!==t&&(Fh(this,U1,t,"f"),this.renderDirtyFlag=!0)}get cy(){return Ur(this,G1,"f")}set cy(t){Ur(this,G1,"f")!==t&&(Fh(this,G1,t,"f"),this.renderDirtyFlag=!0)}get r(){return Ur(this,Lm,"f")}set r(t){Ur(this,Lm,"f")!==t&&(Fh(this,Lm,t,"f"),this.renderDirtyFlag=!0)}get fill(){return Ur(this,TC,"f")}set fill(t){Ur(this,TC,"f")!==t&&(Fh(this,TC,t,"f"),Fh(this,W1,sr.rgb(t),"f"),this.renderDirtyFlag=!0)}get stroke(){return Ur(this,RC,"f")}set stroke(t){Ur(this,RC,"f")!==t&&(Fh(this,RC,t,"f"),this.renderDirtyFlag=!0)}get strokeWidth(){return Ur(this,CC,"f")}set strokeWidth(t){Ur(this,CC,"f")!==t&&(Fh(this,CC,t,"f"),this.renderDirtyFlag=!0)}render(t,e,r){Ur(this,j1,"f")||(Fh(this,j1,t.createProgram({vertex:{glsl:rUt},fragment:{glsl:iUt}}),"f"),Fh(this,BC,t.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*16,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),Fh(this,MC,t.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*8,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),Fh(this,DP,t.createBuffer({viewOrSize:new Float32Array([-1,-1,1,-1,1,1,-1,1]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),Fh(this,PP,t.createBuffer({viewOrSize:new Uint32Array([0,1,2,0,2,3]),usage:dt.INDEX,hint:Et.STATIC}),"f"),Fh(this,IC,t.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:0,offset:0,format:I.F32_RG}]},{arrayStride:32,stepMode:ne.INSTANCE,attributes:[{shaderLocation:1,offset:0,format:I.F32_RG},{shaderLocation:2,offset:8,format:I.F32_RG},{shaderLocation:3,offset:16,format:I.F32_RGBA}]}],indexBufferFormat:I.U32_R,program:Ur(this,j1,"f")}),"f"),Fh(this,OC,t.createRenderPipeline({inputLayout:Ur(this,IC,"f"),program:Ur(this,j1,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}]}}),"f"),Fh(this,FP,t.createBindings({pipeline:Ur(this,OC,"f"),uniformBufferBindings:[{buffer:r},{buffer:Ur(this,BC,"f")}]}),"f")),Ur(this,BC,"f").setSubData(0,new Uint8Array(new Float32Array(L1(this.worldTransform.toArray(!0))).buffer)),this.renderDirtyFlag&&Ur(this,MC,"f").setSubData(0,new Uint8Array(new Float32Array([Ur(this,U1,"f"),Ur(this,G1,"f"),Ur(this,Lm,"f"),Ur(this,Lm,"f"),Ur(this,W1,"f").r/255,Ur(this,W1,"f").g/255,Ur(this,W1,"f").b/255,Ur(this,W1,"f").opacity]).buffer)),e.setP
2741ipeline(Ur(this,OC,"f")),e.setVertexInput(Ur(this,IC,"f"),[{buffer:Ur(this,DP,"f")},{buffer:Ur(this,MC,"f")}],{buffer:Ur(this,PP,"f")}),e.setBindings(Ur(this,FP,"f")),e.drawIndexed(6,1),this.renderDirtyFlag=!1}destroy(){Ur(this,j1,"f").destroy(),Ur(this,MC,"f").destroy(),Ur(this,DP,"f").destroy(),Ur(this,PP,"f").destroy(),Ur(this,BC,"f").destroy(),Ur(this,OC,"f").destroy(),Ur(this,IC,"f").destroy(),Ur(this,FP,"f").destroy()}containsPoint(t,e){const r=Ur(this,CC,"f")/2,i=Plt(Ur(this,U1,"f"),Ur(this,G1,"f"),t,e),[s,o]=jlt(this.pointerEvents,Ur(this,TC,"f"),Ur(this,RC,"f"));return s?i<=Ur(this,Lm,"f"):o?i>=Ur(this,Lm,"f")-r&&i<=Ur(this,Lm,"f")+r:!1}};U1=new WeakMap,G1=new WeakMap,Lm=new WeakMap,TC=new WeakMap,W1=new WeakMap,RC=new WeakMap,CC=new WeakMap,j1=new WeakMap,DP=new WeakMap,MC=new WeakMap,PP=new WeakMap,BC=new WeakMap,OC=new WeakMap,IC=new WeakMap,FP=new WeakMap;const oUt=` 2742layout(std140) uniform SceneUniforms { 2743 mat3 u_ProjectionMatrix; 2744 mat3 u_ViewMatrix; 2745 mat3 u_ViewProjectionInvMatrix; 2746 float u_ZoomScale; 2747 float u_CheckboardStyle; 2748}; 2749 2750layout(location = 0) in vec2 a_Position; 2751 2752out vec2 v_Position; 2753 2754vec2 project_clipspace_to_world(vec2 p) { 2755 return (u_ViewProjectionInvMatrix * vec3(p, 1)).xy; 2756} 2757 2758void main() { 2759 v_Position = project_clipspace_to_world(a_Position); 2760 gl_Position = vec4(a_Position, 0, 1); 2761} 2762`,nUt=` 2763layout(std140) uniform SceneUniforms { 2764 mat3 u_ProjectionMatrix; 2765 mat3 u_ViewMatrix; 2766 mat3 u_ViewProjectionInvMatrix; 2767 float u_ZoomScale; 2768 float u_CheckboardStyle; 2769}; 2770 2771out vec4 outputColor; 2772 2773in vec2 v_Position; 2774 2775const vec4 GRID_COLOR = vec4(0.87, 0.87, 0.87, 1.0); 2776const vec4 PAGE_COLOR = vec4(0.986, 0.986, 0.986, 1.0); 2777const int CHECKERBOARD_STYLE_NONE = 0; 2778const int CHECKERBOARD_STYLE_GRID = 1; 2779const int CHECKERBOARD_STYLE_DOTS = 2; 2780const float BASE_GRID_PIXEL_SIZE = 100.0; 2781const float BASE_DOT_SIZE = 8.0; 2782 2783vec2 scale_grid_size(float zoom) { 2784 if (zoom < 0.125) return vec2(BASE_GRID_PIXEL_SIZE * 125.0, 0.125); 2785 else if (zoom < 0.25) return vec2(BASE_GRID_PIXEL_SIZE * 25.0, 0.25); 2786 else if (zoom < 0.5) return vec2(BASE_GRID_PIXEL_SIZE * 5.0, 0.5); 2787 return vec2(BASE_GRID_PIXEL_SIZE, 4.0); 2788} 2789 2790vec4 render_grid_checkerboard(vec2 coord) { 2791 float alpha = 0.0; 2792 2793 vec2 size = scale_grid_size(u_ZoomScale); 2794 float gridSize1 = size.x; 2795 float gridSize2 = gridSize1 / 10.0; 2796 float zoomStep = size.y; 2797 int checkboardStyle = int(floor(u_CheckboardStyle + 0.5)); 2798 2799 if (checkboardStyle == CHECKERBOARD_STYLE_GRID) { 2800 vec2 grid1 = abs(fract(coord / gridSize1 - 0.5) - 0.5) / fwidth(coord) * gridSize1 / 2.0; 2801 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2; 2802 float v1 = 1.0 - min(min(grid1.x, grid1.y), 1.0); 2803 float v2 = 1.0 - min(min(grid2.x, grid2.y), 1.0); 2804 2805 if (v1 > 0.0) { 2806 alpha = v1; 2807 } else { 2808 alpha = v2 * clamp(u_ZoomScale / zoomStep, 0.0, 1.0); 2809 } 2810 } else if (checkboardStyle == CHECKERBOARD_STYLE_DOTS) { 2811 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2;
2812 alpha = 1.0 - smoothstep(0.0, 1.0, length(grid2) - BASE_DOT_SIZE * u_ZoomScale / zoomStep); 2813 } 2814 2815 return mix(PAGE_COLOR, GRID_COLOR, alpha); 2816} 2817 2818void main() { 2819 outputColor = render_grid_checkerboard(v_Position); 2820} 2821`;var mc=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},NP=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},X1,DC,PC,kP,LP,UP;let Xlt=class{constructor(){X1.set(this,void 0),DC.set(this,void 0),PC.set(this,void 0),kP.set(this,void 0),LP.set(this,void 0),UP.set(this,new Z3t)}appendVertex(t,e){mc(this,UP,"f").appendFloat(t).appendFloat(e)}render(t,e,r){if(!mc(this,X1,"f")){NP(this,X1,t.createProgram({vertex:{glsl:oUt},fragment:{glsl:nUt}}),"f"),NP(this,PC,t.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{format:I.F32_RG,offset:0,shaderLocation:0}]}],indexBufferFormat:null,program:mc(this,X1,"f")}),"f"),NP(this,DC,t.createRenderPipeline({inputLayout:mc(this,PC,"f"),program:mc(this,X1,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],topology:Go.TRIANGLE_STRIP}),"f"),mc(this,UP,"f").clear(),this.appendVertex(-1,-1),this.appendVertex(-1,1),this.appendVertex(1,-1),this.appendVertex(1,1);const i=mc(this,UP,"f").bytes(),s=t.createBuffer({viewOrSize:i.byteLength,usage:dt.VERTEX,hint:Et.DYNAMIC});NP(this,LP,s,"f"),s.setSubData(0,i),NP(this,kP,t.createBindings({pipeline:mc(this,DC,"f"),uniformBufferBindings:[{buffer:r}]}),"f")}
2821e.setBindings(mc(this,kP,"f")),e.setPipeline(mc(this,DC,"f")),e.setVertexInput(mc(this,PC,"f"),[{buffer:mc(this,LP,"f")}],null),e.draw(4)}destroy(){mc(this,X1,"f").destroy(),mc(this,LP,"f").destroy(),mc(this,DC,"f").destroy(),mc(this,PC,"f").destroy(),mc(this,kP,"f").destroy()}};X1=new WeakMap,DC=new WeakMap,PC=new WeakMap,kP=new WeakMap,LP=new WeakMap,UP=new WeakMap;let zlt=class extends _9{constructor(){super(...arguments),this.renderable=!1}containsPoint(t,e){throw new Error("Method not implemented.")}render(t,e,r){}destroy(){}};var aUt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},S_=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Ys=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},FC,Zc,T_,z1,V1,GP,WP,b9;(function(t){t[t.NONE=0]="NONE",t[t.GRID=1]="GRID",t[t.DOTS=2]="DOTS"})(b9||(b9={}));let lUt=class{constructor(){FC.set(this,void 0),Zc.set(this,void 0),T_.set(this,void 0),z1.set(this,void 0),V1.set(this,void 0),GP.set(this,b9.GRID),WP.set(this,void 0)}apply(t){const{hooks:e,canvas:r,renderer:i,shaderCompilerPath:s,devicePixelRatio:o,camera:n}=t;e.initAsync.tapPromise(()=>aUt(this,void 0,void 0,function*(){let a;i==="webgl"?a=new hd({targets:["webgl2","webgl1"],antialias:!0,shaderDebug:!0,trackResources:!0,onContextCreationError:()=>{},onContextLost:()=>{},onContextRestored(u){}}):a=new ud({shaderCompilerPath:s,onContextLost:()=>{}});const{width:l,height:c}=r,h=yield a.createSwapChain(r);h.configureSwapChain(l,c),S_(this,FC,h,"f"),S_(this,Zc,h.getDevice(),"f"),S_(this,T_,Ys(this,Zc,"f").createRenderTargetFromTexture(Ys(this,Zc,"f").createTexture({format:I.U8_RGBA_RT,width:l,height:c,usage:xr.RENDER_TARGET})),"f"),S_(this,V1,Ys(this,Zc,"f").createBuffer({viewOrSize:new Float32Array([...L1(n.projectionMatrix),...L1(n.viewMatrix),...L1(n.viewProjectionMatrixInv),n.zoom,Ys(this,GP,"f"),0,0]),usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),S_(this,WP,new Xlt,"f")})),e.resize.tap((a,l)=>{Ys(this,FC,"f").configureSwapChain(a*o,l*o),Ys(this,T_,"f")&&(Ys(this,T_,"f").destroy(),S_(this,T_,Ys(this,Zc,"f").createRenderTargetFromTexture(Ys(this,Zc,"f").createTexture({format:I.U8_RGBA_RT,width:a*o,height:l*o,usage:xr.RENDER_TARGET})),"f"))}),e.destroy.tap(()=>{Ys(this,V1,"f").destroy(),Ys(this,WP,"f").destroy(),Ys(this,T_,"f").destroy(),Ys(this,Zc,"f").destroy(),Ys(this,Zc,"f").checkForLeaks()}),e.beginFrame.tap(()=>{const{width:a,height:l}=Ys(this,FC,"f").getCanvas(),c=Ys(this,FC,"f").getOnscreenTexture();Ys(this,V1,"f").setSubData(0,new Uint8Array(new Float32Array([...L1(n.projectionMatrix),...L1(n.viewMatrix),...L1(n.viewProjectionMatrixInv),n.zoom,Ys(this,GP,"f"),0,0]).buffer)),Ys(this,Zc,"f").beginFrame(),S_(this,z1,Ys(this,Zc,"f").createRenderPass({colorAttachment:[Ys(this,T_,"f")],colorResolveTo:[c],colorClearColor:[op]}),"f"),Ys(this,z1,"f").setViewport(0,0,a,l),Ys(this,WP,"f").render(Ys(this,Zc,"f"),Ys(this,z1,"f"),Ys(this,V1,"f"))}),e.endFrame.tap(()=>{Ys(this,Zc,"f").submitPass(Ys(this,z1,"f")),Ys(this,Zc,"f").endFrame()}),e.render.tap(a=>{a.transform.updateTransform(a.parent?a.parent.transform:Wlt),a.render(Ys(this,Zc,"f"),Ys(this,z1,"f"),Ys(this,V1,"f"))})}setCheckboardStyle(t){S_(this,GP,t,"f")}};FC=new WeakMap,Zc=new WeakMap,T_=new WeakMap,z1=new WeakMap,V1=new WeakMap,GP=new WeakMap,WP=new WeakMap;var Fp=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Y1=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
2821return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},jP,$1,R_,NC;const cUt=.02,hUt=4,uUt=100,XP=[.02,.05,.1,.15,.2,.33,.5,.75,1,1.25,1.5,2,2.5,3,4],dUt=t=>XP.find(e=>e>t)||XP[XP.length-1],fUt=t=>[...XP].reverse().find(e=>e<t)||XP[0];let pUt=class{constructor(){jP.set(this,void 0),$1.set(this,{}),R_.set(this,void 0),NC.set(this,!1)}apply(t){const{canvas:e,camera:r,root:i,api:{client2Viewport:s}}=t;i.hitArea=new Ua(-Number.MAX_VALUE,-Number.MAX_VALUE,1/0,1/0),i.draggable=!0;const o=Bt();let n,a,l;const c=it();let h,u=!1;function d(y){const _=e.getBoundingClientRect(),w=y.nativeEvent.clientX-_.left,E=y.nativeEvent.clientY-_.top,A=w/e.clientWidth,x=E/e.clientHeight,S=A*2-1,T=x*-2+1;return[S,T]}function f(y){const _=Qt(it(),d(y),o);r.x=n+c[0]-_[0],r.y=a+c[1]-_[1]}function g(y){const _=(y.nativeEvent.clientX-h[0])/100,w=Bt();bi(w,w,[c[0],c[1]]),Mo(w,w,_),bi(w,w,[-c[0],-c[1]]),r.x=n,r.y=a,r.rotation=l,us(w,w,r.matrix),r.rotation=l+_,r.x=w[6],r.y=w[7]}i.addEventListener("dragstart",y=>{Fp(this,R_,"f")||(u=y.shiftKey,fp(o,r.viewProjectionMatrixInv),n=r.x,a=r.y,l=r.rotation,Qt(c,d(y),o),h=[y.nativeEvent.clientX,y.nativeEvent.clientY])}),i.addEventListener("drag",y=>{Fp(this,R_,"f")||(u?g(y):f(y))}),i.addEventListener("dragend",y=>{Fp(this,R_,"f")||(u=!1)});const p=(y,_)=>{const w=Math.max(cUt,Math.min(hUt,r.zoom*Math.pow(2,_*-.01))),E=s(y);r.gotoLandmark(r.createLandmark({viewportX:E.x,viewportY:E.y,zoom:w}),{duration:0})};i.addEventListener("wheel",y=>{y.preventDefault(),p({x:y.nativeEvent.clientX,y:y.nativeEvent.clientY},y.deltaY)});const m=y=>{y.pointerType==="mouse"?Y1(this,jP,!0,"f"):Fp(this,$1,"f")[y.pointerId]||(Fp(this,$1,"f")[y.pointerId]={last:null}),this.touchCount>=2?Y1(this,R_,!0,"f"):Y1(this,R_,!1,"f")},v=y=>{if(y.pointerType==="mouse"&&Y1(this,jP,!1,"f"),y.pointerType!=="mouse"&&delete Fp(this,$1,"f")[y.pointerId],Fp(this,NC,"f")&&this.touchCount<=1)return Y1(this,NC,!1,"f"),Y1(this,R_,!1,"f"),!0},b=y=>{if(this.touchCount>=2){const _=y.global.x,w=y.global.y,E=Fp(this,$1,"f"),A=Object.keys(E),x=Number(A[0]),S=Number(A[1]),T=E[x],R=E[S],B=T.last&&R.last?Math.sqrt(Math.pow(R.last.x-T.last.x,2)+Math.pow(R.last.y-T.last.y,2)):null;if(x===y.pointerId?T.last={x:_,y:w}:S===y.pointerId&&(R.last={x:_,y:w}),B){const O=new ye(T.last.x+(R.last.x-T.last.x)/2,T.last.y+(R.last.y-T.last.y)/2),C=Math.sqrt(Math.pow(R.last.x-T.last.x,2)+Math.pow(R.last.y-T.last.y,2));p(O,(B/C-1)*uUt)}else Fp(this,NC,"f")||Y1(this,NC,!0,"f")}};i.addEventListener("pointerdown",m),i.addEventListener("pointermove",b),i.addEventListener("pointerup",v),i.addEventListener("pointerupoutside",v),i.addEventListener("pointercancel",v)}get touchCount(){return(Fp(this,jP,"f")?1:0)+Object.keys(Fp(this,$1,"f")).length}};jP=new WeakMap,$1=new WeakMap,R_=new WeakMap,NC=new WeakMap;let gUt=class{apply(t){const{canvas:e,hooks:r,globalThis:i,supportsPointerEvents:s,supportsTouchEvents:o}=t,n=y=>{y.preventDefault(),r.pointerMove.call(y)},a=y=>{r.pointerUp.call(y)},l=y=>{r.pointerDown.call(y)},c=y=>{r.pointerOver.call(y)},h=y=>{r.pointerOut.call(y)},u=y=>{r.pointerCancel.call(y)},d=y=>{r.pointerWheel.call(y)},f=y=>{i.document.addEventListener("pointermove",n,!0),y.addEventListener("pointerdown",l,!0),y.addEventListener("pointerleave",h,!0),y.addEventListener("pointerover",c,!0),i.addEventListener("pointerup",a,!0),i.addEventListener("pointercancel",u,!0)},g=y=>{y.addEventListener("touchstart",l,!0),y.addEventListener("touchend",a,!0),y.addEventListener("touchmove",n,!0),y.addEventListener("touchcancel",u,!0)},p=y=>{i.document.addEventListener("mousemove",n,!0),y.addEventListener("mousedown",l,!0),y.addEventListener("mouseout",h,!0),y.addEventListener("mouseover",c,!0),i.addEventListener("mouseup",a,!0)},m=y=>{i.document.removeEventListener("pointermove",n,!0),y.removeEventListener("pointerdown",l,!0),y.removeEventListener("pointerleave",h,!0),y.removeEventListener("pointerover",c,!0),i.removeEventListener("pointerup",a,!0)},v=y=>{y.removeEventListener("touchstart",l,!0),y.removeEventListener("touchend",a,!0),y.removeEventListener("touchmove",n,!0),y.removeEventListener("touchcancel",u,!0)},b=y=>{i.document.removeEventListener("mousemove",n,!0),y.removeEventListener("mousedown",l,!0),y.removeEventListener("mouseout",h,!0),y.removeEventListener("mouseover",c,!0),i.removeEventListener("mouseup",a,!0)};r.init.tap(()=>{s?f(e):(p(e),o&&g(e)),e.addEventListener("wheel",d,{capture:!0})}),r.destroy.tap(()=>{s?m(e):(b(e),o&&v(e)),e.removeEventListener("wheel",d,!0)})}};var Vlt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
2821return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},wl=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},w9,zP,E9,Np,C0;const mUt=1,yUt={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};let vUt=class{constructor(){w9.set(this,!0),zP.set(this,new Pp(null)),E9.set(this,new v9(null)),Np.set(this,void 0),C0.set(this,void 0),this.onPointerMove=t=>{const e=this.normalizeToPointerEvent(t);for(const r of e){const i=this.bootstrapEvent(wl(this,zP,"f"),r);wl(this,Np,"f").mapEvent(i)}this.setCursor(wl(this,Np,"f").cursor)}}apply(t){const{hooks:e,root:r}=t;Vlt(this,C0,t,"f"),Vlt(this,Np,new eUt(r),"f"),wl(this,Np,"f").setPickHandler((i,s)=>{const{picked:o}=e.pickSync.call({position:{x:i,y:s},picked:[],topmost:!0});return o[0]||null}),e.pointerWheel.tap(i=>{const s=this.normalizeWheelEvent(i);wl(this,Np,"f").mapEvent(s)}),e.pointerDown.tap(i=>{const s=this.normalizeToPointerEvent(i);wl(this,w9,"f")&&s[0].isNormalized&&(i.cancelable||!("cancelable"in i))&&i.preventDefault();for(let o=0,n=s.length;o<n;o++){const a=s[o],l=this.bootstrapEvent(wl(this,zP,"f"),a);wl(this,Np,"f").mapEvent(l)}this.setCursor(wl(this,Np,"f").cursor)}),e.pointerUp.tap(i=>{let s=i.target;i.composedPath&&i.composedPath().length>0&&(s=i.composedPath()[0]);const o=s!==wl(this,C0,"f").canvas?"outside":"",n=this.normalizeToPointerEvent(i);for(let a=0,l=n.length;a<l;a++){const c=this.bootstrapEvent(wl(this,zP,"f"),n[a]);c.type+=o,wl(this,Np,"f").mapEvent(c)}this.setCursor(wl(this,Np,"f").cursor)}),e.pointerMove.tap(this.onPointerMove),e.pointerOver.tap(this.onPointerMove),e.pointerOut.tap(this.onPointerMove),e.pointerCancel.tap(this.onPointerMove)}normalizeWheelEvent(t){const e=wl(this,E9,"f");this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode;const{x:r,y:i}=this.getViewportXY(t);e.client.x=r,e.client.y=i;const{x:s,y:o}=wl(this,C0,"f").api.viewport2Canvas(e.client);return e.screen.x=s,e.screen.y=o,e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null}setCursor(t){wl(this,C0,"f").canvas.style.cursor=t}normalizeToPointerEvent(t){const{supportsTouchEvents:e,supportsPointerEvents:r}=wl(this,C0,"f"),i=[];if(e&&t instanceof TouchEvent)for(let s=0;s<t.changedTouches.length;s++){const o=t.changedTouches[s];oa(o.button)&&(o.button=0),oa(o.buttons)&&(o.buttons=1),oa(o.isPrimary)&&(o.isPrimary=t.touches.length===1&&t.type==="touchstart"),oa(o.width)&&(o.width=o.radiusX||1),oa(o.height)&&(o.height=o.radiusY||1),oa(o.tiltX)&&(o.tiltX=0),oa(o.tiltY)&&(o.tiltY=0),oa(o.pointerType)&&(o.pointerType="touch"),oa(o.pointerId)&&(o.pointerId=o.identifier||0),oa(o.pressure)&&(o.pressure=o.force||.5),oa(o.twist)&&(o.twist=0),oa(o.tangentialPressure)&&(o.tangentialPressure=0),o.isNormalized=!0,o.type=t.type,i.push(o)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!r||!(t instanceof globalThis.PointerEvent))){const s=t;oa(s.isPrimary)&&(s.isPrimary=!0),oa(s.width)&&(s.width=1),oa(s.height)&&(s.height=1),oa(s.tiltX)&&(s.tiltX=0),oa(s.tiltY)&&(s.tiltY=0),oa(s.pointerType)&&(s.pointerType="mouse"),oa(s.pointerId)&&(s.pointerId=mUt),oa(s.pressure)&&(s.pressure=.5),oa(s.twist)&&(s.twist=0),oa(s.tangentialPressure)&&(s.tangentialPressure=0),s.isNormalized=!0,i.push(s)}else i.push(t);return i}bootstrapEvent(t,e){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);const{x:r,y:i}=this.getViewportXY(e);t.client.x=r,t.client.y=i;const{x:s,y:o}=wl(this,C0,"f").api.viewport2Canvas(t.client);return t.screen.x=s,t.screen.y=o,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=yUt[t.type]||t.type),t}getViewportXY(t){let e,r;const{offsetX:i,offsetY:s,clientX:o,clientY:n}=t;if(!klt(i)&&!klt(s))e=i,r=s;else{const a=wl(this,C0,"f").api.client2Viewport({x:o,y:n});e=a.x,r=a.y}return{x:e,y:r}}};w9=new WeakMap,zP=new WeakMap,E9=new WeakMap,Np=new WeakMap,C0=new WeakMap;const Ylt=new ye;let _Ut=class{apply(t){const{hooks:e,root:r}=t;e.pickSync.tap(i=>this.pick(i,r))}pick(t,e){const{position:{x:r,y:i}}=t,s=[];return IW(e,o=>{this.hitTest(o,r,i)&&s.unshift(o)}),t.picked=s,t}hitTest(t,e,r){if(t.pointerEvents==="none")return!1;if(t.hitArea||t.renderable){t.worldTransform.applyInverse({x:e,y:r},Ylt);const{x:i,y:s}=Ylt;return t.hitArea?t.hitArea.contains(i,s):t.containsPoint(i,s)}return!1}};var bUt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
2821return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},$lt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},VP;function Hlt(t,e){do{if(t&&e(t))return t;t=t.parent}while(t!==void 0);return null}let wUt=class{constructor(t={}){VP.set(this,void 0),bUt(this,VP,Object.assign({overlap:"pointer",dragstartTimeThreshold:0,dragstartDistanceThreshold:0},t),"f")}apply(t){const{root:e,hooks:r,api:{elementsFromPoint:i}}=t,s=o=>{const n=o.target,a=Hlt(n,l=>l.draggable===!0);if(a){let l=!1;const c=o.timeStamp,h=[o.clientX,o.clientY];let u=null,d=[o.clientX,o.clientY];const f=p=>{if(!l){const y=p.timeStamp-c,_=Plt(p.clientX,p.clientY,...h);if(y<=$lt(this,VP,"f").dragstartTimeThreshold||_<=$lt(this,VP,"f").dragstartDistanceThreshold)return;p.type="dragstart",a.dispatchEvent(p),l=!0}p.type="drag",p.dx=p.clientX-d[0],p.dy=p.clientY-d[1],a.dispatchEvent(p),d=[p.clientX,p.clientY];const m=[p.globalX,p.globalY],v=i(m[0],m[1]),b=v[v.indexOf(n)+1];if(b){const y=Hlt(b,_=>_.droppable===!0);u!==y&&(u&&(p.type="dragleave",p.target=u,u.dispatchEvent(p)),y&&(p.type="dragenter",p.target=y,y.dispatchEvent(p)),u=y,u&&(p.type="dragover",p.target=u,u.dispatchEvent(p)))}};e.addEventListener("pointermove",f);const g=function(p){if(l){p.detail={preventClick:!0};const m=p;u&&(m.type="drop",m.target=u,u.dispatchEvent(m)),m.type="dragend",a.dispatchEvent(m),l=!1}e.removeEventListener("pointermove",f)};n.addEventListener("pointerup",g,{once:!0}),n.addEventListener("pointerupoutside",g,{once:!0})}};r.init.tap(()=>{e.addEventListener("pointerdown",s)}),r.destroy.tap(()=>{e.removeEventListener("pointerdown",s)})}};VP=new WeakMap;var EUt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},na=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},YP=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},LW,Td,$P,UW,C_,HP;let Klt=class{get root(){return na(this,C_,"f")}get camera(){return na(this,HP,"f")}constructor(t){LW.set(this,void 0),Td.set(this,void 0),$P.set(this,void 0),UW.set(this,void 0),C_.set(this,new zlt),HP.set(this,void 0);const{canvas:e,renderer:r="webgl",shaderCompilerPath:i="",devicePixelRatio:s}=t,o=K3t(),n=s??o.devicePixelRatio,a=!!o.PointerEvent,l="ontouchstart"in o,{width:c,height:h}
2821=e,u=new Ult(c/n,h/n);YP(this,HP,u,"f"),YP(this,Td,{globalThis:o,canvas:e,renderer:r,shaderCompilerPath:i,devicePixelRatio:n,supportsPointerEvents:a,supportsTouchEvents:l,hooks:{init:new Sd,initAsync:new $3t,beginFrame:new Sd,render:new Sd,endFrame:new Sd,destroy:new Sd,resize:new Sd,pointerDown:new Sd,pointerUp:new Sd,pointerMove:new Sd,pointerOut:new Sd,pointerOver:new Sd,pointerWheel:new Sd,pointerCancel:new Sd,pickSync:new H3t},camera:u,root:na(this,C_,"f"),api:{elementsFromPoint:this.elementsFromPoint.bind(this),elementFromPoint:this.elementFromPoint.bind(this),client2Viewport:this.client2Viewport.bind(this),viewport2Canvas:u.viewport2Canvas.bind(u),viewport2Client:this.viewport2Client.bind(this),canvas2Viewport:u.canvas2Viewport.bind(u)}},"f"),YP(this,$P,new lUt,"f"),YP(this,UW,new vUt,"f");const d=[new gUt,na(this,UW,"f"),new _Ut,new pUt,na(this,$P,"f"),new wUt({dragstartTimeThreshold:100,dragstartDistanceThreshold:10})];YP(this,LW,EUt(this,void 0,void 0,function*(){const{hooks:f}=na(this,Td,"f");return d.forEach(g=>{g.apply(na(this,Td,"f"))}),f.init.call(),yield f.initAsync.promise(),this}),"f")}get initialized(){return na(this,LW,"f").then(()=>this)}render(){const{hooks:t}=na(this,Td,"f");t.beginFrame.call(),IW(na(this,C_,"f"),e=>{t.render.call(e)}),t.endFrame.call()}resize(t,e){const{hooks:r}=na(this,Td,"f");na(this,HP,"f").projection(t,e),r.resize.call(t,e)}destroy(){const{hooks:t}=na(this,Td,"f");IW(na(this,C_,"f"),e=>{e.destroy()}),t.destroy.call()}getDOM(){return na(this,Td,"f").canvas}appendChild(t){na(this,C_,"f").appendChild(t)}removeChild(t){na(this,C_,"f").removeChild(t)}setCheckboardStyle(t){na(this,$P,"f").setCheckboardStyle(t)}elementsFromPoint(t,e){const{picked:r}=na(this,Td,"f").hooks.pickSync.call({topmost:!1,position:{x:t,y:e},picked:[]});return r}elementFromPoint(t,e){const{picked:r}=na(this,Td,"f").hooks.pickSync.call({topmost:!0,position:{x:t,y:e},picked:[]});return r[0]}client2Viewport({x:t,y:e}){const{left:r,top:i}=na(this,Td,"f").canvas.getBoundingClientRect();return{x:t-r,y:e-i}}viewport2Client({x:t,y:e}){const{left:r,top:i}=na(this,Td,"f").canvas.getBoundingClientRect();return{x:t+r,y:e+i}}zoomIn(){const{camera:t}=this;t.cancelLandmarkAnimation();const e=t.createLandmark({viewportX:t.width/2,viewportY:t.height/2,zoom:dUt(t.zoom)});t.gotoLandmark(e,{duration:300,easing:"ease"})}zoomOut(){const{camera:t}=this;t.cancelLandmarkAnimation();const e=t.createLandmark({viewportX:t.width/2,viewportY:t.height/2,zoom:fUt(t.zoom)});t.gotoLandmark(e,{duration:300,easing:"ease"})}};LW=new WeakMap,Td=new WeakMap,$P=new WeakMap,UW=new WeakMap,C_=new WeakMap,HP=new WeakMap;const GW=globalThis,A9=GW.ShadowRoot&&(GW.ShadyCSS===void 0||GW.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,x9=Symbol(),qlt=new WeakMap;let Zlt=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==x9)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(A9&&t===void 0){const r=e!==void 0&&e.length===1;r&&(t=qlt.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&qlt.set(e,t))}return t}toString(){return this.cssText}},Jlt,Qlt,S9;Jlt=t=>new Zlt(typeof t=="string"?t:t+"",void 0,x9),Lc=(t,...e)=>{const r=t.length===1?t[0]:e.reduce(((i,s,o)=>i+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[o+1]),t[0]);return new Zlt(r,t,x9)},Qlt=(t,e)=>{if(A9)t.adoptedStyleSheets=e.map((r=>r instanceof CSSStyleSheet?r:r.styleSheet));else for(const r of e){const i=document.createElement("style"),s=GW.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=r.cssText,t.appendChild(i)}},S9=A9?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let r="";for(const i of e.cssRules)r+=i.cssText;return Jlt(r)})(t):t;const{is:AUt,defineProperty:xUt,getOwnPropertyDescriptor:SUt,getOwnPropertyNames:TUt,getOwnPropertySymbols:RUt,getPrototypeOf:CUt}=Object,M_=globalThis,tct=M_.trustedTypes,MUt=tct?tct.emptyScript:"",T9=M_.reactiveElementPolyfillSupport,KP=(t,e)=>
vendor: 6,150 bytes, line 2821
2821t,WW={toAttribute(t,e){switch(e){case Boolean:t=t?MUt:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let r=t;switch(e){case Boolean:r=t!==null;break;case Number:r=t===null?null:Number(t);break;case Object:case Array:try{r=JSON.parse(t)}catch{r=null}}return r}},jW=(t,e)=>!AUt(t,e),ect={attribute:!0,type:String,converter:WW,reflect:!1,hasChanged:jW};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),M_.litPropertyMetadata??(M_.litPropertyMetadata=new WeakMap);let kC=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=ect){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const r=Symbol(),i=this.getPropertyDescriptor(t,r,e);i!==void 0&&xUt(this.prototype,t,i)}}static getPropertyDescriptor(t,e,r){const{get:i,set:s}=SUt(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get(){return i==null?void 0:i.call(this)},set(o){const n=i==null?void 0:i.call(this);s.call(this,o),this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??ect}static _$Ei(){if(this.hasOwnProperty(KP("elementProperties")))return;const t=CUt(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(KP("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(KP("properties"))){const e=this.properties,r=[...TUt(e),...RUt(e)];for(const i of r)this.createProperty(i,e[i])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[r,i]of e)this.elementProperties.set(r,i)}this._$Eh=new Map;for(const[e,r]of this.elementProperties){const i=this._$Eu(e,r);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const r=new Set(t.flat(1/0).reverse());for(const i of r)e.unshift(S9(i))}else t!==void 0&&e.push(S9(t));return e}static _$Eu(t,e){const r=e.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach((e=>e(this)))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$EO)==null||e.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Qlt(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach((e=>{var r;return(r=e.hostConnected)==null?void 0:r.call(e)}))}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach((e=>{var r;return(r=e.hostDisconnected)==null?void 0:r.call(e)}))}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$EC(t,e){var s;const r=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,r);if(i!==void 0&&r.reflect===!0){const o=(((s=r.converter)==null?void 0:s.toAttribute)!==void 0?r.converter:WW).toAttribute(e,r.type);this._$Em=t,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,e){var s;const r=this.constructor,i=r._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const o=r.getPropertyOptions(i),n=typeof o.converter=="function"?{fromAttribute:o.converter}:((s=o.converter)==null?void 0:s.fromAttribute)!==void 0?o.converter:WW;this._$Em=i,this[i]=n.fromAttribute(e,o.type),this._$Em=null}}requestUpdate(t,e,r){if(t!==void 0){if(r??(r=this.constructor.getPropertyOptions(t)),!(r.hasChanged??jW)(this[t],e))return;this.P(t,e,r)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,r){this._$AL.has(t)||this._$AL.set(t,e),r.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var r;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[s,o]of this._$Ep)this[s]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[s,o]of i)o.wrapped!==!0||this._$AL.has(s)||this[s]===void 0||this.P(s,this[s],o)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(r=this._$EO)==null||r.forEach((i=>{var s;return(s=i.hostUpdate)==null?void 0:s.call(i)})),this.update(e)):this._$EU()}catch(i){throw t=!1,this._$EU(),i}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach((r=>{var i;return(i=r.hostUpdated)==null?void 0:i.call(r)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach((e=>this._$EC(e,this[e])))),this._$EU()}updated(t){}firstUpdated(t){}};kC.elementStyles=[],kC.shadowRootOptions={mode:"open"},kC[KP("elementProperties")]=new Map,kC[KP("finalized")]=new Map,T9==null||T9({ReactiveElement:kC}),(M_.reactiveElementVersions??(M_.reactiveElementVersions=[])).push("2.0.4");let LC,qP,R9,C9,M0,M9,rct,B_,UC,GC,XW,ict,zW,WC,B9,O9,O_,I9,D9,P9,sct,F9,I_;LC=globalThis,qP=LC.trustedTypes,R9=qP?qP.createPolicy("lit-html",{createHTML:t=>t}):void 0,C9="$lit$",M0=`lit$${Math.random().toFixed(9).slice(2)}$`,M9="?"+M0,rct=`<${M9}>
vendor: 5,203 bytes, lines 2821-2823
2821`,B_=document,UC=()=>B_.createComment(""),GC=t=>t===null||typeof t!="object"&&typeof t!="function",XW=Array.isArray,ict=t=>XW(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",zW=`[ 2822\f\r]`,WC=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,B9=/-->/g,O9=/>/g,O_=RegExp(`>|${zW}(?:([^\\s"'>=/]+)(${zW}*=${zW}*(?:[^ 2823\f\r"'\`<>=]|("|')|))|$)`,"g"),I9=/'/g,D9=/"/g,P9=/^(?:script|style|textarea|title)$/i,sct=t=>(e,...r)=>({_$litType$:t,strings:e,values:r}),Ao=sct(1),tE=Symbol.for("lit-noChange"),al=Symbol.for("lit-nothing"),F9=new WeakMap,I_=B_.createTreeWalker(B_,129);function oct(t,e){if(!XW(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return R9!==void 0?R9.createHTML(e):e}const BUt=(t,e)=>{const r=t.length-1,i=[];let s,o=e===2?"<svg>":e===3?"<math>":"",n=WC;for(let a=0;a<r;a++){const l=t[a];let c,h,u=-1,d=0;for(;d<l.length&&(n.lastIndex=d,h=n.exec(l),h!==null);)d=n.lastIndex,n===WC?h[1]==="!--"?n=B9:h[1]!==void 0?n=O9:h[2]!==void 0?(P9.test(h[2])&&(s=RegExp("</"+h[2],"g")),n=O_):h[3]!==void 0&&(n=O_):n===O_?h[0]===">"?(n=s??WC,u=-1):h[1]===void 0?u=-2:(u=n.lastIndex-h[2].length,c=h[1],n=h[3]===void 0?O_:h[3]==='"'?D9:I9):n===D9||n===I9?n=O_:n===B9||n===O9?n=WC:(n=O_,s=void 0);const f=n===O_&&t[a+1].startsWith("/>")?" ":"";o+=n===WC?l+rct:u>=0?(i.push(c),l.slice(0,u)+C9+l.slice(u)+M0+f):l+M0+(u===-2?a:f)}return[oct(t,o+(t[r]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]};class ZP{constructor({strings:e,_$litType$:r},i){let s;this.parts=[];let o=0,n=0;const a=e.length-1,l=this.parts,[c,h]=BUt(e,r);if(this.el=ZP.createElement(c,i),I_.currentNode=this.el.content,r===2||r===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=I_.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const u of s.getAttributeNames())if(u.endsWith(C9)){const d=h[n++],f=s.getAttribute(u).split(M0),g=/([.?@])?(.*)/.exec(d);l.push({type:1,index:o,name:g[2],strings:f,ctor:g[1]==="."?IUt:g[1]==="?"?DUt:g[1]==="@"?PUt:YW}),s.removeAttribute(u)}else u.startsWith(M0)&&(l.push({type:6,index:o}),s.removeAttribute(u));if(P9.test(s.tagName)){const u=s.textContent.split(M0),d=u.length-1;if(d>0){s.textContent=qP?qP.emptyScript:"";for(let f=0;f<d;f++)s.append(u[f],UC()),I_.nextNode(),l.push({type:2,index:++o});s.append(u[d],UC())}}}else if(s.nodeType===8)if(s.data===M9)l.push({type:2,index:o});else{let u=-1;for(;(u=s.data.indexOf(M0,u+1))!==-1;)l.push({type:7,index:o}),u+=M0.length-1}o++}}static createElement(e,r){const i=B_.createElement("template");return i.innerHTML=e,i}}function jC(t,e,r=t,i){var n,a;if(e===tE)return e;let s=i!==void 0?(n=r._$Co)==null?void 0:n[i]:r._$Cl;const o=GC(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),o===void 0?s=void 0:(s=new o(t),s._$AT(t,r,i)),i!==void 0?(r._$Co??(r._$Co=[]))[i]=s:r._$Cl=s),s!==void 0&&(e=jC(t,s._$AS(t,e.values),s,i)),e}class OUt{constructor(e,r){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=r}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:r},parts:i}=this._$AD,s=((e==null?void 0:e.creationScope)??B_).importNode(r,!0);I_.currentNode=s;let o=I_.nextNode(),n=0,a=0,l=i[0];for(;l!==void 0;){if(n===l.index){let c;l.type===2?c=new VW(o,o.nextSibling,this,e):l.type===1?c=new l.ctor(o,l.name,l.strings,this,e):l.type===6&&(c=new FUt(o,this,e)),this._$AV.push(c),l=i[++a]}n!==(l==null?void 0:l.index)&&(o=I_.nextNode(),n++)}return I_.currentNode=B_,s}p(e){let r=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,r),r+=i.strings.length-2):i._$AI(e[r])),r++}}let VW=class d1t{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,r,i,s){this.type=2,this._$AH=al,this._$AN=void 0,this._$AA=e,this._$AB=r,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const r=this._$AM;return r!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=r.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,r=this){e=jC(this,e,r),GC(e)?e===al||e==null||e===""?(this._$AH!==al&&this._$AR(),this._$AH=al):e!==this._$AH&&e!==tE&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):ict(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==al&&GC(this._$AH)?this._$AA.nextSibling.data=e:this.T(B_.createTextNode(e)),this._$AH=e}$(e){var o;const{values:r,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=ZP.createElement(oct(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(r);else{const n=new OUt(s,this),a=n.u(this.options);n.p(r),this.T(a),this._$AH=n}}_$AC(e){let r=F9.get(e.strings);return r===void 0&&F9.set(e.strings,r=new ZP(e)),r}k(e){XW(this._$AH)||(this._$AH=[],this._$AR());const r=this._$AH;let i,s=0;for(const o of e)s===r.length?r.push(i=new d1t(this.O(UC()),this.O(UC()),this,this.options)):i=r[s],i._$AI(o),s++;s<r.length&&(this._$AR(i&&i._$AB.nextSibling,s),r.length=s)}_$AR(e=this._$AA.nextSibling,r){var i;
2823for((i=this._$AP)==null?void 0:i.call(this,!1,!0,r);e&&e!==this._$AB;){const s=e.nextSibling;e.remove(),e=s}}setConnected(e){var r;this._$AM===void 0&&(this._$Cv=e,(r=this._$AP)==null||r.call(this,e))}};class YW{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,r,i,s,o){this.type=1,this._$AH=al,this._$AN=void 0,this.element=e,this.name=r,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=al}_$AI(e,r=this,i,s){const o=this.strings;let n=!1;if(o===void 0)e=jC(this,e,r,0),n=!GC(e)||e!==this._$AH&&e!==tE,n&&(this._$AH=e);else{const a=e;let l,c;for(e=o[0],l=0;l<o.length-1;l++)c=jC(this,a[i+l],r,l),c===tE&&(c=this._$AH[l]),n||(n=!GC(c)||c!==this._$AH[l]),c===al?e=al:e!==al&&(e+=(c??"")+o[l+1]),this._$AH[l]=c}n&&!s&&this.j(e)}j(e){e===al?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}let IUt=class extends YW{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===al?void 0:t}};class DUt extends YW{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==al)}}let PUt=class extends YW{constructor(t,e,r,i,s){super(t,e,r,i,s),this.type=5}_$AI(t,e=this){if((t=jC(this,t,e,0)??al)===tE)return;const r=this._$AH,i=t===al&&r!==al||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,s=t!==al&&(r===al||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}};class FUt{constructor(e,r,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=r,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){jC(this,e)}}let $W;t1t={I:VW},$W=LC.litHtmlPolyfillSupport,$W==null||$W(ZP,VW),(LC.litHtmlVersions??(LC.litHtmlVersions=[])).push("3.2.1"),Btt=(t,e,r)=>{const i=(r==null?void 0:r.renderBefore)??e;let s=i._$litPart$;if(s===void 0){const o=(r==null?void 0:r.renderBefore)??null;i._$litPart$=s=new VW(e.insertBefore(UC(),o),o,void 0,r??{})}return s._$AI(t),s},Wa=class extends kC{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Btt(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return tE}},Wa._$litElement$=!0,Wa.finalized=!0,(yEt=globalThis.litElementHydrateSupport)==null||yEt.call(globalThis,{LitElement:Wa});const N9=globalThis.litElementPolyfillSupport;N9==null||N9({LitElement:Wa}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");let nct=class extends Event{constructor(t,e,r){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.callback=e,this.subscribe=r??!1}};FEt=function(t){return t};let act=class{constructor(t,e,r,i){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(s,o)=>{this.unsubscribe&&(this.unsubscribe!==o&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=s,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(s,o)),this.unsubscribe=o},this.host=t,e.context!==void 0){const s=e;this.context=s.context,this.callback=s.callback,this.subscribe=s.subscribe??!1}else this.context=e,this.callback=r,this.subscribe=i??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new nct(this.context,this.t,this.subscribe))}};class NUt{get value(){return this.o}set value(e){this.setValue(e)}setValue(e,r=!1){const i=r||!Object.is(e,this.o);this.o=e,i&&this.updateObservers()}constructor(e){this.subscriptions=new Map,this.updateObservers=()=>{for(const[r,{disposer:i}
2823]of this.subscriptions)r(this.o,i)},e!==void 0&&(this.value=e)}addCallback(e,r,i){if(!i)return void e(this.value);this.subscriptions.has(e)||this.subscriptions.set(e,{disposer:()=>{this.subscriptions.delete(e)},consumerHost:r});const{disposer:s}=this.subscriptions.get(e);e(this.value,s)}clearCallbacks(){this.subscriptions.clear()}}let lct;lct=class extends Event{constructor(t){super("context-provider",{bubbles:!0,composed:!0}),this.context=t}},eE=class extends NUt{constructor(t,e,r){var i,s;super(e.context!==void 0?e.initialValue:r),this.onContextRequest=o=>{const n=o.composedPath()[0];o.context===this.context&&n!==this.host&&(o.stopPropagation(),this.addCallback(o.callback,n,o.subscribe))},this.onProviderRequest=o=>{const n=o.composedPath()[0];if(o.context!==this.context||n===this.host)return;const a=new Set;for(const[l,{consumerHost:c}]of this.subscriptions)a.has(l)||(a.add(l),c.dispatchEvent(new nct(this.context,l,!0)));o.stopPropagation()},this.host=t,e.context!==void 0?this.context=e.context:this.context=e,this.attachListeners(),(s=(i=this.host).addController)==null||s.call(i,this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new lct(this.context))}},cm=function({context:t,subscribe:e}){return(r,i)=>{typeof i=="object"?i.addInitializer((function(){new act(this,{context:t,callback:s=>{r.set.call(this,s)},subscribe:e})})):r.constructor.addInitializer((s=>{new act(s,{context:t,callback:o=>{s[i]=o},subscribe:e})}))}};const kUt=Symbol();rE=class{get taskComplete(){return this.t||(this.i===1?this.t=new Promise(((t,e)=>{this.o=t,this.h=e})):this.i===3?this.t=Promise.reject(this.l):this.t=Promise.resolve(this.u)),this.t}constructor(t,e,r){var s;this.p=0,this.i=0,(this._=t).addController(this);const i=typeof e=="object"?e:{task:e,args:r};this.v=i.task,this.j=i.args,this.m=i.argsEqual??LUt,this.k=i.onComplete,this.A=i.onError,this.autoRun=i.autoRun??!0,"initialValue"in i&&(this.u=i.initialValue,this.i=2,this.O=(s=this.T)==null?void 0:s.call(this))}hostUpdate(){this.autoRun===!0&&this.S()}hostUpdated(){this.autoRun==="afterUpdate"&&this.S()}T(){if(this.j===void 0)return;const t=this.j();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async S(){const t=this.T(),e=this.O;this.O=t,t===e||t===void 0||e!==void 0&&this.m(e,t)||await this.run(t)}async run(t){var o,n,a,l,c;let e,r;t??(t=this.T()),this.O=t,this.i===1?(o=this.q)==null||o.abort():(this.t=void 0,this.o=void 0,this.h=void 0),this.i=1,this.autoRun==="afterUpdate"?queueMicrotask((()=>this._.requestUpdate())):this._.requestUpdate();const i=++this.p;this.q=new AbortController;let s=!1;try{e=await this.v(t,{signal:this.q.signal})}catch(h){s=!0,r=h}if(this.p===i){if(e===kUt)this.i=0;else{if(s===!1){try{(n=this.k)==null||n.call(this,e)}catch{}this.i=2,(a=this.o)==null||a.call(this,e)}else{try{(l=this.A)==null||l.call(this,r)}catch{}this.i=3,(c=this.h)==null||c.call(this,r)}this.u=e,this.l=r}this._.requestUpdate()}}abort(t){var e;this.i===1&&((e=this.q)==null||e.abort(t))}get value(){return this.u}get error(){return this.l}get status(){return this.i}render(t){var e,r,i,s;switch(this.i){case 0:return(e=t.initial)==null?void 0:e.call(t);case 1:return(r=t.pending)==null?void 0:r.call(t);case 2:return(i=t.complete)==null?void 0:i.call(t,this.value);case 3:return(s=t.error)==null?void 0:s.call(t,this.error);default:throw Error("Unexpected status: "+this.i)}}};const LUt=(t,e)=>t===e||t.length===e.length&&t.every(((r,i)=>!jW(r,e[i])));Vc=t=>(e,r)=>{r!==void 0?r.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)};const UUt={attribute:!0,type:String,converter:WW,reflect:!1,hasChanged:jW},GUt=(t=UUt,e,r)=>{const{kind:i,metadata:s}=r;let o=globalThis.litPropertyMetadata.get(s);if(o===void 0&&globalThis.litPropertyMetadata.set(s,o=new Map),o.set(r.name,t),i==="accessor"){const{name:n}=r;return{set(a){const l=e.get.call(this);e.set.call(this,a),this.requestUpdate(n,l,t)},init(a){return a!==void 0&&this.P(n,void 0,t),a}}}if(i==="setter"){const{name:n}=r;return function(a){const l=this[n];e.call(this,a),this.requestUpdate(n,l,t)}}throw Error("Unsupported decorator location: "+i)};Pa=function(t){return(e,r)=>typeof r=="object"?GUt(t,e,r):((i,s,o)=>{const n=s.hasOwnProperty(o);return s.constructor.createProperty(o,n?{...i,wrapped:!0}:i),n?Object.getOwnPropertyDescriptor(s,o):void 0})(t,e,r)},em=function(t){return Pa({...t,state:!0,attribute:!1})},r1t=function(t){return(e,r)=>{const i=typeof e=="function"?e:e[r];Object.assign(i,t)}};const HW=(t,e,r)=>(r.configurable=!0,r.enumerable=!0,Reflect.decorate&&typeof e!="object"&&Object.defineProperty(t,e,r),r);PEt=function(t,e){return(r,i,s)=>{const o=n=>{var a;return((a=n.renderRoot)==null?void 0:a.querySelector(t))??null};if(e){const{get:n,set:a}=typeof i=="object"?r:s??(()=>{const l=Symbol();return{get(){return this[l]},set(c){this[l]=c}}})();return HW(r,i,{get(){let l=n.call(this);return l===void 0&&(l=o(this),(l!==null||this.hasUpdated)&&a.call(this,l)),l}})}return HW(r,i,{get(){return o(this)}})}},e1t=function(t){return(e,r)=>{const{slot:i,selector:s}=t??{},o="slot"+(i?`[name=${i}]`:":not([name])");return HW(e,r,{get(){var l;const n=(l=this.renderRoot)==null?void 0:l.querySelector(o),a=(n==null?void 0:n.assignedElements(t))??[];return s===void 0?a:a.filter((c=>c.matches(s)))}})}},QEt=function(t){return(e,r)=>{const{slot:i}=t??{},s="slot"+(i?`[name=${i}]`:":not([name])");return HW(e,r,{get(){var o,n;return((n=(o=this.renderRoot)==null?void 0:o.querySelector(s))==null?void 0:n.assignedNodes(t))??[]}})}};const cct=Symbol("canvas");var KW=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
2823a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},hct=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},df=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},uct=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},k9,ff,JP;function WUt(){return hct(this,void 0,void 0,function*(){if("gpu"in navigator){if(!(yield navigator.gpu.requestAdapter()))throw new Error("No WebGPU adapter available.")}else throw new Error("WebGPU is not supported by the browser.")})}let H1=class extends Wa{constructor(){super(...arguments),this.renderer="webgl",this.shaderCompilerPath="https://unpkg.com/@antv/[email protected]/dist/pkg/glsl_wgsl_compiler_bg.wasm",this.zoom=100,k9.set(this,new eE(this,{context:cct})),ff.set(this,void 0),JP.set(this,void 0),this.initCanvas=new rE(this,{task:t=>hct(this,[t],void 0,function*([e,r]){e==="webgpu"&&(yield WUt());const i=document.createElement("canvas");uct(this,ff,yield new Klt({canvas:i,renderer:e,shaderCompilerPath:r}).initialized,"f"),df(this,k9,"f").setValue(df(this,ff,"f")),df(this,ff,"f").camera.onchange=()=>{this.zoom=Math.round(df(this,ff,"f").camera.zoom*100)},this.dispatchEvent(new CustomEvent("ic-ready",{detail:df(this,ff,"f")}));const s=o=>{this.dispatchEvent(new CustomEvent("ic-frame",{detail:o})),df(this,ff,"f").render(),uct(this,JP,window.requestAnimationFrame(s),"f")};return s(),df(this,ff,"f").getDOM()}),args:()=>[this.renderer,this.shaderCompilerPath]})}connectedCallback(){super.connectedCallback(),this.addEventListener("sl-resize",this.resize)}disconnectedCallback(){var t;this.removeEventListener("sl-resize",this.resize),df(this,JP,"f")&&window.cancelAnimationFrame(df(this,JP,"f")),(t=df(this,ff,"f"))===null||t===void 0||t.destroy(),super.disconnectedCallback()}resize(t){var e;const r=t.detail,{width:i,height:s}=r.entries[0].contentRect,o=window.devicePixelRatio;if(i&&s){const n=df(this,ff,"f").getDOM();n.width=i*o,n.height=s*o,(e=df(this,ff,"f"))===null||e===void 0||e.resize(i,s)}}render(){return this.initCanvas.render({pending:()=>Ao`<sl-spinner></sl-spinner>`,complete:t=>Ao` 2824 <sl-resize-observer> 2825 ${t} 2826 <ic-zoom-toolbar-lesson7 zoom=${this.zoom}></ic-zoom-toolbar-lesson7> 2827 </sl-resize-observer> 2828 `,error:t=>Ao`<sl-alert variant="danger" open> 2829 <sl-icon slot="icon" name="exclamation-octagon"></sl-icon> 2830 <strong>Initialize canvas failed</strong><br /> 2831 ${t.message} 2832 </sl-alert>`})}};k9=new WeakMap,ff=new WeakMap,JP=new WeakMap,H1.styles=Lc` 2833 :host { 2834 position: relative; 2835 } 2836 2837 canvas { 2838 width: 100%; 2839 height: 100%; 2840 outline: none; 2841 padding: 0; 2842 margin: 0; 2843 touch-action: none; 2844 } 2845 `,KW([Pa()],H1.prototype,"renderer",void 0),KW([Pa()],H1.prototype,"shaderCompilerPath",void 0),KW([em()],H1.prototype,"zoom",void 0),H1=KW([Vc("ic-canvas-lesson7")],H1);var L9=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};let XC=class extends Wa{constructor(){super(...arguments),this.zoom=100}zoomOut(){this.canvas.zoomOut()}zoomIn(){this.canvas.zoomIn()}render(){return Ao` 2846 <sl-button-group label="Zoom toolbar"> 2847 <sl-tooltip content="Zoom out"> 2848 <sl-icon-button 2849 name="dash-lg" 2850 label="Zoom out" 2851 @click="${this.zoomOut}" 2852 ></sl-icon-button> 2853 </sl-tooltip>
2854 <span>${this.zoom}%</span> 2855 <sl-tooltip content="Zoom in"> 2856 <sl-icon-button 2857 name="plus-lg" 2858 label="Zoom in" 2859 @click="${this.zoomIn}" 2860 ></sl-icon-button> 2861 </sl-tooltip> 2862 </sl-button-group> 2863 `}};XC.styles=Lc` 2864 :host { 2865 position: absolute; 2866 right: 16px; 2867 bottom: 16px; 2868 box-shadow: var(--sl-shadow-medium); 2869 background: white; 2870 } 2871 2872 span { 2873 font-size: 12px; 2874 line-height: 32px; 2875 width: 32px; 2876 text-align: center; 2877 color: var(--sl-color-neutral-600); 2878 } 2879 `,L9([cm({context:cct,subscribe:!0})],XC.prototype,"canvas",void 0),L9([Pa()],XC.prototype,"zoom",void 0),XC=L9([Vc("ic-zoom-toolbar-lesson7")],XC);const jUt=Object.freeze(Object.defineProperty({__proto__:null,Camera:Ult,Canvas:Klt,Circle:sUt,Grid:Xlt,Group:zlt,IDENTITY_TRANSFORM:Wlt,get InfiniteCanvas(){return H1},Rectangle:Ua,Shape:_9,get ZoomToolbar(){return XC},isFillOrStrokeAffected:jlt},Symbol.toStringTag,{value:"Module"}));var U9=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},QP;let XUt=class{constructor(){QP.set(this,[])}getCallbacksNum(){return U9(this,QP,"f").length}tapPromise(t){U9(this,QP,"f").push(t)}promise(...t){return Promise.all(U9(this,QP,"f").map(e=>e(...t)))}};QP=new WeakMap;var dct=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},qW;let xu=class{constructor(){qW.set(this,[])}tap(t){dct(this,qW,"f").push(t)}call(...t){dct(this,qW,"f").forEach(function(e){e.apply(void 0,t)})}};qW=new WeakMap;var tF=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},K1;let zUt=class{constructor(){K1.set(this,[])}tap(t){tF(this,K1,"f").push(t)}call(...t){if(tF(this,K1,"f").length){let e=tF(this,K1,"f")[0].apply(void 0,t);for(let r=0;r<tF(this,K1,"f").length-1;r++){const i=tF(this,K1,"f")[r];e=i(...e)}return e}return null}};K1=new WeakMap;const VUt=()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};function G9(t,e){e(t)||t.children.forEach(r=>{G9(r,e)})}const W9=0;function q1(t){return[t[0],t[1],t[2],W9,t[3],t[4],t[5],W9,t[6],t[7],t[8],W9]}function fct(t,e,r,i){var s=Math.sqrt(Math.pow(r-t,2)+Math.pow(i-e,2));return s}const YUt={linear:cr(0,0,1,1),ease:cr(.25,.1,.25,1),"ease-in":cr(.42,0,1,1),"ease-out":cr(0,0,.58,1),"ease-in-out":cr(.42,0,.58,1)};var D_;(function(t){t._bytes4=new Uint8Array(4),t._float=new Float32Array(t._bytes4.buffer),t._int=new Int32Array(t._bytes4.buffer),t._bytes2=new Uint8Array(2),t._short=new Int16Array(t._bytes2.buffer);function e(c){return t._float[0]=c,t._int[0]}t.floatToInt=e;function r(c){return t._int[0]=c,t._float[0]}t.intToFloat=r;function i(c){return t._float[0]=c,t._bytes4}t.floatToBytes=i;function s(c,h,u,d){return t._bytes4[0]=c,t._bytes4[1]=h,t._bytes4[2]=u,t._bytes4[3]=d,t._float[0]}t.bytesToFloat=s;function o(c){return t._int[0]=c,t._bytes4}t.intToBytes=o;function n(c,h,u,d){return t._bytes4[0]=c,t._bytes4[1]=h,t._bytes4[2]=u,t._bytes4[3]=d,t._int[0]}t.bytesToInt=n;function a(c){return t._short[0]=c,t._bytes2}t.shortToBytes=a;function l(c,h){return t._bytes2[0]=c,t._bytes2[1]=h,t._short[0]}t.bytesToShort=l})(D_||(D_={}));const pct=256;let $Ut=class{constructor(t=new Uint8Array(pct)){this._bytes=t,this.count=0,this.readOffset=0,this.capacity=pct,this.count=this.capacity=t.length}clear(){this.count=0,this.readOffset=0}byteCount(){return this.count}bytes(){return this._bytes.subarray(0,this.count)}grow(){this.capacity*=2;const t=new Uint8Array(this.capacity);t.set(this._bytes),this._bytes=t}hasMoreToRead(){return this.readOffset<this.count}seekTo(t){this.readOffset=t}skipBytes(t){this.readOffset+=t}appendBytes(t){const e=t.length;return this.count+e>this.capacity&&this.grow(),this._bytes.set(t,this.count),this.count+=e,this}byteAt(t){return this._bytes[t]}appendByte(t){return this.count+1>this.capacity&&this.grow(),this._bytes[this.count]=t,this.count++,this}readByte(){const t=this.byteAt(this.readOffset);return this.readOffset++,t}shortAt(t){return D_.bytesToShort(this._bytes[t],this._bytes[t+1])}appendShort(t){return this.appendBytes(D_.shortToBytes(t)),this}appendShorts(t){for(const e of t)this.appendShort(e);return this}readShort(){const t=this.shortAt(this.readOffset);return this.readOffset+=2,t}intAt(t){return D_.bytesToInt(this._bytes[t],this._bytes[t+1],this._bytes[t+2],this._bytes[t+3])}appendInt(t){return this.appendBytes(D_.intToBytes(t)),this}appendInts(t){for(const e of t)this.appendInt(e);return this}readInt(){const t=this.intAt(this.readOffset);return this.readOffset+=4,t}
2879floatAt(t){return D_.bytesToFloat(this._bytes[t],this._bytes[t+1],this._bytes[t+2],this._bytes[t+3])}appendFloat(t){return this.appendBytes(D_.floatToBytes(t)),this}appendFloats(t){for(const e of t)this.appendFloat(e);return this}readFloat(){const t=this.floatAt(this.readOffset);return this.readOffset+=4,t}isEmpty(){return this.count==0}};const ZW=t=>t instanceof Object,gct=t=>t===!!t,JW=t=>typeof t=="function",aa=t=>t===void 0,mct=t=>t==null,j9={default:-1};function HUt(t="default"){return j9[t]===void 0&&(j9[t]=-1),++j9[t]}var mr=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},yc=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},kp,Su,Tu,pf,eF,rF,Lp,iF,sF,oF,QW,nF;const yct=1e-4;let vct=class f1t{constructor(e,r){this.clipSpaceNearZ=Sh.NEGATIVE_ONE,kp.set(this,1),Su.set(this,0),Tu.set(this,0),pf.set(this,0),eF.set(this,0),rF.set(this,0),Lp.set(this,Bt()),iF.set(this,Bt()),sF.set(this,Bt()),oF.set(this,Bt()),QW.set(this,Bt()),nF.set(this,void 0),this.projection(e,r),this.updateMatrix()}clone(){const e=new f1t(mr(this,eF,"f"),mr(this,rF,"f"));return yc(e,Su,mr(this,Su,"f"),"f"),yc(e,Tu,mr(this,Tu,"f"),"f"),yc(e,kp,mr(this,kp,"f"),"f"),yc(e,pf,mr(this,pf,"f"),"f"),e.updateMatrix(),e}projection(e,r){yc(this,eF,e,"f"),yc(this,rF,r,"f"),ld(mr(this,iF,"f"),e,r),this.updateViewProjectionMatrix()}updateMatrix(){const e=1/mr(this,kp,"f");Yc(mr(this,Lp,"f")),bi(mr(this,Lp,"f"),mr(this,Lp,"f"),[mr(this,Su,"f"),mr(this,Tu,"f")]),Mo(mr(this,Lp,"f"),mr(this,Lp,"f"),mr(this,pf,"f")),xh(mr(this,Lp,"f"),mr(this,Lp,"f"),[e,e]),_i(mr(this,sF,"f"),mr(this,Lp,"f")),this.updateViewProjectionMatrix()}updateViewProjectionMatrix(){us(mr(this,oF,"f"),mr(this,iF,"f"),mr(this,sF,"f")),_i(mr(this,QW,"f"),mr(this,oF,"f")),this.onchange&&this.onchange()}get projectionMatrix(){return mr(this,iF,"f")}get viewMatrix(){return mr(this,sF,"f")}get viewProjectionMatrix(){return mr(this,oF,"f")}get viewProjectionMatrixInv(){return mr(this,QW,"f")}get matrix(){return mr(this,Lp,"f")}get zoom(){return mr(this,kp,"f")}set zoom(e){mr(this,kp,"f")!==e&&(yc(this,kp,e,"f"),this.updateMatrix())}get x(){return mr(this,Su,"f")}set x(e){mr(this,Su,"f")!==e&&(yc(this,Su,e,"f"),this.updateMatrix())}get y(){return mr(this,Tu,"f")}set y(e){mr(this,Tu,"f")!==e&&(yc(this,Tu,e,"f"),this.updateMatrix())}get rotation(){return mr(this,pf,"f")}set rotation(e){mr(this,pf,"f")!==e&&(yc(this,pf,e,"f"),this.updateMatrix())}get width(){return mr(this,eF,"f")}get height(){return mr(this,rF,"f")}createLandmark(e={}){return Object.assign({zoom:mr(this,kp,"f"),x:mr(this,Su,"f"),y:mr(this,Tu,"f"),rotation:mr(this,pf,"f")},e)}gotoLandmark(e,r={}){const{easing:i="linear",duration:s=100,onframe:o=void 0,onfinish:n=void 0}=r,{zoom:a=mr(this,kp,"f"),x:l=mr(this,Su,"f"),y:c=mr(this,Tu,"f"),rotation:h=mr(this,pf,"f"),viewportX:u=0,viewportY:d=0}=e,f=u||d,g=()=>{this.applyLandmark({x:l,y:c,zoom:a,rotation:h,viewportX:u,viewportY:d}),n&&n()};if(s===0){g();return}this.cancelLandmarkAnimation();let p;const m=[l,c],v=[a,h],b=y=>{p===void 0&&(p=y);const _=y-p;if(_>s){g();return}const w=YUt[i](_/s),E=it(),A=Be(1,0);if(ta(E,[mr(this,Su,"f"),mr(this,Tu,"f")],m,w),ta(A,[this.zoom,mr(this,pf,"f")],v,w),this.applyLandmark({x:E[0],y:E[1],zoom:A[0],rotation:A[1],viewportX:u,viewportY:d}),f?za(A,v)<=yct:za(E,m)<=yct){g();return}_<s&&(o&&o(w),yc(this,nF,requestAnimationFrame(b),"f"))};requestAnimationFrame(b)}cancelLandmarkAnimation(){mr(this,nF,"f")!==void 0&&cancelAnimationFrame(mr(this,nF,"f"))}viewport2Canvas({x:e,y:r},i){const{width:s,height:o,viewProjectionMatrixInv:n}=i||this,a=Qt(it(),[e/s*2-1,(1-r/o)*2-1],n);return{x:a[0],y:a[1]}}canvas2Viewport({x:e,y:r},i){const{width:s,height:o,viewProjectionMatrix:n}=i||this,a=Qt(it(),[e,r],n);return{x:(a[0]+1)/2*s,y:(1-(a[1]+1)/2)*o}}applyLandmark(e){const{x:r,y:i,zoom:s,rotation:o,viewportX:n,viewportY:a}=e,l=n||a;let c=0,h=0;if(l){const u=this.viewport2Canvas({x:n,y:a});c=u.x,h=u.y}if(yc(this,kp,s,"f"),yc(this,pf,o,"f"),yc(this,Su,r,"f"),yc(this,Tu,i,"f"),this.updateMatrix(),l){const{x:u,y:d}=this.viewport2Canvas({x:n,y:a});yc(this,Su,mr(this,Su,"f")+(c-u),"f"),yc(this,Tu,mr(this,Tu,"f")+(h-d),"f"),this.updateMatrix()}}};kp=new WeakMap,Su=new WeakMap,Tu=new WeakMap,pf=new WeakMap,eF=new WeakMap,rF=new WeakMap,Lp=new WeakMap,iF=new WeakMap,sF=new WeakMap,oF=new WeakMap,QW=new WeakMap,nF=new WeakMap;let _ct=class p1t{get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=p1t.prototype.NONE,this.prop
2879agationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ye,this.page=new ye,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}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(e,r,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,r,i,s,o){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}},t6=class extends _ct{constructor(){super(...arguments),this.client=new ye,this.movement=new ye,this.offset=new ye,this.global=new ye,this.screen=new ye}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}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,r,i,s,o,n,a,l,c,h,u,d,f,g){throw new Error("Method not implemented.")}},Up=class extends t6{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!")}},X9=class extends t6{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}};var KUt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},qUt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},e6;const ZUt=2048;let JUt=class{constructor(t){this.dispatch=new Uo,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,e6.set(this,void 0),this.rootTarget=t,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)}setPickHandler(t){KUt(this,e6,t,"f")}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((r,i)=>r.priority-i.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.prop
vendor: 6,797 bytes, line 2879
2879agate(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 r=0,i=e.length;r<i;r++)e[r].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){return qUt(this,e6,"f").call(this,t,e)}propagate(t,e){if(!t.target)return;const r=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let i=0,s=r.length-1;i<s;i++)if(t.currentTarget=r[i],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 i=r.length-2;i>=0;i--)if(t.currentTarget=r[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,r=this._allInteractiveElements){if(r.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const i=Array.isArray(e)?e:[e];for(let s=r.length-1;s>=0;s--)i.forEach(o=>{t.currentTarget=r[s],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let r=0;r<ZUt&&t!==this.rootTarget&&t.parent;r++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}notifyTarget(t,e){e=e??t.type;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 Up)){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 i=e.button===2;this.dispatchEvent(e,i?"rightdown":"mousedown")}const r=this.trackingData(t.pointerId);r.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,r,i;if(!(t instanceof Up)){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 s=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const o=s.pointerType==="mouse"||s.pointerType==="pen",n=this.trackingData(t.pointerId),a=this.findMountedTarget(n.overTargets);if(((e=n.overTargets)===null||e===void 0?void 0:e.length)>0&&a!==s.target){const h=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,h,a);if(this.dispatchEvent(u,"pointerout"),o&&this.dispatchEvent(u,"mouseout"),!s.composedPath().includes(a)){const d=this.createPointerEvent(t,"pointerleave",a);for(d.eventPhase=d.AT_TARGET;d.target&&!s.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),o&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(u)}if(a!==s.target){const h=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(s,h);this.dispatchEvent(u,"pointerover"),o&&this.dispatchEvent(u,"mouseover");let d=a==null?void 0:a.parent;for(;d&&d!==this.rootTarget.parent&&d!==s.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(s,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==a&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),o&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(u)}const l=[],c=(r=this.enableGlobalMoveEvents)!==null&&r!==void 0?r:!0;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(s,"pointermove"),c&&l.push("globalpointermove"),s.pointerType==="touch"&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(s,"touchmove"),c&&l.push("globaltouchmove")),o&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(s,"mousemove"),c&&l.push("globalmousemove"),this.cursor=(i=s.target)===null||i===void 0?void 0:i.cursor),l.length>0&&this.all(s,l),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=s.composedPath(),this.freeEvent(s)}mapPointerOver(t){var e;if(!(t instanceof Up)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(e=i.target)===null||e===void 0?void 0:e.cursor);const o=this.clonePointerEvent(i,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;r.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof Up)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const r=t.pointerType==="mouse"||t.pointerType==="pen",i=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",i);this.dispatchEvent(s),r&&this.dispatchEvent(s,"mouseout");const o=this.createPointerEvent(t,"pointerleave",i);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),r&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(s),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){var e;if(!(t instanceof Up)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=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 s=this.trackingData(t.pointerId),o=this.findMountedTarget(s.pressTargetsByButton[t.button]);let n=o;if(o&&!i.composedPath().includes(o)){let a=o;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 l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],n=a}if(n){const a=this.clonePointerEvent(i,"click");a.target=n,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:r});const l=s.clicksByButton[t.button];if(l.target===a.target&&r-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=r,a.detail=l.clickCount,!(!((e=i.detail)===null||e===void 0)&&e.preventClick)){if
2879(a.pointerType==="mouse"){const c=a.button===2;this.dispatchEvent(a,c?"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 Up)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),r=this.findMountedTarget(e.pressTargetsByButton[t.button]),i=this.createPointerEvent(t);if(r){let s=r;for(;s;)i.currentTarget=s,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch"?this.notifyTarget(i,"touchendoutside"):(i.pointerType==="mouse"||i.pointerType==="pen")&&this.notifyTarget(i,i.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(i)}mapWheel(t){if(!(t instanceof X9)){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 r=1;r<t.length&&t[r].parent===e;r++)e=t[r];return e}createPointerEvent(t,e,r){var i;const s=this.allocateEvent(Up);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=(i=r??this.hitTest(s.global.x,s.global.y))!==null&&i!==void 0?i:this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(X9);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 r=this.allocateEvent(Up);return r.nativeEvent=t.nativeEvent,r.originalEvent=t.originalEvent,this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.target=t.target,r.path=t.composedPath().slice(),r.type=e??r.type,r}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Up&&e instanceof Up&&(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.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof t6&&e instanceof t6&&(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 r=t.currentTarget._events[e];if(r)if("fn"in r)r.once&&t.currentTarget.removeListener(e,r.fn,void 0,!0),r.fn.call(r.context,t);else for(let i=0,s=r.length;i<s&&!t.propagationImmediatelyStopped;i++)r[i].once&&t.currentTarget.removeListener(e,r[i].fn,void 0,!0),r[i].fn.call(r[i].context,t)}};e6=new WeakMap;const bct=new uo;let r6=class{constructor(t=1/0,e=1/0,r=-1/0,i=-1/0){this.matrix=bct,this.minX=t,this.minY=e,this.maxX=r,this.maxY=i}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=bct,this}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}
2879addFrame(t,e,r,i,s){s||(s=this.matrix);const o=s.a,n=s.b,a=s.c,l=s.d,c=s.tx,h=s.ty;let u=this.minX,d=this.minY,f=this.maxX,g=this.maxY,p=o*t+a*e+c,m=n*t+l*e+h;p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*r+a*e+c,m=n*r+l*e+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*t+a*i+c,m=n*t+l*i+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*r+a*i+c,m=n*r+l*i+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),this.minX=u,this.minY=d,this.maxX=f,this.maxY=g}};const wct=new wn,Ect=new uo;let z9=class extends Uo{constructor(t={}){var e,r,i,s,o,n,a,l;super(),this.uid=HUt(),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.transform=new wn,this.children=[],this.cursor=(e=t.cursor)!==null&&e!==void 0?e:"default",this.hitArea=t.hitArea,this.pointerEvents=(r=t.pointerEvents)!==null&&r!==void 0?r:"auto",this.visible=(i=t.visible)!==null&&i!==void 0?i:!0,this.renderable=(s=t.renderable)!==null&&s!==void 0?s:!0,this.cullable=(o=t.cullable)!==null&&o!==void 0?o:!0,this.draggable=(n=t.draggable)!==null&&n!==void 0?n:!1,this.droppable=(a=t.droppable)!==null&&a!==void 0?a:!1,this.batchable=(l=t.batchable)!==null&&l!==void 0?l:!1}addEventListener(t,e,r){const i=gct(r)&&r||ZW(r)&&r.capture,s=ZW(r)?r.signal:void 0,o=ZW(r)&&r.once,n=JW(e)?void 0:e;t=i?`${t}capture`:t;const a=JW(e)?e:e.handleEvent;s&&s.addEventListener("abort",()=>{this.off(t,a,n)}),o?this.once(t,a,n):this.on(t,a,n)}removeEventListener(t,e,r){const i=gct(r)&&r||ZW(r)&&r.capture,s=JW(e)?void 0:e;t=i?`${t}capture`:t,e=JW(e)?e:e==null?void 0:e.handleEvent,this.off(t,e,s)}dispatchEvent(t){if(!(t instanceof _ct))throw new Error("Container cannot propagate events outside of the Federated Events API");return t.defaultPrevented=!1,t.path=[],t.target=this,t.manager.dispatchEvent(t),!t.defaultPrevented}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*id}set angle(t){this.transform.rotation=t*eu}get transformDirtyFlag(){var t;return this.transform._localID!==this.transform._currentLocalID||this.transform._parentID!==((t=this.parent)===null||t===void 0?void 0:t.transform._worldID)}appendChild(t){return t.parent&&t.parent.removeChild(t),t.parent=this,t.transform._parentID=-1,this.children.push(t),t}removeChild(t){const e=this.children.indexOf(t);return e===-1?null:(t.parent=void 0,t.transform._parentID=-1,this.children.splice(e,1),t)}getBounds(t){if(!this.boundsDirtyFlag)return this.bounds;this.bounds=this.bounds||new r6,this.bounds.clear();let e;return this.parent?t?e=this.parent.worldTransform:(Ect.identity(),e=Act(this,Ect)):e=uo.IDENTITY,V9(this,this.bounds,e,t),this.boundsDirtyFlag=!1,this.bounds}};function V9(t,e,r,i){if(!t.visible)return;let s;i?s=t.worldTransform:(t.transform.updateLocalTransform(),s=new uo,s.copyFrom(t.localTransform),s.append(r)),t.renderable&&(e.matrix=s,e.addBounds(t.getRenderBounds()));for(let o=0;o<t.children.length;o++)V9(t.children[o],e,s,i)}function Act(t,e){const r=t.parent;return r&&(Act(r,e),r.transform.updateLocalTransform(),e.append(r.localTransform)),e}function xct(t,e,r){let i=!1,s=!1;const o=!!e&&e!=="none",n=!!r&&r!=="none";return t==="visiblepainted"||t==="painted"||t==="auto"?(i=o,s=n):t==="visiblefill"||t==="fill"?i=!0:t==="visiblestroke"||t==="stroke"?s=!0:(t==="visible"||t==="all")&&(i=!0,s=!0),[i,s]}var ts=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Gp=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
2879return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},P_,F_,gf,zC,i6,VC,s6,Z1,aF,lF,cF;let Y9=class extends z9{constructor(t={}){super(t),P_.set(this,void 0),F_.set(this,void 0),gf.set(this,void 0),zC.set(this,void 0),i6.set(this,void 0),VC.set(this,void 0),s6.set(this,void 0),Z1.set(this,void 0),aF.set(this,void 0),lF.set(this,void 0),cF.set(this,void 0);const{cx:e,cy:r,r:i,fill:s,stroke:o,strokeWidth:n,opacity:a,fillOpacity:l,strokeOpacity:c}=t;this.cx=e??0,this.cy=r??0,this.r=i??0,this.fill=s??"black",this.stroke=o??"black",this.strokeWidth=n??0,this.opacity=a??1,this.fillOpacity=l??1,this.strokeOpacity=c??1}get cx(){return ts(this,P_,"f")}set cx(t){ts(this,P_,"f")!==t&&(Gp(this,P_,t,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get cy(){return ts(this,F_,"f")}set cy(t){ts(this,F_,"f")!==t&&(Gp(this,F_,t,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get r(){return ts(this,gf,"f")}set r(t){ts(this,gf,"f")!==t&&(Gp(this,gf,t,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get fill(){return ts(this,zC,"f")}set fill(t){ts(this,zC,"f")!==t&&(Gp(this,zC,t,"f"),Gp(this,i6,sr.rgb(t),"f"),this.renderDirtyFlag=!0)}get fillRGB(){return ts(this,i6,"f")}get stroke(){return ts(this,VC,"f")}set stroke(t){ts(this,VC,"f")!==t&&(Gp(this,VC,t,"f"),Gp(this,s6,sr.rgb(t),"f"),this.renderDirtyFlag=!0)}get strokeRGB(){return ts(this,s6,"f")}get strokeWidth(){return ts(this,Z1,"f")}set strokeWidth(t){ts(this,Z1,"f")!==t&&(Gp(this,Z1,t,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get opacity(){return ts(this,aF,"f")}set opacity(t){ts(this,aF,"f")!==t&&(Gp(this,aF,t,"f"),this.renderDirtyFlag=!0)}get fillOpacity(){return ts(this,lF,"f")}set fillOpacity(t){ts(this,lF,"f")!==t&&(Gp(this,lF,t,"f"),this.renderDirtyFlag=!0)}get strokeOpacity(){return ts(this,cF,"f")}set strokeOpacity(t){ts(this,cF,"f")!==t&&(Gp(this,cF,t,"f"),this.renderDirtyFlag=!0)}containsPoint(t,e){const r=ts(this,Z1,"f")/2,i=fct(ts(this,P_,"f"),ts(this,F_,"f"),t,e),[s,o]=xct(this.pointerEvents,ts(this,zC,"f"),ts(this,VC,"f"));return s?i<=ts(this,gf,"f"):o?i>=ts(this,gf,"f")-r&&i<=ts(this,gf,"f")+r:!1}getRenderBounds(){if(this.renderBoundsDirtyFlag){const t=ts(this,Z1,"f")/2;this.renderBoundsDirtyFlag=!1,this.renderBounds=new r6(ts(this,P_,"f")-ts(this,gf,"f")-t,ts(this,F_,"f")-ts(this,gf,"f")-t,ts(this,P_,"f")+ts(this,gf,"f")+t,ts(this,F_,"f")+ts(this,gf,"f")+t)}return this.renderBounds}};P_=new WeakMap,F_=new WeakMap,gf=new WeakMap,zC=new WeakMap,i6=new WeakMap,VC=new WeakMap,s6=new WeakMap,Z1=new WeakMap,aF=new WeakMap,lF=new WeakMap,cF=new WeakMap;const QUt=` 2880layout(std140) uniform SceneUniforms { 2881 mat3 u_ProjectionMatrix; 2882 mat3 u_ViewMatrix; 2883 mat3 u_ViewProjectionInvMatrix; 2884 float u_ZoomScale; 2885 float u_CheckboardStyle; 2886}; 2887 2888layout(location = 0) in vec2 a_Position; 2889 2890out vec2 v_Position; 2891 2892vec2 project_clipspace_to_world(vec2 p) { 2893 return (u_ViewProjectionInvMatrix * vec3(p, 1)).xy; 2894} 2895 2896void main() { 2897 v_Position = project_clipspace_to_world(a_Position); 2898 gl_Position = vec4(a_Position, 0, 1); 2899} 2900`,tGt=` 2901layout(std140) uniform SceneUniforms { 2902 mat3 u_ProjectionMatrix; 2903 mat3 u_ViewMatrix; 2904 mat3 u_ViewProjectionInvMatrix; 2905 float u_ZoomScale; 2906 float u_CheckboardStyle; 2907}; 2908 2909out vec4 outputColor; 2910 2911in vec2 v_Position; 2912 2913const vec4 GRID_COLOR = vec4(0.87, 0.87, 0.87, 1.0); 2914const vec4 PAGE_COLOR = vec4(0.986, 0.986, 0.986, 1.0); 2915const int CHECKERBOARD_STYLE_NONE = 0; 2916const int CHECKERBOARD_STYLE_GRID = 1; 2917const int CHECKERBOARD_STYLE_DOTS = 2; 2918const float BASE_GRID_PIXEL_SIZE = 100.0; 2919const float BASE_DOT_SIZE = 8.0; 2920 2921vec2 scale_grid_size(float zoom) { 2922 if (zoom < 0.125) return vec2(BASE_GRID_PIXEL_SIZE * 125.0, 0.125); 2923 else if (zoom < 0.25) return vec2(BASE_GRID_PIXEL_SIZE * 25.0, 0.25); 2924 else if (zoom < 0.5) return vec2(BASE_GRID_PIXEL_SIZE * 5.0, 0.5); 2925 return vec2(BASE_GRID_PIXEL_SIZE, 4.0); 2926} 2927 2928vec4 render_grid_checkerboard(vec2 coord) { 2929 float alpha = 0.0; 2930 2931 vec2 size = scale_grid_size(u_ZoomScale); 2932 float gridSize1 = size.x; 2933 float gridSize2 = gridSize1 / 10.0; 2934 float zoomStep = size.y; 2935 int checkboardStyle = int(floor(u_CheckboardStyle + 0.5)); 2936 2937 if (checkboardStyle == CHECKERBOARD_STYLE_GRID) { 2938 vec2 grid1 = abs(fract(coord / gridSize1 - 0.5) - 0.5) / fwidth(coord) * gridSize1 / 2.0; 2939 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2; 2940 float v1 = 1.0 - min(min(grid1.x, grid1.y), 1.0); 2941 float v2 = 1.0 - min(min(grid2.x, grid2.y), 1.0); 2942 2943 if (v1 > 0.0) { 2944 alpha = v1; 2945 } else { 2946 alpha = v2 * clamp(u_ZoomScale / zoomStep, 0.0, 1.0); 2947 } 2948 } else if (checkboardStyle == CHECKERBOARD_STYLE_DOTS) { 2949 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2;
2950 alpha = 1.0 - smoothstep(0.0, 1.0, length(grid2) - BASE_DOT_SIZE * u_ZoomScale / zoomStep); 2951 } 2952 2953 return mix(PAGE_COLOR, GRID_COLOR, alpha); 2954} 2955 2956void main() { 2957 outputColor = render_grid_checkerboard(v_Position); 2958} 2959`;var vc=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},hF=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},J1,YC,$C,uF,dF,fF;let Sct=class{constructor(){J1.set(this,void 0),YC.set(this,void 0),$C.set(this,void 0),uF.set(this,void 0),dF.set(this,void 0),fF.set(this,new $Ut)}appendVertex(t,e){vc(this,fF,"f").appendFloat(t).appendFloat(e)}render(t,e,r){if(!vc(this,J1,"f")){hF(this,J1,t.createProgram({vertex:{glsl:QUt},fragment:{glsl:tGt}}),"f"),hF(this,$C,t.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{format:I.F32_RG,offset:0,shaderLocation:0}]}],indexBufferFormat:null,program:vc(this,J1,"f")}),"f"),hF(this,YC,t.createRenderPipeline({inputLayout:vc(this,$C,"f"),program:vc(this,J1,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,topology:Go.TRIANGLE_STRIP}),"f"),vc(this,fF,"f").clear(),this.appendVertex(-1,-1),this.appendVertex(-1,1),this.appendVertex(1,-1),this.appendVertex(1,1);const i=vc(this,fF,"f").bytes(),s=t.createBuffer({viewOrSize:i.byteLength,usage:dt.VERTEX,hint:Et.DYNAMIC});hF(this,dF,s,"f"),s.setSubData(0,i),hF(this,uF,t.createBindings({pipeline:vc(this,YC,"f"),uniformBufferBindings:[{buffer:r}]}),"f")}
2959e.setBindings(vc(this,uF,"f")),e.setPipeline(vc(this,YC,"f")),e.setVertexInput(vc(this,$C,"f"),[{buffer:vc(this,dF,"f")}],null),e.draw(4)}destroy(){vc(this,J1,"f").destroy(),vc(this,dF,"f").destroy(),vc(this,YC,"f").destroy(),vc(this,$C,"f").destroy(),vc(this,uF,"f").destroy()}};J1=new WeakMap,YC=new WeakMap,$C=new WeakMap,uF=new WeakMap,dF=new WeakMap,fF=new WeakMap;let Tct=class extends z9{constructor(){super(...arguments),this.renderable=!1}containsPoint(t,e){throw new Error("Method not implemented.")}getRenderBounds(){throw new Error("Method not implemented.")}destroy(){}};const Rct=1e5;let eGt=class{constructor(t,e){this.device=t,this.instanced=e,this.shapes=[],this.maxInstances=1/0,this.geometryDirty=!0,this.materialDirty=!0}validate(){return this.count()<=this.maxInstances-1}submit(t,e){this.geometryDirty&&this.createGeometry(),this.materialDirty&&this.createMaterial(e),this.render(t),this.geometryDirty&&(this.geometryDirty=!1),this.materialDirty&&(this.materialDirty=!1)}add(t){this.shapes.includes(t)||(this.shapes.push(t),this.geometryDirty=!0)}remove(t){if(this.shapes.includes(t)){const e=this.shapes.indexOf(t);this.shapes.splice(e,1),this.geometryDirty=!0}}count(){return this.shapes.length}};const rGt=` 2960layout(std140) uniform SceneUniforms { 2961 mat3 u_ProjectionMatrix; 2962 mat3 u_ViewMatrix; 2963}; 2964 2965layout(location = 0) in vec2 a_FragCoord; 2966 2967#ifdef USE_INSTANCES 2968 layout(location = 14) in vec4 a_Abcd; 2969 layout(location = 15) in vec2 a_Txty; 2970 layout(location = 1) in vec4 a_PositionSize; 2971 layout(location = 2) in vec4 a_FillColor; 2972 layout(location = 3) in vec4 a_StrokeColor; 2973 layout(location = 4) in vec4 a_ZIndexStrokeWidth; 2974 layout(location = 5) in vec4 a_Opacity; 2975#else 2976 layout(std140) uniform ShapeUniforms { 2977 mat3 u_ModelMatrix; 2978 vec4 u_PositionSize; 2979 vec4 u_FillColor; 2980 vec4 u_StrokeColor; 2981 vec4 u_ZIndexStrokeWidth; 2982 vec4 u_Opacity; 2983 }; 2984#endif 2985 2986out vec2 v_FragCoord; 2987#ifdef USE_INSTANCES 2988 out vec4 v_FillColor; 2989 out vec4 v_StrokeColor; 2990 out float v_StrokeWidth; 2991 out vec4 v_Opacity; 2992#else 2993#endif 2994out vec2 v_Radius; 2995 2996void main() { 2997 mat3 model; 2998 vec2 position; 2999 vec2 size; 3000 vec4 fillColor; 3001 vec4 strokeColor; 3002 float zIndex; 3003 float strokeWidth; 3004 3005 #ifdef USE_INSTANCES 3006 model = mat3(a_Abcd.x, a_Abcd.y, 0, a_Abcd.z, a_Abcd.w, 0, a_Txty.x, a_Txty.y, 1); 3007 position = a_PositionSize.xy; 3008 size = a_PositionSize.zw; 3009 fillColor = a_FillColor; 3010 strokeColor = a_StrokeColor; 3011 zIndex = a_ZIndexStrokeWidth.x; 3012 strokeWidth = a_ZIndexStrokeWidth.y; 3013 3014 v_FillColor = fillColor; 3015 v_StrokeColor = strokeColor; 3016 v_StrokeWidth = strokeWidth; 3017 v_Opacity = a_Opacity; 3018 #else 3019 model = u_ModelMatrix; 3020 position = u_PositionSize.xy; 3021 size = u_PositionSize.zw; 3022 fillColor = u_FillColor; 3023 strokeColor = u_StrokeColor; 3024 zIndex = u_ZIndexStrokeWidth.x; 3025 strokeWidth = u_ZIndexStrokeWidth.y; 3026 #endif 3027 3028 vec2 radius = size + vec2(strokeWidth / 2.0); 3029 3030 v_FragCoord = a_FragCoord; 3031 v_Radius = radius; 3032 3033 gl_Position = vec4((u_ProjectionMatrix 3034 * u_ViewMatrix 3035 * model 3036 * vec3(position + size * a_FragCoord, 1)).xy, zIndex, 1); 3037} 3038`,iGt=` 3039#ifdef USE_INSTANCES 3040#else 3041 layout(std140) uniform ShapeUniforms { 3042 mat3 u_ModelMatrix; 3043 vec4 u_PositionSize; 3044 vec4 u_FillColor; 3045 vec4 u_StrokeColor; 3046 vec4 u_ZIndexStrokeWidth; 3047 vec4 u_Opacity; 3048 }; 3049#endif 3050 3051out vec4 outputColor; 3052 3053in vec2 v_FragCoord; 3054#ifdef USE_INSTANCES 3055 in vec4 v_FillColor; 3056 in vec4 v_StrokeColor; 3057 in float v_StrokeWidth; 3058 in vec4 v_Opacity; 3059#else 3060#endif 3061in vec2 v_Radius; 3062 3063float epsilon = 0.000001; 3064 3065float sdf_circle(vec2 p, float r) { 3066 return length(p) - r; 3067} 3068 3069void main() { 3070 float strokeWidth; 3071 vec4 fillColor; 3072 vec4 strokeColor; 3073 float opacity; 3074 float fillOpacity; 3075 float strokeOpacity; 3076 3077 #ifdef USE_INSTANCES 3078 fillColor = v_FillColor; 3079 strokeColor = v_StrokeColor; 3080 strokeWidth = v_StrokeWidth; 3081 opacity = v_Opacity.x; 3082 fillOpacity = v_Opacity.y; 3083 strokeOpacity = v_Opacity.z; 3084 #else 3085 fillColor = u_FillColor; 3086 strokeColor = u_StrokeColor; 3087 strokeWidth = u_ZIndexStrokeWidth.y; 3088 opacity = u_Opacity.x; 3089 fillOpacity = u_Opacity.y; 3090 strokeOpacity = u_Opacity.z; 3091 #endif 3092 3093 vec2 r = (v_Radius - strokeWidth) / v_Radius.y; 3094 3095 float outerDistance = sdf_circle(v_FragCoord, 1.0); 3096 float innerDistance = sdf_circle(v_FragCoord, r.x); 3097 float antialiasedBlur = -fwidth(outerDistance); 3098 3099 float opacity_t = clamp(outerDistance / antialiasedBlur, 0.0, 1.0); 3100 3101 float color_t = strokeWidth < 0.01 ? 0.0 : smoothstep( 3102 antialiasedBlur, 3103 0.0, 3104 innerDistance 3105 ); 3106 3107 outputColor = mix(vec4(fillColor.rgb, fillColor.a * fillOpacity), strokeColor * strokeOpacity, color_t); 3108 outputColor.a = outputColor.a * opacity * opacity_t; 3109 3110 if (outputColor.a < epsilon) 3111 discard; 3112} 3113`;var es=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Wp=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3113return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Um,HC,N_,k_,pF,Q1,L_,U_,KC;let sGt=class extends eGt{constructor(){super(...arguments),Um.set(this,void 0),HC.set(this,void 0),N_.set(this,void 0),k_.set(this,void 0),pF.set(this,void 0),Q1.set(this,void 0),L_.set(this,void 0),U_.set(this,void 0),KC.set(this,void 0)}createGeometry(){es(this,HC,"f")||(Wp(this,HC,this.device.createBuffer({viewOrSize:new Float32Array([-1,-1,1,-1,1,1,-1,1]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),Wp(this,pF,this.device.createBuffer({viewOrSize:new Uint32Array([0,1,2,0,2,3]),usage:dt.INDEX,hint:Et.STATIC}),"f")),this.instanced&&(es(this,N_,"f")&&es(this,N_,"f").destroy(),Wp(this,N_,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*20*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),es(this,k_,"f")&&es(this,k_,"f").destroy(),Wp(this,k_,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*6*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"))}createMaterial(t){let e="";this.instanced&&(e+=`#define USE_INSTANCES 3114`),es(this,Um,"f")&&(es(this,Um,"f").destroy(),es(this,U_,"f").destroy(),es(this,L_,"f").destroy());const r=this.device.queryVendorInfo().platformString==="WebGPU"?"diagnostic(off,derivative_uniformity);":"";Wp(this,Um,this.device.createProgram({vertex:{glsl:e+rGt},fragment:{glsl:e+iGt,postprocess:s=>r+s}}),"f");const i=[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:0,offset:0,format:I.F32_RG}]}];this.instanced?(i.push({arrayStride:80,stepMode:ne.INSTANCE,attributes:[{shaderLocation:1,offset:0,format:I.F32_RGBA},{shaderLocation:2,offset:16,format:I.F32_RGBA},{shaderLocation:3,offset:32,format:I.F32_RGBA},{shaderLocation:4,offset:48,format:I.F32_RGBA},{shaderLocation:5,offset:64,format:I.F32_RGBA}]},{arrayStride:24,stepMode:ne.INSTANCE,attributes:[{shaderLocation:14,offset:0,format:I.F32_RGBA},{shaderLocation:15,offset:16,format:I.F32_RG}]}),Wp(this,U_,this.device.createInputLayout({vertexBufferDescriptors:i,indexBufferFormat:I.U32_R,program:es(this,Um,"f")}),"f")):(Wp(this,U_,this.device.createInputLayout({vertexBufferDescriptors:i,indexBufferFormat:I.U32_R,program:es(this,Um,"f")}),"f"),es(this,Q1,"f")||Wp(this,Q1,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*32,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f")),Wp(this,L_,this.device.createRenderPipeline({inputLayout:es(this,U_,"f"),program:es(this,Um,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],depthWrite:!0,depthCompare:qe.GREATER}}),"f"),this.instanced?Wp(this,KC,this.device.createBindings({pipeline:es(this,L_,"f"),uniformBufferBindings:[{buffer:t}]}),"f"):Wp(this,KC,this.device.createBindings({pipeline:es(this,L_,"f"),uniformBufferBindings:[{buffer:t},{buffer:es(this,Q1,"f")}]}),"f")}render(t){if(this.shapes.some(r=>r.renderDirtyFlag)||this.geometryDirty)if(this.instanced){es(this,k_,"f").setSubData(0,new Uint8Array(new Float32Array(this.shapes.map(i=>[i.worldTransform.a,i.worldTransform.b,i.worldTransform.c,i.worldTransform.d,i.worldTransform.tx,i.worldTransform.ty]).flat()).buffer));const r=[];this.shapes.forEach(i=>{if(i instanceof Y9){const{cx:s,cy:o,r:n,fillRGB:{r:a,g:l,b:c,opacity:h},strokeRGB:{r:u,g:d,b:f,opacity:g},strokeWidth:p,opacity:m,fillOpacity:v,strokeOpacity:b}=i;r.push(s,o,n,n,a/255,l/255,c/255,h,u/255,d/255,f/255,g,i.globalRenderOrder/Rct,p,0,0,m,v,b,0)}}),es(this,N_,"f").setSubData(0,new Uint8Array(new Float32Array(r).buffer))}else{const{cx:r,cy:i,r:s,fillRGB:{r:o,g:n,b:a,opacity:l},strokeRGB:{r:c,g:h,b:u,opacity:d},strokeWidth:f,worldTransform:g,opacity:p,fillOpacity:m,strokeOpacity:v}=this.shapes[0];es(this,Q1,"f").setSubData(0,new Uint8Array(new Float32Array([...q1(g.toArray(!0)),r,i,s,s,o/255,n/255,a/255,l,c/255,h/255,u/255,d,this.shapes[0].globalRenderOrder/Rct,f,0,0,p,m,v,0]).buffer))}const e=[{buffer:es(this,HC,"f")}];this.instanced&&e.push({buffer:es(this,N_,"f")},{buffer:es(this,k_,"f")}),t.setPipeline(es(this,L_,"f")),t.setVertexInput(es(this,U_,"f"),e,{buffer:es(this,pF,"f")}),t.setBindings(es(this,KC,"f")),t.drawIndexed(6,this.shapes.length)}destroy(){var t,e,r,i,s,o,n,a;es(this,Um,"f")&&(es(this,Um,"f").destroy(),(t=es(this,k_,"f"))===null||t===void 0||t.destroy(),(e=es(this,N_,"f"))===null||e===void 0||e.destroy(),(r=es(this,HC,"f"))===null||r===void 0||r.destroy(),(i=es(this,pF,"f"))===null||i===void 0||i.destroy(),(s=es(this,Q1,"f"))===null||s===void 0||s.destroy(),(o=es(this,L_,"f"))===null||o===void 0||o.destroy(),(n=es(this,U_,"f"))===null||n===void 0||n.destroy(),(a=es(this,KC,"f"))===null||a===void 0||a.destroy())}};Um=new WeakMap,HC=new WeakMap,N_=new WeakMap,k_=new WeakMap,pF=new WeakMap,Q1=new WeakMap,L_=new WeakMap,U_=new WeakMap,KC=new WeakMap;var _c=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},oGt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3114return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},G_,tA,eA,o6;const Cct=new WeakMap;Cct.set(Y9,[sGt]);let nGt=class{constructor(t){this.device=t,G_.set(this,[]),tA.set(this,Object.create(null)),eA.set(this,Object.create(null)),o6.set(this,new WeakMap)}createDrawcalls(t,e=!1){var r;return(r=Cct.get(t.constructor))===null||r===void 0?void 0:r.map(i=>{const s=new i(this.device,e);return s.add(t),s})}getOrCreateNonBatchableDrawcalls(t){let e=_c(this,tA,"f")[t.uid];return e||(e=this.createDrawcalls(t)||[],_c(this,tA,"f")[t.uid]=e),e}getOrCreateBatchableDrawcalls(t){let e=_c(this,eA,"f")[t.uid];if(!e){const r=t.constructor;let i=_c(this,o6,"f").get(r);i||(i=[]),e=i.find(s=>s.every(o=>o.validate())),e||(e=this.createDrawcalls(t,!0)||[],i.push(e),_c(this,o6,"f").set(r,i)),e.forEach(s=>{s.add(t)}),_c(this,eA,"f")[t.uid]=e}return e}add(t){if(t.batchable){const e=this.getOrCreateBatchableDrawcalls(t);_c(this,G_,"f").indexOf(e[0])===-1&&_c(this,G_,"f").push(...e)}else _c(this,G_,"f").push(...this.getOrCreateNonBatchableDrawcalls(t))}remove(t){t.batchable?(this.getOrCreateBatchableDrawcalls(t).forEach(e=>{e.remove(t)}),delete _c(this,eA,"f")[t.uid]):(this.getOrCreateNonBatchableDrawcalls(t).forEach(e=>{e.destroy()}),delete _c(this,tA,"f")[t.uid])}destroy(){for(const t in _c(this,tA,"f"))_c(this,tA,"f")[t].forEach(e=>{e.destroy()});for(const t in _c(this,eA,"f"))_c(this,eA,"f")[t].forEach(e=>{e.destroy()})}clear(){oGt(this,G_,[],"f")}flush(t,e){_c(this,G_,"f").forEach(r=>{r.submit(t,e)})}stats(){return{drawcallCount:_c(this,G_,"f").length}}};G_=new WeakMap,tA=new WeakMap,eA=new WeakMap,o6=new WeakMap;var aGt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Rd=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},ri=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},qC,$a,W_,rA,iA,sA,gF,mF,j_,yF,$9;(function(t){t[t.NONE=0]="NONE",t[t.GRID=1]="GRID",t[t.DOTS=2]="DOTS"})($9||($9={}));let lGt=class{constructor(){qC.set(this,void 0),$a.set(this,void 0),W_.set(this,void 0),rA.set(this,void 0),iA.set(this,void 0),sA.set(this,void 0),gF.set(this,$9.GRID),mF.set(this,void 0),j_.set(this,void 0),yF.set(this,1)}apply(t){const{hooks:e,canvas:r,renderer:i,shaderCompilerPath:s,devicePixelRatio:o,camera:n}=t;e.initAsync.tapPromise(()=>aGt(this,void 0,void 0,function*(){let a;i==="webgl"?a=new hd({targets:["webgl2","webgl1"],antialias:!0,shaderDebug:!0,trackResources:!0,onContextCreationError:()=>{},onContextLost:()=>{},onContextRestored(u){}}):a=new ud({shaderCompilerPath:s,onContextLost:()=>{}});const{width:l,height:c}=r,h=yield a.createSwapChain(r);h.configureSwapChain(l,c),Rd(this,qC,h,"f"),Rd(this,$a,h.getDevice(),"f"),Rd(this,j_,new nGt(ri(this,$a,"f")),"f"),Rd(this,W_,ri(this,$a,"f").createRenderTargetFromTexture(ri(this,$a,"f").createTexture({format:I.U8_RGBA_RT,width:l,height:c,usage:xr.RENDER_TARGET})),"f"),Rd(this,rA,ri(this,$a,"f").createRenderTargetFromTexture(ri(this,$a,"f").createTexture({format:I.D24_S8,width:l,height:c,usage:xr.RENDER_TARGET})),"f"),Rd(this,sA,ri(this,$a,"f").createBuffer({viewOrSize:new Float32Array([...q1(n.projectionMatrix),...q1(n.viewMatrix),...q1(n.viewProjectionMatrixInv),n.zoom,ri(this,gF,"f"),0,0]),usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),Rd(this,mF,new Sct,"f")})),e.resize.tap((a,l)=>{ri(this,qC,"f").configureSwapChain(a*o,l*o),ri(this,W_,"f")&&(ri(this,W_,"f").destroy(),Rd(this,W_,ri(this,$a,"f").createRenderTargetFromTexture(ri(this,$a,"f").createTexture({format:I.U8_RGBA_RT,width:a*o,height:l*o,usage:xr.RENDER_TARGET})),"f"),ri(this,rA,"f").destroy(),Rd(this,rA,ri(this,$a,"f").createRenderTargetFromTexture(ri(this,$a,"f").createTexture({format:I.D24_S8,width:a*o,height:l*o,usage:xr.RENDER_TARGET})),"f"))}),e.destroy.tap(()=>{ri(this,j_,"f").destroy(),ri(this,sA,"f").destroy(),ri(this,mF,"f").destroy(),ri(this,W_,"f").destroy(),ri(this,rA,"f").destroy(),ri(this,$a,"f").destroy(),ri(this,$a,"f").checkForLeaks()}),e.beginFrame.tap(()=>{const{width:a,height:l}=ri(this,qC,"f").getCanvas(),c=ri(this,qC,"f").getOnscreenTexture();ri(this,sA,"f").setSubData(0,new Uint8Array(new Float32Array([...q1(n.projectionMatrix),...q1(n.viewMatrix),...q1(n.viewProjectionMatrixInv),n.zoom,ri(this,gF,"f"),0,0]).buffer)),ri(this,$a,"f").beginFrame(),Rd(this,iA,ri(this,$a,"f").createRenderPass({colorAttachment:[r
3114i(this,W_,"f")],colorResolveTo:[c],colorClearColor:[op],depthStencilAttachment:ri(this,rA,"f"),depthClearValue:1}),"f"),ri(this,iA,"f").setViewport(0,0,a,l),ri(this,mF,"f").render(ri(this,$a,"f"),ri(this,iA,"f"),ri(this,sA,"f")),ri(this,j_,"f").clear(),Rd(this,yF,1,"f")}),e.endFrame.tap(({all:a,removed:l})=>{[...a.filter(c=>c.culled),...l].forEach(c=>{c.renderable&&ri(this,j_,"f").remove(c)}),ri(this,j_,"f").flush(ri(this,iA,"f"),ri(this,sA,"f")),ri(this,$a,"f").submitPass(ri(this,iA,"f")),ri(this,$a,"f").endFrame()}),e.render.tap(a=>{var l,c;a.globalRenderOrder=(Rd(this,yF,(c=ri(this,yF,"f"),l=c++,c),"f"),l),ri(this,j_,"f").add(a)})}setCheckboardStyle(t){Rd(this,gF,t,"f")}};qC=new WeakMap,$a=new WeakMap,W_=new WeakMap,rA=new WeakMap,iA=new WeakMap,sA=new WeakMap,gF=new WeakMap,mF=new WeakMap,j_=new WeakMap,yF=new WeakMap;var jp=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},oA=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},vF,nA,X_,ZC;const cGt=.02,hGt=4,uGt=100,_F=[.02,.05,.1,.15,.2,.33,.5,.75,1,1.25,1.5,2,2.5,3,4],dGt=t=>_F.find(e=>e>t)||_F[_F.length-1],fGt=t=>[..._F].reverse().find(e=>e<t)||_F[0];let pGt=class{constructor(){vF.set(this,void 0),nA.set(this,{}),X_.set(this,void 0),ZC.set(this,!1)}apply(t){const{canvas:e,camera:r,root:i,api:{client2Viewport:s}}=t;i.draggable=!0;const o=Bt();let n,a,l;const c=it();let h,u=!1;function d(y){const _=e.getBoundingClientRect(),w=y.nativeEvent.clientX-_.left,E=y.nativeEvent.clientY-_.top,A=w/e.clientWidth,x=E/e.clientHeight,S=A*2-1,T=x*-2+1;return[S,T]}function f(y){const _=Qt(it(),d(y),o);r.x=n+c[0]-_[0],r.y=a+c[1]-_[1]}function g(y){const _=(y.nativeEvent.clientX-h[0])/100,w=Bt();bi(w,w,[c[0],c[1]]),Mo(w,w,_),bi(w,w,[-c[0],-c[1]]),r.x=n,r.y=a,r.rotation=l,us(w,w,r.matrix),r.rotation=l+_,r.x=w[6],r.y=w[7]}i.addEventListener("dragstart",y=>{jp(this,X_,"f")||(u=y.shiftKey,fp(o,r.viewProjectionMatrixInv),n=r.x,a=r.y,l=r.rotation,Qt(c,d(y),o),h=[y.nativeEvent.clientX,y.nativeEvent.clientY])}),i.addEventListener("drag",y=>{jp(this,X_,"f")||(u?g(y):f(y))}),i.addEventListener("dragend",y=>{jp(this,X_,"f")||(u=!1)});const p=(y,_)=>{const w=Math.max(cGt,Math.min(hGt,r.zoom*Math.pow(2,_*-.01))),E=s(y);r.gotoLandmark(r.createLandmark({viewportX:E.x,viewportY:E.y,zoom:w}),{duration:0})};i.addEventListener("wheel",y=>{y.preventDefault(),p({x:y.nativeEvent.clientX,y:y.nativeEvent.clientY},y.deltaY)});const m=y=>{y.pointerType==="mouse"?oA(this,vF,!0,"f"):jp(this,nA,"f")[y.pointerId]||(jp(this,nA,"f")[y.pointerId]={last:null}),this.touchCount>=2?oA(this,X_,!0,"f"):oA(this,X_,!1,"f")},v=y=>{if(y.pointerType==="mouse"&&oA(this,vF,!1,"f"),y.pointerType!=="mouse"&&delete jp(this,nA,"f")[y.pointerId],jp(this,ZC,"f")&&this.touchCount<=1)return oA(this,ZC,!1,"f"),oA(this,X_,!1,"f"),!0},b=y=>{if(this.touchCount>=2){const _=y.global.x,w=y.global.y,E=jp(this,nA,"f"),A=Object.keys(E),x=Number(A[0]),S=Number(A[1]),T=E[x],R=E[S],B=T.last&&R.last?Math.sqrt(Math.pow(R.last.x-T.last.x,2)+Math.pow(R.last.y-T.last.y,2)):null;if(x===y.pointerId?T.last={x:_,y:w}:S===y.pointerId&&(R.last={x:_,y:w}),B){const O=new ye(T.last.x+(R.last.x-T.last.x)/2,T.last.y+(R.last.y-T.last.y)/2),C=Math.sqrt(Math.pow(R.last.x-T.last.x,2)+Math.pow(R.last.y-T.last.y,2));p(O,(B/C-1)*uGt)}else jp(this,ZC,"f")||oA(this,ZC,!0,"f")}};i.addEventListener("pointerdown",m),i.addEventListener("pointermove",b),i.addEventListener("pointerup",v),i.addEventListener("pointerupoutside",v),i.addEventListener("pointercancel",v)}get touchCount(){return(jp(this,vF,"f")?1:0)+Object.keys(jp(this,nA,"f")).length}};vF=new WeakMap,nA=new WeakMap,X_=new WeakMap,ZC=new WeakMap;let gGt=class{apply(t){const{canvas:e,hooks:r,globalThis:i,supportsPointerEvents:s,supportsTouchEvents:o}=t,n=y=>{y.preventDefault(),r.pointerMove.call(y)},a=y=>{r.pointerUp.call(y)},l=y=>{r.pointerDown.call(y)},c=y=>{r.pointerOver.call(y)},h=y=>{r.pointerOut.call(y)},u=y=>{r.pointerCancel.call(y)},d=y=>{r.pointerWheel.call(y)},f=y=>{i.document.addEventListener("pointermove",n,!0),y.addEventListener("pointerdown",l,!0),y.addEventListener("pointerleave",h,!0),y.addEventListener("pointerover",c,!0),i.addEventListener("pointerup",a,!0),i.addEventListener("pointercancel",u,!0)},g=y=>{y.addEventListener("touchstart",l,!0),y.addEventListener("touchend",a,!0),y.addEventListener("touchmove",n,!0),y.addEventListener("touchcancel",u,!0)},p=y=>{i.document.addEventListener("mousemove",n,!0),y.addEventListener("mousedown",l,!0),y.addEventListener("mouseout",h,!0),y.addEventListener("mouseover",c,!0),i.addEventListener("mouseup",a,!0)},m=y=>{i.document.removeEventListener("pointermove",n,!0),y.removeEventListener("pointerdown",l,!0),y.removeEventListener("pointerleave",h,!0),y.removeEventListener("pointerover",c,!0),i.removeEventListener("pointerup",a,!0)},v=y=>{y.removeEventListener("touchstart",l,!0),y.removeEventListener("touchend",a,!0),y.removeEventListener("touchmove",n,!0),y.removeEventListener("touchcancel",u,!0)},b=y=>{i.document.removeEventListener("mousemove",n,!0),y.removeEventListener("mousedown",l,!0),y.removeEventListener("mouseout",h,!0),y.removeEventListener("mouseover",c,!0),i.removeEventListener("mouseup",a,!0)};r.init.tap(()=>{s?f(e):(p(e),o&&g(e)),e.addEventListener("wheel",d,{capture:!0})}),r.destroy.tap(()=>{s?m(e):(b(e),o&&v(e)),e.removeEventListener("wheel",d,!0)})}};var Mct=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3114return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},El=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},H9,bF,K9,Xp,B0;const mGt=1,yGt={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};let vGt=class{constructor(){H9.set(this,!0),bF.set(this,new Up(null)),K9.set(this,new X9(null)),Xp.set(this,void 0),B0.set(this,void 0),this.onPointerMove=t=>{const e=this.normalizeToPointerEvent(t);for(const r of e){const i=this.bootstrapEvent(El(this,bF,"f"),r);El(this,Xp,"f").mapEvent(i)}this.setCursor(El(this,Xp,"f").cursor)}}apply(t){const{hooks:e,root:r}=t;Mct(this,B0,t,"f"),Mct(this,Xp,new JUt(r),"f"),El(this,Xp,"f").setPickHandler((i,s)=>{const{picked:o}=e.pickSync.call({position:{x:i,y:s},picked:[],topmost:!0});return o[0]||null}),e.pointerWheel.tap(i=>{const s=this.normalizeWheelEvent(i);El(this,Xp,"f").mapEvent(s)}),e.pointerDown.tap(i=>{const s=this.normalizeToPointerEvent(i);El(this,H9,"f")&&s[0].isNormalized&&(i.cancelable||!("cancelable"in i))&&i.preventDefault();for(let o=0,n=s.length;o<n;o++){const a=s[o],l=this.bootstrapEvent(El(this,bF,"f"),a);El(this,Xp,"f").mapEvent(l)}this.setCursor(El(this,Xp,"f").cursor)}),e.pointerUp.tap(i=>{let s=i.target;i.composedPath&&i.composedPath().length>0&&(s=i.composedPath()[0]);const o=s!==El(this,B0,"f").canvas?"outside":"",n=this.normalizeToPointerEvent(i);for(let a=0,l=n.length;a<l;a++){const c=this.bootstrapEvent(El(this,bF,"f"),n[a]);c.type+=o,El(this,Xp,"f").mapEvent(c)}this.setCursor(El(this,Xp,"f").cursor)}),e.pointerMove.tap(this.onPointerMove),e.pointerOver.tap(this.onPointerMove),e.pointerOut.tap(this.onPointerMove),e.pointerCancel.tap(this.onPointerMove)}normalizeWheelEvent(t){const e=El(this,K9,"f");this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode;const{x:r,y:i}=this.getViewportXY(t);e.client.x=r,e.client.y=i;const{x:s,y:o}=El(this,B0,"f").api.viewport2Canvas(e.client);return e.screen.x=s,e.screen.y=o,e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null}setCursor(t){El(this,B0,"f").canvas.style.cursor=t}normalizeToPointerEvent(t){const{supportsTouchEvents:e,supportsPointerEvents:r}=El(this,B0,"f"),i=[];if(e&&t instanceof TouchEvent)for(let s=0;s<t.changedTouches.length;s++){const o=t.changedTouches[s];aa(o.button)&&(o.button=0),aa(o.buttons)&&(o.buttons=1),aa(o.isPrimary)&&(o.isPrimary=t.touches.length===1&&t.type==="touchstart"),aa(o.width)&&(o.width=o.radiusX||1),aa(o.height)&&(o.height=o.radiusY||1),aa(o.tiltX)&&(o.tiltX=0),aa(o.tiltY)&&(o.tiltY=0),aa(o.pointerType)&&(o.pointerType="touch"),aa(o.pointerId)&&(o.pointerId=o.identifier||0),aa(o.pressure)&&(o.pressure=o.force||.5),aa(o.twist)&&(o.twist=0),aa(o.tangentialPressure)&&(o.tangentialPressure=0),o.isNormalized=!0,o.type=t.type,i.push(o)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!r||!(t instanceof globalThis.PointerEvent))){const s=t;aa(s.isPrimary)&&(s.isPrimary=!0),aa(s.width)&&(s.width=1),aa(s.height)&&(s.height=1),aa(s.tiltX)&&(s.tiltX=0),aa(s.tiltY)&&(s.tiltY=0),aa(s.pointerType)&&(s.pointerType="mouse"),aa(s.pointerId)&&(s.pointerId=mGt),aa(s.pressure)&&(s.pressure=.5),aa(s.twist)&&(s.twist=0),aa(s.tangentialPressure)&&(s.tangentialPressure=0),s.isNormalized=!0,i.push(s)}else i.push(t);return i}bootstrapEvent(t,e){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);const{x:r,y:i}=this.getViewportXY(e);t.client.x=r,t.client.y=i;const{x:s,y:o}=El(this,B0,"f").api.viewport2Canvas(t.client);return t.screen.x=s,t.screen.y=o,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=yGt[t.type]||t.type),t}getViewportXY(t){let e,r;const{offsetX:i,offsetY:s,clientX:o,clientY:n}=t;if(!mct(i)&&!mct(s))e=i,r=s;else{const a=El(this,B0,"f").api.client2Viewport({x:o,y:n});e=a.x,r=a.y}return{x:e,y:r}}};H9=new WeakMap,bF=new WeakMap,K9=new WeakMap,Xp=new WeakMap,B0=new WeakMap;const Bct=new ye;let _Gt=class{apply(t){const{hooks:e,root:r,api:{elementsFromBBox:i}}=t;e.pickSync.tap(s=>{const{position:{x:o,y:n}}=s,a=[r];
3114return i(o,n,o,n).forEach(l=>{this.hitTest(l,o,n)&&a.unshift(l)}),s.picked=a,s})}hitTest(t,e,r){if(t.hitArea||t.renderable){t.worldTransform.applyInverse({x:e,y:r},Bct);const{x:i,y:s}=Bct;return t.hitArea?t.hitArea.contains(i,s):t.containsPoint(i,s)}return!1}};var bGt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Oct=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},wF;function Ict(t,e){do{if(t&&e(t))return t;t=t.parent}while(t!==void 0);return null}let wGt=class{constructor(t={}){wF.set(this,void 0),bGt(this,wF,Object.assign({overlap:"pointer",dragstartTimeThreshold:0,dragstartDistanceThreshold:0},t),"f")}apply(t){const{root:e,hooks:r,api:{elementsFromPoint:i}}=t,s=o=>{const n=o.target,a=Ict(n,l=>l.draggable===!0);if(a){let l=!1;const c=o.timeStamp,h=[o.clientX,o.clientY];let u=null,d=[o.clientX,o.clientY];const f=p=>{if(!l){const y=p.timeStamp-c,_=fct(p.clientX,p.clientY,...h);if(y<=Oct(this,wF,"f").dragstartTimeThreshold||_<=Oct(this,wF,"f").dragstartDistanceThreshold)return;p.type="dragstart",a.dispatchEvent(p),l=!0}p.type="drag",p.dx=p.clientX-d[0],p.dy=p.clientY-d[1],a.dispatchEvent(p),d=[p.clientX,p.clientY];const m=[p.globalX,p.globalY],v=i(m[0],m[1]),b=v[v.indexOf(n)+1];if(b){const y=Ict(b,_=>_.droppable===!0);u!==y&&(u&&(p.type="dragleave",p.target=u,u.dispatchEvent(p)),y&&(p.type="dragenter",p.target=y,y.dispatchEvent(p)),u=y,u&&(p.type="dragover",p.target=u,u.dispatchEvent(p)))}};e.addEventListener("pointermove",f);const g=function(p){if(l){p.detail={preventClick:!0};const m=p;u&&(m.type="drop",m.target=u,u.dispatchEvent(m)),m.type="dragend",a.dispatchEvent(m),l=!1}e.removeEventListener("pointermove",f)};n.addEventListener("pointerup",g,{once:!0}),n.addEventListener("pointerupoutside",g,{once:!0})}};r.init.tap(()=>{e.addEventListener("pointerdown",s)}),r.destroy.tap(()=>{e.removeEventListener("pointerdown",s)})}};wF=new WeakMap;var EGt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},JC=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},n6,aA;let AGt=class{constructor(){n6.set(this,void 0),aA.set(this,new r6)}apply(t){const{hooks:e,rBushRoot:r}=t;EGt(this,n6,t,"f"),e.cameraChange.tap(this.updateViewport.bind(this)),this.updateViewport(),e.beginFrame.tap(({all:i,removed:s,modified:o})=>{const{minX:n,minY:a,maxX:l,maxY:c}=JC(this,aA,"f");[...s,...o].forEach(d=>{d.renderable&&r.remove({shape:d,minX:0,minY:0,maxX:0,maxY:0},(f,g)=>f.shape===g.shape)});const h=[];o.forEach(d=>{if(d.renderable){const f=d.getBounds();h.push({minX:f.minX,minY:f.minY,maxX:f.maxX,maxY:f.maxY,shape:d})}}),r.load(h);const u=r.search({minX:n,minY:a,maxX:l,maxY:c}).map(d=>d.shape);i.forEach(d=>{d.renderable&&d.cullable&&(d.culled=!u.includes(d))})})}updateViewport(){const{camera:t,api:{viewport2Canvas:e}}=JC(this,n6,"f"),{width:r,height:i}=t,s=e({x:0,y:0}),o=e({x:r,y:0}),n=e({x:r,y:i}),a=e({x:0,y:i});JC(this,aA,"f").minX=Math.min(s.x,o.x,n.x,a.x),JC(this,aA,"f").minY=Math.min(s.y,o.y,n.y,a.y),JC(this,aA,"f").maxX=Math.max(s.x,o.x,n.x,a.x),JC(this,aA,"f").maxY=Math.max(s.y,o.y,n.y,a.y)}};n6=new WeakMap,aA=new WeakMap;var xGt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},$s=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},O0=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3114return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},a6,Jc,EF,l6,z_,AF,QC,c6,lA;let Dct=class{get pluginContext(){return $s(this,Jc,"f")}get root(){return $s(this,z_,"f")}get camera(){return $s(this,AF,"f")}constructor(t){a6.set(this,void 0),Jc.set(this,void 0),EF.set(this,void 0),l6.set(this,void 0),z_.set(this,new Tct),AF.set(this,void 0),QC.set(this,!0),c6.set(this,new Set),lA.set(this,new Set);const{canvas:e,renderer:r="webgl",shaderCompilerPath:i="",devicePixelRatio:s}=t,o=VUt(),n=s??o.devicePixelRatio,a=!!o.PointerEvent,l="ontouchstart"in o,{width:c,height:h}=e,u=new vct(c/n,h/n);u.onchange=()=>{$s(this,Jc,"f").hooks.cameraChange.call(),O0(this,QC,!0,"f")},O0(this,AF,u,"f"),O0(this,Jc,{globalThis:o,canvas:e,renderer:r,shaderCompilerPath:i,devicePixelRatio:n,supportsPointerEvents:a,supportsTouchEvents:l,hooks:{init:new xu,initAsync:new XUt,beginFrame:new xu,render:new xu,endFrame:new xu,destroy:new xu,resize:new xu,pointerDown:new xu,pointerUp:new xu,pointerMove:new xu,pointerOut:new xu,pointerOver:new xu,pointerWheel:new xu,pointerCancel:new xu,pickSync:new zUt,cameraChange:new xu},camera:u,root:$s(this,z_,"f"),rBushRoot:new TE,api:{elementsFromPoint:this.elementsFromPoint.bind(this),elementFromPoint:this.elementFromPoint.bind(this),elementsFromBBox:this.elementsFromBBox.bind(this),client2Viewport:this.client2Viewport.bind(this),viewport2Canvas:u.viewport2Canvas.bind(u),viewport2Client:this.viewport2Client.bind(this),canvas2Viewport:u.canvas2Viewport.bind(u)}},"f"),O0(this,EF,new lGt,"f"),O0(this,l6,new vGt,"f");const d=[new gGt,$s(this,l6,"f"),new _Gt,new pGt,new AGt,$s(this,EF,"f"),new wGt({dragstartTimeThreshold:100,dragstartDistanceThreshold:10})];O0(this,a6,xGt(this,void 0,void 0,function*(){const{hooks:f}=$s(this,Jc,"f");return d.forEach(g=>{g.apply($s(this,Jc,"f"))}),f.init.call(),yield f.initAsync.promise(),this}),"f")}get initialized(){return $s(this,a6,"f").then(()=>this)}render(){const{hooks:t}=$s(this,Jc,"f");$s(this,lA,"f").clear();const e=[];if(G9($s(this,z_,"f"),r=>{$s(this,lA,"f").add(r),r.transformDirtyFlag&&(r.renderDirtyFlag=!0),r.renderable&&r.renderDirtyFlag&&(e.push(r),O0(this,QC,!0,"f")),r.transform.updateTransform(r.parent?r.parent.transform:wct)}),$s(this,QC,"f")){const r=Array.from($s(this,lA,"f")),i=[...$s(this,c6,"f")].filter(s=>!$s(this,lA,"f").has(s));t.beginFrame.call({all:r,modified:e,removed:i}),G9($s(this,z_,"f"),s=>{if(s.culled||!s.visible)return!0;s.renderable&&t.render.call(s)}),t.endFrame.call({all:r,modified:e,removed:i}),[...r,...i].forEach(s=>{s.renderDirtyFlag=!1}),O0(this,c6,new Set($s(this,lA,"f")),"f"),O0(this,QC,!1,"f")}}resize(t,e){const{hooks:r}=$s(this,Jc,"f");$s(this,AF,"f").projection(t,e),r.resize.call(t,e)}destroy(){const{hooks:t}=$s(this,Jc,"f");t.destroy.call()}getDOM(){return $s(this,Jc,"f").canvas}appendChild(t){$s(this,z_,"f").appendChild(t)}removeChild(t){return $s(this,z_,"f").removeChild(t)}setCheckboardStyle(t){$s(this,EF,"f").setCheckboardStyle(t)}elementsFromBBox(t,e,r,i){const{rBushRoot:s}=$s(this,Jc,"f"),o=s.search({minX:t,minY:e,maxX:r,maxY:i}),n=[];return o.forEach(({shape:a})=>{const{pointerEvents:l="auto"}=a,c=["auto","visiblepainted","visiblefill","visiblestroke","visible"].includes(l);(!c||c&&a.visible)&&!a.culled&&a.pointerEvents!=="none"&&n.push(a)}),n.sort((a,l)=>a.globalRenderOrder-l.globalRenderOrder),n}elementsFromPoint(t,e){const{picked:r}=$s(this,Jc,"f").hooks.pickSync.call({topmost:!1,position:{x:t,y:e},picked:[]});return r}elementFromPoint(t,e){const{picked:r}=$s(this,Jc,"f").hooks.pickSync.call({topmost:!0,position:{x:t,y:e},picked:[]});return r[0]}client2Viewport({x:t,y:e}){const{left:r,top:i}=$s(this,Jc,"f").canvas.getBoundingClientRect();return{x:t-r,y:e-i}}viewport2Client({x:t,y:e}){const{left:r,top:i}=$s(this,Jc,"f").canvas.getBoundingClientRect();return{x:t+r,y:e+i}}zoomIn(){const{camera:t}=this;t.cancelLandmarkAnimation();const e=t.createLandmark({viewportX:t.width/2,viewportY:t.height/2,zoom:dGt(t.zoom)});t.gotoLandmark(e,{duration:300,easing:"ease"})}zoomOut(){const{camera:t}=this;t.cancelLandmarkAnimation();const e=t.createLandmark({viewportX:t.width/2,viewportY:t.height/2,zoom:fGt(t.zoom)});t.gotoLandmark(e,{duration:300,easing:"ease"})}};a6=new WeakMap,Jc=new WeakMap,EF=new WeakMap,l6=new WeakMap,z_=new WeakMap,AF=new WeakMap,QC=new WeakMap,c6=new WeakMap,lA=new WeakMap;const Pct=Symbol("canvas");var h6=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
3114a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},Fct=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},mf=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Nct=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},q9,yf,xF;function SGt(){return Fct(this,void 0,void 0,function*(){if("gpu"in navigator){if(!(yield navigator.gpu.requestAdapter()))throw new Error("No WebGPU adapter available.")}else throw new Error("WebGPU is not supported by the browser.")})}let cA=class extends Wa{constructor(){super(...arguments),this.renderer="webgl",this.shaderCompilerPath="https://unpkg.com/@antv/[email protected]/dist/pkg/glsl_wgsl_compiler_bg.wasm",this.zoom=100,q9.set(this,new eE(this,{context:Pct})),yf.set(this,void 0),xF.set(this,void 0),this.initCanvas=new rE(this,{task:t=>Fct(this,[t],void 0,function*([e,r]){e==="webgpu"&&(yield SGt());const i=document.createElement("canvas");Nct(this,yf,yield new Dct({canvas:i,renderer:e,shaderCompilerPath:r}).initialized,"f"),mf(this,q9,"f").setValue(mf(this,yf,"f")),mf(this,yf,"f").pluginContext.hooks.cameraChange.tap(()=>{this.zoom=Math.round(mf(this,yf,"f").camera.zoom*100)}),this.dispatchEvent(new CustomEvent("ic-ready",{detail:mf(this,yf,"f")}));const s=o=>{this.dispatchEvent(new CustomEvent("ic-frame",{detail:o})),mf(this,yf,"f").render(),Nct(this,xF,window.requestAnimationFrame(s),"f")};return s(),mf(this,yf,"f").getDOM()}),args:()=>[this.renderer,this.shaderCompilerPath]})}connectedCallback(){super.connectedCallback(),this.addEventListener("sl-resize",this.resize)}disconnectedCallback(){var t;this.removeEventListener("sl-resize",this.resize),mf(this,xF,"f")&&window.cancelAnimationFrame(mf(this,xF,"f")),(t=mf(this,yf,"f"))===null||t===void 0||t.destroy(),super.disconnectedCallback()}resize(t){var e;const r=t.detail,{width:i,height:s}=r.entries[0].contentRect,o=window.devicePixelRatio;if(i&&s){const n=mf(this,yf,"f").getDOM();n.width=i*o,n.height=s*o,(e=mf(this,yf,"f"))===null||e===void 0||e.resize(i,s)}}render(){return this.initCanvas.render({pending:()=>Ao`<sl-spinner></sl-spinner>`,complete:t=>Ao` 3115 <sl-resize-observer> 3116 ${t} 3117 <ic-zoom-toolbar-lesson8 zoom=${this.zoom}></ic-zoom-toolbar-lesson8> 3118 </sl-resize-observer> 3119 `,error:t=>Ao`<sl-alert variant="danger" open> 3120 <sl-icon slot="icon" name="exclamation-octagon"></sl-icon> 3121 <strong>Initialize canvas failed</strong><br /> 3122 ${t.message} 3123 </sl-alert>`})}};q9=new WeakMap,yf=new WeakMap,xF=new WeakMap,cA.styles=Lc` 3124 :host { 3125 position: relative; 3126 } 3127 3128 canvas { 3129 width: 100%; 3130 height: 100%; 3131 outline: none; 3132 padding: 0; 3133 margin: 0; 3134 touch-action: none; 3135 } 3136 `,h6([Pa()],cA.prototype,"renderer",void 0),h6([Pa()],cA.prototype,"shaderCompilerPath",void 0),h6([em()],cA.prototype,"zoom",void 0),cA=h6([Vc("ic-canvas-lesson8")],cA);var Z9=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};let tM=class extends Wa{constructor(){super(...arguments),this.zoom=100}zoomOut(){this.canvas.zoomOut()}zoomIn(){this.canvas.zoomIn()}render(){return Ao` 3137 <sl-button-group label="Zoom toolbar"> 3138 <sl-tooltip content="Zoom out"> 3139 <sl-icon-button 3140 name="dash-lg" 3141 label="Zoom out" 3142 @click="${this.zoomOut}" 3143 ></sl-icon-button> 3144 </sl-tooltip>
3145 <span>${this.zoom}%</span> 3146 <sl-tooltip content="Zoom in"> 3147 <sl-icon-button 3148 name="plus-lg" 3149 label="Zoom in" 3150 @click="${this.zoomIn}" 3151 ></sl-icon-button> 3152 </sl-tooltip> 3153 </sl-button-group> 3154 `}};tM.styles=Lc` 3155 :host { 3156 position: absolute; 3157 right: 16px; 3158 bottom: 16px; 3159 box-shadow: var(--sl-shadow-medium); 3160 background: white; 3161 } 3162 3163 span { 3164 font-size: 12px; 3165 line-height: 32px; 3166 width: 32px; 3167 text-align: center; 3168 color: var(--sl-color-neutral-600); 3169 } 3170 `,Z9([cm({context:Pct,subscribe:!0})],tM.prototype,"canvas",void 0),Z9([Pa()],tM.prototype,"zoom",void 0),tM=Z9([Vc("ic-zoom-toolbar-lesson8")],tM);const TGt=Object.freeze(Object.defineProperty({__proto__:null,AABB:r6,Camera:vct,Canvas:Dct,Circle:Y9,Grid:Sct,Group:Tct,IDENTITY_TRANSFORM:wct,get InfiniteCanvas(){return cA},Rectangle:Ua,Shape:z9,get ZoomToolbar(){return tM},getBounds:V9,isFillOrStrokeAffected:xct},Symbol.toStringTag,{value:"Module"}));var J9=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},SF;let RGt=class{constructor(){SF.set(this,[])}getCallbacksNum(){return J9(this,SF,"f").length}tapPromise(t){J9(this,SF,"f").push(t)}promise(...t){return Promise.all(J9(this,SF,"f").map(e=>e(...t)))}};SF=new WeakMap;var kct=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},u6;let Ru=class{constructor(){u6.set(this,[])}tap(t){kct(this,u6,"f").push(t)}call(...t){kct(this,u6,"f").forEach(function(e){e.apply(void 0,t)})}};u6=new WeakMap;var TF=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},hA;let CGt=class{constructor(){hA.set(this,[])}tap(t){TF(this,hA,"f").push(t)}call(...t){if(TF(this,hA,"f").length){let e=TF(this,hA,"f")[0].apply(void 0,t);for(let r=0;r<TF(this,hA,"f").length-1;r++){const i=TF(this,hA,"f")[r];e=i(...e)}return e}return null}};hA=new WeakMap;const MGt=()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};function Q9(t,e){e(t)||t.children.forEach(r=>{Q9(r,e)})}const t7=0;function V_(t){return[t[0],t[1],t[2],t7,t[3],t[4],t[5],t7,t[6],t[7],t[8],t7]}function Lct(t,e,r,i){var s=Math.sqrt(Math.pow(r-t,2)+Math.pow(i-e,2));return s}const BGt={linear:cr(0,0,1,1),ease:cr(.25,.1,.25,1),"ease-in":cr(.42,0,1,1),"ease-out":cr(0,0,.58,1),"ease-in-out":cr(.42,0,.58,1)};var Y_;(function(t){t._bytes4=new Uint8Array(4),t._float=new Float32Array(t._bytes4.buffer),t._int=new Int32Array(t._bytes4.buffer),t._bytes2=new Uint8Array(2),t._short=new Int16Array(t._bytes2.buffer);function e(c){return t._float[0]=c,t._int[0]}t.floatToInt=e;function r(c){return t._int[0]=c,t._float[0]}t.intToFloat=r;function i(c){return t._float[0]=c,t._bytes4}t.floatToBytes=i;function s(c,h,u,d){return t._bytes4[0]=c,t._bytes4[1]=h,t._bytes4[2]=u,t._bytes4[3]=d,t._float[0]}t.bytesToFloat=s;function o(c){return t._int[0]=c,t._bytes4}t.intToBytes=o;function n(c,h,u,d){return t._bytes4[0]=c,t._bytes4[1]=h,t._bytes4[2]=u,t._bytes4[3]=d,t._int[0]}t.bytesToInt=n;function a(c){return t._short[0]=c,t._bytes2}t.shortToBytes=a;function l(c,h){return t._bytes2[0]=c,t._bytes2[1]=h,t._short[0]}t.bytesToShort=l})(Y_||(Y_={}));const Uct=256;let OGt=class{constructor(t=new Uint8Array(Uct)){this._bytes=t,this.count=0,this.readOffset=0,this.capacity=Uct,this.count=this.capacity=t.length}clear(){this.count=0,this.readOffset=0}byteCount(){return this.count}bytes(){return this._bytes.subarray(0,this.count)}grow(){this.capacity*=2;const t=new Uint8Array(this.capacity);t.set(this._bytes),this._bytes=t}hasMoreToRead(){return this.readOffset<this.count}seekTo(t){this.readOffset=t}skipBytes(t){this.readOffset+=t}appendBytes(t){const e=t.length;return this.count+e>this.capacity&&this.grow(),this._bytes.set(t,this.count),this.count+=e,this}byteAt(t){return this._bytes[t]}appendByte(t){return this.count+1>this.capacity&&this.grow(),this._bytes[this.count]=t,this.count++,this}readByte(){const t=this.byteAt(this.readOffset);return this.readOffset++,t}shortAt(t){return Y_.bytesToShort(this._bytes[t],this._bytes[t+1])}appendShort(t){return this.appendBytes(Y_.shortToBytes(t)),this}appendShorts(t){for(const e of t)this.appendShort(e);return this}readShort(){const t=this.shortAt(this.readOffset);return this.readOffset+=2,t}intAt(t){return Y_.bytesToInt(this._bytes[t],this._bytes[t+1],this._bytes[t+2],this._bytes[t+3])}appendInt(t){return this.appendBytes(Y_.intToBytes(t)),this}appendInts(t){for(const e of t)this.appendInt(e);return this}readInt(){const t=this.intAt(this.readOffset);return this.readOffset+=4,t}
3170floatAt(t){return Y_.bytesToFloat(this._bytes[t],this._bytes[t+1],this._bytes[t+2],this._bytes[t+3])}appendFloat(t){return this.appendBytes(Y_.floatToBytes(t)),this}appendFloats(t){for(const e of t)this.appendFloat(e);return this}readFloat(){const t=this.floatAt(this.readOffset);return this.readOffset+=4,t}isEmpty(){return this.count==0}};const d6=t=>t instanceof Object,Gct=t=>t===!!t,f6=t=>typeof t=="function",la=t=>t===void 0,Wct=t=>t==null,e7={default:-1};function IGt(t="default"){return e7[t]===void 0&&(e7[t]=-1),++e7[t]}var yr=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},bc=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},zp,Cu,Mu,vf,RF,CF,Vp,MF,BF,OF,p6,IF;const jct=1e-4;let Xct=class g1t{constructor(e,r){this.clipSpaceNearZ=Sh.NEGATIVE_ONE,zp.set(this,1),Cu.set(this,0),Mu.set(this,0),vf.set(this,0),RF.set(this,0),CF.set(this,0),Vp.set(this,Bt()),MF.set(this,Bt()),BF.set(this,Bt()),OF.set(this,Bt()),p6.set(this,Bt()),IF.set(this,void 0),this.projection(e,r),this.updateMatrix()}clone(){const e=new g1t(yr(this,RF,"f"),yr(this,CF,"f"));return bc(e,Cu,yr(this,Cu,"f"),"f"),bc(e,Mu,yr(this,Mu,"f"),"f"),bc(e,zp,yr(this,zp,"f"),"f"),bc(e,vf,yr(this,vf,"f"),"f"),e.updateMatrix(),e}projection(e,r){bc(this,RF,e,"f"),bc(this,CF,r,"f"),ld(yr(this,MF,"f"),e,r),this.updateViewProjectionMatrix()}updateMatrix(){const e=1/yr(this,zp,"f");Yc(yr(this,Vp,"f")),bi(yr(this,Vp,"f"),yr(this,Vp,"f"),[yr(this,Cu,"f"),yr(this,Mu,"f")]),Mo(yr(this,Vp,"f"),yr(this,Vp,"f"),yr(this,vf,"f")),xh(yr(this,Vp,"f"),yr(this,Vp,"f"),[e,e]),_i(yr(this,BF,"f"),yr(this,Vp,"f")),this.updateViewProjectionMatrix()}updateViewProjectionMatrix(){us(yr(this,OF,"f"),yr(this,MF,"f"),yr(this,BF,"f")),_i(yr(this,p6,"f"),yr(this,OF,"f")),this.onchange&&this.onchange()}get projectionMatrix(){return yr(this,MF,"f")}get viewMatrix(){return yr(this,BF,"f")}get viewProjectionMatrix(){return yr(this,OF,"f")}get viewProjectionMatrixInv(){return yr(this,p6,"f")}get matrix(){return yr(this,Vp,"f")}get zoom(){return yr(this,zp,"f")}set zoom(e){yr(this,zp,"f")!==e&&(bc(this,zp,e,"f"),this.updateMatrix())}get x(){return yr(this,Cu,"f")}set x(e){yr(this,Cu,"f")!==e&&(bc(this,Cu,e,"f"),this.updateMatrix())}get y(){return yr(this,Mu,"f")}set y(e){yr(this,Mu,"f")!==e&&(bc(this,Mu,e,"f"),this.updateMatrix())}get rotation(){return yr(this,vf,"f")}set rotation(e){yr(this,vf,"f")!==e&&(bc(this,vf,e,"f"),this.updateMatrix())}get width(){return yr(this,RF,"f")}get height(){return yr(this,CF,"f")}createLandmark(e={}){return Object.assign({zoom:yr(this,zp,"f"),x:yr(this,Cu,"f"),y:yr(this,Mu,"f"),rotation:yr(this,vf,"f")},e)}gotoLandmark(e,r={}){const{easing:i="linear",duration:s=100,onframe:o=void 0,onfinish:n=void 0}=r,{zoom:a=yr(this,zp,"f"),x:l=yr(this,Cu,"f"),y:c=yr(this,Mu,"f"),rotation:h=yr(this,vf,"f"),viewportX:u=0,viewportY:d=0}=e,f=u||d,g=()=>{this.applyLandmark({x:l,y:c,zoom:a,rotation:h,viewportX:u,viewportY:d}),n&&n()};if(s===0){g();return}this.cancelLandmarkAnimation();let p;const m=[l,c],v=[a,h],b=y=>{p===void 0&&(p=y);const _=y-p;if(_>s){g();return}const w=BGt[i](_/s),E=it(),A=Be(1,0);if(ta(E,[yr(this,Cu,"f"),yr(this,Mu,"f")],m,w),ta(A,[this.zoom,yr(this,vf,"f")],v,w),this.applyLandmark({x:E[0],y:E[1],zoom:A[0],rotation:A[1],viewportX:u,viewportY:d}),f?za(A,v)<=jct:za(E,m)<=jct){g();return}_<s&&(o&&o(w),bc(this,IF,requestAnimationFrame(b),"f"))};requestAnimationFrame(b)}cancelLandmarkAnimation(){yr(this,IF,"f")!==void 0&&cancelAnimationFrame(yr(this,IF,"f"))}viewport2Canvas({x:e,y:r},i){const{width:s,height:o,viewProjectionMatrixInv:n}=i||this,a=Qt(it(),[e/s*2-1,(1-r/o)*2-1],n);return{x:a[0],y:a[1]}}canvas2Viewport({x:e,y:r},i){const{width:s,height:o,viewProjectionMatrix:n}=i||this,a=Qt(it(),[e,r],n);return{x:(a[0]+1)/2*s,y:(1-(a[1]+1)/2)*o}}applyLandmark(e){const{x:r,y:i,zoom:s,rotation:o,viewportX:n,viewportY:a}=e,l=n||a;let c=0,h=0;if(l){const u=this.viewport2Canvas({x:n,y:a});c=u.x,h=u.y}if(bc(this,zp,s,"f"),bc(this,vf,o,"f"),bc(this,Cu,r,"f"),bc(this,Mu,i,"f"),this.updateMatrix(),l){const{x:u,y:d}=this.viewport2Canvas({x:n,y:a});bc(this,Cu,yr(this,Cu,"f")+(c-u),"f"),bc(this,Mu,yr(this,Mu,"f")+(h-d),"f"),this.updateMatrix()}}};zp=new WeakMap,Cu=new WeakMap,Mu=new WeakMap,vf=new WeakMap,RF=new WeakMap,CF=new WeakMap,Vp=new WeakMap,M
3170F=new WeakMap,BF=new WeakMap,OF=new WeakMap,p6=new WeakMap,IF=new WeakMap;const zct=new uo;let uA=class{constructor(t=1/0,e=1/0,r=-1/0,i=-1/0){this.matrix=zct,this.minX=t,this.minY=e,this.maxX=r,this.maxY=i}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=zct,this}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addFrame(t,e,r,i,s){s||(s=this.matrix);const o=s.a,n=s.b,a=s.c,l=s.d,c=s.tx,h=s.ty;let u=this.minX,d=this.minY,f=this.maxX,g=this.maxY,p=o*t+a*e+c,m=n*t+l*e+h;p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*r+a*e+c,m=n*r+l*e+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*t+a*i+c,m=n*t+l*i+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*r+a*i+c,m=n*r+l*i+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),this.minX=u,this.minY=d,this.maxX=f,this.maxY=g}},Vct=class m1t{get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=m1t.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ye,this.page=new ye,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}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(e,r,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,r,i,s,o){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}},g6=class extends Vct{constructor(){super(...arguments),this.client=new ye,this.movement=new ye,this.offset=new ye,this.global=new ye,this.screen=new ye}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}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,r,i,s,o,n,a,l,c,h,u,d,f,g){throw new Error("Method not implemented.")}},Yp=class extends g6{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!")}},r7=class extends g6{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}};var DGt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},PGt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},m6;const FGt=2048;let NGt=class{constructor(t){this.dispatch=new Uo,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,m6.set(this,void 0),this.rootTarget=t,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)}setPickHandler(t){DGt(this,m6,t,"f")}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((r,i)=>r.priority-i.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.prop
vendor: 6,797 bytes, line 3170
3170agate(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 r=0,i=e.length;r<i;r++)e[r].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){return PGt(this,m6,"f").call(this,t,e)}propagate(t,e){if(!t.target)return;const r=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let i=0,s=r.length-1;i<s;i++)if(t.currentTarget=r[i],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 i=r.length-2;i>=0;i--)if(t.currentTarget=r[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,r=this._allInteractiveElements){if(r.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const i=Array.isArray(e)?e:[e];for(let s=r.length-1;s>=0;s--)i.forEach(o=>{t.currentTarget=r[s],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let r=0;r<FGt&&t!==this.rootTarget&&t.parent;r++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}notifyTarget(t,e){e=e??t.type;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 Yp)){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 i=e.button===2;this.dispatchEvent(e,i?"rightdown":"mousedown")}const r=this.trackingData(t.pointerId);r.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,r,i;if(!(t instanceof Yp)){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 s=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const o=s.pointerType==="mouse"||s.pointerType==="pen",n=this.trackingData(t.pointerId),a=this.findMountedTarget(n.overTargets);if(((e=n.overTargets)===null||e===void 0?void 0:e.length)>0&&a!==s.target){const h=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,h,a);if(this.dispatchEvent(u,"pointerout"),o&&this.dispatchEvent(u,"mouseout"),!s.composedPath().includes(a)){const d=this.createPointerEvent(t,"pointerleave",a);for(d.eventPhase=d.AT_TARGET;d.target&&!s.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),o&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(u)}if(a!==s.target){const h=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(s,h);this.dispatchEvent(u,"pointerover"),o&&this.dispatchEvent(u,"mouseover");let d=a==null?void 0:a.parent;for(;d&&d!==this.rootTarget.parent&&d!==s.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(s,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==a&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),o&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(u)}const l=[],c=(r=this.enableGlobalMoveEvents)!==null&&r!==void 0?r:!0;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(s,"pointermove"),c&&l.push("globalpointermove"),s.pointerType==="touch"&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(s,"touchmove"),c&&l.push("globaltouchmove")),o&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(s,"mousemove"),c&&l.push("globalmousemove"),this.cursor=(i=s.target)===null||i===void 0?void 0:i.cursor),l.length>0&&this.all(s,l),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=s.composedPath(),this.freeEvent(s)}mapPointerOver(t){var e;if(!(t instanceof Yp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(e=i.target)===null||e===void 0?void 0:e.cursor);const o=this.clonePointerEvent(i,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;r.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof Yp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const r=t.pointerType==="mouse"||t.pointerType==="pen",i=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",i);this.dispatchEvent(s),r&&this.dispatchEvent(s,"mouseout");const o=this.createPointerEvent(t,"pointerleave",i);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),r&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(s),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){var e;if(!(t instanceof Yp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=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 s=this.trackingData(t.pointerId),o=this.findMountedTarget(s.pressTargetsByButton[t.button]);let n=o;if(o&&!i.composedPath().includes(o)){let a=o;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 l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],n=a}if(n){const a=this.clonePointerEvent(i,"click");a.target=n,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:r});const l=s.clicksByButton[t.button];if(l.target===a.target&&r-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=r,a.detail=l.clickCount,!(!((e=i.detail)===null||e===void 0)&&e.preventClick)){if
3170(a.pointerType==="mouse"){const c=a.button===2;this.dispatchEvent(a,c?"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 Yp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),r=this.findMountedTarget(e.pressTargetsByButton[t.button]),i=this.createPointerEvent(t);if(r){let s=r;for(;s;)i.currentTarget=s,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch"?this.notifyTarget(i,"touchendoutside"):(i.pointerType==="mouse"||i.pointerType==="pen")&&this.notifyTarget(i,i.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(i)}mapWheel(t){if(!(t instanceof r7)){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 r=1;r<t.length&&t[r].parent===e;r++)e=t[r];return e}createPointerEvent(t,e,r){var i;const s=this.allocateEvent(Yp);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=(i=r??this.hitTest(s.global.x,s.global.y))!==null&&i!==void 0?i:this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(r7);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 r=this.allocateEvent(Yp);return r.nativeEvent=t.nativeEvent,r.originalEvent=t.originalEvent,this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.target=t.target,r.path=t.composedPath().slice(),r.type=e??r.type,r}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Yp&&e instanceof Yp&&(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.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof g6&&e instanceof g6&&(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 r=t.currentTarget._events[e];if(r)if("fn"in r)r.once&&t.currentTarget.removeListener(e,r.fn,void 0,!0),r.fn.call(r.context,t);else for(let i=0,s=r.length;i<s&&!t.propagationImmediatelyStopped;i++)r[i].once&&t.currentTarget.removeListener(e,r[i].fn,void 0,!0),r[i].fn.call(r[i].context,t)}};m6=new WeakMap;let kGt=class extends Uo{constructor(t={}){super();const{cursor:e,hitArea:r,pointerEvents:i,draggable:s,droppable:o}=t;this.cursor=e??"default",this.hitArea=r,this.pointerEvents=i??"auto",this.draggable=s??!1,this.droppable=o??!1}addEventListener(t,e,r){const i=Gct(r)&&r||d6(r)&&r.capture,s=d6(r)?r.signal:void 0,o=d6(r)&&r.once,n=f6(e)?void 0:e;t=i?`${t}capture`:t;const a=f6(e)?e:e.handleEvent;s&&s.addEventListener("abort",()=>{this.off(t,a,n)}),o?this.once(t,a,n):this.on(t,a,n)}removeEventListener(t,e,r){const i=Gct(r)&&r||d6(r)&&r.capture,s=f6(e)?void 0:e;t=i?`${t}capture`:t,e=f6(e)?e:e==null?void 0:e.handleEvent,this.off(t,e,s)}dispatchEvent(t){if(!(t instanceof Vct))throw new Error("Container cannot propagate events outside of the Federated Events API");return t.defaultPrevented=!1,t.path=[],t.target=this,t.manager.dispatchEvent(t),!t.defaultPrevented}};var zn=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Cd=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3170return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r};function LGt(t){var e,r,i,s,o,n,a,l,c,h,u,d,f,g;return g=class extends t{constructor(p={}){super(p),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,e.set(this,void 0),r.set(this,void 0),i.set(this,void 0),s.set(this,void 0),o.set(this,void 0),n.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),h.set(this,void 0),u.set(this,void 0),d.set(this,void 0),f.set(this,void 0);const{renderable:m,visible:v,cullable:b,batchable:y,fill:_,stroke:w,strokeWidth:E,opacity:A,fillOpacity:x,strokeOpacity:S,innerShadowColor:T,innerShadowOffsetX:R,innerShadowOffsetY:B,innerShadowBlurRadius:O}=p;this.renderable=m??!0,this.visible=v??!0,this.cullable=b??!0,this.batchable=y??!0,this.fill=_??"black",this.stroke=w??"black",this.strokeWidth=E??0,this.opacity=A??1,this.fillOpacity=x??1,this.strokeOpacity=S??1,this.innerShadowColor=T??"black",this.innerShadowOffsetX=R??0,this.innerShadowOffsetY=B??0,this.innerShadowBlurRadius=O??0}get fill(){return zn(this,e,"f")}set fill(p){zn(this,e,"f")!==p&&(Cd(this,e,p,"f"),Cd(this,r,sr.rgb(p),"f"),this.renderDirtyFlag=!0)}get fillRGB(){return zn(this,r,"f")}get stroke(){return zn(this,i,"f")}set stroke(p){zn(this,i,"f")!==p&&(Cd(this,i,p,"f"),Cd(this,s,sr.rgb(p),"f"),this.renderDirtyFlag=!0)}get strokeRGB(){return zn(this,s,"f")}get strokeWidth(){return zn(this,o,"f")}set strokeWidth(p){zn(this,o,"f")!==p&&(Cd(this,o,p,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get opacity(){return zn(this,n,"f")}set opacity(p){zn(this,n,"f")!==p&&(Cd(this,n,p,"f"),this.renderDirtyFlag=!0)}get fillOpacity(){return zn(this,a,"f")}set fillOpacity(p){zn(this,a,"f")!==p&&(Cd(this,a,p,"f"),this.renderDirtyFlag=!0)}get strokeOpacity(){return zn(this,l,"f")}set strokeOpacity(p){zn(this,l,"f")!==p&&(Cd(this,l,p,"f"),this.renderDirtyFlag=!0)}get innerShadowColor(){return zn(this,c,"f")}set innerShadowColor(p){zn(this,c,"f")!==p&&(Cd(this,c,p,"f"),Cd(this,h,sr.rgb(p),"f"),this.renderDirtyFlag=!0)}get innerShadowColorRGB(){return zn(this,h,"f")}get innerShadowOffsetX(){return zn(this,u,"f")}set innerShadowOffsetX(p){zn(this,u,"f")!==p&&(Cd(this,u,p,"f"),this.renderDirtyFlag=!0)}get innerShadowOffsetY(){return zn(this,d,"f")}set innerShadowOffsetY(p){zn(this,d,"f")!==p&&(Cd(this,d,p,"f"),this.renderDirtyFlag=!0)}get innerShadowBlurRadius(){return zn(this,f,"f")}set innerShadowBlurRadius(p){zn(this,f,"f")!==p&&(Cd(this,f,p,"f"),this.renderDirtyFlag=!0)}},e=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap,o=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,g}function UGt(t){return class extends t{constructor(){super(...arguments),this.transform=new wn}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(e){this.transform.position.copyFrom(e)}get scale(){return this.transform.scale}set scale(e){this.transform.scale.copyFrom(e)}get pivot(){return this.transform.pivot}set pivot(e){this.transform.pivot.copyFrom(e)}get skew(){return this.transform.skew}set skew(e){this.transform.skew.copyFrom(e)}get rotation(){return this.transform.rotation}set rotation(e){this.transform.rotation=e}get angle(){return this.transform.rotation*id}set angle(e){this.transform.rotation=e*eu}get transformDirtyFlag(){var e;return this.transform._localID!==this.transform._currentLocalID||this.transform._parentID!==((e=this.parent)===null||e===void 0?void 0:e.transform._worldID)}}}const Yct=new wn,$ct=new uo,DF=GGt(LGt(UGt(kGt)));function GGt(t){class e extends t{constructor(i={}){super(i),this.uid=IGt(),this.children=[]}appendChild(i){return i.parent&&i.parent.removeChild(i),i.parent=this,i.transform._parentID=-1,this.children.push(i),i}removeChild(i){const s=this.children.indexOf(i);return s===-1?null:(i.parent=void 0,i.transform._parentID=-1,this.children.splice(s,1),i)}getBounds(i){if(!this.boundsDirtyFlag)return this.bounds;this.bounds=this.bounds||new uA,this.bounds.clear();let s;return this.parent?i?s=this.parent.worldTransform:($ct.identity(),s=Hct(this,$ct)):s=uo.IDENTITY,i7(this,this.bounds,s,i),this.boundsDirtyFlag=!1,this.bounds}}return e}function i7(t,e,r,i){if(!t.visible)return;let s;i?s=t.worldTransform:(t.transform.updateLocalTransform(),s=new uo,s.copyFrom(t.localTransform),s.append(r)),t.renderable&&(e.matrix=s,e.addBounds(t.getRenderBounds()));for(let o=0;o<t.children.length;o++)i7(t.children[o],e,s,i)}function Hct(t,e){const r=t.parent;return r&&(Hct(r,e),r.transform.updateLocalTransform(),e.append(r.localTransform)),e}function y6(t,e,r){let i=!1,s=!1;const o=!!e&&e!=="none",n=!!r&&r!=="none";return t==="visiblepainted"||t==="painted"||t==="auto"?(i=o,s=n):t==="visiblefill"||t==="fill"?i=!0:t==="visiblestroke"||t==="stroke"?s=!0:(t==="visible"||t==="all")&&(i=!0,s=!0),[i,s]}var Al=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},s7=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3170return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},$_,H_,_f;let o7=class extends DF{constructor(t={}){super(t),$_.set(this,void 0),H_.set(this,void 0),_f.set(this,void 0);const{cx:e,cy:r,r:i}=t;this.cx=e??0,this.cy=r??0,this.r=i??0}get cx(){return Al(this,$_,"f")}set cx(t){Al(this,$_,"f")!==t&&(s7(this,$_,t,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get cy(){return Al(this,H_,"f")}set cy(t){Al(this,H_,"f")!==t&&(s7(this,H_,t,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get r(){return Al(this,_f,"f")}set r(t){Al(this,_f,"f")!==t&&(s7(this,_f,t,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}containsPoint(t,e){const r=this.strokeWidth/2,i=Lct(Al(this,$_,"f"),Al(this,H_,"f"),t,e),[s,o]=y6(this.pointerEvents,this.fill,this.stroke);return s?i<=Al(this,_f,"f"):o?i>=Al(this,_f,"f")-r&&i<=Al(this,_f,"f")+r:!1}getRenderBounds(){if(this.renderBoundsDirtyFlag){const t=this.strokeWidth/2;this.renderBoundsDirtyFlag=!1,this.renderBounds=new uA(Al(this,$_,"f")-Al(this,_f,"f")-t,Al(this,H_,"f")-Al(this,_f,"f")-t,Al(this,$_,"f")+Al(this,_f,"f")+t,Al(this,H_,"f")+Al(this,_f,"f")+t)}return this.renderBounds}};$_=new WeakMap,H_=new WeakMap,_f=new WeakMap;var K_=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},v6=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},PF,FF,NF,kF;let n7=class extends DF{constructor(t={}){var e,r;super(t),PF.set(this,void 0),FF.set(this,void 0),NF.set(this,void 0),kF.set(this,void 0);const{cx:i,cy:s,rx:o,ry:n}=t;this.cx=i??0,this.cy=s??0,this.rx=(e=o??n)!==null&&e!==void 0?e:0,this.ry=(r=n??o)!==null&&r!==void 0?r:0}get cx(){return K_(this,PF,"f")}set cx(t){K_(this,PF,"f")!==t&&(v6(this,PF,t,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get cy(){return K_(this,FF,"f")}set cy(t){K_(this,FF,"f")!==t&&(v6(this,FF,t,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get rx(){return K_(this,NF,"f")}set rx(t){K_(this,NF,"f")!==t&&(v6(this,NF,t,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get ry(){return K_(this,kF,"f")}set ry(t){K_(this,kF,"f")!==t&&(v6(this,kF,t,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}containsPoint(t,e){const{cx:r,cy:i,rx:s,ry:o,strokeWidth:n}=this,a=n/2,[l,c]=y6(this.pointerEvents,this.fill,this.stroke);return l&&c?_6(t,e,r,i,s+a,o+a):l?_6(t,e,r,i,s,o):c?!_6(t,e,r,i,s-a,o-a)&&_6(t,e,r,i,s+a,o+a):!1}getRenderBounds(){if(this.renderBoundsDirtyFlag){const{strokeWidth:t,cx:e,cy:r,rx:i,ry:s}=this,o=t/2;this.renderBoundsDirtyFlag=!1,this.renderBounds=new uA(e-i-o,r-s-o,e+i+o,r+s+o)}return this.renderBounds}};PF=new WeakMap,FF=new WeakMap,NF=new WeakMap,kF=new WeakMap;function _6(t,e,r,i,s,o){const n=t-r,a=e-i;return n*n/(s*s)+a*a/(o*o)<=1}var xl=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Gm=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},LF,UF,GF,WF,jF,XF,b6,zF,VF,YF;let a7=class extends DF{constructor(t={}){super(t),LF.set(this,void 0),UF.set(this,void 0),GF.set(this,void 0),WF.set(this,void 0),jF.set(this,void 0),XF.set(this,void 0),b6.set(this,void 0),zF.set(this,void 0),VF.set(this,void 0),YF.set(this,void 0);const{x:e,y:r,width:i,height:s,cornerRadius:o,dropShadowColor:n,dropShadowOffsetX:a,dropShadowOffsetY:l,dropShadowBlurRadius:c}=t;this.x=e??0,this.y=r??0,this.width=i??0,this.height=s??0,this.cornerRadius=o??0,this.dropShadowColor=n??"black",this.dropShadowOffsetX=a??0,this.dropShadowOffsetY=l??0,this.dropShadowBlurRadius=c??0}get x(){return xl(this,LF,"f")}set x(t){xl(this,LF,"f")!==t&&(Gm(this,LF,t,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get y(){return xl(this,UF,"f")}set y(t){xl(this,UF,"f")!==t&&(Gm(this,UF,t,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get width(){return xl(this,GF,"f")}set width(t){xl(this,GF,"f")!==t&&(Gm(this,GF,t,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get height(){return xl(this,WF,"f")}set height(t){xl(this,WF,"f")!==t&&(Gm(this,WF,t,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get cornerRadius(){return xl(this,jF,"f")}set cornerRadius(t){xl(this,jF,"f")!==t&&(Gm(this,jF,t,"f"),this.renderDirtyFlag=!0)}get dropShadowColor(){return xl(this,XF,"f")}set dropShadowColor(t){xl(this,XF,"f")!==t&&(Gm(this,XF,t,"f"),Gm(this,b6,sr.rgb(t),"f"),this.renderDirtyFlag=!0)}get dropShadowColorRGB(){return xl(this,b6,"f")}get dropShadowOffsetX(){return xl(this,zF,"f")}set dropShadowOffsetX(t){xl(this,zF,"f")!==t&&(Gm(this,zF,t,"f"),this.renderDirtyFlag=!0)}get dropShadowOffsetY(){return xl(this,VF,"f")}set dropShadowOffsetY(t){xl(this,VF,"f")!==t&&(Gm(this,VF,t,"f"),this.renderDirtyFlag=!0)}get dropShadowBlurRadius(){return xl(this,YF,"f")}set dropShadowBlurRadius(t){xl(this,YF,"f")!==t&&(Gm(this,YF,t,"f"),this.renderDirtyFlag=!0)}containsPoint(t,e){const{x:r,y:i,width:s,height:o,strokeWidth:n,cornerRadius:a}=this,l=n/2,[c,h]=y6(this.pointerEvents,this.dropShadowColor,this.stroke);return c&&h?w6(t,e,r-l,i-l,r+s+l,i+o+l,a):c?w6(t,e,r,i,r+s,i+o,a):h?!w6(t,e,r+l,i+l,r+s-l,i+o-l,a)&&w6(t,e,r-l,i-l,r+s+l,i+o+l,a):!1}getRenderBounds(){if(this.renderBoundsDirtyFlag){const{strokeWidth:t,x:e,y:r,width:i,height:s,dropShadowOffsetX:o,dropShadowOffsetY:n,dropShadowBlurRadius:a}=this,l=t/2;this.renderBoundsDirtyFlag=!1,this.renderBounds=new uA(e-l,r-l,e+i+l,r+s+l),this.renderBounds.addBounds(new uA(e+o-a,r+n-a,e+o+i+a,r+n+s+a))}return this.renderBounds}};LF=new WeakMap,UF=new WeakMap,GF=new WeakMap,WF=new WeakMap,jF=new WeakMap,XF=new WeakMap,b6=new WeakMap,zF=new WeakMap,VF=new WeakMap,YF=new WeakMap;function w6(t,e,r,i,s,o,n){function a(l,c,h,u,d){return Math.sqrt(Math.pow(l-h,2)+Math.pow(c-u,2))<=d}return t>=r&&t<=s&&e>=i&&e<=o?a(t,e,r+n,i+n,n)||a(t,e,s-n,i+n,n)||a(t,e,s-n,o-n,n)||a(t,e,r+n,o-n,n)?!0:!(t<=r+n||t>=s-n||e<=i+n||e>=o-n):!1}const WGt=` 3171layout(std140) uniform SceneUniforms { 3172 mat3 u_ProjectionMatrix; 3173 mat3 u_ViewMatrix; 3174 mat3 u_ViewProjectionInvMatrix; 3175 float u_ZoomScale; 3176 float u_CheckboardStyle; 3177}; 3178 3179layout(location = 0) in vec2 a_Position; 3180 3181out vec2 v_Position; 3182 3183vec2 project_clipspace_to_world(vec2 p) { 3184 return (u_ViewProjectionInvMatrix * vec3(p, 1)).xy; 3185} 3186 3187void main() { 3188 v_Position = project_clipspace_to_world(a_Position); 3189 gl_Position = vec4(a_Position, 0, 1); 3190} 3191`,jGt=` 3192layout(std140) uniform SceneUniforms { 3193 mat3 u_ProjectionMatrix; 3194 mat3 u_ViewMatrix; 3195 mat3 u_ViewProjectionInvMatrix; 3196 float u_ZoomScale; 3197 float u_CheckboardStyle; 3198}; 3199 3200out vec4 outputColor; 3201 3202in vec2 v_Position; 3203 3204const vec4 GRID_COLOR = vec4(0.87, 0.87, 0.87, 1.0); 3205const vec4 PAGE_COLOR = vec4(0.986, 0.986, 0.986, 1.0); 3206const int CHECKERBOARD_STYLE_NONE = 0; 3207const int CHECKERBOARD_STYLE_GRID = 1; 3208const int CHECKERBOARD_STYLE_DOTS = 2; 3209const float BASE_GRID_PIXEL_SIZE = 100.0; 3210const float BASE_DOT_SIZE = 8.0; 3211 3212vec2 scale_grid_size(float zoom) { 3213 if (zoom < 0.125) return vec2(BASE_GRID_PIXEL_SIZE * 125.0, 0.125); 3214 else if (zoom < 0.25) return vec2(BASE_GRID_PIXEL_SIZE * 25.0, 0.25); 3215 else if (zoom < 0.5) return vec2(BASE_GRID_PIXEL_SIZE * 5.0, 0.5); 3216 return vec2(BASE_GRID_PIXEL_SIZE, 4.0); 3217} 3218 3219vec4 render_grid_checkerboard(vec2 coord) { 3220 float alpha = 0.0; 3221 3222 vec2 size = scale_grid_size(u_ZoomScale); 3223 float gridSize1 = size.x; 3224 float gridSize2 = gridSize1 / 10.0;
3225 float zoomStep = size.y; 3226 int checkboardStyle = int(floor(u_CheckboardStyle + 0.5)); 3227 3228 if (checkboardStyle == CHECKERBOARD_STYLE_GRID) { 3229 vec2 grid1 = abs(fract(coord / gridSize1 - 0.5) - 0.5) / fwidth(coord) * gridSize1 / 2.0; 3230 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2; 3231 float v1 = 1.0 - min(min(grid1.x, grid1.y), 1.0); 3232 float v2 = 1.0 - min(min(grid2.x, grid2.y), 1.0); 3233 3234 if (v1 > 0.0) { 3235 alpha = v1; 3236 } else { 3237 alpha = v2 * clamp(u_ZoomScale / zoomStep, 0.0, 1.0); 3238 } 3239 } else if (checkboardStyle == CHECKERBOARD_STYLE_DOTS) { 3240 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2; 3241 alpha = 1.0 - smoothstep(0.0, 1.0, length(grid2) - BASE_DOT_SIZE * u_ZoomScale / zoomStep); 3242 } 3243 3244 return mix(PAGE_COLOR, GRID_COLOR, alpha); 3245} 3246 3247void main() { 3248 outputColor = render_grid_checkerboard(v_Position); 3249} 3250`;var wc=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},$F=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},dA,eM,rM,HF,KF,qF;let Kct=class{constructor(){dA.set(this,void 0),eM.set(this,void 0),rM.set(this,void 0),HF.set(this,void 0),KF.set(this,void 0),qF.set(this,new OGt)}appendVertex(t,e){wc(this,qF,"f").appendFloat(t).appendFloat(e)}render(t,e,r){if(!wc(this,dA,"f")){$F(this,dA,t.createProgram({vertex:{glsl:WGt},fragment:{glsl:jGt}}),"f"),$F(this,rM,t.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{format:I.F32_RG,offset:0,shaderLocation:0}]}],indexBufferFormat:null,program:wc(this,dA,"f")}),"f"),$F(this,eM,t.createRenderPipeline({inputLayout:wc(this,rM,"f"),program:wc(this,dA,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,topology:Go.TRIANGLE_STRIP}),"f"),wc(this,qF,"f").clear(),this.appendVertex(-1,-1),this.appendVertex(-1,1),this.appendVertex(1,-1),this.appendVertex(1,1);const i=wc(this,qF,"f").bytes(),s=t.createBuffer({viewOrSize:i.byteLength,usage:dt.VERTEX,hint:Et.DYNAMIC});$F(this,KF,s,"f"),s.setSubData(0,i),$F(this,HF,t.createBindings({pipeline:wc(this,eM,"f"),uniformBufferBindings:[{buffer:r}]}),"f")}
3250e.setBindings(wc(this,HF,"f")),e.setPipeline(wc(this,eM,"f")),e.setVertexInput(wc(this,rM,"f"),[{buffer:wc(this,KF,"f")}],null),e.draw(4)}destroy(){wc(this,dA,"f").destroy(),wc(this,KF,"f").destroy(),wc(this,eM,"f").destroy(),wc(this,rM,"f").destroy(),wc(this,HF,"f").destroy()}};dA=new WeakMap,eM=new WeakMap,rM=new WeakMap,HF=new WeakMap,KF=new WeakMap,qF=new WeakMap;let qct=class extends DF{constructor(){super(...arguments),this.renderable=!1}containsPoint(t,e){throw new Error("Method not implemented.")}getRenderBounds(){throw new Error("Method not implemented.")}destroy(){}};const Zct=1e5;let Jct=class{constructor(t,e){this.device=t,this.instanced=e,this.shapes=[],this.maxInstances=1/0,this.geometryDirty=!0,this.materialDirty=!0}validate(){return this.count()<=this.maxInstances-1}submit(t,e){this.geometryDirty&&this.createGeometry(),this.materialDirty&&this.createMaterial(e),this.render(t),this.geometryDirty&&(this.geometryDirty=!1),this.materialDirty&&(this.materialDirty=!1)}add(t){this.shapes.includes(t)||(this.shapes.push(t),this.geometryDirty=!0)}remove(t){if(this.shapes.includes(t)){const e=this.shapes.indexOf(t);this.shapes.splice(e,1),this.geometryDirty=!0}}count(){return this.shapes.length}};const XGt=` 3251layout(std140) uniform SceneUniforms { 3252 mat3 u_ProjectionMatrix; 3253 mat3 u_ViewMatrix; 3254}; 3255 3256layout(location = 0) in vec2 a_FragCoord; 3257 3258#ifdef USE_INSTANCES 3259 layout(location = 14) in vec4 a_Abcd; 3260 layout(location = 15) in vec2 a_Txty; 3261 layout(location = 1) in vec4 a_PositionSize; 3262 layout(location = 2) in vec4 a_FillColor; 3263 layout(location = 3) in vec4 a_StrokeColor; 3264 layout(location = 4) in vec4 a_ZIndexStrokeWidth; 3265 layout(location = 5) in vec4 a_Opacity; 3266 layout(location = 6) in vec4 a_InnerShadowColor; 3267 layout(location = 7) in vec4 a_InnerShadow; 3268#else 3269 layout(std140) uniform ShapeUniforms { 3270 mat3 u_ModelMatrix; 3271 vec4 u_PositionSize; 3272 vec4 u_FillColor; 3273 vec4 u_StrokeColor; 3274 vec4 u_ZIndexStrokeWidth; 3275 vec4 u_Opacity; 3276 vec4 u_InnerShadowColor; 3277 vec4 u_InnerShadow; 3278 }; 3279#endif 3280 3281out vec2 v_FragCoord; 3282#ifdef USE_INSTANCES 3283 out vec4 v_FillColor; 3284 out vec4 v_StrokeColor; 3285 out float v_StrokeWidth; 3286 out vec4 v_Opacity; 3287 out float v_CornerRadius; 3288 out vec4 v_InnerShadowColor; 3289 out vec4 v_InnerShadow; 3290#else 3291#endif 3292out vec2 v_Radius; 3293 3294void main() { 3295 mat3 model; 3296 vec2 position; 3297 vec2 size; 3298 vec4 fillColor; 3299 vec4 strokeColor; 3300 float zIndex; 3301 float strokeWidth; 3302 3303 #ifdef USE_INSTANCES 3304 model = mat3(a_Abcd.x, a_Abcd.y, 0, a_Abcd.z, a_Abcd.w, 0, a_Txty.x, a_Txty.y, 1); 3305 position = a_PositionSize.xy; 3306 size = a_PositionSize.zw; 3307 fillColor = a_FillColor; 3308 strokeColor = a_StrokeColor; 3309 zIndex = a_ZIndexStrokeWidth.x; 3310 strokeWidth = a_ZIndexStrokeWidth.y; 3311 3312 v_FillColor = fillColor; 3313 v_StrokeColor = strokeColor; 3314 v_StrokeWidth = strokeWidth; 3315 v_Opacity = a_Opacity; 3316 v_CornerRadius = a_ZIndexStrokeWidth.z; 3317 v_InnerShadowColor = a_InnerShadowColor; 3318 v_InnerShadow = a_InnerShadow; 3319 #else 3320 model = u_ModelMatrix; 3321 position = u_PositionSize.xy; 3322 size = u_PositionSize.zw; 3323 fillColor = u_FillColor; 3324 strokeColor = u_StrokeColor; 3325 zIndex = u_ZIndexStrokeWidth.x; 3326 strokeWidth = u_ZIndexStrokeWidth.y; 3327 #endif 3328 3329 vec2 radius = size + vec2(strokeWidth / 2.0); 3330 3331 v_FragCoord = vec2(a_FragCoord * radius); 3332 v_Radius = radius; 3333 3334 gl_Position = vec4((u_ProjectionMatrix 3335 * u_ViewMatrix 3336 * model 3337 * vec3(position + v_FragCoord, 1)).xy, zIndex, 1); 3338} 3339`,zGt=` 3340#ifdef USE_INSTANCES 3341#else 3342 layout(std140) uniform ShapeUniforms { 3343 mat3 u_ModelMatrix; 3344 vec4 u_PositionSize; 3345 vec4 u_FillColor; 3346 vec4 u_StrokeColor; 3347 vec4 u_ZIndexStrokeWidth; 3348 vec4 u_Opacity; 3349 vec4 u_InnerShadowColor; 3350 vec4 u_InnerShadow; 3351 }; 3352#endif 3353 3354out vec4 outputColor; 3355 3356in vec2 v_FragCoord; 3357#ifdef USE_INSTANCES 3358 in vec4 v_FillColor; 3359 in vec4 v_StrokeColor; 3360 in float v_StrokeWidth; 3361 in vec4 v_Opacity; 3362 in float v_CornerRadius; 3363 in vec4 v_InnerShadowColor; 3364 in vec4 v_InnerShadow; 3365#else 3366#endif 3367in vec2 v_Radius; 3368 3369float epsilon = 0.000001; 3370 3371float sdf_circle(vec2 p, float r) { 3372 return length(p) - r; 3373} 3374 3375float sdf_ellipse(vec2 p, vec2 r) {
3376 float k0 = length(p / r); 3377 float k1 = length(p / (r * r)); 3378 return k0 * (k0 - 1.0) / k1; 3379 3380 // V1 3381 // float k1 = length(p/r); 3382 // return (k1-1.0)*min(r.x,r.y); 3383 3384 // V3 3385 // float k1 = length(p/r); 3386 // return length(p)*(1.0-1.0/k1); 3387} 3388 3389float sdf_rounded_box(vec2 p, vec2 b, float r) { 3390 vec2 q = abs(p) - b + r; 3391 return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r; 3392} 3393 3394vec4 over(vec4 below, vec4 above) { 3395 vec4 result; 3396 float alpha = above.a + below.a * (1.0 - above.a); 3397 result.rgb = 3398 (above.rgb * above.a + below.rgb * below.a * (1.0 - above.a)) / alpha; 3399 result.a = alpha; 3400 return result; 3401} 3402 3403float antialias(float distance) { 3404 return clamp(distance / -fwidth(distance), 0.0, 1.0); 3405} 3406 3407vec4 mix_border_inside(vec4 border, vec4 inside, float distance) { 3408 // Blend the border on top of the background and then linearly interpolate 3409 // between the two as we slide inside the background. 3410 return mix(border, inside, clamp(1.0 - distance, 0.0, 1.0) * antialias(distance)); 3411} 3412 3413float sigmoid(float t) { 3414 return 1.0 / (1.0 + exp(-t)); 3415} 3416 3417float make_shadow(vec2 pos, vec2 halfSize, float cornerRd, float blurRd, float distMul, float shape) { 3418 float distance; 3419 if (shape < 0.5) { 3420 distance = sdf_circle(pos, halfSize.x); 3421 } else if (shape < 1.5) { 3422 distance = sdf_ellipse(pos, halfSize); 3423 } else if (shape < 2.5) { 3424 distance = sdf_rounded_box(pos, halfSize, cornerRd + blurRd); 3425 } 3426 float dist = sigmoid(distMul * distance / blurRd); 3427 return clamp(dist, 0.0, 1.0); 3428} 3429 3430void main() { 3431 float strokeWidth; 3432 vec4 fillColor; 3433 vec4 strokeColor; 3434 float opacity; 3435 float fillOpacity; 3436 float strokeOpacity; 3437 float shape; 3438 float cornerRadius; 3439 vec4 innerShadowColor; 3440 vec4 innerShadow; 3441 3442 #ifdef USE_INSTANCES 3443 fillColor = v_FillColor; 3444 strokeColor = v_StrokeColor; 3445 strokeWidth = v_StrokeWidth; 3446 opacity = v_Opacity.x; 3447 fillOpacity = v_Opacity.y; 3448 strokeOpacity = v_Opacity.z; 3449 shape = v_Opacity.w; 3450 cornerRadius = v_CornerRadius; 3451 innerShadowColor = v_InnerShadowColor; 3452 innerShadow = v_InnerShadow; 3453 #else 3454 fillColor = u_FillColor; 3455 strokeColor = u_StrokeColor; 3456 strokeWidth = u_ZIndexStrokeWidth.y; 3457 opacity = u_Opacity.x; 3458 fillOpacity = u_Opacity.y; 3459 strokeOpacity = u_Opacity.z; 3460 shape = u_Opacity.w; 3461 cornerRadius = u_ZIndexStrokeWidth.z; 3462 innerShadowColor = u_InnerShadowColor; 3463 innerShadow = u_InnerShadow; 3464 #endif 3465 3466 float distance; 3467 // 'circle', 'ellipse', 'rect' 3468 if (shape < 0.5) { 3469 distance = sdf_circle(v_FragCoord, v_Radius.x); 3470 } else if (shape < 1.5) { 3471 distance = sdf_ellipse(v_FragCoord, v_Radius); 3472 } else if (shape < 2.5) { 3473 distance = sdf_rounded_box(v_FragCoord, v_Radius, cornerRadius); 3474 // TODO: Fast path when the quad is not rounded and doesn't have any border. 3475 } 3476 3477 // based on the target alpha compositing mode. 3478 fillColor.a *= fillOpacity; 3479 strokeColor.a *= strokeOpacity; 3480 3481 vec4 color = fillColor; 3482 if (strokeWidth > 0.0) { 3483 color = mix_border_inside(over(fillColor, strokeColor), fillColor, distance + strokeWidth); 3484 color = mix_border_inside(strokeColor, color, distance + strokeWidth / 2.0); 3485 } 3486 outputColor = color; 3487 3488 float innerShadowBlurRadius = innerShadow.z / 2.0; 3489 if (innerShadowBlurRadius > 0.0) { 3490 vec2 shadowOffset = -innerShadow.xy; 3491 float blurRadius = innerShadow.z; 3492 float distMul = -1.0; 3493 float lowerShadow = make_shadow(v_FragCoord + shadowOffset, v_Radius, cornerRadius, blurRadius, distMul, shape); 3494 3495 vec3 lowerShadowColor = innerShadowColor.rgb * innerShadowColor.a; 3496 outputColor = over(vec4(color.xyz, 1.0), vec4(lowerShadowColor, 1.0 - lowerShadow)); 3497 outputColor = over(outputColor, vec4(color.xyz, clamp(distance, 0.0, 1.0))); 3498 } 3499 3500 float antialiasedBlur = -fwidth(length(v_FragCoord)); 3501 float opacity_t = clamp(distance / antialiasedBlur, 0.0, 1.0); 3502 outputColor.a *= clamp(1.0 - distance, 0.0, 1.0) * opacity * opacity_t; 3503 3504 // TODO: antialiasing 3505 if (outputColor.a < epsilon) 3506 discard; 3507} 3508`;var rs=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},$p=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3508return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Wm,iM,q_,Z_,ZF,fA,J_,Q_,sM;let l7=class extends Jct{constructor(){super(...arguments),Wm.set(this,void 0),iM.set(this,void 0),q_.set(this,void 0),Z_.set(this,void 0),ZF.set(this,void 0),fA.set(this,void 0),J_.set(this,void 0),Q_.set(this,void 0),sM.set(this,void 0)}createGeometry(){rs(this,iM,"f")||($p(this,iM,this.device.createBuffer({viewOrSize:new Float32Array([-1,-1,1,-1,1,1,-1,1]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),$p(this,ZF,this.device.createBuffer({viewOrSize:new Uint32Array([0,1,2,0,2,3]),usage:dt.INDEX,hint:Et.STATIC}),"f")),this.instanced&&(rs(this,q_,"f")&&rs(this,q_,"f").destroy(),$p(this,q_,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*28*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),rs(this,Z_,"f")&&rs(this,Z_,"f").destroy(),$p(this,Z_,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*6*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"))}createMaterial(t){let e="";this.instanced&&(e+=`#define USE_INSTANCES 3509`),rs(this,Wm,"f")&&(rs(this,Wm,"f").destroy(),rs(this,Q_,"f").destroy(),rs(this,J_,"f").destroy());const r=this.device.queryVendorInfo().platformString==="WebGPU"?"diagnostic(off,derivative_uniformity);":"";$p(this,Wm,this.device.createProgram({vertex:{glsl:e+XGt},fragment:{glsl:e+zGt,postprocess:s=>r+s}}),"f");const i=[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:0,offset:0,format:I.F32_RG}]}];this.instanced?(i.push({arrayStride:112,stepMode:ne.INSTANCE,attributes:[{shaderLocation:1,offset:0,format:I.F32_RGBA},{shaderLocation:2,offset:16,format:I.F32_RGBA},{shaderLocation:3,offset:32,format:I.F32_RGBA},{shaderLocation:4,offset:48,format:I.F32_RGBA},{shaderLocation:5,offset:64,format:I.F32_RGBA},{shaderLocation:6,offset:80,format:I.F32_RGBA},{shaderLocation:7,offset:96,format:I.F32_RGBA}]},{arrayStride:24,stepMode:ne.INSTANCE,attributes:[{shaderLocation:14,offset:0,format:I.F32_RGBA},{shaderLocation:15,offset:16,format:I.F32_RG}]}),$p(this,Q_,this.device.createInputLayout({vertexBufferDescriptors:i,indexBufferFormat:I.U32_R,program:rs(this,Wm,"f")}),"f")):($p(this,Q_,this.device.createInputLayout({vertexBufferDescriptors:i,indexBufferFormat:I.U32_R,program:rs(this,Wm,"f")}),"f"),rs(this,fA,"f")||$p(this,fA,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*40,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f")),$p(this,J_,this.device.createRenderPipeline({inputLayout:rs(this,Q_,"f"),program:rs(this,Wm,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],depthWrite:!0,depthCompare:qe.GREATER}}),"f"),this.instanced?$p(this,sM,this.device.createBindings({pipeline:rs(this,J_,"f"),uniformBufferBindings:[{buffer:t}]}),"f"):$p(this,sM,this.device.createBindings({pipeline:rs(this,J_,"f"),uniformBufferBindings:[{buffer:t},{buffer:rs(this,fA,"f")}]}),"f")}render(t){if(this.shapes.some(r=>r.renderDirtyFlag)||this.geometryDirty)if(this.instanced){rs(this,Z_,"f").setSubData(0,new Uint8Array(new Float32Array(this.shapes.map(i=>[i.worldTransform.a,i.worldTransform.b,i.worldTransform.c,i.worldTransform.d,i.worldTransform.tx,i.worldTransform.ty]).flat()).buffer));const r=[];this.shapes.forEach(i=>{r.push(...this.generateBuffer(i))}),rs(this,q_,"f").setSubData(0,new Uint8Array(new Float32Array(r).buffer))}else{const{worldTransform:r}=this.shapes[0];rs(this,fA,"f").setSubData(0,new Uint8Array(new Float32Array([...V_(r.toArray(!0)),...this.generateBuffer(this.shapes[0])]).buffer))}const e=[{buffer:rs(this,iM,"f")}];this.instanced&&e.push({buffer:rs(this,q_,"f")},{buffer:rs(this,Z_,"f")}),t.setPipeline(rs(this,J_,"f")),t.setVertexInput(rs(this,Q_,"f"),e,{buffer:rs(this,ZF,"f")}),t.setBindings(rs(this,sM,"f")),t.drawIndexed(6,this.shapes.length)}destroy(){var t,e,r,i,s,o,n,a;rs(this,Wm,"f")&&(rs(this,Wm,"f").destroy(),(t=rs(this,Z_,"f"))===null||t===void 0||t.destroy(),(e=rs(this,q_,"f"))===null||e===void 0||e.destroy(),(r=rs(this,iM,"f"))===null||r===void 0||r.destroy(),(i=rs(this,ZF,"f"))===null||i===void 0||i.destroy(),(s=rs(this,fA,"f"))===null||s===void 0||s.destroy(),(o=rs(this,J_,"f"))===null||o===void 0||o.destroy(),(n=rs(this,Q_,"f"))===null||n===void 0||n.destroy(),(a=rs(this,sM,"f"))===null||a===void 0||a.destroy())}generateBuffer(t){const{fillRGB:{r:e,g:r,b:i,opacity:s},strokeRGB:{r:o,g:n,b:a,opacity:l},strokeWidth:c,opacity:h,fillOpacity:u,strokeOpacity:d,innerShadowColorRGB:{r:f,g,b:p,opacity:m},innerShadowOffsetX:v,innerShadowOffsetY:b,innerShadowBlurRadius:y}=t;let _,w,E=0;if(t instanceof o7){const{cx:A,cy:x,r:S}=t;_=[A,x,S,S],w=0}else if(t instanceof n7){const{cx:A,cy:x,rx:S,ry:T}=t;_=[A,x,S,T],w=1}else if(t instanceof a7){const{x:A,y:x,width:S,height:T,cornerRadius:R}=t;_=[A+S/2,x+T/2,S/2,T/2],w=2,E=R}return[..._,e/255,r/255,i/255,s,o/255,n/255,a/255,l,t.globalRenderOrder/Zct,c,E,0,h,u,d,w,f/255,g/255,p/255,m,v,b,y,0]}};Wm=new WeakMap,iM=new WeakMap,q_=new WeakMap,Z_=new WeakMap,ZF=new WeakMap,fA=new WeakMap,J_=new WeakMap,Q_=new WeakMap,sM=new WeakMap;const VGt=` 3510layout(std140) uniform SceneUniforms { 3511 mat3 u_ProjectionMatrix; 3512 mat3 u_ViewMatrix; 3513}; 3514 3515layout(location = 0) in vec2 a_FragCoord; 3516 3517#ifdef USE_INSTANCES 3518 layout(location = 14) in vec4 a_Abcd; 3519 layout(location = 15) in vec2 a_Txty; 3520 layout(location = 1) in vec4 a_PositionSize; 3521 layout(location = 4) in vec4 a_ZIndexStrokeWidth; 3522 layout(location = 5) in vec4 a_DropShadowColor; 3523 layout(location = 6) in vec4 a_DropShadow; 3524#else 3525 layout(std140) uniform ShapeUniforms { 3526 mat3 u_ModelMatrix; 3527 vec4 u_PositionSize; 3528 vec4 u_ZIndexStrokeWidth; 3529 vec4 u_DropShadowColor; 3530 vec4 u_DropShadow; 3531 }; 3532#endif 3533 3534out vec2 v_Origin; 3535#ifdef USE_INSTANCES 3536 out float v_CornerRadius; 3537 out vec4 v_DropShadowColor; 3538 out vec4 v_DropShadow; 3539#else 3540#endif 3541out vec2 v_Size; 3542out vec2 v_Point; 3543 3544void main() { 3545 mat3 model; 3546 vec2 origin; 3547 vec2 size; 3548 float zIndex; 3549 vec4 dropShadow; 3550 3551 #ifdef USE_INSTANCES 3552 model = mat3(a_Abcd.x, a_Abcd.y, 0, a_Abcd.z, a_Abcd.w, 0, a_Txty.x, a_Txty.y, 1); 3553 origin = a_PositionSize.xy; 3554 size = a_PositionSize.zw; 3555 zIndex = a_ZIndexStrokeWidth.x; 3556 dropShadow = a_DropShadow; 3557 v_CornerRadius = a_ZIndexStrokeWidth.z; 3558 v_DropShadowColor = a_DropShadowColor; 3559 v_DropShadow = dropShadow; 3560 #else 3561 model = u_ModelMatrix; 3562 origin = u_PositionSize.xy; 3563 size = u_PositionSize.zw; 3564 zIndex = u_ZIndexStrokeWidth.x; 3565 dropShadow = u_DropShadow; 3566 #endif 3567 3568 // Set the bounds of the shadow and adjust its size based on the shadow's 3569 // spread radius to achieve the spreading effect 3570 float margin = 3.0 * dropShadow.z; 3571 origin += dropShadow.xy; 3572 v_Origin = origin; 3573 v_Size = size; 3574 3575 origin -= margin; 3576 size += 2.0 * margin; 3577 vec2 center = origin + size / 2.0; 3578 v_Point = center + a_FragCoord * (size / 2.0); 3579 3580 gl_Position = vec4((u_ProjectionMatrix
3581 * u_ViewMatrix 3582 * model 3583 * vec3(v_Point, 1)).xy, zIndex, 1); 3584} 3585`,YGt=` 3586#ifdef USE_INSTANCES 3587#else 3588 layout(std140) uniform ShapeUniforms { 3589 mat3 u_ModelMatrix; 3590 vec4 u_PositionSize; 3591 vec4 u_ZIndexStrokeWidth; 3592 vec4 u_DropShadowColor; 3593 vec4 u_DropShadow; 3594 }; 3595#endif 3596 3597out vec4 outputColor; 3598 3599in vec2 v_Origin; 3600#ifdef USE_INSTANCES 3601 in float v_CornerRadius; 3602 in vec4 v_DropShadowColor; 3603 in vec4 v_DropShadow; 3604#else 3605#endif 3606in vec2 v_Size; 3607in vec2 v_Point; 3608 3609float epsilon = 0.000001; 3610float PI = 3.1415926; 3611 3612// A standard gaussian function, used for weighting samples 3613float gaussian(float x, float sigma) { 3614 return exp(-(x * x) / (2. * sigma * sigma)) / (sqrt(2. * PI) * sigma); 3615} 3616 3617// This approximates the error function, needed for the gaussian integral 3618vec2 erf(vec2 x) { 3619 vec2 s = sign(x), a = abs(x); 3620 x = 1.0 + (0.278393 + (0.230389 + 0.078108 * (a * a)) * a) * a; 3621 x *= x; 3622 return s - s / (x * x); 3623} 3624 3625// @see https://raphlinus.github.io/graphics/2020/04/21/blurred-rounded-rects.html 3626// vec2 erf7(vec2 x) { 3627// x = x * sqrt(2. * PI); 3628// vec2 xx = x * x; 3629// x = x + (0.24295 + (0.03395 + 0.0104 * xx) * xx) * (x * xx); 3630// return x / sqrt(1.0 + x * x); 3631// } 3632 3633float rect_shadow(vec2 pixel_position, vec2 origin, vec2 size, float sigma) { 3634 vec2 bottom_right = origin + size; 3635 vec2 x_distance = vec2(pixel_position.x - origin.x, pixel_position.x - bottom_right.x); 3636 vec2 y_distance = vec2(pixel_position.y - origin.y, pixel_position.y - bottom_right.y); 3637 vec2 integral_x = 0.5 + 0.5 * erf(x_distance * (sqrt(0.5) / sigma)); 3638 vec2 integral_y = 0.5 + 0.5 * erf(y_distance * (sqrt(0.5) / sigma)); 3639 return (integral_x.x - integral_x.y) * (integral_y.x - integral_y.y); 3640} 3641 3642float blur_along_x(float x, float y, float sigma, float corner, vec2 half_size) { 3643 float delta = min(half_size.y - corner - abs(y), 0.0); 3644 float curved = half_size.x - corner + sqrt(max(0., corner * corner - delta * delta)); 3645 vec2 integral = 0.5 + 0.5 * erf((x + vec2(-curved, curved)) * (sqrt(0.5) / sigma)); 3646 return integral.y - integral.x; 3647} 3648 3649void main() { 3650 float cornerRadius; 3651 vec4 dropShadow; 3652 vec4 dropShadowColor; 3653 3654 #ifdef USE_INSTANCES 3655 cornerRadius = v_CornerRadius; 3656 dropShadowColor = v_DropShadowColor; 3657 dropShadow = v_DropShadow; 3658 #else 3659 cornerRadius = u_ZIndexStrokeWidth.z; 3660 dropShadowColor = u_DropShadowColor; 3661 dropShadow = u_DropShadow; 3662 #endif 3663 3664 float blur_radius = dropShadow.z; 3665 if (blur_radius > 0.0) { 3666 float alpha = 0.; 3667 vec2 point = v_Point; 3668 3669 if (cornerRadius > 0.0) { 3670 vec2 half_size = v_Size / 2.0; 3671 vec2 center = v_Origin + half_size; 3672 vec2 center_to_point = point - center; 3673 3674 // The signal is only non-zero in a limited range, so don't waste samples 3675 float low = center_to_point.y - half_size.y; 3676 float high = center_to_point.y + half_size.y; 3677 float start = clamp(-3. * blur_radius, low, high); 3678 float end = clamp(3. * blur_radius, low, high); 3679 3680 // Accumulate samples (we can get away with surprisingly few samples) 3681 float step = (end - start) / 4.; 3682 float y = start + step * 0.5; 3683 3684 for (int i = 0; i < 4; i++) { 3685 alpha += blur_along_x(center_to_point.x, center_to_point.y - y, blur_radius, 3686 cornerRadius, half_size) * 3687 gaussian(y, blur_radius) * step; 3688 y += step; 3689 } 3690 } else { 3691 alpha = rect_shadow(point, v_Origin, v_Size, blur_radius); 3692 } 3693 3694 outputColor = dropShadowColor; 3695 outputColor.a = alpha; 3696 } else { 3697 discard; 3698 } 3699} 3700`;var is=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Hp=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3700return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},jm,oM,tb,eb,JF,pA,rb,ib,nM;let $Gt=class extends Jct{constructor(){super(...arguments),jm.set(this,void 0),oM.set(this,void 0),tb.set(this,void 0),eb.set(this,void 0),JF.set(this,void 0),pA.set(this,void 0),rb.set(this,void 0),ib.set(this,void 0),nM.set(this,void 0)}createGeometry(){is(this,oM,"f")||(Hp(this,oM,this.device.createBuffer({viewOrSize:new Float32Array([-1,-1,1,-1,1,1,-1,1]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),Hp(this,JF,this.device.createBuffer({viewOrSize:new Uint32Array([0,1,2,0,2,3]),usage:dt.INDEX,hint:Et.STATIC}),"f")),this.instanced&&(is(this,tb,"f")&&is(this,tb,"f").destroy(),Hp(this,tb,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*16*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),is(this,eb,"f")&&is(this,eb,"f").destroy(),Hp(this,eb,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*6*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"))}createMaterial(t){let e="";this.instanced&&(e+=`#define USE_INSTANCES 3701`),is(this,jm,"f")&&(is(this,jm,"f").destroy(),is(this,ib,"f").destroy(),is(this,rb,"f").destroy()),Hp(this,jm,this.device.createProgram({vertex:{glsl:e+VGt},fragment:{glsl:e+YGt}}),"f");const r=[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:0,offset:0,format:I.F32_RG}]}];this.instanced?(r.push({arrayStride:64,stepMode:ne.INSTANCE,attributes:[{shaderLocation:1,offset:0,format:I.F32_RGBA},{shaderLocation:4,offset:16,format:I.F32_RGBA},{shaderLocation:5,offset:32,format:I.F32_RGBA},{shaderLocation:6,offset:48,format:I.F32_RGBA}]},{arrayStride:24,stepMode:ne.INSTANCE,attributes:[{shaderLocation:14,offset:0,format:I.F32_RGBA},{shaderLocation:15,offset:16,format:I.F32_RG}]}),Hp(this,ib,this.device.createInputLayout({vertexBufferDescriptors:r,indexBufferFormat:I.U32_R,program:is(this,jm,"f")}),"f")):(Hp(this,ib,this.device.createInputLayout({vertexBufferDescriptors:r,indexBufferFormat:I.U32_R,program:is(this,jm,"f")}),"f"),is(this,pA,"f")||Hp(this,pA,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*28,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f")),Hp(this,rb,this.device.createRenderPipeline({inputLayout:is(this,ib,"f"),program:is(this,jm,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],depthWrite:!1,depthCompare:qe.GREATER}}),"f"),this.instanced?Hp(this,nM,this.device.createBindings({pipeline:is(this,rb,"f"),uniformBufferBindings:[{buffer:t}]}),"f"):Hp(this,nM,this.device.createBindings({pipeline:is(this,rb,"f"),uniformBufferBindings:[{buffer:t},{buffer:is(this,pA,"f")}]}),"f")}render(t){if(this.shapes.some(r=>r.renderDirtyFlag)||this.geometryDirty)if(this.instanced){is(this,eb,"f").setSubData(0,new Uint8Array(new Float32Array(this.shapes.map(i=>[i.worldTransform.a,i.worldTransform.b,i.worldTransform.c,i.worldTransform.d,i.worldTransform.tx,i.worldTransform.ty]).flat()).buffer));const r=[];this.shapes.forEach(i=>{r.push(...this.generateBuffer(i))}),is(this,tb,"f").setSubData(0,new Uint8Array(new Float32Array(r).buffer))}else{const{worldTransform:r}=this.shapes[0];is(this,pA,"f").setSubData(0,new Uint8Array(new Float32Array([...V_(r.toArray(!0)),...this.generateBuffer(this.shapes[0])]).buffer))}const e=[{buffer:is(this,oM,"f")}];this.instanced&&e.push({buffer:is(this,tb,"f")},{buffer:is(this,eb,"f")}),t.setPipeline(is(this,rb,"f")),t.setVertexInput(is(this,ib,"f"),e,{buffer:is(this,JF,"f")}),t.setBindings(is(this,nM,"f")),t.drawIndexed(6,this.shapes.length)}destroy(){var t,e,r,i,s,o,n,a;is(this,jm,"f")&&(is(this,jm,"f").destroy(),(t=is(this,eb,"f"))===null||t===void 0||t.destroy(),(e=is(this,tb,"f"))===null||e===void 0||e.destroy(),(r=is(this,oM,"f"))===null||r===void 0||r.destroy(),(i=is(this,JF,"f"))===null||i===void 0||i.destroy(),(s=is(this,pA,"f"))===null||s===void 0||s.destroy(),(o=is(this,rb,"f"))===null||o===void 0||o.destroy(),(n=is(this,ib,"f"))===null||n===void 0||n.destroy(),(a=is(this,nM,"f"))===null||a===void 0||a.destroy())}generateBuffer(t){const{x:e,y:r,width:i,height:s,strokeWidth:o,cornerRadius:n,dropShadowColorRGB:{r:a,g:l,b:c,opacity:h},dropShadowOffsetX:u,dropShadowOffsetY:d,dropShadowBlurRadius:f}=t;return[e,r,i,s,t.globalRenderOrder/Zct,o,n,0,a/255,l/255,c/255,h,u,d,f,0]}};jm=new WeakMap,oM=new WeakMap,tb=new WeakMap,eb=new WeakMap,JF=new WeakMap,pA=new WeakMap,rb=new WeakMap,ib=new WeakMap,nM=new WeakMap;var Ec=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},HGt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3701return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},sb,gA,mA,E6;const A6=new WeakMap;A6.set(o7,[l7]),A6.set(n7,[l7]),A6.set(a7,[$Gt,l7]);let KGt=class{constructor(t){this.device=t,sb.set(this,[]),gA.set(this,Object.create(null)),mA.set(this,Object.create(null)),E6.set(this,new WeakMap)}createDrawcalls(t,e=!1){var r;return(r=A6.get(t.constructor))===null||r===void 0?void 0:r.map(i=>{const s=new i(this.device,e);return s.add(t),s})}getOrCreateNonBatchableDrawcalls(t){let e=Ec(this,gA,"f")[t.uid];return e||(e=this.createDrawcalls(t)||[],Ec(this,gA,"f")[t.uid]=e),e}getOrCreateBatchableDrawcalls(t){let e=Ec(this,mA,"f")[t.uid];if(!e){const r=t.constructor;let i=Ec(this,E6,"f").get(r);i||(i=[]),e=i.find(s=>s.every(o=>o.validate())),e||(e=this.createDrawcalls(t,!0)||[],i.push(e),Ec(this,E6,"f").set(r,i)),e.forEach(s=>{s.add(t)}),Ec(this,mA,"f")[t.uid]=e}return e}add(t){if(t.batchable){const e=this.getOrCreateBatchableDrawcalls(t);Ec(this,sb,"f").indexOf(e[0])===-1&&Ec(this,sb,"f").push(...e)}else Ec(this,sb,"f").push(...this.getOrCreateNonBatchableDrawcalls(t))}remove(t){t.batchable?(this.getOrCreateBatchableDrawcalls(t).forEach(e=>{e.remove(t)}),delete Ec(this,mA,"f")[t.uid]):(this.getOrCreateNonBatchableDrawcalls(t).forEach(e=>{e.destroy()}),delete Ec(this,gA,"f")[t.uid])}destroy(){for(const t in Ec(this,gA,"f"))Ec(this,gA,"f")[t].forEach(e=>{e.destroy()});for(const t in Ec(this,mA,"f"))Ec(this,mA,"f")[t].forEach(e=>{e.destroy()})}clear(){HGt(this,sb,[],"f")}flush(t,e){Ec(this,sb,"f").forEach(r=>{r.submit(t,e)})}stats(){return{drawcallCount:Ec(this,sb,"f").length}}};sb=new WeakMap,gA=new WeakMap,mA=new WeakMap,E6=new WeakMap;var qGt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Md=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},ii=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},aM,Ha,ob,yA,vA,_A,QF,tN,nb,eN,c7;(function(t){t[t.NONE=0]="NONE",t[t.GRID=1]="GRID",t[t.DOTS=2]="DOTS"})(c7||(c7={}));let ZGt=class{constructor(){aM.set(this,void 0),Ha.set(this,void 0),ob.set(this,void 0),yA.set(this,void 0),vA.set(this,void 0),_A.set(this,void 0),QF.set(this,c7.GRID),tN.set(this,void 0),nb.set(this,void 0),eN.set(this,1)}apply(t){const{hooks:e,canvas:r,renderer:i,shaderCompilerPath:s,devicePixelRatio:o,camera:n}=t;e.initAsync.tapPromise(()=>qGt(this,void 0,void 0,function*(){let a;i==="webgl"?a=new hd({targets:["webgl2","webgl1"],antialias:!0,shaderDebug:!0,trackResources:!0,onContextCreationError:()=>{},onContextLost:()=>{},onContextRestored(u){}}):a=new ud({shaderCompilerPath:s,onContextLost:()=>{}});const{width:l,height:c}=r,h=yield a.createSwapChain(r);h.configureSwapChain(l,c),Md(this,aM,h,"f"),Md(this,Ha,h.getDevice(),"f"),Md(this,nb,new KGt(ii(this,Ha,"f")),"f"),Md(this,ob,ii(this,Ha,"f").createRenderTargetFromTexture(ii(this,Ha,"f").createTexture({format:I.U8_RGBA_RT,width:l,height:c,usage:xr.RENDER_TARGET})),"f"),Md(this,yA,ii(this,Ha,"f").createRenderTargetFromTexture(ii(this,Ha,"f").createTexture({format:I.D24_S8,width:l,height:c,usage:xr.RENDER_TARGET})),"f"),Md(this,_A,ii(this,Ha,"f").createBuffer({viewOrSize:new Float32Array([...V_(n.projectionMatrix),...V_(n.viewMatrix),...V_(n.viewProjectionMatrixInv),n.zoom,ii(this,QF,"f"),0,0]),usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),Md(this,tN,new Kct,"f")})),e.resize.tap((a,l)=>{ii(this,aM,"f").configureSwapChain(a*o,l*o),ii(this,ob,"f")&&(ii(this,ob,"f").destroy(),Md(this,ob,ii(this,Ha,"f").createRenderTargetFromTexture(ii(this,Ha,"f").createTexture({format:I.U8_RGBA_RT,width:a*o,height:l*o,usage:xr.RENDER_TARGET})),"f"),ii(this,yA,"f").destroy(),Md(this,yA,ii(this,Ha,"f").createRenderTargetFromTexture(ii(this,Ha,"f").createTexture({format:I.D24_S8,width:a*o,height:l*o,usage:xr.RENDER_TARGET})),"f"))}),e.destroy.tap(()=>{ii(this,nb,"f").destroy(),ii(this,_A,"f").destroy(),ii(this,tN,"f").destroy(),ii(this,ob,"f").destroy(),ii(this,yA,"f").destroy(),ii(this,Ha,"f").destroy(),ii(this,Ha,"f").checkForLeaks()}),e.beginFrame.tap(()=>{const{width:a,height:l}=ii(this,aM,"f").getCanvas(),c=ii(this,aM,"f").getOnscreenTexture();ii(this,_A,"f").setSubData(0,new Uint8Array(new Float32Array([...V_(n.projectionMatrix),...V_(n.viewMatrix),...V_(n.viewProjectionMatrixInv),n.zoom,ii(this,QF,"f"),0,0]).buffer)),ii(this,Ha,"f").beginFrame(),Md(this,vA,ii(this,Ha,"f").createRenderPass({colorAttachment:[ii(this,ob,"f")],colorResolveTo:[c],colorClearColor:[op],depthStencilAttachment:ii(this,yA,"f"),depthClearValue:1}),"f"),ii(this,vA,"f").setViewport(0,0,a,l),ii(this,tN,"f").render(ii(this,Ha,"f"),ii(this,vA,"f"),ii(this,_A,"f")),ii(this,nb,"f").clear(),Md(this,eN,1,"f")}),e.endFrame.tap(({all:a,removed:l})=>{[...a.filter(c=>c.culled),...l].forEach(c=>{c.renderable&&ii(this,nb,"f").remove(c)}),ii(this,nb,"f").flush(ii(this,vA,"f"),ii(this,_A,"f")),ii(this,Ha,"f").submitPass(ii(this,vA,"f")),ii(this,Ha,"f").endFrame()}),e.render.tap(a=>{var l,c;a.globalRenderOrder=(Md(this,eN,(c=ii(this,eN,"f"),l=c++,c),"f"),l),ii(this,nb,"f").add(a)})}setCheckboardStyle(t){Md(this,QF,t,"f")}};aM=new WeakMap,Ha=new WeakMap,ob=new WeakMap,yA=new WeakMap,vA=new WeakMap,_A=new WeakMap,QF=new WeakMap,tN=new WeakMap,nb=new WeakMap,eN=new WeakMap;var Kp=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},bA=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3701return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},rN,wA,ab,lM;const JGt=.02,QGt=4,t4t=100,iN=[.02,.05,.1,.15,.2,.33,.5,.75,1,1.25,1.5,2,2.5,3,4],e4t=t=>iN.find(e=>e>t)||iN[iN.length-1],r4t=t=>[...iN].reverse().find(e=>e<t)||iN[0];let i4t=class{constructor(){rN.set(this,void 0),wA.set(this,{}),ab.set(this,void 0),lM.set(this,!1)}apply(t){const{canvas:e,camera:r,root:i,api:{client2Viewport:s}}=t;i.draggable=!0;const o=Bt();let n,a,l;const c=it();let h,u=!1;function d(y){const _=e.getBoundingClientRect(),w=y.nativeEvent.clientX-_.left,E=y.nativeEvent.clientY-_.top,A=w/e.clientWidth,x=E/e.clientHeight,S=A*2-1,T=x*-2+1;return[S,T]}function f(y){const _=Qt(it(),d(y),o);r.x=n+c[0]-_[0],r.y=a+c[1]-_[1]}function g(y){const _=(y.nativeEvent.clientX-h[0])/100,w=Bt();bi(w,w,[c[0],c[1]]),Mo(w,w,_),bi(w,w,[-c[0],-c[1]]),r.x=n,r.y=a,r.rotation=l,us(w,w,r.matrix),r.rotation=l+_,r.x=w[6],r.y=w[7]}i.addEventListener("dragstart",y=>{Kp(this,ab,"f")||(u=y.shiftKey,fp(o,r.viewProjectionMatrixInv),n=r.x,a=r.y,l=r.rotation,Qt(c,d(y),o),h=[y.nativeEvent.clientX,y.nativeEvent.clientY])}),i.addEventListener("drag",y=>{Kp(this,ab,"f")||(u?g(y):f(y))}),i.addEventListener("dragend",y=>{Kp(this,ab,"f")||(u=!1)});const p=(y,_)=>{const w=Math.max(JGt,Math.min(QGt,r.zoom*Math.pow(2,_*-.01))),E=s(y);r.gotoLandmark(r.createLandmark({viewportX:E.x,viewportY:E.y,zoom:w}),{duration:0})};i.addEventListener("wheel",y=>{y.preventDefault(),p({x:y.nativeEvent.clientX,y:y.nativeEvent.clientY},y.deltaY)});const m=y=>{y.pointerType==="mouse"?bA(this,rN,!0,"f"):Kp(this,wA,"f")[y.pointerId]||(Kp(this,wA,"f")[y.pointerId]={last:null}),this.touchCount>=2?bA(this,ab,!0,"f"):bA(this,ab,!1,"f")},v=y=>{if(y.pointerType==="mouse"&&bA(this,rN,!1,"f"),y.pointerType!=="mouse"&&delete Kp(this,wA,"f")[y.pointerId],Kp(this,lM,"f")&&this.touchCount<=1)return bA(this,lM,!1,"f"),bA(this,ab,!1,"f"),!0},b=y=>{if(this.touchCount>=2){const _=y.global.x,w=y.global.y,E=Kp(this,wA,"f"),A=Object.keys(E),x=Number(A[0]),S=Number(A[1]),T=E[x],R=E[S],B=T.last&&R.last?Math.sqrt(Math.pow(R.last.x-T.last.x,2)+Math.pow(R.last.y-T.last.y,2)):null;if(x===y.pointerId?T.last={x:_,y:w}:S===y.pointerId&&(R.last={x:_,y:w}),B){const O=new ye(T.last.x+(R.last.x-T.last.x)/2,T.last.y+(R.last.y-T.last.y)/2),C=Math.sqrt(Math.pow(R.last.x-T.last.x,2)+Math.pow(R.last.y-T.last.y,2));p(O,(B/C-1)*t4t)}else Kp(this,lM,"f")||bA(this,lM,!0,"f")}};i.addEventListener("pointerdown",m),i.addEventListener("pointermove",b),i.addEventListener("pointerup",v),i.addEventListener("pointerupoutside",v),i.addEventListener("pointercancel",v)}get touchCount(){return(Kp(this,rN,"f")?1:0)+Object.keys(Kp(this,wA,"f")).length}};rN=new WeakMap,wA=new WeakMap,ab=new WeakMap,lM=new WeakMap;let s4t=class{apply(t){const{canvas:e,hooks:r,globalThis:i,supportsPointerEvents:s,supportsTouchEvents:o}=t,n=y=>{y.preventDefault(),r.pointerMove.call(y)},a=y=>{r.pointerUp.call(y)},l=y=>{r.pointerDown.call(y)},c=y=>{r.pointerOver.call(y)},h=y=>{r.pointerOut.call(y)},u=y=>{r.pointerCancel.call(y)},d=y=>{r.pointerWheel.call(y)},f=y=>{i.document.addEventListener("pointermove",n,!0),y.addEventListener("pointerdown",l,!0),y.addEventListener("pointerleave",h,!0),y.addEventListener("pointerover",c,!0),i.addEventListener("pointerup",a,!0),i.addEventListener("pointercancel",u,!0)},g=y=>{y.addEventListener("touchstart",l,!0),y.addEventListener("touchend",a,!0),y.addEventListener("touchmove",n,!0),y.addEventListener("touchcancel",u,!0)},p=y=>{i.document.addEventListener("mousemove",n,!0),y.addEventListener("mousedown",l,!0),y.addEventListener("mouseout",h,!0),y.addEventListener("mouseover",c,!0),i.addEventListener("mouseup",a,!0)},m=y=>{i.document.removeEventListener("pointermove",n,!0),y.removeEventListener("pointerdown",l,!0),y.removeEventListener("pointerleave",h,!0),y.removeEventListener("pointerover",c,!0),i.removeEventListener("pointerup",a,!0)},v=y=>{y.removeEventListener("touchstart",l,!0),y.removeEventListener("touchend",a,!0),y.removeEventListener("touchmove",n,!0),y.removeEventListener("touchcancel",u,!0)},b=y=>{i.document.removeEventListener("mousemove",n,!0),y.removeEventListener("mousedown",l,!0),y.removeEventListener("mouseout",h,!0),y.removeEventListener("mouseover",c,!0),i.removeEventListener("mouseup",a,!0)};r.init.tap(()=>{s?f(e):(p(e),o&&g(e)),e.addEventListener("wheel",d,{capture:!0})}),r.destroy.tap(()=>{s?m(e):(b(e),o&&v(e)),e.removeEventListener("wheel",d,!0)})}};var Qct=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3701return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Sl=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},h7,sN,u7,qp,I0;const o4t=1,n4t={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};let a4t=class{constructor(){h7.set(this,!0),sN.set(this,new Yp(null)),u7.set(this,new r7(null)),qp.set(this,void 0),I0.set(this,void 0),this.onPointerMove=t=>{const e=this.normalizeToPointerEvent(t);for(const r of e){const i=this.bootstrapEvent(Sl(this,sN,"f"),r);Sl(this,qp,"f").mapEvent(i)}this.setCursor(Sl(this,qp,"f").cursor)}}apply(t){const{hooks:e,root:r}=t;Qct(this,I0,t,"f"),Qct(this,qp,new NGt(r),"f"),Sl(this,qp,"f").setPickHandler((i,s)=>{const{picked:o}=e.pickSync.call({position:{x:i,y:s},picked:[],topmost:!0});return o[0]||null}),e.pointerWheel.tap(i=>{const s=this.normalizeWheelEvent(i);Sl(this,qp,"f").mapEvent(s)}),e.pointerDown.tap(i=>{const s=this.normalizeToPointerEvent(i);Sl(this,h7,"f")&&s[0].isNormalized&&(i.cancelable||!("cancelable"in i))&&i.preventDefault();for(let o=0,n=s.length;o<n;o++){const a=s[o],l=this.bootstrapEvent(Sl(this,sN,"f"),a);Sl(this,qp,"f").mapEvent(l)}this.setCursor(Sl(this,qp,"f").cursor)}),e.pointerUp.tap(i=>{let s=i.target;i.composedPath&&i.composedPath().length>0&&(s=i.composedPath()[0]);const o=s!==Sl(this,I0,"f").canvas?"outside":"",n=this.normalizeToPointerEvent(i);for(let a=0,l=n.length;a<l;a++){const c=this.bootstrapEvent(Sl(this,sN,"f"),n[a]);c.type+=o,Sl(this,qp,"f").mapEvent(c)}this.setCursor(Sl(this,qp,"f").cursor)}),e.pointerMove.tap(this.onPointerMove),e.pointerOver.tap(this.onPointerMove),e.pointerOut.tap(this.onPointerMove),e.pointerCancel.tap(this.onPointerMove)}normalizeWheelEvent(t){const e=Sl(this,u7,"f");this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode;const{x:r,y:i}=this.getViewportXY(t);e.client.x=r,e.client.y=i;const{x:s,y:o}=Sl(this,I0,"f").api.viewport2Canvas(e.client);return e.screen.x=s,e.screen.y=o,e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null}setCursor(t){Sl(this,I0,"f").canvas.style.cursor=t}normalizeToPointerEvent(t){const{supportsTouchEvents:e,supportsPointerEvents:r}=Sl(this,I0,"f"),i=[];if(e&&t instanceof TouchEvent)for(let s=0;s<t.changedTouches.length;s++){const o=t.changedTouches[s];la(o.button)&&(o.button=0),la(o.buttons)&&(o.buttons=1),la(o.isPrimary)&&(o.isPrimary=t.touches.length===1&&t.type==="touchstart"),la(o.width)&&(o.width=o.radiusX||1),la(o.height)&&(o.height=o.radiusY||1),la(o.tiltX)&&(o.tiltX=0),la(o.tiltY)&&(o.tiltY=0),la(o.pointerType)&&(o.pointerType="touch"),la(o.pointerId)&&(o.pointerId=o.identifier||0),la(o.pressure)&&(o.pressure=o.force||.5),la(o.twist)&&(o.twist=0),la(o.tangentialPressure)&&(o.tangentialPressure=0),o.isNormalized=!0,o.type=t.type,i.push(o)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!r||!(t instanceof globalThis.PointerEvent))){const s=t;la(s.isPrimary)&&(s.isPrimary=!0),la(s.width)&&(s.width=1),la(s.height)&&(s.height=1),la(s.tiltX)&&(s.tiltX=0),la(s.tiltY)&&(s.tiltY=0),la(s.pointerType)&&(s.pointerType="mouse"),la(s.pointerId)&&(s.pointerId=o4t),la(s.pressure)&&(s.pressure=.5),la(s.twist)&&(s.twist=0),la(s.tangentialPressure)&&(s.tangentialPressure=0),s.isNormalized=!0,i.push(s)}else i.push(t);return i}bootstrapEvent(t,e){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);const{x:r,y:i}=this.getViewportXY(e);t.client.x=r,t.client.y=i;const{x:s,y:o}=Sl(this,I0,"f").api.viewport2Canvas(t.client);return t.screen.x=s,t.screen.y=o,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=n4t[t.type]||t.type),t}getViewportXY(t){let e,r;const{offsetX:i,offsetY:s,clientX:o,clientY:n}=t;if(!Wct(i)&&!Wct(s))e=i,r=s;else{const a=Sl(this,I0,"f").api.client2Viewport({x:o,y:n});e=a.x,r=a.y}return{x:e,y:r}}};h7=new WeakMap,sN=new WeakMap,u7=new WeakMap,qp=new WeakMap,I0=new WeakMap;const tht=new ye;let l4t=class{apply(t){const{hooks:e,root:r,api:{elementsFromBBox:i}}=t;e.pickSync.tap(s=>{const{position:{x:o,y:n}}=s,a=[r];
3701return i(o,n,o,n).forEach(l=>{this.hitTest(l,o,n)&&a.unshift(l)}),s.picked=a,s})}hitTest(t,e,r){if(t.hitArea||t.renderable){t.worldTransform.applyInverse({x:e,y:r},tht);const{x:i,y:s}=tht;return t.hitArea?t.hitArea.contains(i,s):t.containsPoint(i,s)}return!1}};var c4t=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},eht=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},oN;function rht(t,e){do{if(t&&e(t))return t;t=t.parent}while(t!==void 0);return null}let h4t=class{constructor(t={}){oN.set(this,void 0),c4t(this,oN,Object.assign({overlap:"pointer",dragstartTimeThreshold:0,dragstartDistanceThreshold:0},t),"f")}apply(t){const{root:e,hooks:r,api:{elementsFromPoint:i}}=t,s=o=>{const n=o.target,a=rht(n,l=>l.draggable===!0);if(a){let l=!1;const c=o.timeStamp,h=[o.clientX,o.clientY];let u=null,d=[o.clientX,o.clientY];const f=p=>{if(!l){const y=p.timeStamp-c,_=Lct(p.clientX,p.clientY,...h);if(y<=eht(this,oN,"f").dragstartTimeThreshold||_<=eht(this,oN,"f").dragstartDistanceThreshold)return;p.type="dragstart",a.dispatchEvent(p),l=!0}p.type="drag",p.dx=p.clientX-d[0],p.dy=p.clientY-d[1],a.dispatchEvent(p),d=[p.clientX,p.clientY];const m=[p.globalX,p.globalY],v=i(m[0],m[1]),b=v[v.indexOf(n)+1];if(b){const y=rht(b,_=>_.droppable===!0);u!==y&&(u&&(p.type="dragleave",p.target=u,u.dispatchEvent(p)),y&&(p.type="dragenter",p.target=y,y.dispatchEvent(p)),u=y,u&&(p.type="dragover",p.target=u,u.dispatchEvent(p)))}};e.addEventListener("pointermove",f);const g=function(p){if(l){p.detail={preventClick:!0};const m=p;u&&(m.type="drop",m.target=u,u.dispatchEvent(m)),m.type="dragend",a.dispatchEvent(m),l=!1}e.removeEventListener("pointermove",f)};n.addEventListener("pointerup",g,{once:!0}),n.addEventListener("pointerupoutside",g,{once:!0})}};r.init.tap(()=>{e.addEventListener("pointerdown",s)}),r.destroy.tap(()=>{e.removeEventListener("pointerdown",s)})}};oN=new WeakMap;var u4t=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},cM=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},x6,EA;let d4t=class{constructor(){x6.set(this,void 0),EA.set(this,new uA)}apply(t){const{hooks:e,rBushRoot:r}=t;u4t(this,x6,t,"f"),e.cameraChange.tap(this.updateViewport.bind(this)),this.updateViewport(),e.beginFrame.tap(({all:i,removed:s,modified:o})=>{const{minX:n,minY:a,maxX:l,maxY:c}=cM(this,EA,"f");[...s,...o].forEach(d=>{d.renderable&&r.remove({shape:d,minX:0,minY:0,maxX:0,maxY:0},(f,g)=>f.shape===g.shape)});const h=[];o.forEach(d=>{if(d.renderable){const f=d.getBounds();h.push({minX:f.minX,minY:f.minY,maxX:f.maxX,maxY:f.maxY,shape:d})}}),r.load(h);const u=r.search({minX:n,minY:a,maxX:l,maxY:c}).map(d=>d.shape);i.forEach(d=>{d.renderable&&d.cullable&&(d.culled=!u.includes(d))})})}updateViewport(){const{camera:t,api:{viewport2Canvas:e}}=cM(this,x6,"f"),{width:r,height:i}=t,s=e({x:0,y:0}),o=e({x:r,y:0}),n=e({x:r,y:i}),a=e({x:0,y:i});cM(this,EA,"f").minX=Math.min(s.x,o.x,n.x,a.x),cM(this,EA,"f").minY=Math.min(s.y,o.y,n.y,a.y),cM(this,EA,"f").maxX=Math.max(s.x,o.x,n.x,a.x),cM(this,EA,"f").maxY=Math.max(s.y,o.y,n.y,a.y)}};x6=new WeakMap,EA=new WeakMap;var f4t=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Hs=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},D0=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3701return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},S6,Qc,nN,T6,lb,aN,hM,R6,AA;let iht=class{get pluginContext(){return Hs(this,Qc,"f")}get root(){return Hs(this,lb,"f")}get camera(){return Hs(this,aN,"f")}constructor(t){S6.set(this,void 0),Qc.set(this,void 0),nN.set(this,void 0),T6.set(this,void 0),lb.set(this,new qct),aN.set(this,void 0),hM.set(this,!0),R6.set(this,new Set),AA.set(this,new Set);const{canvas:e,renderer:r="webgl",shaderCompilerPath:i="",devicePixelRatio:s}=t,o=MGt(),n=s??o.devicePixelRatio,a=!!o.PointerEvent,l="ontouchstart"in o,{width:c,height:h}=e,u=new Xct(c/n,h/n);u.onchange=()=>{Hs(this,Qc,"f").hooks.cameraChange.call(),D0(this,hM,!0,"f")},D0(this,aN,u,"f"),D0(this,Qc,{globalThis:o,canvas:e,renderer:r,shaderCompilerPath:i,devicePixelRatio:n,supportsPointerEvents:a,supportsTouchEvents:l,hooks:{init:new Ru,initAsync:new RGt,beginFrame:new Ru,render:new Ru,endFrame:new Ru,destroy:new Ru,resize:new Ru,pointerDown:new Ru,pointerUp:new Ru,pointerMove:new Ru,pointerOut:new Ru,pointerOver:new Ru,pointerWheel:new Ru,pointerCancel:new Ru,pickSync:new CGt,cameraChange:new Ru},camera:u,root:Hs(this,lb,"f"),rBushRoot:new TE,api:{elementsFromPoint:this.elementsFromPoint.bind(this),elementFromPoint:this.elementFromPoint.bind(this),elementsFromBBox:this.elementsFromBBox.bind(this),client2Viewport:this.client2Viewport.bind(this),viewport2Canvas:u.viewport2Canvas.bind(u),viewport2Client:this.viewport2Client.bind(this),canvas2Viewport:u.canvas2Viewport.bind(u)}},"f"),D0(this,nN,new ZGt,"f"),D0(this,T6,new a4t,"f");const d=[new s4t,Hs(this,T6,"f"),new l4t,new i4t,new d4t,Hs(this,nN,"f"),new h4t({dragstartTimeThreshold:100,dragstartDistanceThreshold:10})];D0(this,S6,f4t(this,void 0,void 0,function*(){const{hooks:f}=Hs(this,Qc,"f");return d.forEach(g=>{g.apply(Hs(this,Qc,"f"))}),f.init.call(),yield f.initAsync.promise(),this}),"f")}get initialized(){return Hs(this,S6,"f").then(()=>this)}render(){const{hooks:t}=Hs(this,Qc,"f");Hs(this,AA,"f").clear();const e=[];if(Q9(Hs(this,lb,"f"),r=>{Hs(this,AA,"f").add(r),r.transformDirtyFlag&&(r.renderDirtyFlag=!0),r.renderable&&r.renderDirtyFlag&&(e.push(r),D0(this,hM,!0,"f")),r.transform.updateTransform(r.parent?r.parent.transform:Yct)}),Hs(this,hM,"f")){const r=Array.from(Hs(this,AA,"f")),i=[...Hs(this,R6,"f")].filter(s=>!Hs(this,AA,"f").has(s));t.beginFrame.call({all:r,modified:e,removed:i}),Q9(Hs(this,lb,"f"),s=>{if(s.culled||!s.visible)return!0;s.renderable&&t.render.call(s)}),t.endFrame.call({all:r,modified:e,removed:i}),[...r,...i].forEach(s=>{s.renderDirtyFlag=!1}),D0(this,R6,new Set(Hs(this,AA,"f")),"f"),D0(this,hM,!1,"f")}}resize(t,e){const{hooks:r}=Hs(this,Qc,"f");Hs(this,aN,"f").projection(t,e),r.resize.call(t,e)}destroy(){const{hooks:t}=Hs(this,Qc,"f");t.destroy.call()}getDOM(){return Hs(this,Qc,"f").canvas}appendChild(t){Hs(this,lb,"f").appendChild(t)}removeChild(t){return Hs(this,lb,"f").removeChild(t)}setCheckboardStyle(t){Hs(this,nN,"f").setCheckboardStyle(t)}elementsFromBBox(t,e,r,i){const{rBushRoot:s}=Hs(this,Qc,"f"),o=s.search({minX:t,minY:e,maxX:r,maxY:i}),n=[];return o.forEach(({shape:a})=>{const{pointerEvents:l="auto"}=a,c=["auto","visiblepainted","visiblefill","visiblestroke","visible"].includes(l);(!c||c&&a.visible)&&!a.culled&&a.pointerEvents!=="none"&&n.push(a)}),n.sort((a,l)=>a.globalRenderOrder-l.globalRenderOrder),n}elementsFromPoint(t,e){const{picked:r}=Hs(this,Qc,"f").hooks.pickSync.call({topmost:!1,position:{x:t,y:e},picked:[]});return r}elementFromPoint(t,e){const{picked:r}=Hs(this,Qc,"f").hooks.pickSync.call({topmost:!0,position:{x:t,y:e},picked:[]});return r[0]}client2Viewport({x:t,y:e}){const{left:r,top:i}=Hs(this,Qc,"f").canvas.getBoundingClientRect();return{x:t-r,y:e-i}}viewport2Client({x:t,y:e}){const{left:r,top:i}=Hs(this,Qc,"f").canvas.getBoundingClientRect();return{x:t+r,y:e+i}}zoomIn(){const{camera:t}=this;t.cancelLandmarkAnimation();const e=t.createLandmark({viewportX:t.width/2,viewportY:t.height/2,zoom:e4t(t.zoom)});t.gotoLandmark(e,{duration:300,easing:"ease"})}zoomOut(){const{camera:t}=this;t.cancelLandmarkAnimation();const e=t.createLandmark({viewportX:t.width/2,viewportY:t.height/2,zoom:r4t(t.zoom)});t.gotoLandmark(e,{duration:300,easing:"ease"})}};S6=new WeakMap,Qc=new WeakMap,nN=new WeakMap,T6=new WeakMap,lb=new WeakMap,aN=new WeakMap,hM=new WeakMap,R6=new WeakMap,AA=new WeakMap;const sht=Symbol("canvas");var C6=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
3701a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},oht=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},bf=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},nht=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},d7,wf,lN;function p4t(){return oht(this,void 0,void 0,function*(){if("gpu"in navigator){if(!(yield navigator.gpu.requestAdapter()))throw new Error("No WebGPU adapter available.")}else throw new Error("WebGPU is not supported by the browser.")})}let xA=class extends Wa{constructor(){super(...arguments),this.renderer="webgl",this.shaderCompilerPath="https://unpkg.com/@antv/[email protected]/dist/pkg/glsl_wgsl_compiler_bg.wasm",this.zoom=100,d7.set(this,new eE(this,{context:sht})),wf.set(this,void 0),lN.set(this,void 0),this.initCanvas=new rE(this,{task:t=>oht(this,[t],void 0,function*([e,r]){e==="webgpu"&&(yield p4t());const i=document.createElement("canvas");nht(this,wf,yield new iht({canvas:i,renderer:e,shaderCompilerPath:r}).initialized,"f"),bf(this,d7,"f").setValue(bf(this,wf,"f")),bf(this,wf,"f").pluginContext.hooks.cameraChange.tap(()=>{this.zoom=Math.round(bf(this,wf,"f").camera.zoom*100)}),this.dispatchEvent(new CustomEvent("ic-ready",{detail:bf(this,wf,"f")}));const s=o=>{this.dispatchEvent(new CustomEvent("ic-frame",{detail:o})),bf(this,wf,"f").render(),nht(this,lN,window.requestAnimationFrame(s),"f")};return s(),bf(this,wf,"f").getDOM()}),args:()=>[this.renderer,this.shaderCompilerPath]})}connectedCallback(){super.connectedCallback(),this.addEventListener("sl-resize",this.resize)}disconnectedCallback(){var t;this.removeEventListener("sl-resize",this.resize),bf(this,lN,"f")&&window.cancelAnimationFrame(bf(this,lN,"f")),(t=bf(this,wf,"f"))===null||t===void 0||t.destroy(),super.disconnectedCallback()}resize(t){var e;const r=t.detail,{width:i,height:s}=r.entries[0].contentRect,o=window.devicePixelRatio;if(i&&s){const n=bf(this,wf,"f").getDOM();n.width=i*o,n.height=s*o,(e=bf(this,wf,"f"))===null||e===void 0||e.resize(i,s)}}render(){return this.initCanvas.render({pending:()=>Ao`<sl-spinner></sl-spinner>`,complete:t=>Ao` 3702 <sl-resize-observer> 3703 ${t} 3704 <ic-zoom-toolbar-lesson9 zoom=${this.zoom}></ic-zoom-toolbar-lesson9> 3705 </sl-resize-observer> 3706 `,error:t=>Ao`<sl-alert variant="danger" open> 3707 <sl-icon slot="icon" name="exclamation-octagon"></sl-icon> 3708 <strong>Initialize canvas failed</strong><br /> 3709 ${t.message} 3710 </sl-alert>`})}};d7=new WeakMap,wf=new WeakMap,lN=new WeakMap,xA.styles=Lc` 3711 :host { 3712 position: relative; 3713 } 3714 3715 canvas { 3716 width: 100%; 3717 height: 100%; 3718 outline: none; 3719 padding: 0; 3720 margin: 0; 3721 touch-action: none; 3722 } 3723 `,C6([Pa()],xA.prototype,"renderer",void 0),C6([Pa()],xA.prototype,"shaderCompilerPath",void 0),C6([em()],xA.prototype,"zoom",void 0),xA=C6([Vc("ic-canvas-lesson9")],xA);var f7=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};let uM=class extends Wa{constructor(){super(...arguments),this.zoom=100}zoomOut(){this.canvas.zoomOut()}zoomIn(){this.canvas.zoomIn()}render(){return Ao` 3724 <sl-button-group label="Zoom toolbar"> 3725 <sl-tooltip content="Zoom out"> 3726 <sl-icon-button 3727 name="dash-lg" 3728 label="Zoom out" 3729 @click="${this.zoomOut}" 3730 ></sl-icon-button> 3731 </sl-tooltip>
3732 <span>${this.zoom}%</span> 3733 <sl-tooltip content="Zoom in"> 3734 <sl-icon-button 3735 name="plus-lg" 3736 label="Zoom in" 3737 @click="${this.zoomIn}" 3738 ></sl-icon-button> 3739 </sl-tooltip> 3740 </sl-button-group> 3741 `}};uM.styles=Lc` 3742 :host { 3743 position: absolute; 3744 right: 16px; 3745 bottom: 16px; 3746 box-shadow: var(--sl-shadow-medium); 3747 background: white; 3748 } 3749 3750 span { 3751 font-size: 12px; 3752 line-height: 32px; 3753 width: 32px; 3754 text-align: center; 3755 color: var(--sl-color-neutral-600); 3756 } 3757 `,f7([cm({context:sht,subscribe:!0})],uM.prototype,"canvas",void 0),f7([Pa()],uM.prototype,"zoom",void 0),uM=f7([Vc("ic-zoom-toolbar-lesson9")],uM);const g4t=Object.freeze(Object.defineProperty({__proto__:null,AABB:uA,Camera:Xct,Canvas:iht,Circle:o7,Ellipse:n7,Grid:Kct,Group:qct,IDENTITY_TRANSFORM:Yct,get InfiniteCanvas(){return xA},Rect:a7,Rectangle:Ua,Shape:DF,get ZoomToolbar(){return uM},getBounds:i7,isFillOrStrokeAffected:y6},Symbol.toStringTag,{value:"Module"}));var p7=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},cN;let m4t=class{constructor(){cN.set(this,[])}getCallbacksNum(){return p7(this,cN,"f").length}tapPromise(t){p7(this,cN,"f").push(t)}promise(...t){return Promise.all(p7(this,cN,"f").map(e=>e(...t)))}};cN=new WeakMap;var aht=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},M6;let Bu=class{constructor(){M6.set(this,[])}tap(t){aht(this,M6,"f").push(t)}call(...t){aht(this,M6,"f").forEach(function(e){e.apply(void 0,t)})}};M6=new WeakMap;var hN=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},SA;let y4t=class{constructor(){SA.set(this,[])}tap(t){hN(this,SA,"f").push(t)}call(...t){if(hN(this,SA,"f").length){let e=hN(this,SA,"f")[0].apply(void 0,t);for(let r=0;r<hN(this,SA,"f").length-1;r++){const i=hN(this,SA,"f")[r];e=i(...e)}return e}return null}};SA=new WeakMap;const v4t=()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};function gs(t,e){return(e||document).createElementNS("http://www.w3.org/2000/svg",t)}function _4t(t){return t instanceof ImageBitmap||t instanceof HTMLCanvasElement||t instanceof OffscreenCanvas}function g7(t,e){e(t)||t.children.forEach(r=>{g7(r,e)})}const m7=0;function cb(t){return[t[0],t[1],t[2],m7,t[3],t[4],t[5],m7,t[6],t[7],t[8],m7]}function lht(t,e,r,i){var s=Math.sqrt(Math.pow(r-t,2)+Math.pow(i-e,2));return s}const b4t={linear:cr(0,0,1,1),ease:cr(.25,.1,.25,1),"ease-in":cr(.42,0,1,1),"ease-out":cr(0,0,.58,1),"ease-in-out":cr(.42,0,.58,1)};var hb;(function(t){t._bytes4=new Uint8Array(4),t._float=new Float32Array(t._bytes4.buffer),t._int=new Int32Array(t._bytes4.buffer),t._bytes2=new Uint8Array(2),t._short=new Int16Array(t._bytes2.buffer);function e(c){return t._float[0]=c,t._int[0]}t.floatToInt=e;function r(c){return t._int[0]=c,t._float[0]}t.intToFloat=r;function i(c){return t._float[0]=c,t._bytes4}t.floatToBytes=i;function s(c,h,u,d){return t._bytes4[0]=c,t._bytes4[1]=h,t._bytes4[2]=u,t._bytes4[3]=d,t._float[0]}t.bytesToFloat=s;function o(c){return t._int[0]=c,t._bytes4}t.intToBytes=o;function n(c,h,u,d){return t._bytes4[0]=c,t._bytes4[1]=h,t._bytes4[2]=u,t._bytes4[3]=d,t._int[0]}t.bytesToInt=n;function a(c){return t._short[0]=c,t._bytes2}t.shortToBytes=a;function l(c,h){return t._bytes2[0]=c,t._bytes2[1]=h,t._short[0]}t.bytesToShort=l})(hb||(hb={}));const cht=256;let w4t=class{constructor(t=new Uint8Array(cht)){this._bytes=t,this.count=0,this.readOffset=0,this.capacity=cht,this.count=this.capacity=t.length}clear(){this.count=0,this.readOffset=0}byteCount(){return this.count}bytes(){return this._bytes.subarray(0,this.count)}grow(){this.capacity*=2;const t=new Uint8Array(this.capacity);t.set(this._bytes),this._bytes=t}hasMoreToRead(){return this.readOffset<this.count}seekTo(t){this.readOffset=t}skipBytes(t){this.readOffset+=t}appendBytes(t){const e=t.length;return this.count+e>this.capacity&&this.grow(),this._bytes.set(t,this.count),this.count+=e,this}byteAt(t){return this._bytes[t]}appendByte(t){return this.count+1>this.capacity&&this.grow(),this._bytes[this.count]=t,this.count++,this}readByte(){const t=this.byteAt(this.readOffset);return this.readOffset++,t}shortAt(t){return hb.bytesToShort(this._bytes[t],this._bytes[t+1])}appendShort(t){return this.appendBytes(hb.shortToBytes(t)),this}appendShorts(t){for(const e of t)this.appendShort(e);return this}readShort(){const t=this.shortAt(this.readOffset);return this.readOffset+=2,t}intAt(t){return hb.bytesToInt(this._bytes[t],this._bytes[t+1],this._bytes[t+2],this._bytes[t+3])}appendInt(t){return this.appendBytes(hb.intToBytes(t)),this}appendInts(t){for(const e of t)this.appendInt(e);return this}readInt(){const t=this.intAt(this.readOffset);return this.readOffset+=4,t}
3757floatAt(t){return hb.bytesToFloat(this._bytes[t],this._bytes[t+1],this._bytes[t+2],this._bytes[t+3])}appendFloat(t){return this.appendBytes(hb.floatToBytes(t)),this}appendFloats(t){for(const e of t)this.appendFloat(e);return this}readFloat(){const t=this.floatAt(this.readOffset);return this.readOffset+=4,t}isEmpty(){return this.count==0}};const B6=t=>t instanceof Object,hht=t=>t===!!t,O6=t=>typeof t=="function",ca=t=>t===void 0,uht=t=>t==null,TA=t=>typeof t=="string";function E4t(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}const A4t=/^data:([a-z]+\/[a-z0-9\-\+]+)?(;charset=[a-z0-9\-]+)?(;base64)?,[a-z0-9\!\$&',\(\)\*\+,;=\-\._\~:@\/\?%\s]*$/i;function dht(t){return A4t.test(t)}const y7={default:-1};function x4t(t="default"){return y7[t]===void 0&&(y7[t]=-1),++y7[t]}const fht=new uo;let Xm=class{constructor(t=1/0,e=1/0,r=-1/0,i=-1/0){this.matrix=fht,this.minX=t,this.minY=e,this.maxX=r,this.maxY=i}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=fht,this}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addFrame(t,e,r,i,s){s||(s=this.matrix);const o=s.a,n=s.b,a=s.c,l=s.d,c=s.tx,h=s.ty;let u=this.minX,d=this.minY,f=this.maxX,g=this.maxY,p=o*t+a*e+c,m=n*t+l*e+h;p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*r+a*e+c,m=n*r+l*e+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*t+a*i+c,m=n*t+l*i+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*r+a*i+c,m=n*r+l*i+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),this.minX=u,this.minY=d,this.maxX=f,this.maxY=g}},pht=class y1t{get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=y1t.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ye,this.page=new ye,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}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(e,r,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,r,i,s,o){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}},I6=class extends pht{constructor(){super(...arguments),this.client=new ye,this.movement=new ye,this.offset=new ye,this.global=new ye,this.screen=new ye}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}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,r,i,s,o,n,a,l,c,h,u,d,f,g){throw new Error("Method not implemented.")}},Zp=class extends I6{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!")}},v7=class extends I6{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}};var S4t=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3757return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},T4t=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},D6;const R4t=2048;let C4t=class{constructor(t){this.dispatch=new Uo,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,D6.set(this,void 0),this.rootTarget=t,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)}setPickHandler(t){S4t(this,D6,t,"f")}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((r,i)=>r.priority-i.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(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 r=0,i=e.length;r<i;r++)e[r].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}
vendor: 6,556 bytes, line 3757
3757hitTest(t,e){return T4t(this,D6,"f").call(this,t,e)}propagate(t,e){if(!t.target)return;const r=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let i=0,s=r.length-1;i<s;i++)if(t.currentTarget=r[i],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 i=r.length-2;i>=0;i--)if(t.currentTarget=r[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,r=this._allInteractiveElements){if(r.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const i=Array.isArray(e)?e:[e];for(let s=r.length-1;s>=0;s--)i.forEach(o=>{t.currentTarget=r[s],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let r=0;r<R4t&&t!==this.rootTarget&&t.parent;r++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}notifyTarget(t,e){e=e??t.type;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 Zp)){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 i=e.button===2;this.dispatchEvent(e,i?"rightdown":"mousedown")}const r=this.trackingData(t.pointerId);r.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,r,i;if(!(t instanceof Zp)){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 s=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const o=s.pointerType==="mouse"||s.pointerType==="pen",n=this.trackingData(t.pointerId),a=this.findMountedTarget(n.overTargets);if(((e=n.overTargets)===null||e===void 0?void 0:e.length)>0&&a!==s.target){const h=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,h,a);if(this.dispatchEvent(u,"pointerout"),o&&this.dispatchEvent(u,"mouseout"),!s.composedPath().includes(a)){const d=this.createPointerEvent(t,"pointerleave",a);for(d.eventPhase=d.AT_TARGET;d.target&&!s.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),o&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(u)}if(a!==s.target){const h=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(s,h);this.dispatchEvent(u,"pointerover"),o&&this.dispatchEvent(u,"mouseover");let d=a==null?void 0:a.parent;for(;d&&d!==this.rootTarget.parent&&d!==s.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(s,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==a&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),o&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(u)}const l=[],c=(r=this.enableGlobalMoveEvents)!==null&&r!==void 0?r:!0;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(s,"pointermove"),c&&l.push("globalpointermove"),s.pointerType==="touch"&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(s,"touchmove"),c&&l.push("globaltouchmove")),o&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(s,"mousemove"),c&&l.push("globalmousemove"),this.cursor=(i=s.target)===null||i===void 0?void 0:i.cursor),l.length>0&&this.all(s,l),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=s.composedPath(),this.freeEvent(s)}mapPointerOver(t){var e;if(!(t instanceof Zp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(e=i.target)===null||e===void 0?void 0:e.cursor);const o=this.clonePointerEvent(i,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;r.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof Zp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const r=t.pointerType==="mouse"||t.pointerType==="pen",i=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",i);this.dispatchEvent(s),r&&this.dispatchEvent(s,"mouseout");const o=this.createPointerEvent(t,"pointerleave",i);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),r&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(s),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){var e;if(!(t instanceof Zp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=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 s=this.trackingData(t.pointerId),o=this.findMountedTarget(s.pressTargetsByButton[t.button]);let n=o;if(o&&!i.composedPath().includes(o)){let a=o;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 l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],n=a}if(n){const a=this.clonePointerEvent(i,"click");a.target=n,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:r});const l=s.clicksByButton[t.button];if(l.target===a.target&&r-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=r,a.detail=l.clickCount,!(!((e=i.detail)===null||e===void 0)&&e.preventClick)){if
3757(a.pointerType==="mouse"){const c=a.button===2;this.dispatchEvent(a,c?"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 Zp)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),r=this.findMountedTarget(e.pressTargetsByButton[t.button]),i=this.createPointerEvent(t);if(r){let s=r;for(;s;)i.currentTarget=s,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch"?this.notifyTarget(i,"touchendoutside"):(i.pointerType==="mouse"||i.pointerType==="pen")&&this.notifyTarget(i,i.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(i)}mapWheel(t){if(!(t instanceof v7)){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 r=1;r<t.length&&t[r].parent===e;r++)e=t[r];return e}createPointerEvent(t,e,r){var i;const s=this.allocateEvent(Zp);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=(i=r??this.hitTest(s.global.x,s.global.y))!==null&&i!==void 0?i:this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(v7);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 r=this.allocateEvent(Zp);return r.nativeEvent=t.nativeEvent,r.originalEvent=t.originalEvent,this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.target=t.target,r.path=t.composedPath().slice(),r.type=e??r.type,r}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Zp&&e instanceof Zp&&(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.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof I6&&e instanceof I6&&(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 r=t.currentTarget._events[e];if(r)if("fn"in r)r.once&&t.currentTarget.removeListener(e,r.fn,void 0,!0),r.fn.call(r.context,t);else for(let i=0,s=r.length;i<s&&!t.propagationImmediatelyStopped;i++)r[i].once&&t.currentTarget.removeListener(e,r[i].fn,void 0,!0),r[i].fn.call(r[i].context,t)}};D6=new WeakMap;let M4t=class extends Uo{constructor(t={}){super();const{cursor:e,hitArea:r,pointerEvents:i,draggable:s,droppable:o}=t;this.cursor=e??"default",this.hitArea=r,this.pointerEvents=i??"auto",this.draggable=s??!1,this.droppable=o??!1}addEventListener(t,e,r){const i=hht(r)&&r||B6(r)&&r.capture,s=B6(r)?r.signal:void 0,o=B6(r)&&r.once,n=O6(e)?void 0:e;t=i?`${t}capture`:t;const a=O6(e)?e:e.handleEvent;s&&s.addEventListener("abort",()=>{this.off(t,a,n)}),o?this.once(t,a,n):this.on(t,a,n)}removeEventListener(t,e,r){const i=hht(r)&&r||B6(r)&&r.capture,s=O6(e)?void 0:e;t=i?`${t}capture`:t,e=O6(e)?e:e==null?void 0:e.handleEvent,this.off(t,e,s)}dispatchEvent(t){if(!(t instanceof pht))throw new Error("Container cannot propagate events outside of the Federated Events API");return t.defaultPrevented=!1,t.path=[],t.target=this,t.manager.dispatchEvent(t),!t.defaultPrevented}};var cn=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Ou=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3757return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r};function B4t(t){var e,r,i,s,o,n,a,l,c,h,u,d,f,g,p;return p=class extends t{constructor(m={}){super(m),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,e.set(this,void 0),r.set(this,void 0),i.set(this,void 0),s.set(this,void 0),o.set(this,void 0),n.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),h.set(this,void 0),u.set(this,void 0),d.set(this,void 0),f.set(this,void 0),g.set(this,void 0);const{renderable:v,visible:b,cullable:y,batchable:_,fill:w,stroke:E,strokeWidth:A,strokeAlignment:x,opacity:S,fillOpacity:T,strokeOpacity:R,innerShadowColor:B,innerShadowOffsetX:O,innerShadowOffsetY:C,innerShadowBlurRadius:F}=m;this.renderable=v??!0,this.visible=b??!0,this.cullable=y??!0,this.batchable=_??!0,this.fill=w??"black",this.stroke=E??"black",this.strokeWidth=A??0,this.strokeAlignment=x??"center",this.opacity=S??1,this.fillOpacity=T??1,this.strokeOpacity=R??1,this.innerShadowColor=B??"black",this.innerShadowOffsetX=O??0,this.innerShadowOffsetY=C??0,this.innerShadowBlurRadius=F??0}get fill(){return cn(this,e,"f")}set fill(m){cn(this,e,"f")!==m&&(Ou(this,e,m,"f"),TA(m)&&Ou(this,r,sr.rgb(m),"f"),this.renderDirtyFlag=!0)}get fillRGB(){return cn(this,r,"f")}get stroke(){return cn(this,i,"f")}set stroke(m){cn(this,i,"f")!==m&&(Ou(this,i,m,"f"),Ou(this,s,sr.rgb(m),"f"),this.renderDirtyFlag=!0)}get strokeRGB(){return cn(this,s,"f")}get strokeWidth(){return cn(this,o,"f")}set strokeWidth(m){cn(this,o,"f")!==m&&(Ou(this,o,m,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get strokeAlignment(){return cn(this,n,"f")}set strokeAlignment(m){cn(this,n,"f")!==m&&(Ou(this,n,m,"f"),this.renderDirtyFlag=!0)}get opacity(){return cn(this,a,"f")}set opacity(m){cn(this,a,"f")!==m&&(Ou(this,a,m,"f"),this.renderDirtyFlag=!0)}get fillOpacity(){return cn(this,l,"f")}set fillOpacity(m){cn(this,l,"f")!==m&&(Ou(this,l,m,"f"),this.renderDirtyFlag=!0)}get strokeOpacity(){return cn(this,c,"f")}set strokeOpacity(m){cn(this,c,"f")!==m&&(Ou(this,c,m,"f"),this.renderDirtyFlag=!0)}get innerShadowColor(){return cn(this,h,"f")}set innerShadowColor(m){cn(this,h,"f")!==m&&(Ou(this,h,m,"f"),Ou(this,u,sr.rgb(m),"f"),this.renderDirtyFlag=!0)}get innerShadowColorRGB(){return cn(this,u,"f")}get innerShadowOffsetX(){return cn(this,d,"f")}set innerShadowOffsetX(m){cn(this,d,"f")!==m&&(Ou(this,d,m,"f"),this.renderDirtyFlag=!0)}get innerShadowOffsetY(){return cn(this,f,"f")}set innerShadowOffsetY(m){cn(this,f,"f")!==m&&(Ou(this,f,m,"f"),this.renderDirtyFlag=!0)}get innerShadowBlurRadius(){return cn(this,g,"f")}set innerShadowBlurRadius(m){cn(this,g,"f")!==m&&(Ou(this,g,m,"f"),this.renderDirtyFlag=!0)}},e=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap,o=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,g=new WeakMap,p}function O4t(t){return class extends t{constructor(){super(...arguments),this.transform=new wn}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(e){this.transform.position.copyFrom(e)}get scale(){return this.transform.scale}set scale(e){this.transform.scale.copyFrom(e)}get pivot(){return this.transform.pivot}set pivot(e){this.transform.pivot.copyFrom(e)}get skew(){return this.transform.skew}set skew(e){this.transform.skew.copyFrom(e)}get rotation(){return this.transform.rotation}set rotation(e){this.transform.rotation=e}get angle(){return this.transform.rotation*id}set angle(e){this.transform.rotation=e*eu}get transformDirtyFlag(){var e;return this.transform._localID!==this.transform._currentLocalID||this.transform._parentID!==((e=this.parent)===null||e===void 0?void 0:e.transform._worldID)}}}const ght=new wn,mht=new uo,uN=I4t(B4t(O4t(M4t)));function I4t(t){class e extends t{constructor(i={}){super(i),this.uid=x4t(),this.children=[]}appendChild(i){return i.parent&&i.parent.removeChild(i),i.parent=this,i.transform._parentID=-1,this.children.push(i),i}removeChild(i){const s=this.children.indexOf(i);return s===-1?null:(i.parent=void 0,i.transform._parentID=-1,this.children.splice(s,1),i)}getBounds(i){if(!this.boundsDirtyFlag)return this.bounds;this.bounds=this.bounds||new Xm,this.bounds.clear();let s;return this.parent?i?s=this.parent.worldTransform:(mht.identity(),s=yht(this,mht)):s=uo.IDENTITY,_7(this,this.bounds,s,i),this.boundsDirtyFlag=!1,this.bounds}}return e}function _7(t,e,r,i){if(!t.visible)return;let s;i?s=t.worldTransform:(t.transform.updateLocalTransform(),s=new uo,s.copyFrom(t.localTransform),s.append(r)),t.renderable&&(e.matrix=s,e.addBounds(t.getRenderBounds()));for(let o=0;o<t.children.length;o++)_7(t.children[o],e,s,i)}function yht(t,e){const r=t.parent;return r&&(yht(r,e),r.transform.updateLocalTransform(),e.append(r.localTransform)),e}function RA(t,e){if(t==="center")return e/2;if(t==="inner")return 0;if(t==="outer")return e}function P6(t,e,r){let i=!1,s=!1;const o=!!e&&e!=="none",n=!!r&&r!=="none";return t==="visiblepainted"||t==="painted"||t==="auto"?(i=o,s=n):t==="visiblefill"||t==="fill"?i=!0:t==="visiblestroke"||t==="stroke"?s=!0:(t==="visible"||t==="all")&&(i=!0,s=!0),[i,s]}var dM=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},b7=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3757return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},dN,fN,pN;let fM=class v1t extends uN{static getGeometryBounds(e){const{cx:r,cy:i,r:s}=e;return new Xm(r-s,i-s,r+s,i+s)}constructor(e={}){super(e),dN.set(this,void 0),fN.set(this,void 0),pN.set(this,void 0);const{cx:r,cy:i,r:s}=e;this.cx=r??0,this.cy=i??0,this.r=s??0}get cx(){return dM(this,dN,"f")}set cx(e){dM(this,dN,"f")!==e&&(b7(this,dN,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get cy(){return dM(this,fN,"f")}set cy(e){dM(this,fN,"f")!==e&&(b7(this,fN,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get r(){return dM(this,pN,"f")}set r(e){dM(this,pN,"f")!==e&&(b7(this,pN,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}containsPoint(e,r){const{strokeWidth:i,strokeAlignment:s,cx:o,cy:n,r:a,pointerEvents:l,fill:c,stroke:h}=this,u=lht(o,n,e,r),[d,f]=P6(l,c,h);if(d)return u<=a;if(f){const g=RA(s,i);return u>=a+g-i&&u<=a+g}return!1}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.geometryBoundsDirtyFlag=!1,this.geometryBounds=v1t.getGeometryBounds(this)),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){const{strokeWidth:e,strokeAlignment:r,cx:i,cy:s,r:o}=this,n=RA(r,e);this.renderBoundsDirtyFlag=!1,this.renderBounds=new Xm(i-o-n,s-o-n,i+o+n,s+o+n)}return this.renderBounds}};dN=new WeakMap,fN=new WeakMap,pN=new WeakMap;var ub=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},F6=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},gN,mN,yN,vN;let pM=class _1t extends uN{static getGeometryBounds(e){const{cx:r,cy:i,rx:s,ry:o}=e;return new Xm(r-s,i-o,r+s,i+o)}constructor(e={}){var r,i;super(e),gN.set(this,void 0),mN.set(this,void 0),yN.set(this,void 0),vN.set(this,void 0);const{cx:s,cy:o,rx:n,ry:a}=e;this.cx=s??0,this.cy=o??0,this.rx=(r=n??a)!==null&&r!==void 0?r:0,this.ry=(i=a??n)!==null&&i!==void 0?i:0}get cx(){return ub(this,gN,"f")}set cx(e){ub(this,gN,"f")!==e&&(F6(this,gN,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get cy(){return ub(this,mN,"f")}set cy(e){ub(this,mN,"f")!==e&&(F6(this,mN,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get rx(){return ub(this,yN,"f")}set rx(e){ub(this,yN,"f")!==e&&(F6(this,yN,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get ry(){return ub(this,vN,"f")}set ry(e){ub(this,vN,"f")!==e&&(F6(this,vN,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}containsPoint(e,r){const{cx:i,cy:s,rx:o,ry:n,strokeWidth:a,strokeAlignment:l,pointerEvents:c,fill:h,stroke:u}=this,d=RA(l,a),[f,g]=P6(c,h,u);return f&&g?N6(e,r,i,s,o+d,n+d):f?N6(e,r,i,s,o,n):g?!N6(e,r,i,s,o+d-a,n+d-a)&&N6(e,r,i,s,o+d,n+d):!1}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.geometryBoundsDirtyFlag=!1,this.geometryBounds=_1t.getGeometryBounds(this)),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){const{strokeWidth:e,strokeAlignment:r,cx:i,cy:s,rx:o,ry:n}=this,a=RA(r,e);this.renderBoundsDirtyFlag=!1,this.renderBounds=new Xm(i-o-a,s-n-a,i+o+a,s+n+a)}return this.renderBounds}};gN=new WeakMap,mN=new WeakMap,yN=new WeakMap,vN=new WeakMap;function N6(t,e,r,i,s,o){const n=t-r,a=e-i;return n*n/(s*s)+a*a/(o*o)<=1}var Tl=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},zm=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
3757return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},_N,bN,wN,EN,AN,xN,k6,SN,TN,RN;let gM=class b1t extends uN{static getGeometryBounds(e){const{x:r,y:i,width:s,height:o}=e;return new Xm(r,i,r+s,i+o)}constructor(e={}){super(e),_N.set(this,void 0),bN.set(this,void 0),wN.set(this,void 0),EN.set(this,void 0),AN.set(this,void 0),xN.set(this,void 0),k6.set(this,void 0),SN.set(this,void 0),TN.set(this,void 0),RN.set(this,void 0);const{x:r,y:i,width:s,height:o,cornerRadius:n,dropShadowColor:a,dropShadowOffsetX:l,dropShadowOffsetY:c,dropShadowBlurRadius:h}=e;this.x=r??0,this.y=i??0,this.width=s??0,this.height=o??0,this.cornerRadius=n??0,this.dropShadowColor=a??"black",this.dropShadowOffsetX=l??0,this.dropShadowOffsetY=c??0,this.dropShadowBlurRadius=h??0}get x(){return Tl(this,_N,"f")}set x(e){Tl(this,_N,"f")!==e&&(zm(this,_N,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get y(){return Tl(this,bN,"f")}set y(e){Tl(this,bN,"f")!==e&&(zm(this,bN,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get width(){return Tl(this,wN,"f")}set width(e){Tl(this,wN,"f")!==e&&(zm(this,wN,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get height(){return Tl(this,EN,"f")}set height(e){Tl(this,EN,"f")!==e&&(zm(this,EN,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get cornerRadius(){return Tl(this,AN,"f")}set cornerRadius(e){Tl(this,AN,"f")!==e&&(zm(this,AN,e,"f"),this.renderDirtyFlag=!0)}get dropShadowColor(){return Tl(this,xN,"f")}set dropShadowColor(e){Tl(this,xN,"f")!==e&&(zm(this,xN,e,"f"),zm(this,k6,sr.rgb(e),"f"),this.renderDirtyFlag=!0)}get dropShadowColorRGB(){return Tl(this,k6,"f")}get dropShadowOffsetX(){return Tl(this,SN,"f")}set dropShadowOffsetX(e){Tl(this,SN,"f")!==e&&(zm(this,SN,e,"f"),this.renderDirtyFlag=!0)}get dropShadowOffsetY(){return Tl(this,TN,"f")}set dropShadowOffsetY(e){Tl(this,TN,"f")!==e&&(zm(this,TN,e,"f"),this.renderDirtyFlag=!0)}get dropShadowBlurRadius(){return Tl(this,RN,"f")}set dropShadowBlurRadius(e){Tl(this,RN,"f")!==e&&(zm(this,RN,e,"f"),this.renderDirtyFlag=!0)}containsPoint(e,r){const{x:i,y:s,width:o,height:n,strokeWidth:a,strokeAlignment:l,cornerRadius:c}=this,h=RA(l,a),[u,d]=P6(this.pointerEvents,this.dropShadowColor,this.stroke);if(u&&d)return L6(e,r,i-h,s-h,i+o+h,s+n+h,c);if(u)return L6(e,r,i,s,i+o,s+n,c);if(d){const f=h-a;return!L6(e,r,i-f,s-f,i+o+f,s+n+f,c)&&L6(e,r,i-h,s-h,i+o+h,s+n+h,c)}return!1}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.geometryBoundsDirtyFlag=!1,this.geometryBounds=b1t.getGeometryBounds(this)),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){const{x:e,y:r,width:i,height:s,strokeWidth:o,strokeAlignment:n,dropShadowOffsetX:a,dropShadowOffsetY:l,dropShadowBlurRadius:c}=this,h=RA(n,o);this.renderBoundsDirtyFlag=!1,this.renderBounds=new Xm(e-h,r-h,e+i+h,r+s+h),this.renderBounds.addBounds(new Xm(e+a-c,r+l-c,e+a+i+c,r+l+s+c))}return this.renderBounds}};_N=new WeakMap,bN=new WeakMap,wN=new WeakMap,EN=new WeakMap,AN=new WeakMap,xN=new WeakMap,k6=new WeakMap,SN=new WeakMap,TN=new WeakMap,RN=new WeakMap;function L6(t,e,r,i,s,o,n){function a(l,c,h,u,d){return Math.sqrt(Math.pow(l-h,2)+Math.pow(c-u,2))<=d}return t>=r&&t<=s&&e>=i&&e<=o?a(t,e,r+n,i+n,n)||a(t,e,s-n,i+n,n)||a(t,e,s-n,o-n,n)||a(t,e,r+n,o-n,n)?!0:!(t<=r+n||t>=s-n||e<=i+n||e>=o-n):!1}const D4t=` 3758layout(std140) uniform SceneUniforms { 3759 mat3 u_ProjectionMatrix; 3760 mat3 u_ViewMatrix; 3761 mat3 u_ViewProjectionInvMatrix; 3762 float u_ZoomScale; 3763 float u_CheckboardStyle; 3764}; 3765 3766layout(location = 0) in vec2 a_Position; 3767 3768out vec2 v_Position; 3769 3770vec2 project_clipspace_to_world(vec2 p) { 3771 return (u_ViewProjectionInvMatrix * vec3(p, 1)).xy; 3772} 3773 3774void main() { 3775 v_Position = project_clipspace_to_world(a_Position); 3776 gl_Position = vec4(a_Position, 0, 1); 3777} 3778`,P4t=` 3779layout(std140) uniform SceneUniforms { 3780 mat3 u_ProjectionMatrix; 3781 mat3 u_ViewMatrix; 3782 mat3 u_ViewProjectionInvMatrix; 3783 float u_ZoomScale; 3784 float u_CheckboardStyle; 3785}; 3786 3787out vec4 outputColor; 3788 3789in vec2 v_Position; 3790 3791const vec4 GRID_COLOR = vec4(0.87, 0.87, 0.87, 1.0); 3792const vec4 PAGE_COLOR = vec4(0.986, 0.986, 0.986, 1.0); 3793const int CHECKERBOARD_STYLE_NONE = 0; 3794const int CHECKERBOARD_STYLE_GRID = 1; 3795const int CHECKERBOARD_STYLE_DOTS = 2; 3796const float BASE_GRID_PIXEL_SIZE = 100.0; 3797const float BASE_DOT_SIZE = 8.0; 3798 3799vec2 scale_grid_size(float zoom) { 3800 if (zoom < 0.125) return vec2(BASE_GRID_PIXEL_SIZE * 125.0, 0.125); 3801 else if (zoom < 0.25) return vec2(BASE_GRID_PIXEL_SIZE * 25.0, 0.25); 3802 else if (zoom < 0.5) return vec2(BASE_GRID_PIXEL_SIZE * 5.0, 0.5); 3803 return vec2(BASE_GRID_PIXEL_SIZE, 4.0); 3804} 3805 3806vec4 render_grid_checkerboard(vec2 coord) { 3807 float alpha = 0.0; 3808 3809 vec2 size = scale_grid_size(u_ZoomScale); 3810 float gridSize1 = size.x; 3811 float gridSize2 = gridSize1 / 10.0;
3812 float zoomStep = size.y; 3813 int checkboardStyle = int(floor(u_CheckboardStyle + 0.5)); 3814 3815 if (checkboardStyle == CHECKERBOARD_STYLE_GRID) { 3816 vec2 grid1 = abs(fract(coord / gridSize1 - 0.5) - 0.5) / fwidth(coord) * gridSize1 / 2.0; 3817 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2; 3818 float v1 = 1.0 - min(min(grid1.x, grid1.y), 1.0); 3819 float v2 = 1.0 - min(min(grid2.x, grid2.y), 1.0); 3820 3821 if (v1 > 0.0) { 3822 alpha = v1; 3823 } else { 3824 alpha = v2 * clamp(u_ZoomScale / zoomStep, 0.0, 1.0); 3825 } 3826 } else if (checkboardStyle == CHECKERBOARD_STYLE_DOTS) { 3827 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2; 3828 alpha = 1.0 - smoothstep(0.0, 1.0, length(grid2) - BASE_DOT_SIZE * u_ZoomScale / zoomStep); 3829 } 3830 3831 return mix(PAGE_COLOR, GRID_COLOR, alpha); 3832} 3833 3834void main() { 3835 outputColor = render_grid_checkerboard(v_Position); 3836} 3837`;var Ac=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},CN=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},CA,mM,yM,MN,BN,ON;let vht=class{constructor(){CA.set(this,void 0),mM.set(this,void 0),yM.set(this,void 0),MN.set(this,void 0),BN.set(this,void 0),ON.set(this,new w4t)}appendVertex(t,e){Ac(this,ON,"f").appendFloat(t).appendFloat(e)}render(t,e,r){if(!Ac(this,CA,"f")){CN(this,CA,t.createProgram({vertex:{glsl:D4t},fragment:{glsl:P4t}}),"f"),CN(this,yM,t.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{format:I.F32_RG,offset:0,shaderLocation:0}]}],indexBufferFormat:null,program:Ac(this,CA,"f")}),"f"),CN(this,mM,t.createRenderPipeline({inputLayout:Ac(this,yM,"f"),program:Ac(this,CA,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,topology:Go.TRIANGLE_STRIP}),"f"),Ac(this,ON,"f").clear(),this.appendVertex(-1,-1),this.appendVertex(-1,1),this.appendVertex(1,-1),this.appendVertex(1,1);const i=Ac(this,ON,"f").bytes(),s=t.createBuffer({viewOrSize:i.byteLength,usage:dt.VERTEX,hint:Et.DYNAMIC});CN(this,BN,s,"f"),s.setSubData(0,i),CN(this,MN,t.createBindings({pipeline:Ac(this,mM,"f"),uniformBufferBindings:[{buffer:r}]}),"f")}
3837e.setBindings(Ac(this,MN,"f")),e.setPipeline(Ac(this,mM,"f")),e.setVertexInput(Ac(this,yM,"f"),[{buffer:Ac(this,BN,"f")}],null),e.draw(4)}destroy(){Ac(this,CA,"f").destroy(),Ac(this,BN,"f").destroy(),Ac(this,mM,"f").destroy(),Ac(this,yM,"f").destroy(),Ac(this,MN,"f").destroy()}};CA=new WeakMap,mM=new WeakMap,yM=new WeakMap,MN=new WeakMap,BN=new WeakMap,ON=new WeakMap;let U6=class extends uN{constructor(){super(...arguments),this.renderable=!1}containsPoint(t,e){throw new Error("Method not implemented.")}getGeometryBounds(){throw new Error("Method not implemented.")}getRenderBounds(){throw new Error("Method not implemented.")}destroy(){}};var _ht=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},bht=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};const wht=["renderable","visible"],w7=["cullable","batchable","fill","stroke","strokeWidth","strokeAlignment","opacity","fillOpacity","strokeOpacity","innerShadowColor","innerShadowOffsetX","innerShadowOffsetY","innerShadowBlurRadius"],F4t=["cx","cy","r"],N4t=["cx","cy","rx","ry"],k4t=["x","y","width","height","cornerRadius","dropShadowColor","dropShadowOffsetX","dropShadowOffsetY","dropShadowBlurRadius"],L4t={opacity:1,fillOpacity:1,strokeOpacity:1,fill:"black",stroke:"none",strokeWidth:1,strokeLinecap:"butt",strokeLinejoin:"miter",strokeAlignment:"center",strokeMiterlimit:4,strokeDasharray:"none",strokeDashoffset:0,innerShadowBlurRadius:0,innerShadowColor:"none",innerShadowOffsetX:0,innerShadowOffsetY:0,visibility:"visible",transform:"matrix(1,0,0,1,0,0)",cornerRadius:0,dropShadowColor:"none",dropShadowOffsetX:0,dropShadowOffsetY:0,dropShadowBlurRadius:0};function U4t(t){if(t instanceof U6)return["g",wht];if(t instanceof fM)return["circle",[...w7,...F4t]];if(t instanceof pM)return["ellipse",[...w7,...N4t]];if(t instanceof gM)return["rect",[...w7,...k4t]]}function Eht(t){return _ht(this,void 0,void 0,function*(){const{type:e,attributes:r,children:i}=t;let s;e==="g"?s=new U6:e==="circle"?s=new fM:e==="ellipse"?s=new pM:e==="rect"&&(s=new gM);const{transform:o}=r,n=bht(r,["transform"]);Object.assign(s,n);const{fill:a}=n;if(a&&TA(a)&&dht(a)&&(s.fill=yield nu(a,Hh)),o){const{position:l,scale:c,skew:h,rotation:u,pivot:d}=o;s.transform.position.set(l.x,l.y),s.transform.scale.set(c.x,c.y),s.transform.skew.set(h.x,h.y),s.transform.rotation=u,s.transform.pivot.set(d.x,d.y)}return i&&i.length>0&&(yield Promise.all(i.map(l=>_ht(this,void 0,void 0,function*(){s.appendChild(yield Eht(l))})))),s})}function E7(t){const[e,r]=U4t(t),i={uid:t.uid,type:e,attributes:[...wht,...r].reduce((o,n)=>(o[n]=t[n],o),{})},{fill:s}=i.attributes;return s&&!TA(s)&&(i.attributes.fill=V4t(s)),i.attributes.transform=G4t(t.transform),i.children=t.children.map(E7),i}function G4t(t){const{a:e,b:r,c:i,d:s,tx:o,ty:n}=t.localTransform;return{matrix:{a:e,b:r,c:i,d:s,tx:o,ty:n},position:{x:t.position.x,y:t.position.y},scale:{x:t.scale.x,y:t.scale.y},skew:{x:t.skew.x,y:t.skew.y},rotation:t.rotation,pivot:{x:t.pivot.x,y:t.pivot.y}}}function W4t(t,e,r,i){const{type:s,attributes:o}=t,{strokeWidth:n,strokeAlignment:a}=o,l=a==="inner",c=n/2,h=e.cloneNode();if(e.setAttribute("stroke","none"),h.setAttribute("fill","none"),s==="circle"){const{r:u}=o,d=l?-c:c;h.setAttribute("r",`${u+d}`)}else if(s==="ellipse"){const{rx:u,ry:d}=o,f=l?-c:c;h.setAttribute("rx",`${u+f}`),h.setAttribute("ry",`${d+f}`)}else if(s==="rect"){const{x:u,y:d,width:f,height:g,strokeWidth:p}=o;h.setAttribute("x",`${u+(l?c:-c)}`),h.setAttribute("y",`${d+(l?c:-c)}`),h.setAttribute("width",`${f+(l?-p:p)}`),h.setAttribute("height",`${g+(l?-p:p)}`)}r.appendChild(h)}function j4t(t,e,r,i){const{uid:s,attributes:{innerShadowOffsetX:o,innerShadowOffsetY:n,innerShadowBlurRadius:a,innerShadowColor:l}}=t,c=gs("defs",i),h=gs("filter",i);h.id=`filter_inner_shadow_${s}`;const u=gs("feComponentTransfer",i);u.setAttribute("in","SourceAlpha");const d=gs("feFuncA",i);d.setAttribute("type","table"),d.setAttribute("tableValues","1 0"),u.appendChild(d),h.appendChild(u);const f=gs("feGaussianBlur",i);f.setAttribute("stdDeviation",`${(a||0)/4}`),h.appendChild(f);const g=gs("feOffset",i);g.setAttribute("dx",`${(o||0)/2}`),g.setAttribute("dy",`${(n||0)/2}`),g.setAttribute("result","offsetblur"),h.appendChild(g);const p=gs("feFlood",i);p.setAttribute("flood-color",l),p.setAttribute("result","color"),h.appendChild(p);const m=gs("feComposite",i);m.setAttribute("in2","offsetblur"),m.setAttribute("operator","in"),h.appendChild(m);const v=gs("feComposite",i);v.setAttribute("in2","SourceAlpha"),v.setAttribute("operator","in"),h.appendChild(v);const b=gs("feMerge",i);h.appendChild(b);const y=gs("feMergeNode",i);y.setAttribute("in","SourceGraphic");const _=gs("feMergeNode",i);b.appendChild(y),b.appendChild(_),c.appendChild(h),e.appendChild(c);const w=e.getAttribute("filter")||"";e.setAttribute("filter",`${w} url(#${h.id})`.trim())}function X4t(t,e,r,i){const{uid:s,attributes:{dropShadowBlurRadius:o,dropShadowColor:n,dropShadowOffsetX:a,dropShadowOffsetY:l}}=t,c=gs("defs",i),h=gs("filter",i);h.id=`filter_drop_shadow_${s}`;const u=gs("feDropShadow",i);
3837u.setAttribute("dx",`${(a||0)/2}`),u.setAttribute("dy",`${(l||0)/2}`),u.setAttribute("stdDeviation",`${(o||0)/4}`),u.setAttribute("flood-color",n),h.appendChild(u),c.appendChild(h),e.appendChild(c);const d=e.getAttribute("filter")||"";e.setAttribute("filter",`${d} url(#${h.id})`.trim())}function z4t(t,e,r,i){const s=gs("defs",i),o=gs("pattern",i);o.id=`image-fill_${t.uid}`,o.setAttribute("patternUnits","objectBoundingBox"),o.setAttribute("width","1"),o.setAttribute("height","1");const n=gs("image",i);n.setAttribute("href",t.attributes.fill),n.setAttribute("x","0"),n.setAttribute("y","0");let a;t.type==="circle"?a=fM.getGeometryBounds(t.attributes):t.type==="ellipse"?a=pM.getGeometryBounds(t.attributes):t.type==="rect"&&(a=gM.getGeometryBounds(t.attributes)),n.setAttribute("width",`${a.maxX-a.minX}`),n.setAttribute("height",`${a.maxY-a.minY}`),o.appendChild(n),s.appendChild(o),r.appendChild(s),e.setAttribute("fill",`url(#${o.id})`)}function A7(t,e){const{type:r,attributes:i,children:s}=t,o=gs(r,e),{transform:n,visible:a,cullable:l,renderable:c,batchable:h,innerShadowColor:u,innerShadowOffsetX:d,innerShadowOffsetY:f,innerShadowBlurRadius:g,dropShadowColor:p,dropShadowOffsetX:m,dropShadowOffsetY:v,dropShadowBlurRadius:b,strokeAlignment:y,cornerRadius:_}=i,w=bht(i,["transform","visible","cullable","renderable","batchable","innerShadowColor","innerShadowOffsetX","innerShadowOffsetY","innerShadowBlurRadius","dropShadowColor","dropShadowOffsetX","dropShadowOffsetY","dropShadowBlurRadius","strokeAlignment","cornerRadius"]);Object.entries(w).forEach(([F,U])=>{`${U}`!=""&&`${L4t[F]}`!=`${U}`&&o.setAttribute(E4t(F),`${U}`)});const E=y==="inner"||y==="outer",A=w.fill&&TA(w.fill)&&dht(w.fill);let x;(s&&s.length>0&&r!=="g"||E||A)&&(x=gs("g",e),x.appendChild(o)),E&&W4t(t,o,x),g>0&&j4t(t,o,x,e),b>0&&X4t(t,o,x,e),A&&z4t(t,o,x,e),x=x||o,a===!1&&x.setAttribute("visibility","hidden"),_&&(x.setAttribute("rx",`${_}`),x.setAttribute("ry",`${_}`));const{a:S,b:T,c:R,d:B,tx:O,ty:C}=n.matrix;return(S!==1||T!==0||R!==0||B!==1||O!==0||C!==0)&&x.setAttribute("transform",`matrix(${S},${T},${R},${B},${O},${C})`),[...s].map(F=>A7(F,e)).forEach(F=>{x.appendChild(F)}),x}function V4t(t){const e=document.createElement("canvas");return e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0),e.toDataURL()}var vr=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},xc=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Jp,Iu,Du,Ef,IN,DN,Qp,PN,FN,NN,G6,kN;const Aht=1e-4;let xht=class w1t{constructor(e,r){this.clipSpaceNearZ=Sh.NEGATIVE_ONE,Jp.set(this,1),Iu.set(this,0),Du.set(this,0),Ef.set(this,0),IN.set(this,0),DN.set(this,0),Qp.set(this,Bt()),PN.set(this,Bt()),FN.set(this,Bt()),NN.set(this,Bt()),G6.set(this,Bt()),kN.set(this,void 0),this.projection(e,r),this.updateMatrix()}clone(){const e=new w1t(vr(this,IN,"f"),vr(this,DN,"f"));return xc(e,Iu,vr(this,Iu,"f"),"f"),xc(e,Du,vr(this,Du,"f"),"f"),xc(e,Jp,vr(this,Jp,"f"),"f"),xc(e,Ef,vr(this,Ef,"f"),"f"),e.updateMatrix(),e}projection(e,r){xc(this,IN,e,"f"),xc(this,DN,r,"f"),ld(vr(this,PN,"f"),e,r),this.updateViewProjectionMatrix()}updateMatrix(){const e=1/vr(this,Jp,"f");Yc(vr(this,Qp,"f")),bi(vr(this,Qp,"f"),vr(this,Qp,"f"),[vr(this,Iu,"f"),vr(this,Du,"f")]),Mo(vr(this,Qp,"f"),vr(this,Qp,"f"),vr(this,Ef,"f")),xh(vr(this,Qp,"f"),vr(this,Qp,"f"),[e,e]),_i(vr(this,FN,"f"),vr(this,Qp,"f")),this.updateViewProjectionMatrix()}updateViewProjectionMatrix(){us(vr(this,NN,"f"),vr(this,PN,"f"),vr(this,FN,"f")),_i(vr(this,G6,"f"),vr(this,NN,"f")),this.onchange&&this.onchange()}get projectionMatrix(){return vr(this,PN,"f")}get viewMatrix(){return vr(this,FN,"f")}get viewProjectionMatrix(){return vr(this,NN,"f")}get viewProjectionMatrixInv(){return vr(this,G6,"f")}get matrix(){return vr(this,Qp,"f")}get zoom(){return vr(this,Jp,"f")}set zoom(e){vr(this,Jp,"f")!==e&&(xc(this,Jp,e,"f"),this.updateMatrix())}get x(){return vr(this,Iu,"f")}set x(e){vr(this,Iu,"f")!==e&&(xc(this,Iu,e,"f"),this.updateMatrix())}get y(){return vr(this,Du,"f")}set y(e){vr(this,Du,"f")!==e&&(xc(this,Du,e,"f"),this.updateMatrix())}get rotation(){return vr(this,Ef,"f")}set rotation(e){vr(this,Ef,"f")!==e&&(xc(this,Ef,e,"f"),this.updateMatrix())}get width(){return vr(this,IN,"f")}get height(){return vr(this,DN,"f")}createLandmark(e={}){return Object.assign({zoom:vr(this,Jp,"f"),x:vr(this,Iu,"f"),y:vr(this,Du,"f"),rotation:vr(this,Ef,"f")},e)}gotoLandmark(e,r={}){const{easing:i="linear",duration:s=100,onframe:o=void 0,onfinish:n=void 0}=r,{zoom:a=vr(this,Jp,"f"),x:l=vr(this,Iu,"f"),y:c=vr(this,Du,"f"),rotation:h=vr(this,Ef,"f"),viewportX:u
3837=0,viewportY:d=0}=e,f=u||d,g=()=>{this.applyLandmark({x:l,y:c,zoom:a,rotation:h,viewportX:u,viewportY:d}),n&&n()};if(s===0){g();return}this.cancelLandmarkAnimation();let p;const m=[l,c],v=[a,h],b=y=>{p===void 0&&(p=y);const _=y-p;if(_>s){g();return}const w=b4t[i](_/s),E=it(),A=Be(1,0);if(ta(E,[vr(this,Iu,"f"),vr(this,Du,"f")],m,w),ta(A,[this.zoom,vr(this,Ef,"f")],v,w),this.applyLandmark({x:E[0],y:E[1],zoom:A[0],rotation:A[1],viewportX:u,viewportY:d}),f?za(A,v)<=Aht:za(E,m)<=Aht){g();return}_<s&&(o&&o(w),xc(this,kN,requestAnimationFrame(b),"f"))};requestAnimationFrame(b)}cancelLandmarkAnimation(){vr(this,kN,"f")!==void 0&&cancelAnimationFrame(vr(this,kN,"f"))}viewport2Canvas({x:e,y:r},i){const{width:s,height:o,viewProjectionMatrixInv:n}=i||this,a=Qt(it(),[e/s*2-1,(1-r/o)*2-1],n);return{x:a[0],y:a[1]}}canvas2Viewport({x:e,y:r},i){const{width:s,height:o,viewProjectionMatrix:n}=i||this,a=Qt(it(),[e,r],n);return{x:(a[0]+1)/2*s,y:(1-(a[1]+1)/2)*o}}applyLandmark(e){const{x:r,y:i,zoom:s,rotation:o,viewportX:n,viewportY:a}=e,l=n||a;let c=0,h=0;if(l){const u=this.viewport2Canvas({x:n,y:a});c=u.x,h=u.y}if(xc(this,Jp,s,"f"),xc(this,Ef,o,"f"),xc(this,Iu,r,"f"),xc(this,Du,i,"f"),this.updateMatrix(),l){const{x:u,y:d}=this.viewport2Canvas({x:n,y:a});xc(this,Iu,vr(this,Iu,"f")+(c-u),"f"),xc(this,Du,vr(this,Du,"f")+(h-d),"f"),this.updateMatrix()}}};Jp=new WeakMap,Iu=new WeakMap,Du=new WeakMap,Ef=new WeakMap,IN=new WeakMap,DN=new WeakMap,Qp=new WeakMap,PN=new WeakMap,FN=new WeakMap,NN=new WeakMap,G6=new WeakMap,kN=new WeakMap;const Sht=1e5;let Tht=class{constructor(t,e,r){this.device=t,this.renderCache=e,this.instanced=r,this.shapes=[],this.maxInstances=1/0,this.geometryDirty=!0,this.materialDirty=!0}validate(t){return this.count()<=this.maxInstances-1}submit(t,e){this.geometryDirty&&this.createGeometry(),this.materialDirty&&this.createMaterial(e),this.render(t),this.geometryDirty&&(this.geometryDirty=!1),this.materialDirty&&(this.materialDirty=!1)}add(t){this.shapes.includes(t)||(this.shapes.push(t),this.geometryDirty=!0)}remove(t){if(this.shapes.includes(t)){const e=this.shapes.indexOf(t);this.shapes.splice(e,1),this.geometryDirty=!0}}count(){return this.shapes.length}};const Y4t=` 3838layout(std140) uniform SceneUniforms { 3839 mat3 u_ProjectionMatrix; 3840 mat3 u_ViewMatrix; 3841}; 3842 3843layout(location = 0) in vec2 a_FragCoord; 3844 3845#ifdef USE_INSTANCES 3846 layout(location = 14) in vec4 a_Abcd; 3847 layout(location = 15) in vec2 a_Txty; 3848 layout(location = 1) in vec4 a_PositionSize; 3849 layout(location = 2) in vec4 a_FillColor; 3850 layout(location = 3) in vec4 a_StrokeColor; 3851 layout(location = 4) in vec4 a_ZIndexStrokeWidth; 3852 layout(location = 5) in vec4 a_Opacity; 3853 layout(location = 6) in vec4 a_InnerShadowColor; 3854 layout(location = 7) in vec4 a_InnerShadow; 3855#else 3856 layout(std140) uniform ShapeUniforms { 3857 mat3 u_ModelMatrix; 3858 vec4 u_PositionSize; 3859 vec4 u_FillColor; 3860 vec4 u_StrokeColor; 3861 vec4 u_ZIndexStrokeWidth; 3862 vec4 u_Opacity; 3863 vec4 u_InnerShadowColor; 3864 vec4 u_InnerShadow; 3865 }; 3866#endif 3867 3868out vec2 v_FragCoord; 3869#ifdef USE_INSTANCES 3870 out vec4 v_FillColor; 3871 out vec4 v_StrokeColor; 3872 out float v_StrokeWidth; 3873 out vec4 v_Opacity; 3874 out float v_CornerRadius; 3875 out float v_StrokeAlignment; 3876 out vec4 v_InnerShadowColor; 3877 out vec4 v_InnerShadow; 3878#else 3879#endif 3880out vec2 v_Radius; 3881out vec2 v_Uv; 3882 3883void main() { 3884 mat3 model; 3885 vec2 position; 3886 vec2 size; 3887 vec4 fillColor; 3888 vec4 strokeColor; 3889 float zIndex; 3890 float strokeWidth; 3891 float strokeAlignment; 3892 3893 #ifdef USE_INSTANCES 3894 model = mat3(a_Abcd.x, a_Abcd.y, 0, a_Abcd.z, a_Abcd.w, 0, a_Txty.x, a_Txty.y, 1); 3895 position = a_PositionSize.xy; 3896 size = a_PositionSize.zw; 3897 fillColor = a_FillColor; 3898 strokeColor = a_StrokeColor; 3899 zIndex = a_ZIndexStrokeWidth.x; 3900 strokeWidth = a_ZIndexStrokeWidth.y; 3901 strokeAlignment = a_ZIndexStrokeWidth.w; 3902 3903 v_FillColor = fillColor; 3904 v_StrokeColor = strokeColor; 3905 v_StrokeWidth = strokeWidth; 3906 v_Opacity = a_Opacity; 3907 v_CornerRadius = a_ZIndexStrokeWidth.z; 3908 v_StrokeAlignment = a_ZIndexStrokeWidth.w; 3909 v_InnerShadowColor = a_InnerShadowColor; 3910 v_InnerShadow = a_InnerShadow; 3911 #else 3912 model = u_ModelMatrix; 3913 position = u_PositionSize.xy; 3914 size = u_PositionSize.zw; 3915 fillColor = u_FillColor; 3916 strokeColor = u_StrokeColor; 3917 zIndex = u_ZIndexStrokeWidth.x; 3918 strokeWidth = u_ZIndexStrokeWidth.y; 3919 strokeAlignment = u_ZIndexStrokeWidth.w; 3920 #endif 3921 3922 float strokeOffset; 3923 if (strokeAlignment < 0.5) { 3924 strokeOffset = strokeWidth / 2.0; 3925 } else if (strokeAlignment < 1.5) { 3926 strokeOffset = 0.0; 3927 } else if (strokeAlignment < 2.5) { 3928 strokeOffset = strokeWidth; 3929 } 3930 3931 vec2 radius = size + vec2(strokeOffset); 3932 3933 v_FragCoord = vec2(a_FragCoord * radius);
3934 v_Radius = radius; 3935 v_Uv = (a_FragCoord * radius / size + 1.0) / 2.0; 3936 3937 gl_Position = vec4((u_ProjectionMatrix 3938 * u_ViewMatrix 3939 * model 3940 * vec3(position + v_FragCoord, 1)).xy, zIndex, 1); 3941} 3942`,$4t=` 3943#ifdef USE_INSTANCES 3944#else 3945 layout(std140) uniform ShapeUniforms { 3946 mat3 u_ModelMatrix; 3947 vec4 u_PositionSize; 3948 vec4 u_FillColor; 3949 vec4 u_StrokeColor; 3950 vec4 u_ZIndexStrokeWidth; 3951 vec4 u_Opacity; 3952 vec4 u_InnerShadowColor; 3953 vec4 u_InnerShadow; 3954 }; 3955#endif 3956 3957out vec4 outputColor; 3958 3959in vec2 v_FragCoord; 3960#ifdef USE_INSTANCES 3961 in vec4 v_FillColor; 3962 in vec4 v_StrokeColor; 3963 in float v_StrokeWidth; 3964 in vec4 v_Opacity; 3965 in float v_CornerRadius; 3966 in float v_StrokeAlignment; 3967 in vec4 v_InnerShadowColor; 3968 in vec4 v_InnerShadow; 3969#else 3970#endif 3971in vec2 v_Radius; 3972 3973in vec2 v_Uv; 3974uniform sampler2D u_Texture; 3975 3976float epsilon = 0.000001; 3977 3978float sdf_circle(vec2 p, float r) { 3979 return length(p) - r; 3980} 3981 3982float sdf_ellipse(vec2 p, vec2 r) { 3983 float k0 = length(p / r); 3984 float k1 = length(p / (r * r)); 3985 return k0 * (k0 - 1.0) / k1; 3986 3987 // V1 3988 // float k1 = length(p/r); 3989 // return (k1-1.0)*min(r.x,r.y); 3990 3991 // V3 3992 // float k1 = length(p/r); 3993 // return length(p)*(1.0-1.0/k1); 3994} 3995 3996float sdf_rounded_box(vec2 p, vec2 b, float r) { 3997 vec2 q = abs(p) - b + r; 3998 return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r; 3999} 4000 4001vec4 over(vec4 below, vec4 above) { 4002 vec4 result; 4003 float alpha = above.a + below.a * (1.0 - above.a); 4004 result.rgb = 4005 (above.rgb * above.a + below.rgb * below.a * (1.0 - above.a)) / alpha; 4006 result.a = alpha; 4007 return result; 4008} 4009 4010float antialias(float distance) { 4011 return clamp(distance / -fwidth(distance), 0.0, 1.0); 4012} 4013 4014vec4 mix_border_inside(vec4 border, vec4 inside, float distance) { 4015 // Blend the border on top of the background and then linearly interpolate 4016 // between the two as we slide inside the background. 4017 return mix(border, inside, clamp(1.0 - distance, 0.0, 1.0) * antialias(distance)); 4018} 4019 4020float sigmoid(float t) { 4021 return 1.0 / (1.0 + exp(-t)); 4022} 4023 4024float make_shadow(vec2 pos, vec2 halfSize, float cornerRd, float blurRd, float distMul, float shape) { 4025 float distance; 4026 if (shape < 0.5) { 4027 distance = sdf_circle(pos, halfSize.x); 4028 } else if (shape < 1.5) { 4029 distance = sdf_ellipse(pos, halfSize); 4030 } else if (shape < 2.5) { 4031 distance = sdf_rounded_box(pos, halfSize, cornerRd + blurRd); 4032 } 4033 float dist = sigmoid(distMul * distance / blurRd); 4034 return clamp(dist, 0.0, 1.0); 4035} 4036 4037void main() { 4038 float strokeWidth; 4039 vec4 fillColor; 4040 vec4 strokeColor; 4041 float opacity; 4042 float fillOpacity; 4043 float strokeOpacity; 4044 float shape; 4045 float cornerRadius; 4046 vec4 innerShadowColor; 4047 vec4 innerShadow; 4048 float strokeAlignment; 4049 4050 #ifdef USE_INSTANCES 4051 fillColor = v_FillColor; 4052 strokeColor = v_StrokeColor; 4053 strokeWidth = v_StrokeWidth; 4054 opacity = v_Opacity.x; 4055 fillOpacity = v_Opacity.y; 4056 strokeOpacity = v_Opacity.z; 4057 shape = v_Opacity.w; 4058 cornerRadius = v_CornerRadius; 4059 strokeAlignment = v_StrokeAlignment; 4060 innerShadowColor = v_InnerShadowColor; 4061 innerShadow = v_InnerShadow; 4062 #else 4063 fillColor = u_FillColor; 4064 strokeColor = u_StrokeColor; 4065 strokeWidth = u_ZIndexStrokeWidth.y; 4066 opacity = u_Opacity.x; 4067 fillOpacity = u_Opacity.y; 4068 strokeOpacity = u_Opacity.z; 4069 shape = u_Opacity.w; 4070 cornerRadius = u_ZIndexStrokeWidth.z; 4071 strokeAlignment = u_ZIndexStrokeWidth.w; 4072 innerShadowColor = u_InnerShadowColor; 4073 innerShadow = u_InnerShadow; 4074 #endif 4075 4076 bool useFillImage = innerShadow.w > 0.5; 4077 if (useFillImage) { 4078 fillColor = texture(SAMPLER_2D(u_Texture), v_Uv); 4079 } 4080 4081 float distance; 4082 // 'circle', 'ellipse', 'rect' 4083 if (shape < 0.5) { 4084 distance = sdf_circle(v_FragCoord, v_Radius.x); 4085 } else if (shape < 1.5) { 4086 distance = sdf_ellipse(v_FragCoord, v_Radius); 4087 } else if (shape < 2.5) { 4088 distance = sdf_rounded_box(v_FragCoord, v_Radius, cornerRadius); 4089 // TODO: Fast path when the quad is not rounded and doesn't have any border. 4090 } 4091 4092 // based on the target alpha compositing mode. 4093 fillColor.a *= fillOpacity; 4094 strokeColor.a *= strokeOpacity; 4095 4096 vec4 color = fillColor; 4097 if (strokeWidth > 0.0) { 4098 float d1; 4099 float d2; 4100 if (strokeAlignment < 0.5) { 4101 d1 = distance + strokeWidth; 4102 d2 = distance + strokeWidth / 2.0; 4103 color = mix_border_inside(over(fillColor, strokeColor), fillColor, d1); 4104 color = mix_border_inside(strokeColor, color, d2); 4105 } else if (strokeAlignment < 1.5) { 4106 d1 = distance + strokeWidth; 4107 d2 = distance; 4108 color = mix_border_inside(over(fillColor, strokeColor), fillColor, d1); 4109 color = mix_border_inside(strokeColor, color, d2); 4110 } else if (strokeAlignment < 2.5) { 4111 d2 = distance + strokeWidth; 4112 color = mix_border_inside(strokeColor, color, d2); 4113 } 4114 } 4115 outputColor = color; 4116 4117 float innerShadowBlurRadius = innerShadow.z / 2.0; 4118 if (innerShadowBlurRadius > 0.0) { 4119 vec2 shadowOffset = -innerShadow.xy; 4120 float blurRadius = innerShadow.z; 4121 float distMul = -1.0; 4122 float lowerShadow = make_shadow(v_FragCoord + shadowOffset, v_Radius, cornerRadius, blurRadius, distMul, shape); 4123 4124 vec3 lowerShadowColor = innerShadowColor.rgb * innerShadowColor.a; 4125 outputColor = over(vec4(color.xyz, 1.0), vec4(lowerShadowColor, 1.0 - lowerShadow)); 4126 outputColor = over(outputColor, vec4(color.xyz, clamp(distance, 0.0, 1.0))); 4127 } 4128 4129 float antialiasedBlur = -fwidth(length(v_FragCoord)); 4130 float opacity_t = clamp(distance / antialiasedBlur, 0.0, 1.0); 4131 outputColor.a *= clamp(1.0 - distance, 0.0, 1.0) * opacity * opacity_t; 4132 4133 if (outputColor.a < epsilon) 4134 discard; 4135} 4136`;var ms=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Vm=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
4136return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Ym,vM,db,fb,LN,MA,BA,pb,UN;const H4t={center:0,inner:1,outer:2};let x7=class extends Tht{constructor(){super(...arguments),Ym.set(this,void 0),vM.set(this,void 0),db.set(this,void 0),fb.set(this,void 0),LN.set(this,void 0),MA.set(this,void 0),BA.set(this,void 0),pb.set(this,void 0),UN.set(this,void 0)}validate(t){if(!super.validate(t))return!1;if(this.shapes.length===0)return!0;const e=!TA(this.shapes[0].fill),r=!TA(t.fill);return e!==r?!1:e&&r?this.shapes[0].fill===t.fill:!0}createGeometry(){ms(this,vM,"f")||(Vm(this,vM,this.device.createBuffer({viewOrSize:new Float32Array([-1,-1,1,-1,1,1,-1,1]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),Vm(this,LN,this.device.createBuffer({viewOrSize:new Uint32Array([0,1,2,0,2,3]),usage:dt.INDEX,hint:Et.STATIC}),"f")),this.instanced&&(ms(this,db,"f")&&ms(this,db,"f").destroy(),Vm(this,db,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*28*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),ms(this,fb,"f")&&ms(this,fb,"f").destroy(),Vm(this,fb,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*6*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"))}createMaterial(t){let e="";this.instanced&&(e+=`#define USE_INSTANCES 4137`),ms(this,Ym,"f")&&(ms(this,Ym,"f").destroy(),ms(this,pb,"f").destroy(),ms(this,BA,"f").destroy());const r=this.device.queryVendorInfo().platformString==="WebGPU"?"diagnostic(off,derivative_uniformity);":"";Vm(this,Ym,this.renderCache.createProgram({vertex:{glsl:e+Y4t},fragment:{glsl:e+$4t,postprocess:n=>r+n}}),"f");const i=[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:0,offset:0,format:I.F32_RG}]}];this.instanced?(i.push({arrayStride:112,stepMode:ne.INSTANCE,attributes:[{shaderLocation:1,offset:0,format:I.F32_RGBA},{shaderLocation:2,offset:16,format:I.F32_RGBA},{shaderLocation:3,offset:32,format:I.F32_RGBA},{shaderLocation:4,offset:48,format:I.F32_RGBA},{shaderLocation:5,offset:64,format:I.F32_RGBA},{shaderLocation:6,offset:80,format:I.F32_RGBA},{shaderLocation:7,offset:96,format:I.F32_RGBA}]},{arrayStride:24,stepMode:ne.INSTANCE,attributes:[{shaderLocation:14,offset:0,format:I.F32_RGBA},{shaderLocation:15,offset:16,format:I.F32_RG}]}),Vm(this,pb,this.renderCache.createInputLayout({vertexBufferDescriptors:i,indexBufferFormat:I.U32_R,program:ms(this,Ym,"f")}),"f")):(Vm(this,pb,this.renderCache.createInputLayout({vertexBufferDescriptors:i,indexBufferFormat:I.U32_R,program:ms(this,Ym,"f")}),"f"),ms(this,MA,"f")||Vm(this,MA,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*40,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f")),Vm(this,BA,this.renderCache.createRenderPipeline({inputLayout:ms(this,pb,"f"),program:ms(this,Ym,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],blendConstant:kn,depthWrite:!0,depthCompare:qe.GREATER,stencilWrite:!1,stencilFront:{compare:qe.ALWAYS},stencilBack:{compare:qe.ALWAYS}}}),"f");const s={pipeline:ms(this,BA,"f"),uniformBufferBindings:[{buffer:t}]};this.instanced||s.uniformBufferBindings.push({buffer:ms(this,MA,"f")});const{fill:o}=this.shapes[0];if(!TA(o)&&_4t(o)){const n=this.device.createTexture({format:I.U8_RGBA_NORM,width:o.width,height:o.height,usage:xr.SAMPLED});n.setImageData([o]);const a=this.renderCache.createSampler({addressModeU:Zn.CLAMP_TO_EDGE,addressModeV:Zn.CLAMP_TO_EDGE,minFilter:io.POINT,magFilter:io.BILINEAR,mipmapFilter:xn.LINEAR,lodMinClamp:0,lodMaxClamp:0});s.samplerBindings=[{texture:n,sampler:a}]}Vm(this,UN,this.renderCache.createBindings(s),"f")}render(t){if(this.shapes.some(r=>r.renderDirtyFlag)||this.geometryDirty)if(this.instanced){ms(this,fb,"f").setSubData(0,new Uint8Array(new Float32Array(this.shapes.map(i=>[i.worldTransform.a,i.worldTransform.b,i.worldTransform.c,i.worldTransform.d,i.worldTransform.tx,i.worldTransform.ty]).flat()).buffer));const r=[];
4137this.shapes.forEach(i=>{r.push(...this.generateBuffer(i))}),ms(this,db,"f").setSubData(0,new Uint8Array(new Float32Array(r).buffer))}else{const{worldTransform:r}=this.shapes[0];ms(this,MA,"f").setSubData(0,new Uint8Array(new Float32Array([...cb(r.toArray(!0)),...this.generateBuffer(this.shapes[0])]).buffer))}const e=[{buffer:ms(this,vM,"f")}];this.instanced&&e.push({buffer:ms(this,db,"f")},{buffer:ms(this,fb,"f")}),t.setPipeline(ms(this,BA,"f")),t.setVertexInput(ms(this,pb,"f"),e,{buffer:ms(this,LN,"f")}),t.setBindings(ms(this,UN,"f")),t.drawIndexed(6,this.shapes.length)}destroy(){var t,e,r,i,s,o,n,a;ms(this,Ym,"f")&&(ms(this,Ym,"f").destroy(),(t=ms(this,fb,"f"))===null||t===void 0||t.destroy(),(e=ms(this,db,"f"))===null||e===void 0||e.destroy(),(r=ms(this,vM,"f"))===null||r===void 0||r.destroy(),(i=ms(this,LN,"f"))===null||i===void 0||i.destroy(),(s=ms(this,MA,"f"))===null||s===void 0||s.destroy(),(o=ms(this,BA,"f"))===null||o===void 0||o.destroy(),(n=ms(this,pb,"f"))===null||n===void 0||n.destroy(),(a=ms(this,UN,"f"))===null||a===void 0||a.destroy())}generateBuffer(t){const{fillRGB:e,strokeRGB:{r,g:i,b:s,opacity:o},strokeWidth:n,strokeAlignment:a,opacity:l,fillOpacity:c,strokeOpacity:h,innerShadowColorRGB:{r:u,g:d,b:f,opacity:g},innerShadowOffsetX:p,innerShadowOffsetY:m,innerShadowBlurRadius:v}=t;let b,y,_=0;if(t instanceof fM){const{cx:S,cy:T,r:R}=t;b=[S,T,R,R],y=0}else if(t instanceof pM){const{cx:S,cy:T,rx:R,ry:B}=t;b=[S,T,R,B],y=1}else if(t instanceof gM){const{x:S,y:T,width:R,height:B,cornerRadius:O}=t;b=[S+R/2,T+B/2,R/2,B/2],y=2,_=O}const{r:w,g:E,b:A,opacity:x}=e||{};return[...b,w/255,E/255,A/255,x,r/255,i/255,s/255,o,t.globalRenderOrder/Sht,n,_,H4t[a],l,c,h,y,u/255,d/255,f/255,g,p,m,v,e?0:1]}};Ym=new WeakMap,vM=new WeakMap,db=new WeakMap,fb=new WeakMap,LN=new WeakMap,MA=new WeakMap,BA=new WeakMap,pb=new WeakMap,UN=new WeakMap;const K4t=` 4138layout(std140) uniform SceneUniforms { 4139 mat3 u_ProjectionMatrix; 4140 mat3 u_ViewMatrix; 4141}; 4142 4143layout(location = 0) in vec2 a_FragCoord; 4144 4145#ifdef USE_INSTANCES 4146 layout(location = 14) in vec4 a_Abcd; 4147 layout(location = 15) in vec2 a_Txty; 4148 layout(location = 1) in vec4 a_PositionSize; 4149 layout(location = 4) in vec4 a_ZIndexStrokeWidth; 4150 layout(location = 5) in vec4 a_DropShadowColor; 4151 layout(location = 6) in vec4 a_DropShadow; 4152#else 4153 layout(std140) uniform ShapeUniforms { 4154 mat3 u_ModelMatrix; 4155 vec4 u_PositionSize; 4156 vec4 u_ZIndexStrokeWidth; 4157 vec4 u_DropShadowColor; 4158 vec4 u_DropShadow; 4159 }; 4160#endif 4161 4162out vec2 v_Origin; 4163#ifdef USE_INSTANCES 4164 out float v_CornerRadius; 4165 out vec4 v_DropShadowColor; 4166 out vec4 v_DropShadow; 4167#else 4168#endif 4169out vec2 v_Size; 4170out vec2 v_Point; 4171 4172void main() { 4173 mat3 model; 4174 vec2 origin; 4175 vec2 size; 4176 float zIndex; 4177 vec4 dropShadow; 4178 4179 #ifdef USE_INSTANCES 4180 model = mat3(a_Abcd.x, a_Abcd.y, 0, a_Abcd.z, a_Abcd.w, 0, a_Txty.x, a_Txty.y, 1); 4181 origin = a_PositionSize.xy; 4182 size = a_PositionSize.zw; 4183 zIndex = a_ZIndexStrokeWidth.x; 4184 dropShadow = a_DropShadow; 4185 v_CornerRadius = a_ZIndexStrokeWidth.z; 4186 v_DropShadowColor = a_DropShadowColor; 4187 v_DropShadow = dropShadow; 4188 #else 4189 model = u_ModelMatrix; 4190 origin = u_PositionSize.xy; 4191 size = u_PositionSize.zw; 4192 zIndex = u_ZIndexStrokeWidth.x; 4193 dropShadow = u_DropShadow; 4194 #endif 4195 4196 // Set the bounds of the shadow and adjust its size based on the shadow's 4197 // spread radius to achieve the spreading effect 4198 float margin = 3.0 * dropShadow.z; 4199 origin += dropShadow.xy; 4200 v_Origin = origin; 4201 v_Size = size; 4202 4203 origin -= margin; 4204 size += 2.0 * margin; 4205 vec2 center = origin + size / 2.0; 4206 v_Point = center + a_FragCoord * (size / 2.0); 4207 4208 gl_Position = vec4((u_ProjectionMatrix 4209 * u_ViewMatrix 4210 * model 4211 * vec3(v_Point, 1)).xy, zIndex, 1); 4212} 4213`,q4t=` 4214#ifdef USE_INSTANCES 4215#else 4216 layout(std140) uniform ShapeUniforms { 4217 mat3 u_ModelMatrix; 4218 vec4 u_PositionSize; 4219 vec4 u_ZIndexStrokeWidth; 4220 vec4 u_DropShadowColor; 4221 vec4 u_DropShadow; 4222 }; 4223#endif 4224 4225out vec4 outputColor; 4226 4227in vec2 v_Origin; 4228#ifdef USE_INSTANCES 4229 in float v_CornerRadius; 4230 in vec4 v_DropShadowColor; 4231 in vec4 v_DropShadow; 4232#else 4233#endif 4234in vec2 v_Size; 4235in vec2 v_Point; 4236 4237float epsilon = 0.000001; 4238float PI = 3.1415926; 4239 4240// A standard gaussian function, used for weighting samples 4241float gaussian(float x, float sigma) { 4242 return exp(-(x * x) / (2. * sigma * sigma)) / (sqrt(2. * PI) * sigma); 4243} 4244 4245// This approximates the error function, needed for the gaussian integral 4246vec2 erf(vec2 x) { 4247 vec2 s = sign(x), a = abs(x); 4248 x = 1.0 + (0.278393 + (0.230389 + 0.078108 * (a * a)) * a) * a; 4249 x *= x; 4250 return s - s / (x * x); 4251} 4252
4253// @see https://raphlinus.github.io/graphics/2020/04/21/blurred-rounded-rects.html 4254// vec2 erf7(vec2 x) { 4255// x = x * sqrt(2. * PI); 4256// vec2 xx = x * x; 4257// x = x + (0.24295 + (0.03395 + 0.0104 * xx) * xx) * (x * xx); 4258// return x / sqrt(1.0 + x * x); 4259// } 4260 4261float rect_shadow(vec2 pixel_position, vec2 origin, vec2 size, float sigma) { 4262 vec2 bottom_right = origin + size; 4263 vec2 x_distance = vec2(pixel_position.x - origin.x, pixel_position.x - bottom_right.x); 4264 vec2 y_distance = vec2(pixel_position.y - origin.y, pixel_position.y - bottom_right.y); 4265 vec2 integral_x = 0.5 + 0.5 * erf(x_distance * (sqrt(0.5) / sigma)); 4266 vec2 integral_y = 0.5 + 0.5 * erf(y_distance * (sqrt(0.5) / sigma)); 4267 return (integral_x.x - integral_x.y) * (integral_y.x - integral_y.y); 4268} 4269 4270float blur_along_x(float x, float y, float sigma, float corner, vec2 half_size) { 4271 float delta = min(half_size.y - corner - abs(y), 0.0); 4272 float curved = half_size.x - corner + sqrt(max(0., corner * corner - delta * delta)); 4273 vec2 integral = 0.5 + 0.5 * erf((x + vec2(-curved, curved)) * (sqrt(0.5) / sigma)); 4274 return integral.y - integral.x; 4275} 4276 4277void main() { 4278 float cornerRadius; 4279 vec4 dropShadow; 4280 vec4 dropShadowColor; 4281 4282 #ifdef USE_INSTANCES 4283 cornerRadius = v_CornerRadius; 4284 dropShadowColor = v_DropShadowColor; 4285 dropShadow = v_DropShadow; 4286 #else 4287 cornerRadius = u_ZIndexStrokeWidth.z; 4288 dropShadowColor = u_DropShadowColor; 4289 dropShadow = u_DropShadow; 4290 #endif 4291 4292 float blur_radius = dropShadow.z; 4293 if (blur_radius > 0.0) { 4294 float alpha = 0.; 4295 vec2 point = v_Point; 4296 4297 if (cornerRadius > 0.0) { 4298 vec2 half_size = v_Size / 2.0; 4299 vec2 center = v_Origin + half_size; 4300 vec2 center_to_point = point - center; 4301 4302 // The signal is only non-zero in a limited range, so don't waste samples 4303 float low = center_to_point.y - half_size.y; 4304 float high = center_to_point.y + half_size.y; 4305 float start = clamp(-3. * blur_radius, low, high); 4306 float end = clamp(3. * blur_radius, low, high); 4307 4308 // Accumulate samples (we can get away with surprisingly few samples) 4309 float step = (end - start) / 4.; 4310 float y = start + step * 0.5; 4311 4312 for (int i = 0; i < 4; i++) { 4313 alpha += blur_along_x(center_to_point.x, center_to_point.y - y, blur_radius, 4314 cornerRadius, half_size) * 4315 gaussian(y, blur_radius) * step; 4316 y += step; 4317 } 4318 } else { 4319 alpha = rect_shadow(point, v_Origin, v_Size, blur_radius); 4320 } 4321 4322 outputColor = dropShadowColor; 4323 outputColor.a = alpha; 4324 } else { 4325 discard; 4326 } 4327} 4328`;var ss=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},tg=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},$m,_M,gb,mb,GN,OA,yb,vb,bM;let Z4t=class extends Tht{constructor(){super(...arguments),$m.set(this,void 0),_M.set(this,void 0),gb.set(this,void 0),mb.set(this,void 0),GN.set(this,void 0),OA.set(this,void 0),yb.set(this,void 0),vb.set(this,void 0),bM.set(this,void 0)}createGeometry(){ss(this,_M,"f")||(tg(this,_M,this.device.createBuffer({viewOrSize:new Float32Array([-1,-1,1,-1,1,1,-1,1]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),tg(this,GN,this.device.createBuffer({viewOrSize:new Uint32Array([0,1,2,0,2,3]),usage:dt.INDEX,hint:Et.STATIC}),"f")),this.instanced&&(ss(this,gb,"f")&&ss(this,gb,"f").destroy(),tg(this,gb,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*16*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),ss(this,mb,"f")&&ss(this,mb,"f").destroy(),tg(this,mb,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*6*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"))}createMaterial(t){let e="";this.instanced&&(e+=`#define USE_INSTANCES 4329`),ss(this,$m,"f")&&(ss(this,$m,"f").destroy(),ss(this,vb,"f").destroy(),ss(this,yb,"f").destroy()),tg(this,$m,this.renderCache.createProgram({vertex:{glsl:e+K4t},fragment:{glsl:e+q4t}}),"f");
4329const r=[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:0,offset:0,format:I.F32_RG}]}];this.instanced?(r.push({arrayStride:64,stepMode:ne.INSTANCE,attributes:[{shaderLocation:1,offset:0,format:I.F32_RGBA},{shaderLocation:4,offset:16,format:I.F32_RGBA},{shaderLocation:5,offset:32,format:I.F32_RGBA},{shaderLocation:6,offset:48,format:I.F32_RGBA}]},{arrayStride:24,stepMode:ne.INSTANCE,attributes:[{shaderLocation:14,offset:0,format:I.F32_RGBA},{shaderLocation:15,offset:16,format:I.F32_RG}]}),tg(this,vb,this.renderCache.createInputLayout({vertexBufferDescriptors:r,indexBufferFormat:I.U32_R,program:ss(this,$m,"f")}),"f")):(tg(this,vb,this.renderCache.createInputLayout({vertexBufferDescriptors:r,indexBufferFormat:I.U32_R,program:ss(this,$m,"f")}),"f"),ss(this,OA,"f")||tg(this,OA,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*28,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f")),tg(this,yb,this.renderCache.createRenderPipeline({inputLayout:ss(this,vb,"f"),program:ss(this,$m,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],blendConstant:kn,depthWrite:!1,depthCompare:qe.GREATER,stencilWrite:!1,stencilFront:{compare:qe.ALWAYS},stencilBack:{compare:qe.ALWAYS}}}),"f"),this.instanced?tg(this,bM,this.renderCache.createBindings({pipeline:ss(this,yb,"f"),uniformBufferBindings:[{buffer:t}]}),"f"):tg(this,bM,this.device.createBindings({pipeline:ss(this,yb,"f"),uniformBufferBindings:[{buffer:t},{buffer:ss(this,OA,"f")}]}),"f")}render(t){if(this.shapes.some(r=>r.renderDirtyFlag)||this.geometryDirty)if(this.instanced){ss(this,mb,"f").setSubData(0,new Uint8Array(new Float32Array(this.shapes.map(i=>[i.worldTransform.a,i.worldTransform.b,i.worldTransform.c,i.worldTransform.d,i.worldTransform.tx,i.worldTransform.ty]).flat()).buffer));const r=[];this.shapes.forEach(i=>{r.push(...this.generateBuffer(i))}),ss(this,gb,"f").setSubData(0,new Uint8Array(new Float32Array(r).buffer))}else{const{worldTransform:r}=this.shapes[0];ss(this,OA,"f").setSubData(0,new Uint8Array(new Float32Array([...cb(r.toArray(!0)),...this.generateBuffer(this.shapes[0])]).buffer))}const e=[{buffer:ss(this,_M,"f")}];this.instanced&&e.push({buffer:ss(this,gb,"f")},{buffer:ss(this,mb,"f")}),t.setPipeline(ss(this,yb,"f")),t.setVertexInput(ss(this,vb,"f"),e,{buffer:ss(this,GN,"f")}),t.setBindings(ss(this,bM,"f")),t.drawIndexed(6,this.shapes.length)}destroy(){var t,e,r,i,s,o,n,a;ss(this,$m,"f")&&(ss(this,$m,"f").destroy(),(t=ss(this,mb,"f"))===null||t===void 0||t.destroy(),(e=ss(this,gb,"f"))===null||e===void 0||e.destroy(),(r=ss(this,_M,"f"))===null||r===void 0||r.destroy(),(i=ss(this,GN,"f"))===null||i===void 0||i.destroy(),(s=ss(this,OA,"f"))===null||s===void 0||s.destroy(),(o=ss(this,yb,"f"))===null||o===void 0||o.destroy(),(n=ss(this,vb,"f"))===null||n===void 0||n.destroy(),(a=ss(this,bM,"f"))===null||a===void 0||a.destroy())}generateBuffer(t){const{x:e,y:r,width:i,height:s,strokeWidth:o,cornerRadius:n,dropShadowColorRGB:{r:a,g:l,b:c,opacity:h},dropShadowOffsetX:u,dropShadowOffsetY:d,dropShadowBlurRadius:f}=t;return[e,r,i,s,t.globalRenderOrder/Sht,o,n,0,a/255,l/255,c/255,h,u,d,f,0]}};$m=new WeakMap,_M=new WeakMap,gb=new WeakMap,mb=new WeakMap,GN=new WeakMap,OA=new WeakMap,yb=new WeakMap,vb=new WeakMap,bM=new WeakMap;function Ds(t,e=0){return t+=e,t+=t<<10,t+=t>>>6,t>>>0}function Rht(t){return t+=t<<3,t^=t>>>11,t+=t<<15,t>>>0}function S7(){return 0}let J4t=class{constructor(){this.keys=[],this.values=[]}},WN=class{constructor(t,e){this.keyEqualFunc=t,this.keyHashFunc=e,this.buckets=new Map}findBucketIndex(t,e){for(let r=0;r<t.keys.length;r++)if(this.keyEqualFunc(e,t.keys[r]))return r;return-1}findBucket(t){const e=this.keyHashFunc(t);return this.buckets.get(e)}get(t){const e=this.findBucket(t);if(e===void 0)return null;const r=this.findBucketIndex(e,t);return r<0?null:e.values[r]}add(t,e){const r=this.keyHashFunc(t);this.buckets.get(r)===void 0&&this.buckets.set(r,new J4t);const i=this.buckets.get(r);i.keys.push(t),i.values.push(e)}delete(t){const e=this.findBucket(t);if(e===void 0)return;const r=this.findBucketIndex(e,t);r!==-1&&(e.keys.splice(r,1),e.values.splice(r,1))}clear(){this.buckets.clear()}size(){let t=0;for(const e of this.buckets.values())t+=e.values.length;return t}*values(){for(const t of this.buckets.values())for(let e=t.values.length-1;e>=0;e--)yield t.values[e]}};function Cht(t,e){return t=Ds(t,e.blendMode),t=Ds(t,e.blendSrcFactor),t=Ds(t,e.blendDstFactor),t}function Q4t(t,e){return t=Cht(t,e.rgbBlendState),t=Cht(t,e.alphaBlendState),t=Ds(t,e.channelWriteMask),t}function t5t(t,e){return t=Ds(t,e.r<<24|e.g<<16|e.b<<8|e.a),t}function e5t(t,e){var r,i,s,o,n,a,l,c;for(let h=0;h<e.attachmentsState.length;
4329h++)t=Q4t(t,e.attachmentsState[h]);return t=t5t(t,e.blendConstant||kn),t=Ds(t,e.depthCompare),t=Ds(t,e.depthWrite?1:0),t=Ds(t,(r=e.stencilFront)===null||r===void 0?void 0:r.compare),t=Ds(t,(i=e.stencilFront)===null||i===void 0?void 0:i.passOp),t=Ds(t,(s=e.stencilFront)===null||s===void 0?void 0:s.failOp),t=Ds(t,(o=e.stencilFront)===null||o===void 0?void 0:o.depthFailOp),t=Ds(t,(n=e.stencilBack)===null||n===void 0?void 0:n.compare),t=Ds(t,(a=e.stencilBack)===null||a===void 0?void 0:a.passOp),t=Ds(t,(l=e.stencilBack)===null||l===void 0?void 0:l.failOp),t=Ds(t,(c=e.stencilBack)===null||c===void 0?void 0:c.depthFailOp),t=Ds(t,e.stencilWrite?1:0),t=Ds(t,e.cullMode),t=Ds(t,e.frontFace?1:0),t=Ds(t,e.polygonOffset?1:0),t}function r5t(t){let e=0;e=Ds(e,t.program.id),t.inputLayout!==null&&(e=Ds(e,t.inputLayout.id)),e=e5t(e,t.megaStateDescriptor);for(let r=0;r<t.colorAttachmentFormats.length;r++)e=Ds(e,t.colorAttachmentFormats[r]||0);return e=Ds(e,t.depthStencilAttachmentFormat||0),Rht(e)}function i5t(t){let e=0;if(t.samplerBindings)for(let r=0;r<t.samplerBindings.length;r++){const i=t.samplerBindings[r];i!==null&&i.texture!==null&&(e=Ds(e,i.texture.id))}if(t.uniformBufferBindings)for(let r=0;r<t.uniformBufferBindings.length;r++){const i=t.uniformBufferBindings[r];i!==null&&i.buffer!==null&&(e=Ds(e,i.buffer.id),e=Ds(e,i.binding),e=Ds(e,i.offset),e=Ds(e,i.size))}if(t.storageBufferBindings)for(let r=0;r<t.storageBufferBindings.length;r++){const i=t.storageBufferBindings[r];i!==null&&i.buffer!==null&&(e=Ds(e,i.buffer.id),e=Ds(e,i.binding),e=Ds(e,i.offset),e=Ds(e,i.size))}if(t.storageTextureBindings)for(let r=0;r<t.storageTextureBindings.length;r++){const i=t.storageTextureBindings[r];i!==null&&i.texture!==null&&(e=Ds(e,i.texture.id),e=Ds(e,i.binding))}return Rht(e)}function s5t(t,e){var r,i,s,o;return((r=t.vertex)===null||r===void 0?void 0:r.glsl)===((i=e.vertex)===null||i===void 0?void 0:i.glsl)&&((s=t.fragment)===null||s===void 0?void 0:s.glsl)===((o=e.fragment)===null||o===void 0?void 0:o.glsl)}function o5t(t){var e,r;return{vertex:{glsl:(e=t.vertex)===null||e===void 0?void 0:e.glsl},fragment:{glsl:(r=t.fragment)===null||r===void 0?void 0:r.glsl}}}let n5t=class{constructor(t){this.device=t,this.bindingsCache=new WN(L4,i5t),this.renderPipelinesCache=new WN(G4,r5t),this.inputLayoutsCache=new WN(W4,S7),this.programCache=new WN(s5t,S7),this.samplerCache=new WN(j4,S7)}createBindings(t){let e=this.bindingsCache.get(t);if(e===null){const r=X4(t);e=this.device.createBindings(r),this.bindingsCache.add(r,e)}return e}createRenderPipeline(t){let e=this.renderPipelinesCache.get(t);if(e===null){const r=z4(t);r.colorAttachmentFormats=r.colorAttachmentFormats.filter(i=>i),e=this.device.createRenderPipeline(r),this.renderPipelinesCache.add(r,e)}return e}createInputLayout(t){t.vertexBufferDescriptors=t.vertexBufferDescriptors.filter(r=>!!r);let e=this.inputLayoutsCache.get(t);if(e===null){const r=V4(t);e=this.device.createInputLayout(r),this.inputLayoutsCache.add(r,e)}return e}createProgram(t){let e=this.programCache.get(t);if(e===null){const r=o5t(t);e=this.device.createProgram(t),this.programCache.add(r,e)}return e}createSampler(t){let e=this.samplerCache.get(t);return e===null&&(e=this.device.createSampler(t),this.samplerCache.add(t,e)),e}destroy(){for(const t of this.bindingsCache.values())t.destroy();for(const t of this.renderPipelinesCache.values())t.destroy();for(const t of this.inputLayoutsCache.values())t.destroy();for(const t of this.programCache.values())t.destroy();for(const t of this.samplerCache.values())t.destroy();this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()}};var Mht=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Rl=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},_b,IA,DA,W6,jN;const j6=new WeakMap;j6.set(fM,[x7]),j6.set(pM,[x7]),j6.set(gM,[Z4t,x7]);let a5t=class{constructor(t){this.device=t,_b.set(this,[]),IA.set(this,Object.create(null)),DA.set(this,Object.create(null)),W6.set(this,new WeakMap),jN.set(this,void 0),Mht(this,jN,new n5t(t),"f")}createDrawcalls(t,e=!1){var r;return(r=j6.get(t.constructor))===null||r===void 0?void 0:r.map(i=>{const s=new i(this.device,Rl(this,jN,"f"),e);return s.add(t),s})}getOrCreateNonBatchableDrawcalls(t){let e=Rl(this,IA,"f")[t.uid];return e||(e=this.createDrawcalls(t)||[],Rl(this,IA,"f")[t.uid]=e),e}getOrCreateBatchableDrawcalls(t){let e=Rl(this,DA,"f")[t.uid];if(!e){const r=t.constructor;let i=Rl(this,W6,"f").get(r);i||(i=[]),e=i.find(s=>s.every(o=>o.validate(t))),e||(e=this.createDrawcalls(t,!0)||[],i.push(e),Rl(this,W6,"f").set(r,i)),e.forEach(s=>{s.add(t)}),Rl(this,DA,"f")[t.uid]=e}return e}add(t){if(t.batchable){const e=this.getOrCreateBatchableDrawcalls(t);Rl(this,_b,"f").indexOf(e[0])===-1&&Rl(this,_b,"f").push(...e)}else Rl(this,_b,"f").push(...this.getOrCreateNonBatchableDrawcalls(t))}remove(t){t.batchable?(this.getOrCreateBatchableDrawcalls(t).forEach(e
4329=>{e.remove(t)}),delete Rl(this,DA,"f")[t.uid]):(this.getOrCreateNonBatchableDrawcalls(t).forEach(e=>{e.destroy()}),delete Rl(this,IA,"f")[t.uid])}destroy(){for(const t in Rl(this,IA,"f"))Rl(this,IA,"f")[t].forEach(e=>{e.destroy()});for(const t in Rl(this,DA,"f"))Rl(this,DA,"f")[t].forEach(e=>{e.destroy()});Rl(this,jN,"f").destroy()}clear(){Mht(this,_b,[],"f")}flush(t,e){Rl(this,_b,"f").forEach(r=>{r.submit(t,e)})}stats(){return{drawcallCount:Rl(this,_b,"f").length}}};_b=new WeakMap,IA=new WeakMap,DA=new WeakMap,W6=new WeakMap,jN=new WeakMap;var Bht=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Ka=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},_r=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},PA,qa,bb,FA,NA,kA,wM,XN,wb,zN,LA,EM,X6,AM,VN;(function(t){t[t.NONE=0]="NONE",t[t.GRID=1]="GRID",t[t.DOTS=2]="DOTS"})(VN||(VN={}));let l5t=class{constructor(){PA.set(this,void 0),qa.set(this,void 0),bb.set(this,void 0),FA.set(this,void 0),NA.set(this,void 0),kA.set(this,void 0),wM.set(this,VN.GRID),XN.set(this,void 0),wb.set(this,void 0),zN.set(this,1),LA.set(this,void 0),EM.set(this,void 0),X6.set(this,void 0),AM.set(this,void 0)}apply(t){const{hooks:e,canvas:r,renderer:i,shaderCompilerPath:s,devicePixelRatio:o,camera:n}=t;e.initAsync.tapPromise(()=>Bht(this,void 0,void 0,function*(){let a;i==="webgl"?a=new hd({targets:["webgl2","webgl1"],antialias:!0,shaderDebug:!0,trackResources:!0,onContextCreationError:()=>{},onContextLost:()=>{},onContextRestored(u){}}):a=new ud({shaderCompilerPath:s,onContextLost:()=>{}});const{width:l,height:c}=r,h=yield a.createSwapChain(r);h.configureSwapChain(l,c),Ka(this,PA,h,"f"),Ka(this,qa,h.getDevice(),"f"),Ka(this,wb,new a5t(_r(this,qa,"f")),"f"),Ka(this,bb,_r(this,qa,"f").createRenderTargetFromTexture(_r(this,qa,"f").createTexture({format:I.U8_RGBA_RT,width:l,height:c,usage:xr.RENDER_TARGET})),"f"),Ka(this,FA,_r(this,qa,"f").createRenderTargetFromTexture(_r(this,qa,"f").createTexture({format:I.D24_S8,width:l,height:c,usage:xr.RENDER_TARGET})),"f"),Ka(this,kA,_r(this,qa,"f").createBuffer({viewOrSize:new Float32Array([...cb(n.projectionMatrix),...cb(n.viewMatrix),...cb(n.viewProjectionMatrixInv),n.zoom,_r(this,wM,"f"),0,0]),usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),Ka(this,XN,new vht,"f")})),e.resize.tap((a,l)=>{_r(this,PA,"f").configureSwapChain(a*o,l*o),_r(this,bb,"f")&&(_r(this,bb,"f").destroy(),Ka(this,bb,_r(this,qa,"f").createRenderTargetFromTexture(_r(this,qa,"f").createTexture({format:I.U8_RGBA_RT,width:a*o,height:l*o,usage:xr.RENDER_TARGET})),"f"),_r(this,FA,"f").destroy(),Ka(this,FA,_r(this,qa,"f").createRenderTargetFromTexture(_r(this,qa,"f").createTexture({format:I.D24_S8,width:a*o,height:l*o,usage:xr.RENDER_TARGET})),"f"))}),e.destroy.tap(()=>{_r(this,wb,"f").destroy(),_r(this,kA,"f").destroy(),_r(this,XN,"f").destroy(),_r(this,bb,"f").destroy(),_r(this,FA,"f").destroy(),_r(this,qa,"f").destroy(),_r(this,qa,"f").checkForLeaks()}),e.beginFrame.tap(()=>{const{width:a,height:l}=_r(this,PA,"f").getCanvas(),c=_r(this,PA,"f").getOnscreenTexture();_r(this,kA,"f").setSubData(0,new Uint8Array(new Float32Array([...cb(n.projectionMatrix),...cb(n.viewMatrix),...cb(n.viewProjectionMatrixInv),n.zoom,_r(this,wM,"f"),0,0]).buffer)),_r(this,qa,"f").beginFrame(),Ka(this,NA,_r(this,qa,"f").createRenderPass({colorAttachment:[_r(this,bb,"f")],colorResolveTo:[c],colorClearColor:[op],depthStencilAttachment:_r(this,FA,"f"),depthClearValue:1}),"f"),_r(this,NA,"f").setViewport(0,0,a,l),(!_r(this,LA,"f")||_r(this,LA,"f")&&_r(this,EM,"f").grid)&&_r(this,XN,"f").render(_r(this,qa,"f"),_r(this,NA,"f"),_r(this,kA,"f")),_r(this,wb,"f").clear(),Ka(this,zN,1,"f")}),e.endFrame.tap(({all:a,removed:l})=>
4329{if([...a.filter(c=>c.culled),...l].forEach(c=>{c.renderable&&_r(this,wb,"f").remove(c)}),_r(this,wb,"f").flush(_r(this,NA,"f"),_r(this,kA,"f")),_r(this,qa,"f").submitPass(_r(this,NA,"f")),_r(this,qa,"f").endFrame(),_r(this,LA,"f")&&_r(this,AM,"f")){const{type:c,encoderOptions:h}=_r(this,EM,"f"),u=_r(this,PA,"f").getCanvas().toDataURL(c,h);_r(this,AM,"f").call(this,u),Ka(this,LA,!1,"f"),Ka(this,EM,void 0,"f"),Ka(this,AM,void 0,"f")}}),e.render.tap(a=>{var l,c;a.globalRenderOrder=(Ka(this,zN,(c=_r(this,zN,"f"),l=c++,c),"f"),l),_r(this,wb,"f").add(a)})}get checkboardStyle(){return _r(this,wM,"f")}set checkboardStyle(t){Ka(this,wM,t,"f")}toDataURL(t){return Bht(this,void 0,void 0,function*(){return Ka(this,LA,!0,"f"),Ka(this,EM,t,"f"),Ka(this,X6,new Promise(e=>{Ka(this,AM,r=>{e(r)},"f")}),"f"),_r(this,X6,"f")})}};PA=new WeakMap,qa=new WeakMap,bb=new WeakMap,FA=new WeakMap,NA=new WeakMap,kA=new WeakMap,wM=new WeakMap,XN=new WeakMap,wb=new WeakMap,zN=new WeakMap,LA=new WeakMap,EM=new WeakMap,X6=new WeakMap,AM=new WeakMap;var eg=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},UA=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},YN,GA,Eb,xM;const c5t=.02,h5t=4,u5t=100,$N=[.02,.05,.1,.15,.2,.33,.5,.75,1,1.25,1.5,2,2.5,3,4],d5t=t=>$N.find(e=>e>t)||$N[$N.length-1],f5t=t=>[...$N].reverse().find(e=>e<t)||$N[0];let p5t=class{constructor(){YN.set(this,void 0),GA.set(this,{}),Eb.set(this,void 0),xM.set(this,!1)}apply(t){const{canvas:e,camera:r,root:i,api:{client2Viewport:s}}=t;i.draggable=!0;const o=Bt();let n,a,l;const c=it();let h,u=!1;function d(y){const _=e.getBoundingClientRect(),w=y.nativeEvent.clientX-_.left,E=y.nativeEvent.clientY-_.top,A=w/e.clientWidth,x=E/e.clientHeight,S=A*2-1,T=x*-2+1;return[S,T]}function f(y){const _=Qt(it(),d(y),o);r.x=n+c[0]-_[0],r.y=a+c[1]-_[1]}function g(y){const _=(y.nativeEvent.clientX-h[0])/100,w=Bt();bi(w,w,[c[0],c[1]]),Mo(w,w,_),bi(w,w,[-c[0],-c[1]]),r.x=n,r.y=a,r.rotation=l,us(w,w,r.matrix),r.rotation=l+_,r.x=w[6],r.y=w[7]}i.addEventListener("dragstart",y=>{eg(this,Eb,"f")||(u=y.shiftKey,fp(o,r.viewProjectionMatrixInv),n=r.x,a=r.y,l=r.rotation,Qt(c,d(y),o),h=[y.nativeEvent.clientX,y.nativeEvent.clientY])}),i.addEventListener("drag",y=>{eg(this,Eb,"f")||(u?g(y):f(y))}),i.addEventListener("dragend",y=>{eg(this,Eb,"f")||(u=!1)});const p=(y,_)=>{const w=Math.max(c5t,Math.min(h5t,r.zoom*Math.pow(2,_*-.01))),E=s(y);r.gotoLandmark(r.createLandmark({viewportX:E.x,viewportY:E.y,zoom:w}),{duration:0})};i.addEventListener("wheel",y=>{y.preventDefault(),p({x:y.nativeEvent.clientX,y:y.nativeEvent.clientY},y.deltaY)});const m=y=>{y.pointerType==="mouse"?UA(this,YN,!0,"f"):eg(this,GA,"f")[y.pointerId]||(eg(this,GA,"f")[y.pointerId]={last:null}),this.touchCount>=2?UA(this,Eb,!0,"f"):UA(this,Eb,!1,"f")},v=y=>{if(y.pointerType==="mouse"&&UA(this,YN,!1,"f"),y.pointerType!=="mouse"&&delete eg(this,GA,"f")[y.pointerId],eg(this,xM,"f")&&this.touchCount<=1)return UA(this,xM,!1,"f"),UA(this,Eb,!1,"f"),!0},b=y=>{if(this.touchCount>=2){const _=y.global.x,w=y.global.y,E=eg(this,GA,"f"),A=Object.keys(E),x=Number(A[0]),S=Number(A[1]),T=E[x],R=E[S],B=T.last&&R.last?Math.sqrt(Math.pow(R.last.x-T.last.x,2)+Math.pow(R.last.y-T.last.y,2)):null;if(x===y.pointerId?T.last={x:_,y:w}:S===y.pointerId&&(R.last={x:_,y:w}),B){const O=new ye(T.last.x+(R.last.x-T.last.x)/2,T.last.y+(R.last.y-T.last.y)/2),C=Math.sqrt(Math.pow(R.last.x-T.last.x,2)+Math.pow(R.last.y-T.last.y,2));p(O,(B/C-1)*u5t)}else eg(this,xM,"f")||UA(this,xM,!0,"f")}};i.addEventListener("pointerdown",m),i.addEventListener("pointermove",b),i.addEventListener("pointerup",v),i.addEventListener("pointerupoutside",v),i.addEventListener("pointercancel",v)}get touchCount(){return(eg(this,YN,"f")?1:0)+Object.keys(eg(this,GA,"f")).length}};
4329YN=new WeakMap,GA=new WeakMap,Eb=new WeakMap,xM=new WeakMap;let g5t=class{apply(t){const{canvas:e,hooks:r,globalThis:i,supportsPointerEvents:s,supportsTouchEvents:o}=t,n=y=>{y.preventDefault(),r.pointerMove.call(y)},a=y=>{r.pointerUp.call(y)},l=y=>{r.pointerDown.call(y)},c=y=>{r.pointerOver.call(y)},h=y=>{r.pointerOut.call(y)},u=y=>{r.pointerCancel.call(y)},d=y=>{r.pointerWheel.call(y)},f=y=>{i.document.addEventListener("pointermove",n,!0),y.addEventListener("pointerdown",l,!0),y.addEventListener("pointerleave",h,!0),y.addEventListener("pointerover",c,!0),i.addEventListener("pointerup",a,!0),i.addEventListener("pointercancel",u,!0)},g=y=>{y.addEventListener("touchstart",l,!0),y.addEventListener("touchend",a,!0),y.addEventListener("touchmove",n,!0),y.addEventListener("touchcancel",u,!0)},p=y=>{i.document.addEventListener("mousemove",n,!0),y.addEventListener("mousedown",l,!0),y.addEventListener("mouseout",h,!0),y.addEventListener("mouseover",c,!0),i.addEventListener("mouseup",a,!0)},m=y=>{i.document.removeEventListener("pointermove",n,!0),y.removeEventListener("pointerdown",l,!0),y.removeEventListener("pointerleave",h,!0),y.removeEventListener("pointerover",c,!0),i.removeEventListener("pointerup",a,!0)},v=y=>{y.removeEventListener("touchstart",l,!0),y.removeEventListener("touchend",a,!0),y.removeEventListener("touchmove",n,!0),y.removeEventListener("touchcancel",u,!0)},b=y=>{i.document.removeEventListener("mousemove",n,!0),y.removeEventListener("mousedown",l,!0),y.removeEventListener("mouseout",h,!0),y.removeEventListener("mouseover",c,!0),i.removeEventListener("mouseup",a,!0)};r.init.tap(()=>{s?f(e):(p(e),o&&g(e)),e.addEventListener("wheel",d,{capture:!0})}),r.destroy.tap(()=>{s?m(e):(b(e),o&&v(e)),e.removeEventListener("wheel",d,!0)})}};var Oht=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Cl=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},T7,HN,R7,rg,P0;const m5t=1,y5t={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};let v5t=class{constructor(){T7.set(this,!0),HN.set(this,new Zp(null)),R7.set(this,new v7(null)),rg.set(this,void 0),P0.set(this,void 0),this.onPointerMove=t=>{const e=this.normalizeToPointerEvent(t);for(const r of e){const i=this.bootstrapEvent(Cl(this,HN,"f"),r);Cl(this,rg,"f").mapEvent(i)}this.setCursor(Cl(this,rg,"f").cursor)}}apply(t){const{hooks:e,root:r}=t;Oht(this,P0,t,"f"),Oht(this,rg,new C4t(r),"f"),Cl(this,rg,"f").setPickHandler((i,s)=>{const{picked:o}=e.pickSync.call({position:{x:i,y:s},picked:[],topmost:!0});return o[0]||null}),e.pointerWheel.tap(i=>{const s=this.normalizeWheelEvent(i);Cl(this,rg,"f").mapEvent(s)}),e.pointerDown.tap(i=>{const s=this.normalizeToPointerEvent(i);Cl(this,T7,"f")&&s[0].isNormalized&&(i.cancelable||!("cancelable"in i))&&i.preventDefault();for(let o=0,n=s.length;o<n;o++){const a=s[o],l=this.bootstrapEvent(Cl(this,HN,"f"),a);Cl(this,rg,"f").mapEvent(l)}this.setCursor(Cl(this,rg,"f").cursor)}),e.pointerUp.tap(i=>{let s=i.target;i.composedPath&&i.composedPath().length>0&&(s=i.composedPath()[0]);const o=s!==Cl(this,P0,"f").canvas?"outside":"",n=this.normalizeToPointerEvent(i);for(let a=0,l=n.length;a<l;a++){const c=this.bootstrapEvent(Cl(this,HN,"f"),n[a]);c.type+=o,Cl(this,rg,"f").mapEvent(c)}this.setCursor(Cl(this,rg,"f").cursor)}),e.pointerMove.tap(this.onPointerMove),e.pointerOver.tap(this.onPointerMove),e.pointerOut.tap(this.onPointerMove),e.pointerCancel.tap(this.onPointerMove)}normalizeWheelEvent(t){const e=Cl(this,R7,"f");this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode;const{x:r,y:i}=this.getViewportXY(t);e.client.x=r,e.client.y=i;const{x:s,y:o}=Cl(this,P0,"f").api.viewport2Canvas(e.client);return e.screen.x=s,e.screen.y=o,e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null}
4329setCursor(t){Cl(this,P0,"f").canvas.style.cursor=t}normalizeToPointerEvent(t){const{supportsTouchEvents:e,supportsPointerEvents:r}=Cl(this,P0,"f"),i=[];if(e&&t instanceof TouchEvent)for(let s=0;s<t.changedTouches.length;s++){const o=t.changedTouches[s];ca(o.button)&&(o.button=0),ca(o.buttons)&&(o.buttons=1),ca(o.isPrimary)&&(o.isPrimary=t.touches.length===1&&t.type==="touchstart"),ca(o.width)&&(o.width=o.radiusX||1),ca(o.height)&&(o.height=o.radiusY||1),ca(o.tiltX)&&(o.tiltX=0),ca(o.tiltY)&&(o.tiltY=0),ca(o.pointerType)&&(o.pointerType="touch"),ca(o.pointerId)&&(o.pointerId=o.identifier||0),ca(o.pressure)&&(o.pressure=o.force||.5),ca(o.twist)&&(o.twist=0),ca(o.tangentialPressure)&&(o.tangentialPressure=0),o.isNormalized=!0,o.type=t.type,i.push(o)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!r||!(t instanceof globalThis.PointerEvent))){const s=t;ca(s.isPrimary)&&(s.isPrimary=!0),ca(s.width)&&(s.width=1),ca(s.height)&&(s.height=1),ca(s.tiltX)&&(s.tiltX=0),ca(s.tiltY)&&(s.tiltY=0),ca(s.pointerType)&&(s.pointerType="mouse"),ca(s.pointerId)&&(s.pointerId=m5t),ca(s.pressure)&&(s.pressure=.5),ca(s.twist)&&(s.twist=0),ca(s.tangentialPressure)&&(s.tangentialPressure=0),s.isNormalized=!0,i.push(s)}else i.push(t);return i}bootstrapEvent(t,e){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);const{x:r,y:i}=this.getViewportXY(e);t.client.x=r,t.client.y=i;const{x:s,y:o}=Cl(this,P0,"f").api.viewport2Canvas(t.client);return t.screen.x=s,t.screen.y=o,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=y5t[t.type]||t.type),t}getViewportXY(t){let e,r;const{offsetX:i,offsetY:s,clientX:o,clientY:n}=t;if(!uht(i)&&!uht(s))e=i,r=s;else{const a=Cl(this,P0,"f").api.client2Viewport({x:o,y:n});e=a.x,r=a.y}return{x:e,y:r}}};T7=new WeakMap,HN=new WeakMap,R7=new WeakMap,rg=new WeakMap,P0=new WeakMap;const Iht=new ye;let _5t=class{apply(t){const{hooks:e,root:r,api:{elementsFromBBox:i}}=t;e.pickSync.tap(s=>{const{position:{x:o,y:n}}=s,a=[r];return i(o,n,o,n).forEach(l=>{this.hitTest(l,o,n)&&a.unshift(l)}),s.picked=a,s})}hitTest(t,e,r){if(t.hitArea||t.renderable){t.worldTransform.applyInverse({x:e,y:r},Iht);const{x:i,y:s}=Iht;return t.hitArea?t.hitArea.contains(i,s):t.containsPoint(i,s)}return!1}};var b5t=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Dht=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},KN;function Pht(t,e){do{if(t&&e(t))return t;t=t.parent}while(t!==void 0);return null}let w5t=class{constructor(t={}){KN.set(this,void 0),b5t(this,KN,Object.assign({overlap:"pointer",dragstartTimeThreshold:0,dragstartDistanceThreshold:0},t),"f")}apply(t){const{root:e,hooks:r,api:{elementsFromPoint:i}}=t,s=o=>{const n=o.target,a=Pht(n,l=>l.draggable===!0);if(a){let l=!1;const c=o.timeStamp,h=[o.clientX,o.clientY];let u=null,d=[o.clientX,o.clientY];const f=p=>{if(!l){const y=p.timeStamp-c,_=lht(p.clientX,p.clientY,...h);if(y<=Dht(this,KN,"f").dragstartTimeThreshold||_<=Dht(this,KN,"f").dragstartDistanceThreshold)return;p.type="dragstart",a.dispatchEvent(p),l=!0}p.type="drag",p.dx=p.clientX-d[0],p.dy=p.clientY-d[1],a.dispatchEvent(p),d=[p.clientX,p.clientY];const m=[p.globalX,p.globalY],v=i(m[0],m[1]),b=v[v.indexOf(n)+1];if(b){const y=Pht(b,_=>_.droppable===!0);u!==y&&(u&&(p.type="dragleave",p.target=u,u.dispatchEvent(p)),y&&(p.type="dragenter",p.target=y,y.dispatchEvent(p)),u=y,u&&(p.type="dragover",p.target=u,u.dispatchEvent(p)))}};e.addEventListener("pointermove",f);const g=function(p){if(l){p.detail={preventClick:!0};const m=p;u&&(m.type="drop",m.target=u,u.dispatchEvent(m)),m.type="dragend",a.dispatchEvent(m),l=!1}e.removeEventListener("pointermove",f)};n.addEventListener("pointerup",g,{once:!0}),n.addEventListener("pointerupoutside",g,{once:!0})}};r.init.tap(()=>{e.addEventListener("pointerdown",s)}),r.destroy.tap(()=>{e.removeEventListener("pointerdown",s)})}};KN=new WeakMap;var E5t=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
4329return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},SM=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},z6,WA;let A5t=class{constructor(){z6.set(this,void 0),WA.set(this,new Xm)}apply(t){const{hooks:e,rBushRoot:r}=t;E5t(this,z6,t,"f"),e.cameraChange.tap(this.updateViewport.bind(this)),this.updateViewport(),e.beginFrame.tap(({all:i,removed:s,modified:o})=>{const{minX:n,minY:a,maxX:l,maxY:c}=SM(this,WA,"f");[...s,...o].forEach(d=>{d.renderable&&r.remove({shape:d,minX:0,minY:0,maxX:0,maxY:0},(f,g)=>f.shape===g.shape)});const h=[];o.forEach(d=>{if(d.renderable){const f=d.getBounds();h.push({minX:f.minX,minY:f.minY,maxX:f.maxX,maxY:f.maxY,shape:d})}}),r.load(h);const u=r.search({minX:n,minY:a,maxX:l,maxY:c}).map(d=>d.shape);i.forEach(d=>{d.renderable&&d.cullable&&(d.culled=!u.includes(d))})})}updateViewport(){const{camera:t,api:{viewport2Canvas:e}}=SM(this,z6,"f"),{width:r,height:i}=t,s=e({x:0,y:0}),o=e({x:r,y:0}),n=e({x:r,y:i}),a=e({x:0,y:i});SM(this,WA,"f").minX=Math.min(s.x,o.x,n.x,a.x),SM(this,WA,"f").minY=Math.min(s.y,o.y,n.y,a.y),SM(this,WA,"f").maxX=Math.max(s.x,o.x,n.x,a.x),SM(this,WA,"f").maxY=Math.max(s.y,o.y,n.y,a.y)}};z6=new WeakMap,WA=new WeakMap;var Fht=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Ts=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},F0=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},V6,Sc,jA,Y6,Ab,qN,TM,$6,XA;let Nht=class{get pluginContext(){return Ts(this,Sc,"f")}get root(){return Ts(this,Ab,"f")}get camera(){return Ts(this,qN,"f")}constructor(t){V6.set(this,void 0),Sc.set(this,void 0),jA.set(this,void 0),Y6.set(this,void 0),Ab.set(this,new U6),qN.set(this,void 0),TM.set(this,!0),$6.set(this,new Set),XA.set(this,new Set);const{canvas:e,renderer:r="webgl",shaderCompilerPath:i="",devicePixelRatio:s}=t,o=v4t(),n=s??o.devicePixelRatio,a=!!o.PointerEvent,l="ontouchstart"in o,{width:c,height:h}
4329=e,u=new xht(c/n,h/n);u.onchange=()=>{Ts(this,Sc,"f").hooks.cameraChange.call(),F0(this,TM,!0,"f")},F0(this,qN,u,"f"),F0(this,Sc,{globalThis:o,canvas:e,renderer:r,shaderCompilerPath:i,devicePixelRatio:n,supportsPointerEvents:a,supportsTouchEvents:l,hooks:{init:new Bu,initAsync:new m4t,beginFrame:new Bu,render:new Bu,endFrame:new Bu,destroy:new Bu,resize:new Bu,pointerDown:new Bu,pointerUp:new Bu,pointerMove:new Bu,pointerOut:new Bu,pointerOver:new Bu,pointerWheel:new Bu,pointerCancel:new Bu,pickSync:new y4t,cameraChange:new Bu},camera:u,root:Ts(this,Ab,"f"),rBushRoot:new TE,api:{elementsFromPoint:this.elementsFromPoint.bind(this),elementFromPoint:this.elementFromPoint.bind(this),elementsFromBBox:this.elementsFromBBox.bind(this),client2Viewport:this.client2Viewport.bind(this),viewport2Canvas:u.viewport2Canvas.bind(u),viewport2Client:this.viewport2Client.bind(this),canvas2Viewport:u.canvas2Viewport.bind(u)}},"f"),F0(this,jA,new l5t,"f"),F0(this,Y6,new v5t,"f");const d=[new g5t,Ts(this,Y6,"f"),new _5t,new p5t,new A5t,Ts(this,jA,"f"),new w5t({dragstartTimeThreshold:100,dragstartDistanceThreshold:10})];F0(this,V6,Fht(this,void 0,void 0,function*(){const{hooks:f}=Ts(this,Sc,"f");return d.forEach(g=>{g.apply(Ts(this,Sc,"f"))}),f.init.call(),yield f.initAsync.promise(),this}),"f")}get initialized(){return Ts(this,V6,"f").then(()=>this)}render(){const{hooks:t}=Ts(this,Sc,"f");Ts(this,XA,"f").clear();const e=[];if(g7(Ts(this,Ab,"f"),r=>{Ts(this,XA,"f").add(r),r.transformDirtyFlag&&(r.renderDirtyFlag=!0),r.renderable&&r.renderDirtyFlag&&(e.push(r),F0(this,TM,!0,"f")),r.transform.updateTransform(r.parent?r.parent.transform:ght)}),Ts(this,TM,"f")){const r=Array.from(Ts(this,XA,"f")),i=[...Ts(this,$6,"f")].filter(s=>!Ts(this,XA,"f").has(s));t.beginFrame.call({all:r,modified:e,removed:i}),g7(Ts(this,Ab,"f"),s=>{if(s.culled||!s.visible)return!0;s.renderable&&t.render.call(s)}),t.endFrame.call({all:r,modified:e,removed:i}),[...r,...i].forEach(s=>{s.renderDirtyFlag=!1}),F0(this,$6,new Set(Ts(this,XA,"f")),"f"),F0(this,TM,!1,"f")}}resize(t,e){const{hooks:r}=Ts(this,Sc,"f");Ts(this,qN,"f").projection(t,e),r.resize.call(t,e)}destroy(){const{hooks:t}=Ts(this,Sc,"f");t.destroy.call()}getDOM(){return Ts(this,Sc,"f").canvas}getDPR(){return Ts(this,Sc,"f").devicePixelRatio}toDataURL(){return Fht(this,arguments,void 0,function*(t={}){return Ts(this,jA,"f").toDataURL(t)})}appendChild(t){Ts(this,Ab,"f").appendChild(t)}removeChild(t){return Ts(this,Ab,"f").removeChild(t)}set checkboardStyle(t){Ts(this,jA,"f").checkboardStyle=t}get checkboardStyle(){return Ts(this,jA,"f").checkboardStyle}elementsFromBBox(t,e,r,i){const{rBushRoot:s}=Ts(this,Sc,"f"),o=s.search({minX:t,minY:e,maxX:r,maxY:i}),n=[];return o.forEach(({shape:a})=>{const{pointerEvents:l="auto"}=a,c=["auto","visiblepainted","visiblefill","visiblestroke","visible"].includes(l);(!c||c&&a.visible)&&!a.culled&&a.pointerEvents!=="none"&&n.push(a)}),n.sort((a,l)=>a.globalRenderOrder-l.globalRenderOrder),n}elementsFromPoint(t,e){const{picked:r}=Ts(this,Sc,"f").hooks.pickSync.call({topmost:!1,position:{x:t,y:e},picked:[]});return r}elementFromPoint(t,e){const{picked:r}=Ts(this,Sc,"f").hooks.pickSync.call({topmost:!0,position:{x:t,y:e},picked:[]});return r[0]}client2Viewport({x:t,y:e}){const{left:r,top:i}=Ts(this,Sc,"f").canvas.getBoundingClientRect();return{x:t-r,y:e-i}}viewport2Client({x:t,y:e}){const{left:r,top:i}=Ts(this,Sc,"f").canvas.getBoundingClientRect();return{x:t+r,y:e+i}}zoomIn(){const{camera:t}=this;t.cancelLandmarkAnimation();const e=t.createLandmark({viewportX:t.width/2,viewportY:t.height/2,zoom:d5t(t.zoom)});t.gotoLandmark(e,{duration:300,easing:"ease"})}zoomOut(){const{camera:t}=this;t.cancelLandmarkAnimation();const e=t.createLandmark({viewportX:t.width/2,viewportY:t.height/2,zoom:f5t(t.zoom)});t.gotoLandmark(e,{duration:300,easing:"ease"})}};V6=new WeakMap,Sc=new WeakMap,jA=new WeakMap,Y6=new WeakMap,Ab=new WeakMap,qN=new WeakMap,TM=new WeakMap,$6=new WeakMap,XA=new WeakMap;const C7=Symbol("canvas");var H6=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
4329a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},kht=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Af=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Lht=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},M7,xf,ZN;function x5t(){return kht(this,void 0,void 0,function*(){if("gpu"in navigator){if(!(yield navigator.gpu.requestAdapter()))throw new Error("No WebGPU adapter available.")}else throw new Error("WebGPU is not supported by the browser.")})}let zA=class extends Wa{constructor(){super(...arguments),this.renderer="webgl",this.shaderCompilerPath="https://unpkg.com/@antv/[email protected]/dist/pkg/glsl_wgsl_compiler_bg.wasm",this.zoom=100,M7.set(this,new eE(this,{context:C7})),xf.set(this,void 0),ZN.set(this,void 0),this.initCanvas=new rE(this,{task:t=>kht(this,[t],void 0,function*([e,r]){e==="webgpu"&&(yield x5t());const i=document.createElement("canvas");Lht(this,xf,yield new Nht({canvas:i,renderer:e,shaderCompilerPath:r}).initialized,"f"),Af(this,M7,"f").setValue(Af(this,xf,"f")),Af(this,xf,"f").pluginContext.hooks.cameraChange.tap(()=>{this.zoom=Math.round(Af(this,xf,"f").camera.zoom*100)}),this.dispatchEvent(new CustomEvent("ic-ready",{detail:Af(this,xf,"f")}));const s=o=>{this.dispatchEvent(new CustomEvent("ic-frame",{detail:o})),Af(this,xf,"f").render(),Lht(this,ZN,window.requestAnimationFrame(s),"f")};return s(),Af(this,xf,"f").getDOM()}),args:()=>[this.renderer,this.shaderCompilerPath]})}connectedCallback(){super.connectedCallback(),this.addEventListener("sl-resize",this.resize)}disconnectedCallback(){var t;this.removeEventListener("sl-resize",this.resize),Af(this,ZN,"f")&&window.cancelAnimationFrame(Af(this,ZN,"f")),(t=Af(this,xf,"f"))===null||t===void 0||t.destroy(),super.disconnectedCallback()}resize(t){var e;const r=t.detail,{width:i,height:s}=r.entries[0].contentRect,o=window.devicePixelRatio;if(i&&s){const n=Af(this,xf,"f").getDOM();n.width=i*o,n.height=s*o,(e=Af(this,xf,"f"))===null||e===void 0||e.resize(i,s)}}render(){return this.initCanvas.render({pending:()=>Ao`<sl-spinner></sl-spinner>`,complete:t=>Ao` 4330 <sl-resize-observer> 4331 ${t} 4332 <ic-zoom-toolbar-lesson10 4333 zoom=${this.zoom} 4334 ></ic-zoom-toolbar-lesson10> 4335 <ic-exporter-lesson10></ic-exporter-lesson10> 4336 </sl-resize-observer> 4337 `,error:t=>Ao`<sl-alert variant="danger" open> 4338 <sl-icon slot="icon" name="exclamation-octagon"></sl-icon> 4339 <strong>Initialize canvas failed</strong><br /> 4340 ${t.message} 4341 </sl-alert>`})}};M7=new WeakMap,xf=new WeakMap,ZN=new WeakMap,zA.styles=Lc` 4342 :host { 4343 position: relative; 4344 } 4345 4346 canvas { 4347 width: 100%; 4348 height: 100%; 4349 outline: none; 4350 padding: 0; 4351 margin: 0; 4352 touch-action: none; 4353 } 4354 `,H6([Pa()],zA.prototype,"renderer",void 0),H6([Pa()],zA.prototype,"shaderCompilerPath",void 0),H6([em()],zA.prototype,"zoom",void 0),zA=H6([Vc("ic-canvas-lesson10")],zA);var B7=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};let RM=class extends Wa{constructor(){super(...arguments),this.zoom=100}zoomOut(){this.canvas.zoomOut()}zoomIn(){this.canvas.zoomIn()}render(){return Ao` 4355 <sl-button-group label="Zoom toolbar"> 4356 <sl-tooltip content="Zoom out"> 4357 <sl-icon-button 4358 name="dash-lg" 4359 label="Zoom out" 4360 @click="${this.zoomOut}" 4361 ></sl-icon-button> 4362 </sl-tooltip>
4363 <span>${this.zoom}%</span> 4364 <sl-tooltip content="Zoom in"> 4365 <sl-icon-button 4366 name="plus-lg" 4367 label="Zoom in" 4368 @click="${this.zoomIn}" 4369 ></sl-icon-button> 4370 </sl-tooltip> 4371 </sl-button-group> 4372 `}};RM.styles=Lc` 4373 :host { 4374 position: absolute; 4375 right: 16px; 4376 bottom: 16px; 4377 box-shadow: var(--sl-shadow-medium); 4378 background: white; 4379 } 4380 4381 span { 4382 font-size: 12px; 4383 line-height: 32px; 4384 width: 32px; 4385 text-align: center; 4386 color: var(--sl-color-neutral-600); 4387 } 4388 `,B7([cm({context:C7,subscribe:!0})],RM.prototype,"canvas",void 0),B7([Pa()],RM.prototype,"zoom",void 0),RM=B7([Vc("ic-zoom-toolbar-lesson10")],RM);var S5t=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},T5t=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};let Uht=class{constructor(t){this.options=t}toCanvas(){return S5t(this,arguments,void 0,function*(t={}){const{canvas:e}=this.options,{width:r,height:i}=e.getDOM(),s=e.getDPR(),{clippingRegion:o=new Ua(0,0,r,i),beforeDrawImage:n,afterDrawImage:a}=t,l=T5t(t,["clippingRegion","beforeDrawImage","afterDrawImage"]),c=yield e.toDataURL(l),h=yield this.getOrCreateImage(c),{x:u,y:d,width:f,height:g}=o,p=document.createElement("canvas");p.width=f*s,p.height=g*s;const m=p.getContext("2d");m.scale(s,s),n&&n(m);const v=h.width>r?s:1;return m.drawImage(h,u*v,d*v,f*v,g*v,0,0,f,g),a&&a(m),p})}toSVGDataURL(t={}){const{grid:e}=t,{canvas:r}=this.options,{width:i,height:s}=r.getDOM(),o=gs("svg");o.setAttribute("width",`${i}`),o.setAttribute("height",`${s}`),e&&(r.checkboardStyle===VN.GRID?this.drawLinesGrid(o):r.checkboardStyle===VN.DOTS&&this.drawDotsGrid(o)),o.appendChild(A7(E7(r.root)));const n=document.implementation.createDocumentType("svg","-//W3C//DTD SVG 1.1//EN","http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"),a=document.implementation.createDocument("http://www.w3.org/2000/svg","svg",n);return a.replaceChild(o,a.documentElement),`data:image/svg+xml;charset=utf8,${encodeURIComponent(new XMLSerializer().serializeToString(a))}`}downloadImage(t){const{defaultFilename:e}=this.options,{dataURL:r,name:i=e||"g"}=t,s=r.substring(r.indexOf(":")+1,r.indexOf(";")).split("/")[1],o=r.startsWith("data:image/svg"),n=`${i}.${o?"svg":s}`,a=document.createElement("a");if(o)a.addEventListener("click",()=>{a.download=n,a.href=r});else if(window.Blob&&window.URL){const l=r.split(",");let c="";if(l&&l.length>0){const g=l[0].match(/:(.*?);/);g&&g.length>=2&&(c=g[1])}const h=atob(l[1]);let u=h.length;const d=new Uint8Array(u);for(;u--;)d[u]=h.charCodeAt(u);const f=new Blob([d],{type:c});navigator.msSaveBlob?navigator.msSaveBlob(f,n):a.addEventListener("click",()=>{a.download=n,a.href=window.URL.createObjectURL(f)})}if(a.click)a.click();else{const l=document.createEvent("MouseEvents");l.initEvent("click",!1,!1),a.dispatchEvent(l)}}getOrCreateImage(t){return new Promise((e,r)=>{const i=new window.Image;i&&(i.onload=()=>{e(i)},i.onerror=s=>{r(s)},i.crossOrigin="Anonymous",i.src=t)})}drawLinesGrid(t){const e=gs("defs");t.appendChild(e);const r=gs("pattern");r.setAttribute("id","small-grid"),r.setAttribute("width","10"),r.setAttribute("height","10"),r.setAttribute("patternUnits","userSpaceOnUse");const i=gs("path");i.setAttribute("d","M 10 0 L 0 0 0 10"),i.setAttribute("fill","none"),i.setAttribute("stroke","rgba(221,221,221,1)"),i.setAttribute("stroke-width","1"),r.appendChild(i);const s=gs("pattern");s.setAttribute("id","grid"),s.setAttribute("width","100"),s.setAttribute("height","100"),s.setAttribute("patternUnits","userSpaceOnUse");const o=gs("rect");o.setAttribute("width","100"),o.setAttribute("height","100"),o.setAttribute("fill","url(#small-grid)"),s.appendChild(o);const n=gs("path");n.setAttribute("d","M 100 0 L 0 0 0 100"),n.setAttribute("fill","none"),n.setAttribute("stroke","rgba(221,221,221,1)"),n.setAttribute("stroke-width","2"),s.appendChild(n),e.appendChild(r),e.a
4388ppendChild(s);const a=gs("rect");a.setAttribute("width","100%"),a.setAttribute("height","100%"),a.setAttribute("fill","url(#grid)"),t.appendChild(a)}drawDotsGrid(t){const e=gs("defs");t.appendChild(e);const r=gs("circle");r.setAttribute("id","dot-tl"),r.setAttribute("cx","0"),r.setAttribute("cy","0"),r.setAttribute("r","2"),r.setAttribute("fill","rgba(221,221,221,1)");const i=r.cloneNode(),s=r.cloneNode(),o=r.cloneNode();i.setAttribute("id","dot-tr"),i.setAttribute("cx","20"),s.setAttribute("id","dot-bl"),s.setAttribute("cy","20"),o.setAttribute("id","dot-br"),o.setAttribute("cx","20"),o.setAttribute("cy","20"),e.appendChild(r),e.appendChild(i),e.appendChild(s),e.appendChild(o);const n=gs("pattern");n.setAttribute("id","dots-grid"),n.setAttribute("width","20"),n.setAttribute("height","20"),n.setAttribute("patternUnits","userSpaceOnUse");const a=gs("use");a.setAttribute("xlink:href","#dot-bl");const l=gs("use");l.setAttribute("xlink:href","#dot-br");const c=gs("use");c.setAttribute("xlink:href","#dot-tl");const h=gs("use");h.setAttribute("xlink:href","#dot-tr"),n.appendChild(a),n.appendChild(l),n.appendChild(c),n.appendChild(h),e.appendChild(n);const u=gs("rect");u.setAttribute("width","100%"),u.setAttribute("height","100%"),u.setAttribute("fill","url(#dots-grid)"),t.appendChild(u)}};var O7=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},R5t=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};let CM=class extends Wa{constructor(){super(...arguments),this.grid=!1}handleInputChange(){this.grid=!this.grid}connectedCallback(){super.connectedCallback();const t=new Uht({canvas:this.canvas});this.addEventListener("sl-select",e=>R5t(this,void 0,void 0,function*(){const r=e.detail.item;let i;r.value==="download-image-png"||r.value==="download-image-jpeg"?i=(yield t.toCanvas({grid:this.grid})).toDataURL(`image/${r.value.split("-").reverse()[0]}`):r.value==="download-image-svg"&&(i=t.toSVGDataURL({grid:this.grid})),i&&t.downloadImage({dataURL:i,name:"infinite-canvas-screenshot"})}))}render(){return Ao`<sl-dropdown> 4389 <sl-icon-button 4390 slot="trigger" 4391 name="download" 4392 label="Download" 4393 ></sl-icon-button> 4394 <sl-menu> 4395 <sl-switch 4396 size="small" 4397 .checked=${this.grid} 4398 @sl-input=${this.handleInputChange} 4399 >Grids included</sl-switch 4400 > 4401 <sl-menu-item value="download-image-png" 4402 >Download PNG image</sl-menu-item 4403 > 4404 <sl-menu-item value="download-image-jpeg" 4405 >Download JPEG image</sl-menu-item 4406 > 4407 <sl-menu-item value="download-image-svg" 4408 >Download SVG image</sl-menu-item 4409 > 4410 </sl-menu> 4411 </sl-dropdown>`}};CM.styles=Lc` 4412 :host { 4413 position: absolute; 4414 right: 16px; 4415 top: 16px; 4416 box-shadow: var(--sl-shadow-medium); 4417 background: white; 4418 } 4419 4420 sl-switch { 4421 margin-left: 24px; 4422 } 4423 4424 sl-menu-item::part(base) { 4425 font-size: 14px; 4426 } 4427 `,O7([cm({context:C7,subscribe:!0})],CM.prototype,"canvas",void 0),O7([em()],CM.prototype,"grid",void 0),CM=O7([Vc("ic-exporter-lesson10")],CM);const C5t=Object.freeze(Object.defineProperty({__proto__:null,AABB:Xm,Camera:xht,Canvas:Nht,Circle:fM,Ellipse:pM,get Exporter(){return CM},Grid:vht,Group:U6,IDENTITY_TRANSFORM:ght,ImageExporter:Uht,get InfiniteCanvas(){return zA},Rect:gM,Rectangle:Ua,Shape:uN,get ZoomToolbar(){return RM},deserializeNode:Eht,getBounds:_7,isFillOrStrokeAffected:P6,serializeNode:E7,strokeOffset:RA,toSVGElement:A7},Symbol.toStringTag,{value:"Module"}));var I7=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},JN;let M5t=class{constructor(){JN.set(this,[])}getCallbacksNum(){return I7(this,JN,"f").length}tapPromise(t){I7(this,JN,"f").push(t)}promise(...t){return Promise.all(I7(this,JN,"f").map(e=>e(...t)))}};JN=new WeakMap;var Ght=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},K6;let Pu=class{constructor(){K6.set(this,[])}tap(t){Ght(this,K6,"f").push(t)}call(...t){Ght(this,K6,"f").forEach(function(e){e.apply(void 0,t)})}};K6=new WeakMap;var QN=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},VA;
4427let B5t=class{constructor(){VA.set(this,[])}tap(t){QN(this,VA,"f").push(t)}call(...t){if(QN(this,VA,"f").length){let e=QN(this,VA,"f")[0].apply(void 0,t);for(let r=0;r<QN(this,VA,"f").length-1;r++){const i=QN(this,VA,"f")[r];e=i(...e)}return e}return null}};VA=new WeakMap;const O5t=()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};function ys(t,e){return(e||document).createElementNS("http://www.w3.org/2000/svg",t)}function D7(t,e){e(t)||t.children.forEach(r=>{D7(r,e)})}const P7=0;function MM(t){return[t[0],t[1],t[2],P7,t[3],t[4],t[5],P7,t[6],t[7],t[8],P7]}function Wht(t,e,r,i){return Math.sqrt(Math.pow(r-t,2)+Math.pow(i-e,2))}function I5t(t,e,r,i,s,o){const n=[r-t,i-e];if(hO(n,[0,0]))return Math.sqrt((s-t)*(s-t)+(o-e)*(o-e));const a=[-n[1],n[0]];aE(a,a);const l=[s-t,o-e];return Math.abs(Yy(l,a))}function D5t(t,e,r){const i=Ea(it(),Aa(it(),t,e),.5);return Ea(i,i,1/Yy(t,i)),Ea(i,i,r)}const P5t={linear:cr(0,0,1,1),ease:cr(.25,.1,.25,1),"ease-in":cr(.42,0,1,1),"ease-out":cr(0,0,.58,1),"ease-in-out":cr(.42,0,.58,1)};var F7;(function(t){t._bytes4=new Uint8Array(4),t._float=new Float32Array(t._bytes4.buffer);function e(r){return t._float[0]=r,t._bytes4}t.floatToBytes=e})(F7||(F7={}));const jht=256;let F5t=class{constructor(t=new Uint8Array(jht)){this._bytes=t,this.count=0,this.capacity=jht,this.count=this.capacity=t.length}clear(){this.count=0}bytes(){return this._bytes.subarray(0,this.count)}grow(){this.capacity*=2;const t=new Uint8Array(this.capacity);t.set(this._bytes),this._bytes=t}appendBytes(t){const e=t.length;return this.count+e>this.capacity&&this.grow(),this._bytes.set(t,this.count),this.count+=e,this}appendFloat(t){return this.appendBytes(F7.floatToBytes(t)),this}};const q6=t=>t instanceof Object,Xht=t=>t===!!t,Z6=t=>typeof t=="function",ha=t=>t===void 0,zht=t=>t==null,N0=t=>typeof t=="string";function N5t(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}const k5t=/^data:([a-z]+\/[a-z0-9\-\+]+)?(;charset=[a-z0-9\-]+)?(;base64)?,[a-z0-9\!\$&',\(\)\*\+,;=\-\._\~:@\/\?%\s]*$/i;function Vht(t){return k5t.test(t)}const N7={default:-1};function L5t(t="default"){return N7[t]===void 0&&(N7[t]=-1),++N7[t]}const Yht=new uo;let Bd=class{constructor(t=1/0,e=1/0,r=-1/0,i=-1/0){this.matrix=Yht,this.minX=t,this.minY=e,this.maxX=r,this.maxY=i}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Yht,this}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addFrame(t,e,r,i,s){s||(s=this.matrix);const o=s.a,n=s.b,a=s.c,l=s.d,c=s.tx,h=s.ty;let u=this.minX,d=this.minY,f=this.maxX,g=this.maxY,p=o*t+a*e+c,m=n*t+l*e+h;p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*r+a*e+c,m=n*r+l*e+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*t+a*i+c,m=n*t+l*i+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*r+a*i+c,m=n*r+l*i+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),this.minX=u,this.minY=d,this.maxX=f,this.maxY=g}},$ht=class E1t{get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=E1t.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ye,this.page=new ye,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}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(e,r,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,r,i,s,o){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}},J6=class extends $ht{constructor(){super(...arguments),this.client=new ye,this.movement=new ye,this.offset=new ye,this.global=new ye,this.screen=new ye}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}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,r,i,s,o,n,a,l,c,h,u,d,f,g){throw new Error("Method not implemented.")}},ig=class extends J6{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!")}},k7=class extends J6{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}};var U5t=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
4427return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},G5t=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Q6;const W5t=2048;let j5t=class{constructor(t){this.dispatch=new Uo,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,Q6.set(this,void 0),this.rootTarget=t,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)}setPickHandler(t){U5t(this,Q6,t,"f")}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((r,i)=>r.priority-i.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(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 r=0,i=e.length;r<i;r++)e[r].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}
vendor: 6,556 bytes, line 4427
4427hitTest(t,e){return G5t(this,Q6,"f").call(this,t,e)}propagate(t,e){if(!t.target)return;const r=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let i=0,s=r.length-1;i<s;i++)if(t.currentTarget=r[i],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 i=r.length-2;i>=0;i--)if(t.currentTarget=r[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,r=this._allInteractiveElements){if(r.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const i=Array.isArray(e)?e:[e];for(let s=r.length-1;s>=0;s--)i.forEach(o=>{t.currentTarget=r[s],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let r=0;r<W5t&&t!==this.rootTarget&&t.parent;r++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}notifyTarget(t,e){e=e??t.type;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 ig)){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 i=e.button===2;this.dispatchEvent(e,i?"rightdown":"mousedown")}const r=this.trackingData(t.pointerId);r.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,r,i;if(!(t instanceof ig)){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 s=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const o=s.pointerType==="mouse"||s.pointerType==="pen",n=this.trackingData(t.pointerId),a=this.findMountedTarget(n.overTargets);if(((e=n.overTargets)===null||e===void 0?void 0:e.length)>0&&a!==s.target){const h=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,h,a);if(this.dispatchEvent(u,"pointerout"),o&&this.dispatchEvent(u,"mouseout"),!s.composedPath().includes(a)){const d=this.createPointerEvent(t,"pointerleave",a);for(d.eventPhase=d.AT_TARGET;d.target&&!s.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),o&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(u)}if(a!==s.target){const h=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(s,h);this.dispatchEvent(u,"pointerover"),o&&this.dispatchEvent(u,"mouseover");let d=a==null?void 0:a.parent;for(;d&&d!==this.rootTarget.parent&&d!==s.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(s,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==a&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),o&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(u)}const l=[],c=(r=this.enableGlobalMoveEvents)!==null&&r!==void 0?r:!0;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(s,"pointermove"),c&&l.push("globalpointermove"),s.pointerType==="touch"&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(s,"touchmove"),c&&l.push("globaltouchmove")),o&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(s,"mousemove"),c&&l.push("globalmousemove"),this.cursor=(i=s.target)===null||i===void 0?void 0:i.cursor),l.length>0&&this.all(s,l),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=s.composedPath(),this.freeEvent(s)}mapPointerOver(t){var e;if(!(t instanceof ig)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(e=i.target)===null||e===void 0?void 0:e.cursor);const o=this.clonePointerEvent(i,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;r.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof ig)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const r=t.pointerType==="mouse"||t.pointerType==="pen",i=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",i);this.dispatchEvent(s),r&&this.dispatchEvent(s,"mouseout");const o=this.createPointerEvent(t,"pointerleave",i);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),r&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(s),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){var e;if(!(t instanceof ig)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=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 s=this.trackingData(t.pointerId),o=this.findMountedTarget(s.pressTargetsByButton[t.button]);let n=o;if(o&&!i.composedPath().includes(o)){let a=o;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 l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],n=a}if(n){const a=this.clonePointerEvent(i,"click");a.target=n,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:r});const l=s.clicksByButton[t.button];if(l.target===a.target&&r-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=r,a.detail=l.clickCount,!(!((e=i.detail)===null||e===void 0)&&e.preventClick)){if
4427(a.pointerType==="mouse"){const c=a.button===2;this.dispatchEvent(a,c?"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 ig)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),r=this.findMountedTarget(e.pressTargetsByButton[t.button]),i=this.createPointerEvent(t);if(r){let s=r;for(;s;)i.currentTarget=s,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch"?this.notifyTarget(i,"touchendoutside"):(i.pointerType==="mouse"||i.pointerType==="pen")&&this.notifyTarget(i,i.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(i)}mapWheel(t){if(!(t instanceof k7)){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 r=1;r<t.length&&t[r].parent===e;r++)e=t[r];return e}createPointerEvent(t,e,r){var i;const s=this.allocateEvent(ig);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=(i=r??this.hitTest(s.global.x,s.global.y))!==null&&i!==void 0?i:this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(k7);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 r=this.allocateEvent(ig);return r.nativeEvent=t.nativeEvent,r.originalEvent=t.originalEvent,this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.target=t.target,r.path=t.composedPath().slice(),r.type=e??r.type,r}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof ig&&e instanceof ig&&(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.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof J6&&e instanceof J6&&(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 r=t.currentTarget._events[e];if(r)if("fn"in r)r.once&&t.currentTarget.removeListener(e,r.fn,void 0,!0),r.fn.call(r.context,t);else for(let i=0,s=r.length;i<s&&!t.propagationImmediatelyStopped;i++)r[i].once&&t.currentTarget.removeListener(e,r[i].fn,void 0,!0),r[i].fn.call(r[i].context,t)}};Q6=new WeakMap;let X5t=class extends Uo{constructor(t={}){super();const{cursor:e,hitArea:r,pointerEvents:i,draggable:s,droppable:o}=t;this.cursor=e??"default",this.hitArea=r,this.pointerEvents=i??"auto",this.draggable=s??!1,this.droppable=o??!1}addEventListener(t,e,r){const i=Xht(r)&&r||q6(r)&&r.capture,s=q6(r)?r.signal:void 0,o=q6(r)&&r.once,n=Z6(e)?void 0:e;t=i?`${t}capture`:t;const a=Z6(e)?e:e.handleEvent;s&&s.addEventListener("abort",()=>{this.off(t,a,n)}),o?this.once(t,a,n):this.on(t,a,n)}removeEventListener(t,e,r){const i=Xht(r)&&r||q6(r)&&r.capture,s=Z6(e)?void 0:e;t=i?`${t}capture`:t,e=Z6(e)?e:e==null?void 0:e.handleEvent,this.off(t,e,s)}dispatchEvent(t){if(!(t instanceof $ht))throw new Error("Container cannot propagate events outside of the Federated Events API");return t.defaultPrevented=!1,t.path=[],t.target=this,t.manager.dispatchEvent(t),!t.defaultPrevented}};var vs=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Oa=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
4427return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r};function z5t(t){var e,r,i,s,o,n,a,l,c,h,u,d,f,g,p,m,v,b,y,_;return _=class extends t{constructor(w={}){super(w),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,e.set(this,void 0),r.set(this,void 0),i.set(this,void 0),s.set(this,void 0),o.set(this,void 0),n.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),h.set(this,void 0),u.set(this,void 0),d.set(this,void 0),f.set(this,void 0),g.set(this,void 0),p.set(this,void 0),m.set(this,void 0),v.set(this,void 0),b.set(this,void 0),y.set(this,void 0);const{renderable:E,visible:A,cullable:x,batchable:S,sizeAttenuation:T,fill:R,stroke:B,strokeWidth:O,strokeAlignment:C,strokeLinecap:F,strokeLinejoin:U,strokeMiterlimit:H,strokeDasharray:N,strokeDashoffset:G,opacity:Y,fillOpacity:q,strokeOpacity:L,innerShadowColor:J,innerShadowOffsetX:tt,innerShadowOffsetY:bt,innerShadowBlurRadius:ct}=w;this.renderable=E??!0,this.visible=A??!0,this.cullable=x??!0,this.batchable=S??!0,this.sizeAttenuation=T??!0,this.fill=R??"black",this.stroke=B??"none",this.strokeWidth=O??1,this.strokeAlignment=C??"center",this.strokeLinecap=F??"butt",this.strokeLinejoin=U??"miter",this.strokeMiterlimit=H??4,this.strokeDasharray=N??[],this.strokeDashoffset=G??0,this.opacity=Y??1,this.fillOpacity=q??1,this.strokeOpacity=L??1,this.innerShadowColor=J??"black",this.innerShadowOffsetX=tt??0,this.innerShadowOffsetY=bt??0,this.innerShadowBlurRadius=ct??0}get fill(){return vs(this,e,"f")}set fill(w){vs(this,e,"f")!==w&&(Oa(this,e,w,"f"),N0(w)&&(w==="none"?Oa(this,r,sr.rgb(255,255,255,0),"f"):Oa(this,r,sr.rgb(w),"f")),this.renderDirtyFlag=!0)}get fillRGB(){return vs(this,r,"f")}get stroke(){return vs(this,i,"f")}set stroke(w){vs(this,i,"f")!==w&&(Oa(this,i,w,"f"),w==="none"?Oa(this,s,sr.rgb(255,255,255,0),"f"):Oa(this,s,sr.rgb(w),"f"),this.renderDirtyFlag=!0)}get strokeRGB(){return vs(this,s,"f")}get strokeWidth(){return vs(this,o,"f")}set strokeWidth(w){vs(this,o,"f")!==w&&(Oa(this,o,w,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get strokeAlignment(){return vs(this,n,"f")}set strokeAlignment(w){vs(this,n,"f")!==w&&(Oa(this,n,w,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get strokeLinecap(){return vs(this,a,"f")}set strokeLinecap(w){vs(this,a,"f")!==w&&(Oa(this,a,w,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get strokeLinejoin(){return vs(this,l,"f")}set strokeLinejoin(w){vs(this,l,"f")!==w&&(Oa(this,l,w,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get strokeMiterlimit(){return vs(this,c,"f")}set strokeMiterlimit(w){vs(this,c,"f")!==w&&(Oa(this,c,w,"f"),this.renderDirtyFlag=!0)}get strokeDasharray(){return vs(this,h,"f")}set strokeDasharray(w){(!vs(this,h,"f")||!vs(this,h,"f").every((E,A)=>E===w[A]))&&(Oa(this,h,w,"f"),this.renderDirtyFlag=!0)}get strokeDashoffset(){return vs(this,u,"f")}set strokeDashoffset(w){vs(this,u,"f")!==w&&(Oa(this,u,w,"f"),this.renderDirtyFlag=!0)}get opacity(){return vs(this,d,"f")}set opacity(w){vs(this,d,"f")!==w&&(Oa(this,d,w,"f"),this.renderDirtyFlag=!0)}get fillOpacity(){return vs(this,f,"f")}set fillOpacity(w){vs(this,f,"f")!==w&&(Oa(this,f,w,"f"),this.renderDirtyFlag=!0)}get strokeOpacity(){return vs(this,g,"f")}set strokeOpacity(w){vs(this,g,"f")!==w&&(Oa(this,g,w,"f"),this.renderDirtyFlag=!0)}get innerShadowColor(){return vs(this,p,"f")}set innerShadowColor(w){vs(this,p,"f")!==w&&(Oa(this,p,w,"f"),Oa(this,m,sr.rgb(w),"f"),this.renderDirtyFlag=!0)}get innerShadowColorRGB(){return vs(this,m,"f")}get innerShadowOffsetX(){return vs(this,v,"f")}set innerShadowOffsetX(w){vs(this,v,"f")!==w&&(Oa(this,v,w,"f"),this.renderDirtyFlag=!0)}get innerShadowOffsetY(){return vs(this,b,"f")}set innerShadowOffsetY(w){vs(this,b,"f")!==w&&(Oa(this,b,w,"f"),this.renderDirtyFlag=!0)}get innerShadowBlurRadius(){return vs(this,y,"f")}set innerShadowBlurRadius(w){vs(this,y,"f")!==w&&(Oa(this,y,w,"f"),this.renderDirtyFlag=!0)}},e=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap,o=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,g=new WeakMap,p=new WeakMap,m=new WeakMap,v=new WeakMap,b=new WeakMap,y=new WeakMap,_}function V5t(t){return class extends t{constructor(){super(...arguments),this.transform=new wn}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(e){this.transform.position.copyFrom(e)}get scale(){return this.transform.scale}set scale(e){this.transform.scale.copyFrom(e)}get pivot(){return this.transform.pivot}set pivot(e){this.transform.pivot.copyFrom(e)}get skew(){return this.transform.skew}set skew(e){this.transform.skew.copyFrom(e)}get rotation(){return this.transform.rotation}set rotation(e){this.transform.rotation=e}get angle(){return this.transform.rotation*id}set angle(e){this.transform.rotation=e*eu}get transformDirtyFlag(){return this.transform._localID!==this.transform._currentLocalID||this.parent&&this.transform._parentID!==this.parent.transform._worldID}}}const Hht=new wn,Kht=new uo,BM=Y5t(z5t(V5t(X5t)));function Y5t(t){class e extends t{constructor(i={}){super(i),this.uid=L5t(),this.children=[]}appendChild(i){return i.parent&&i.parent.removeChild(i),i.parent=this,i.transform._parentID=-1,this.children.push(i),i}removeChild(i){const s=this.children.indexOf(i);return s===-1?null:(i.parent=void 0,i.transform._parentID=-1,this.children.splice(s,1),i)}getBounds(i){if(!this.boundsDirtyFlag)return this.bounds;this.bounds=this.bounds||new Bd,this.bounds.clear();let s;return this.parent?i?s=this.parent.worldTransform:(Kht.identity(),s=qht(this,Kht)):s=uo.IDENTITY,L7(this,this.bounds,s,i),this.boundsDirtyFlag=!1,this.bounds}}return e}function L7(t,e,r,i){if(!t.visible)return;let s;i?s=t.worldTransform:(t.transform.updateLocalTransform(),s=new uo,s.copyFrom(t.localTransform),s.append(r)),t.renderable&&(e.matrix=s,e.addBounds(t.getRenderBounds()));for(let o=0;o<t.children.length;o++)L7(t.children[o],e,s,i)}function qht(t,e){const r=t.parent;return r&&(qht(r,e),r.transform.updateLocalTransform(),e.append(r.localTransform)),e}function YA(t,e){return t==="center"?e/2:t==="inner"?0:t==="outer"?e:0}function tk(t,e,r){let i=!1,s=!1;const o=!!e&&e!=="none",n=!!r&&r!=="none";return t==="visiblepainted"||t==="painted"||t==="auto"?(i=o,s=n):t==="visiblefill"||t==="fill"?i=!0:t==="visiblestroke"||t==="stroke"?s=!0:(t==="visible"||t==="all")&&(i=!0,s=!0),[i,s]}var OM=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},U7=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
4427return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},ek,rk,ik;let k0=class A1t extends BM{static getGeometryBounds(e){const{cx:r=0,cy:i=0,r:s=0}=e;return new Bd(r-s,i-s,r+s,i+s)}constructor(e={}){super(e),ek.set(this,void 0),rk.set(this,void 0),ik.set(this,void 0);const{cx:r,cy:i,r:s}=e;this.cx=r??0,this.cy=i??0,this.r=s??0}get cx(){return OM(this,ek,"f")}set cx(e){OM(this,ek,"f")!==e&&(U7(this,ek,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get cy(){return OM(this,rk,"f")}set cy(e){OM(this,rk,"f")!==e&&(U7(this,rk,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get r(){return OM(this,ik,"f")}set r(e){OM(this,ik,"f")!==e&&(U7(this,ik,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}containsPoint(e,r){const{strokeWidth:i,strokeAlignment:s,cx:o,cy:n,r:a,pointerEvents:l,fill:c,stroke:h}=this,u=Wht(o,n,e,r),d=YA(s,i),[f,g]=tk(l,c,h);return f&&g?u<=a+d:f?u<=a:g?u>=a+d-i&&u<=a+d:!1}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.geometryBoundsDirtyFlag=!1,this.geometryBounds=A1t.getGeometryBounds(this)),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){const{strokeWidth:e,strokeAlignment:r,cx:i,cy:s,r:o}=this,n=YA(r,e);this.renderBoundsDirtyFlag=!1,this.renderBounds=new Bd(i-o-n,s-o-n,i+o+n,s+o+n)}return this.renderBounds}};ek=new WeakMap,rk=new WeakMap,ik=new WeakMap;var xb=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},t8=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},sk,ok,nk,ak;let L0=class x1t extends BM{static getGeometryBounds(e){const{cx:r=0,cy:i=0,rx:s=0,ry:o=0}=e;return new Bd(r-s,i-o,r+s,i+o)}constructor(e={}){var r,i;super(e),sk.set(this,void 0),ok.set(this,void 0),nk.set(this,void 0),ak.set(this,void 0);const{cx:s,cy:o,rx:n,ry:a}=e;this.cx=s??0,this.cy=o??0,this.rx=(r=n??a)!==null&&r!==void 0?r:0,this.ry=(i=a??n)!==null&&i!==void 0?i:0}get cx(){return xb(this,sk,"f")}set cx(e){xb(this,sk,"f")!==e&&(t8(this,sk,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get cy(){return xb(this,ok,"f")}set cy(e){xb(this,ok,"f")!==e&&(t8(this,ok,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get rx(){return xb(this,nk,"f")}set rx(e){xb(this,nk,"f")!==e&&(t8(this,nk,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get ry(){return xb(this,ak,"f")}set ry(e){xb(this,ak,"f")!==e&&(t8(this,ak,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}containsPoint(e,r){const{cx:i,cy:s,rx:o,ry:n,strokeWidth:a,strokeAlignment:l,pointerEvents:c,fill:h,stroke:u}=this,d=YA(l,a),[f,g]=tk(c,h,u);return f&&g?e8(e,r,i,s,o+d,n+d):f?e8(e,r,i,s,o,n):g?!e8(e,r,i,s,o+d-a,n+d-a)&&e8(e,r,i,s,o+d,n+d):!1}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.geometryBoundsDirtyFlag=!1,this.geometryBounds=x1t.getGeometryBounds(this)),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){const{strokeWidth:e,strokeAlignment:r,cx:i,cy:s,rx:o,ry:n}=this,a=YA(r,e);this.renderBoundsDirtyFlag=!1,this.renderBounds=new Bd(i-o-a,s-n-a,i+o+a,s+n+a)}return this.renderBounds}};sk=new WeakMap,ok=new WeakMap,nk=new WeakMap,ak=new WeakMap;function e8(t,e,r,i,s,o){const n=t-r,a=e-i;return n*n/(s*s)+a*a/(o*o)<=1}var Ml=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Hm=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
4427return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},lk,ck,hk,uk,dk,fk,r8,pk,gk,mk;let Km=class S1t extends BM{static getGeometryBounds(e){const{x:r=0,y:i=0,width:s=0,height:o=0}=e;return new Bd(r,i,r+s,i+o)}constructor(e={}){super(e),lk.set(this,void 0),ck.set(this,void 0),hk.set(this,void 0),uk.set(this,void 0),dk.set(this,void 0),fk.set(this,void 0),r8.set(this,void 0),pk.set(this,void 0),gk.set(this,void 0),mk.set(this,void 0);const{x:r,y:i,width:s,height:o,cornerRadius:n,dropShadowColor:a,dropShadowOffsetX:l,dropShadowOffsetY:c,dropShadowBlurRadius:h}=e;this.x=r??0,this.y=i??0,this.width=s??0,this.height=o??0,this.cornerRadius=n??0,this.dropShadowColor=a??"black",this.dropShadowOffsetX=l??0,this.dropShadowOffsetY=c??0,this.dropShadowBlurRadius=h??0}get x(){return Ml(this,lk,"f")}set x(e){Ml(this,lk,"f")!==e&&(Hm(this,lk,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get y(){return Ml(this,ck,"f")}set y(e){Ml(this,ck,"f")!==e&&(Hm(this,ck,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get width(){return Ml(this,hk,"f")}set width(e){Ml(this,hk,"f")!==e&&(Hm(this,hk,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get height(){return Ml(this,uk,"f")}set height(e){Ml(this,uk,"f")!==e&&(Hm(this,uk,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get cornerRadius(){return Ml(this,dk,"f")}set cornerRadius(e){Ml(this,dk,"f")!==e&&(Hm(this,dk,e,"f"),this.renderDirtyFlag=!0)}get dropShadowColor(){return Ml(this,fk,"f")}set dropShadowColor(e){Ml(this,fk,"f")!==e&&(Hm(this,fk,e,"f"),Hm(this,r8,sr.rgb(e),"f"),this.renderDirtyFlag=!0)}get dropShadowColorRGB(){return Ml(this,r8,"f")}get dropShadowOffsetX(){return Ml(this,pk,"f")}set dropShadowOffsetX(e){Ml(this,pk,"f")!==e&&(Hm(this,pk,e,"f"),this.renderDirtyFlag=!0)}get dropShadowOffsetY(){return Ml(this,gk,"f")}set dropShadowOffsetY(e){Ml(this,gk,"f")!==e&&(Hm(this,gk,e,"f"),this.renderDirtyFlag=!0)}get dropShadowBlurRadius(){return Ml(this,mk,"f")}set dropShadowBlurRadius(e){Ml(this,mk,"f")!==e&&(Hm(this,mk,e,"f"),this.renderDirtyFlag=!0)}containsPoint(e,r){const{x:i,y:s,width:o,height:n,strokeWidth:a,strokeAlignment:l,cornerRadius:c}=this,h=YA(l,a),[u,d]=tk(this.pointerEvents,this.dropShadowColor,this.stroke);if(u&&d)return i8(e,r,i-h,s-h,i+o+h,s+n+h,c);if(u)return i8(e,r,i,s,i+o,s+n,c);if(d){const f=h-a;return!i8(e,r,i-f,s-f,i+o+f,s+n+f,c)&&i8(e,r,i-h,s-h,i+o+h,s+n+h,c)}return!1}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.geometryBoundsDirtyFlag=!1,this.geometryBounds=S1t.getGeometryBounds(this)),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){const{x:e,y:r,width:i,height:s,strokeWidth:o,strokeAlignment:n,dropShadowOffsetX:a,dropShadowOffsetY:l,dropShadowBlurRadius:c}=this,h=YA(n,o);this.renderBoundsDirtyFlag=!1,this.renderBounds=new Bd(e-h,r-h,e+i+h,r+s+h),this.renderBounds.addBounds(new Bd(e+a-c,r+l-c,e+a+i+c,r+l+s+c))}return this.renderBounds}};lk=new WeakMap,ck=new WeakMap,hk=new WeakMap,uk=new WeakMap,dk=new WeakMap,fk=new WeakMap,r8=new WeakMap,pk=new WeakMap,gk=new WeakMap,mk=new WeakMap;function i8(t,e,r,i,s,o,n){function a(l,c,h,u,d){return Math.sqrt(Math.pow(l-h,2)+Math.pow(c-u,2))<=d}return t>=r&&t<=s&&e>=i&&e<=o?a(t,e,r+n,i+n,n)||a(t,e,s-n,i+n,n)||a(t,e,s-n,o-n,n)||a(t,e,r+n,o-n,n)?!0:!(t<=r+n||t>=s-n||e<=i+n||e>=o-n):!1}var $A=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Zht=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
4427return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Sb,yk;let HA=class T1t extends BM{static getGeometryBounds(e){const{points:r}=e;if(!r||r.length<2)return new Bd(0,0,0,0);const i=Math.min(...r.map(a=>isNaN(a[0])?1/0:a[0])),s=Math.max(...r.map(a=>isNaN(a[0])?-1/0:a[0])),o=Math.min(...r.map(a=>isNaN(a[1])?1/0:a[1])),n=Math.max(...r.map(a=>isNaN(a[1])?-1/0:a[1]));return new Bd(i,o,s,n)}constructor(e={}){super(e),Sb.set(this,void 0),yk.set(this,[]),this.batchable=!1;const{points:r}=e;this.points=r??[[0,0],[0,0]]}get points(){return $A(this,Sb,"f")}set points(e){(!$A(this,Sb,"f")||!$A(this,Sb,"f").every((r,i)=>r[0]===e[i][0]&&r[1]===e[i][1]))&&(Zht(this,Sb,e,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0)}computeShiftedPoints(){const{strokeWidth:e,strokeAlignment:r}=this;Zht(this,yk,r==="center"?$A(this,Sb,"f"):G7($A(this,Sb,"f"),r==="inner",e),"f")}containsPoint(e,r){const{strokeWidth:i}=this;this.getGeometryBounds();const[,s]=tk(this.pointerEvents,this.dropShadowColor,this.stroke);return s?Qht($A(this,yk,"f"),i,e,r):!1}getTotalLength(){const{points:e}=this;let r=0;for(let i=0;i<e.length-1;i++){const[s,o]=e[i],[n,a]=e[i+1];r+=Math.hypot(n-s,a-o)}return r}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.computeShiftedPoints(),this.geometryBoundsDirtyFlag=!1,this.geometryBounds=T1t.getGeometryBounds(Object.assign(Object.assign({},this),{points:$A(this,yk,"f")}))),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){this.renderBoundsDirtyFlag=!1;const{strokeWidth:e,strokeLinecap:r,strokeLinejoin:i,strokeMiterlimit:s}=this;let o=.5;r==="square"&&(o=Math.SQRT1_2),o*=e;const{minX:n,minY:a,maxX:l,maxY:c}=this.getGeometryBounds();this.renderBounds=new Bd(n-o,a-o,l+o,c+o)}return this.renderBounds}};Sb=new WeakMap,yk=new WeakMap;function Jht(t,e,r,i,s,o,n){const a=Math.min(t,r),l=Math.max(t,r),c=Math.min(e,i),h=Math.max(e,i),u=s/2;return o>=a-u&&o<=l+u&&n>=c-u&&n<=h+u?I5t(t,e,r,i,o,n)<=s/2:!1}function G7(t,e,r){const i=[];return t.forEach(([s,o],n)=>{const a=Be(s,o),l=n===0?a:Be(t[n-1][0],t[n-1][1]),c=n===t.length-1?a:Be(t[n+1][0],t[n+1][1]),h=ru(it(),a,l),u=rm(h),d=it();$y(d,h,Be(u,u));const f=Be(d[1],-d[0]),g=ru(it(),c,a),p=rm(g),m=it();$y(m,g,Be(p,p));const v=Be(m[1],-m[0]),b=f[0]*v[1]-f[1]*v[0],y=2*(e?0:1)-1,_=r/2*y;u===0?Aa(a,a,Ea(v,v,_)):p===0||Math.abs(b)<.01?Aa(a,a,Ea(f,f,_)):Aa(a,a,D5t(f,v,_)),i.push([a[0],a[1]])}),i}function Qht(t,e,r,i){const s=t.length;if(s<2)return!1;for(let o=0;o<s-1;o++){const n=t[o][0],a=t[o][1],l=t[o+1][0],c=t[o+1][1];if(Jht(n,a,l,c,e,r,i))return!0}return!1}const $5t=` 4428layout(std140) uniform SceneUniforms { 4429 mat3 u_ProjectionMatrix; 4430 mat3 u_ViewMatrix; 4431 mat3 u_ViewProjectionInvMatrix; 4432 vec4 u_BackgroundColor; 4433 vec4 u_GridColor; 4434 float u_ZoomScale; 4435 float u_CheckboardStyle; 4436}; 4437 4438layout(location = 0) in vec2 a_Position; 4439 4440out vec2 v_Position; 4441 4442vec2 project_clipspace_to_world(vec2 p) { 4443 return (u_ViewProjectionInvMatrix * vec3(p, 1)).xy; 4444} 4445 4446void main() { 4447 v_Position = project_clipspace_to_world(a_Position); 4448 gl_Position = vec4(a_Position, 0, 1); 4449} 4450`,H5t=` 4451layout(std140) uniform SceneUniforms { 4452 mat3 u_ProjectionMatrix; 4453 mat3 u_ViewMatrix; 4454 mat3 u_ViewProjectionInvMatrix; 4455 vec4 u_BackgroundColor; 4456 vec4 u_GridColor; 4457 float u_ZoomScale; 4458 float u_CheckboardStyle; 4459}; 4460 4461out vec4 outputColor; 4462 4463in vec2 v_Position; 4464 4465const int CHECKERBOARD_STYLE_NONE = 0; 4466const int CHECKERBOARD_STYLE_GRID = 1; 4467const int CHECKERBOARD_STYLE_DOTS = 2; 4468const float BASE_GRID_PIXEL_SIZE = 100.0; 4469const float BASE_DOT_SIZE = 8.0; 4470 4471vec2 scale_grid_size(float zoom) { 4472 if (zoom < 0.125) return vec2(BASE_GRID_PIXEL_SIZE * 125.0, 0.125); 4473 else if (zoom < 0.25) return vec2(BASE_GRID_PIXEL_SIZE * 25.0, 0.25); 4474 else if (zoom < 0.5) return vec2(BASE_GRID_PIXEL_SIZE * 5.0, 0.5); 4475 return vec2(BASE_GRID_PIXEL_SIZE, 4.0); 4476} 4477 4478vec4 render_grid_checkerboard(vec2 coord) { 4479 float alpha = 0.0; 4480 4481 vec2 size = scale_grid_size(u_ZoomScale); 4482 float gridSize1 = size.x; 4483 float gridSize2 = gridSize1 / 10.0; 4484 float zoomStep = size.y; 4485 int checkboardStyle = int(floor(u_CheckboardStyle + 0.5)); 4486 4487 if (checkboardStyle == CHECKERBOARD_STYLE_GRID) { 4488 vec2 grid1 = abs(fract(coord / gridSize1 - 0.5) - 0.5) / fwidth(coord) * gridSize1 / 2.0; 4489 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2; 4490 float v1 = 1.0 - min(min(grid1.x, grid1.y), 1.0); 4491 float v2 = 1.0 - min(min(grid2.x, grid2.y), 1.0); 4492 4493 if (v1 > 0.0) { 4494 alpha = v1; 4495 } else { 4496 alpha = v2 * clamp(u_ZoomScale / zoomStep, 0.0, 1.0); 4497 } 4498 } else if (checkboardStyle == CHECKERBOARD_STYLE_DOTS) { 4499 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2;
4500 alpha = 1.0 - smoothstep(0.0, 1.0, length(grid2) - BASE_DOT_SIZE * u_ZoomScale / zoomStep); 4501 } 4502 4503 return mix(u_BackgroundColor, u_GridColor, alpha); 4504} 4505 4506void main() { 4507 outputColor = render_grid_checkerboard(v_Position); 4508} 4509`;var Yl=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},vk=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Tb,IM,DM,_k,bk,wk;let tut=class{constructor(){Tb.set(this,void 0),IM.set(this,void 0),DM.set(this,void 0),_k.set(this,void 0),bk.set(this,void 0),wk.set(this,new F5t)}appendVertex(t,e){Yl(this,wk,"f").appendFloat(t).appendFloat(e)}render(t,e,r,i){if(!Yl(this,Tb,"f")){vk(this,Tb,t.createProgram({vertex:{glsl:$5t},fragment:{glsl:H5t}}),"f"),vk(this,DM,t.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{format:I.F32_RG,offset:0,shaderLocation:0}]}],indexBufferFormat:null,program:Yl(this,Tb,"f")}),"f"),vk(this,IM,t.createRenderPipeline({inputLayout:Yl(this,DM,"f"),program:Yl(this,Tb,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,topology:Go.TRIANGLE_STRIP}),"f"),Yl(this,wk,"f").clear(),this.appendVertex(-1,-1),this.appendVertex(-1,1),this.appendVertex(1,-1),this.appendVertex(1,1);const s=Yl(this,wk,"f").bytes(),o=t.createBuffer({viewOrSize:s.byteLength,usage:dt.VERTEX,hint:Et.DYNAMIC});vk(this,bk,o,"f"),o.setSubData(0,s),vk(this,_k,t.createBindings({pipeline:Yl(this,IM,"f"),uniformBufferBindings:[{buffer:r}]}),"f")}Yl(this,Tb,"f").setUniformsLegacy(i),e.setBindings(Yl(this,_k,"f")),e.setP
4509ipeline(Yl(this,IM,"f")),e.setVertexInput(Yl(this,DM,"f"),[{buffer:Yl(this,bk,"f")}],null),e.draw(4)}destroy(){var t,e,r,i,s;(t=Yl(this,Tb,"f"))===null||t===void 0||t.destroy(),(e=Yl(this,bk,"f"))===null||e===void 0||e.destroy(),(r=Yl(this,IM,"f"))===null||r===void 0||r.destroy(),(i=Yl(this,DM,"f"))===null||i===void 0||i.destroy(),(s=Yl(this,_k,"f"))===null||s===void 0||s.destroy()}};Tb=new WeakMap,IM=new WeakMap,DM=new WeakMap,_k=new WeakMap,bk=new WeakMap,wk=new WeakMap;let s8=class extends BM{constructor(){super(...arguments),this.renderable=!1}containsPoint(t,e){throw new Error("Method not implemented.")}getGeometryBounds(){throw new Error("Method not implemented.")}getRenderBounds(){throw new Error("Method not implemented.")}destroy(){}};var eut=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},rut=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};const iut=["renderable","visible"],o8=["cullable","batchable","fill","stroke","strokeWidth","strokeAlignment","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeDasharray","strokeDashoffset","opacity","fillOpacity","strokeOpacity","innerShadowColor","innerShadowOffsetX","innerShadowOffsetY","innerShadowBlurRadius"],K5t=["cx","cy","r"],q5t=["cx","cy","rx","ry"],Z5t=["x","y","width","height","cornerRadius","dropShadowColor","dropShadowOffsetX","dropShadowOffsetY","dropShadowBlurRadius"],J5t=["points"],Q5t={opacity:1,fillOpacity:1,strokeOpacity:1,fill:"black",stroke:"none",strokeWidth:1,strokeLinecap:"butt",strokeLinejoin:"miter",strokeAlignment:"center",strokeMiterlimit:4,strokeDasharray:"none",strokeDashoffset:0,innerShadowBlurRadius:0,innerShadowColor:"none",innerShadowOffsetX:0,innerShadowOffsetY:0,visibility:"visible",transform:"matrix(1,0,0,1,0,0)",cornerRadius:0,dropShadowColor:"none",dropShadowOffsetX:0,dropShadowOffsetY:0,dropShadowBlurRadius:0};function tWt(t){if(t instanceof s8)return["g",iut];if(t instanceof k0)return["circle",[...o8,...K5t]];if(t instanceof L0)return["ellipse",[...o8,...q5t]];if(t instanceof Km)return["rect",[...o8,...Z5t]];if(t instanceof HA)return["polyline",[...o8,...J5t]]}function sut(t){return eut(this,void 0,void 0,function*(){const{type:e,attributes:r,children:i}=t;let s;e==="g"?s=new s8:e==="circle"?s=new k0:e==="ellipse"?s=new L0:e==="rect"?s=new Km:e==="polyline"&&(s=new HA);const{transform:o}=r,n=rut(r,["transform"]);Object.assign(s,n);const{fill:a,points:l,strokeDasharray:c}=n;if(a&&N0(a)&&Vht(a)&&(s.fill=yield nu(a,Hh)),l&&N0(l)&&(s.points=l.split(" ").map(h=>h.split(",").map(Number))),c&&N0(c)&&(s.strokeDasharray=c.split(" ").map(Number)),o){const{position:h,scale:u,skew:d,rotation:f,pivot:g}=o;s.transform.position.set(h.x,h.y),s.transform.scale.set(u.x,u.y),s.transform.skew.set(d.x,d.y),s.transform.rotation=f,s.transform.pivot.set(g.x,g.y)}return i&&i.length>0&&(yield Promise.all(i.map(h=>eut(this,void 0,void 0,function*(){s.appendChild(yield sut(h))})))),s})}function W7(t){const[e,r]=tWt(t),i={uid:t.uid,type:e,attributes:[...iut,...r].reduce((a,l)=>(a[l]=t[l],a),{})},{fill:s,points:o,strokeDasharray:n}=i.attributes;return s&&!N0(s)&&(i.attributes.fill=nWt(s)),o&&(i.attributes.points=o.map(([a,l])=>`${a},${l}`).join(" ")),n&&(i.attributes.strokeDasharray=n.join(" ")),i.attributes.transform=eWt(t.transform),i.children=t.children.map(W7),i}function eWt(t){const{a:e,b:r,c:i,d:s,tx:o,ty:n}=t.localTransform;return{matrix:{a:e,b:r,c:i,d:s,tx:o,ty:n},position:{x:t.position.x,y:t.position.y},scale:{x:t.scale.x,y:t.scale.y},skew:{x:t.skew.x,y:t.skew.y},rotation:t.rotation,pivot:{x:t.pivot.x,y:t.pivot.y}}}function rWt(t,e,r,i){const{type:s,attributes:o}=t,{strokeWidth:n,strokeAlignment:a}=o,l=a==="inner",c=n/2;
4509if(s==="polyline"){const{points:h}=o,u=h.split(" ").map(f=>f.split(",").map(Number)),d=G7(u,l,n);e.setAttribute("points",d.map(f=>f.join(",")).join(" "))}else{const h=e.cloneNode();if(e.setAttribute("stroke","none"),h.setAttribute("fill","none"),s==="circle"){const{r:u}=o,d=l?-c:c;h.setAttribute("r",`${u+d}`)}else if(s==="ellipse"){const{rx:u,ry:d}=o,f=l?-c:c;h.setAttribute("rx",`${u+f}`),h.setAttribute("ry",`${d+f}`)}else if(s==="rect"){const{x:u,y:d,width:f,height:g,strokeWidth:p}=o;h.setAttribute("x",`${u+(l?c:-c)}`),h.setAttribute("y",`${d+(l?c:-c)}`),h.setAttribute("width",`${f+(l?-p:p)}`),h.setAttribute("height",`${g+(l?-p:p)}`)}r.appendChild(h)}}function iWt(t,e,r,i){const{uid:s,attributes:{innerShadowOffsetX:o,innerShadowOffsetY:n,innerShadowBlurRadius:a,innerShadowColor:l}}=t,c=ys("defs",i),h=ys("filter",i);h.id=`filter_inner_shadow_${s}`;const u=ys("feComponentTransfer",i);u.setAttribute("in","SourceAlpha");const d=ys("feFuncA",i);d.setAttribute("type","table"),d.setAttribute("tableValues","1 0"),u.appendChild(d),h.appendChild(u);const f=ys("feGaussianBlur",i);f.setAttribute("stdDeviation",`${(a||0)/4}`),h.appendChild(f);const g=ys("feOffset",i);g.setAttribute("dx",`${(o||0)/2}`),g.setAttribute("dy",`${(n||0)/2}`),g.setAttribute("result","offsetblur"),h.appendChild(g);const p=ys("feFlood",i);p.setAttribute("flood-color",l),p.setAttribute("result","color"),h.appendChild(p);const m=ys("feComposite",i);m.setAttribute("in2","offsetblur"),m.setAttribute("operator","in"),h.appendChild(m);const v=ys("feComposite",i);v.setAttribute("in2","SourceAlpha"),v.setAttribute("operator","in"),h.appendChild(v);const b=ys("feMerge",i);h.appendChild(b);const y=ys("feMergeNode",i);y.setAttribute("in","SourceGraphic");const _=ys("feMergeNode",i);b.appendChild(y),b.appendChild(_),c.appendChild(h),e.appendChild(c);const w=e.getAttribute("filter")||"";e.setAttribute("filter",`${w} url(#${h.id})`.trim())}function sWt(t,e,r,i){const{uid:s,attributes:{dropShadowBlurRadius:o,dropShadowColor:n,dropShadowOffsetX:a,dropShadowOffsetY:l}}=t,c=ys("defs",i),h=ys("filter",i);h.id=`filter_drop_shadow_${s}`;const u=ys("feDropShadow",i);u.setAttribute("dx",`${(a||0)/2}`),u.setAttribute("dy",`${(l||0)/2}`),u.setAttribute("stdDeviation",`${(o||0)/4}`),u.setAttribute("flood-color",n),h.appendChild(u),c.appendChild(h),e.appendChild(c);const d=e.getAttribute("filter")||"";e.setAttribute("filter",`${d} url(#${h.id})`.trim())}function oWt(t,e,r,i){const s=ys("defs",i),o=ys("pattern",i);o.id=`image-fill_${t.uid}`,o.setAttribute("patternUnits","objectBoundingBox"),o.setAttribute("width","1"),o.setAttribute("height","1");const n=ys("image",i);n.setAttribute("href",t.attributes.fill),n.setAttribute("x","0"),n.setAttribute("y","0");let a;t.type==="circle"?a=k0.getGeometryBounds(t.attributes):t.type==="ellipse"?a=L0.getGeometryBounds(t.attributes):t.type==="rect"&&(a=Km.getGeometryBounds(t.attributes)),n.setAttribute("width",`${a.maxX-a.minX}`),n.setAttribute("height",`${a.maxY-a.minY}`),o.appendChild(n),s.appendChild(o),r.appendChild(s),e.setAttribute("fill",`url(#${o.id})`)}function j7(t,e){const{type:r,attributes:i,children:s}=t,o=ys(r,e),{transform:n,visible:a,cullable:l,renderable:c,batchable:h,innerShadowColor:u,innerShadowOffsetX:d,innerShadowOffsetY:f,innerShadowBlurRadius:g,dropShadowColor:p,dropShadowOffsetX:m,dropShadowOffsetY:v,dropShadowBlurRadius:b,strokeAlignment:y,cornerRadius:_}=i,w=rut(i,["transform","visible","cullable","renderable","batchable","innerShadowColor","innerShadowOffsetX","innerShadowOffsetY","innerShadowBlurRadius","dropShadowColor","dropShadowOffsetX","dropShadowOffsetY","dropShadowBlurRadius","strokeAlignment","cornerRadius"]);Object.entries(w).forEach(([F,U])=>{`${U}`!=""&&`${Q5t[F]}`!=`${U}`&&o.setAttribute(N5t(F),`${U}`)});const E=y==="inner"||y==="outer",A=w.fill&&N0(w.fill)&&Vht(w.fill);let x;(s&&s.length>0&&r!=="g"||E&&r!=="polyline"||A)&&(x=ys("g",e),x.appendChild(o)),E&&rWt(t,o,x),g>0&&iWt(t,o,x,e),b>0&&sWt(t,o,x,e),A&&oWt(t,o,x,e),x=x||o,a===!1&&x.setAttribute("visibility","hidden"),_&&(x.setAttribute("rx",`${_}`),x.setAttribute("ry",`${_}`));const{a:S,b:T,c:R,d:B,tx:O,ty:C}=n.matrix;return(S!==1||T!==0||R!==0||B!==1||O!==0||C!==0)&&x.setAttribute("transform",`matrix(${S},${T},${R},${B},${O},${C})`),[...s].map(F=>
4509j7(F,e)).forEach(F=>{x.appendChild(F)}),x}function nWt(t){const e=document.createElement("canvas");return e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0),e.toDataURL()}var br=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Tc=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},sg,Fu,Nu,Sf,Ek,Ak,og,xk,Sk,Tk,n8,Rk;const out=1e-4;let nut=class R1t{constructor(e,r){this.clipSpaceNearZ=Sh.NEGATIVE_ONE,sg.set(this,1),Fu.set(this,0),Nu.set(this,0),Sf.set(this,0),Ek.set(this,0),Ak.set(this,0),og.set(this,Bt()),xk.set(this,Bt()),Sk.set(this,Bt()),Tk.set(this,Bt()),n8.set(this,Bt()),Rk.set(this,void 0),this.projection(e,r),this.updateMatrix()}clone(){const e=new R1t(br(this,Ek,"f"),br(this,Ak,"f"));return Tc(e,Fu,br(this,Fu,"f"),"f"),Tc(e,Nu,br(this,Nu,"f"),"f"),Tc(e,sg,br(this,sg,"f"),"f"),Tc(e,Sf,br(this,Sf,"f"),"f"),e.updateMatrix(),e}projection(e,r){Tc(this,Ek,e,"f"),Tc(this,Ak,r,"f"),ld(br(this,xk,"f"),e,r),this.updateViewProjectionMatrix()}updateMatrix(){const e=1/br(this,sg,"f");Yc(br(this,og,"f")),bi(br(this,og,"f"),br(this,og,"f"),[br(this,Fu,"f"),br(this,Nu,"f")]),Mo(br(this,og,"f"),br(this,og,"f"),br(this,Sf,"f")),xh(br(this,og,"f"),br(this,og,"f"),[e,e]),_i(br(this,Sk,"f"),br(this,og,"f")),this.updateViewProjectionMatrix()}updateViewProjectionMatrix(){us(br(this,Tk,"f"),br(this,xk,"f"),br(this,Sk,"f")),_i(br(this,n8,"f"),br(this,Tk,"f")),this.onchange&&this.onchange()}get projectionMatrix(){return br(this,xk,"f")}get viewMatrix(){return br(this,Sk,"f")}get viewProjectionMatrix(){return br(this,Tk,"f")}get viewProjectionMatrixInv(){return br(this,n8,"f")}get matrix(){return br(this,og,"f")}get zoom(){return br(this,sg,"f")}set zoom(e){br(this,sg,"f")!==e&&(Tc(this,sg,e,"f"),this.updateMatrix())}get x(){return br(this,Fu,"f")}set x(e){br(this,Fu,"f")!==e&&(Tc(this,Fu,e,"f"),this.updateMatrix())}get y(){return br(this,Nu,"f")}set y(e){br(this,Nu,"f")!==e&&(Tc(this,Nu,e,"f"),this.updateMatrix())}get rotation(){return br(this,Sf,"f")}set rotation(e){br(this,Sf,"f")!==e&&(Tc(this,Sf,e,"f"),this.updateMatrix())}get width(){return br(this,Ek,"f")}get height(){return br(this,Ak,"f")}createLandmark(e={}){return Object.assign({zoom:br(this,sg,"f"),x:br(this,Fu,"f"),y:br(this,Nu,"f"),rotation:br(this,Sf,"f")},e)}gotoLandmark(e,r={},i){const{easing:s="linear",duration:o=100,onframe:n=void 0,onfinish:a=void 0}=r,{zoom:l=br(this,sg,"f"),x:c=br(this,Fu,"f"),y:h=br(this,Nu,"f"),rotation:u=br(this,Sf,"f"),viewportX:d=0,viewportY:f=0}=e,g=d||f,p=()=>{this.applyLandmark({x:c,y:h,zoom:l,rotation:u,viewportX:d,viewportY:f}),a&&a()};if(o===0){p();return}this.cancelLandmarkAnimation();let m;const v=[c,h],b=[l,u],y=_=>{m===void 0&&(m=_);const w=_-m;if(w>o){p();return}const E=P5t[s](w/o),A=it(),x=Be(1,0);if(ta(A,[br(this,Fu,"f"),br(this,Nu,"f")],v,E),ta(x,[this.zoom,br(this,Sf,"f")],b,E),this.applyLandmark({x:A[0],y:A[1],zoom:x[0],rotation:x[1],viewportX:d,viewportY:f}),g?za(x,b)<=out:za(A,v)<=out){p();return}w<o&&(n&&n(E),Tc(this,Rk,(i||requestAnimationFrame)(y),"f"))};(i||requestAnimationFrame)(y)}cancelLandmarkAnimation(e){br(this,Rk,"f")!==void 0&&(e||cancelAnimationFrame)(br(this,Rk,"f"))}viewport2Canvas({x:e,y:r},i){const{width:s,height:o,viewProjectionMatrixInv:n}=i||this,a=Qt(it(),[e/s*2-1,(1-r/o)*2-1],n);return{x:a[0],y:a[1]}}canvas2Viewport({x:e,y:r},i){const{width:s,height:o,viewProjectionMatrix:n}=i||this,a=Qt(it(),[e,r],n);return{x:(a[0]+1)/2*s,y:(1-(a[1]+1)/2)*o}}applyLandmark(e){const{x:r,y:i,zoom:s,rotation:o,viewportX:n,viewportY:a}=e,l=n||a;let c=0,h=0;if(l){const u=this.viewport2Canvas({x:n,y:a});c=u.x,h=u.y}if(Tc(this,sg,s,"f"),Tc(this,Sf,o,"f"),Tc(this,Fu,r,"f"),Tc(this,Nu,i,"f"),this.updateMatrix(),l){const{x:u,y:d}=this.viewport2Canvas({x:n,y:a});Tc(this,Fu,br(this,Fu,"f")+(c-u),"f"),Tc(this,Nu,br(this,Nu,"f")+(h-d),"f"),this.updateMatrix()}}};
4509sg=new WeakMap,Fu=new WeakMap,Nu=new WeakMap,Sf=new WeakMap,Ek=new WeakMap,Ak=new WeakMap,og=new WeakMap,xk=new WeakMap,Sk=new WeakMap,Tk=new WeakMap,n8=new WeakMap,Rk=new WeakMap;const X7=1e5;let z7=class{constructor(t,e,r){this.device=t,this.renderCache=e,this.instanced=r,this.shapes=[],this.maxInstances=1/0,this.geometryDirty=!0,this.materialDirty=!0}validate(t){return this.count()<=this.maxInstances-1}submit(t,e,r){this.geometryDirty&&this.createGeometry(),this.materialDirty&&this.createMaterial(e),this.render(t,r),this.geometryDirty&&(this.geometryDirty=!1),this.materialDirty&&(this.materialDirty=!1)}add(t){this.shapes.includes(t)||(this.shapes.push(t),this.geometryDirty=!0)}remove(t){if(this.shapes.includes(t)){const e=this.shapes.indexOf(t);this.shapes.splice(e,1),this.geometryDirty=!0}}count(){return this.shapes.length}};const aWt=` 4510layout(std140) uniform SceneUniforms { 4511 mat3 u_ProjectionMatrix; 4512 mat3 u_ViewMatrix; 4513 mat3 u_ViewProjectionInvMatrix; 4514 vec4 u_BackgroundColor; 4515 vec4 u_GridColor; 4516 float u_ZoomScale; 4517 float u_CheckboardStyle; 4518}; 4519 4520layout(location = 0) in vec2 a_FragCoord; 4521 4522#ifdef USE_INSTANCES 4523 layout(location = 14) in vec4 a_Abcd; 4524 layout(location = 15) in vec2 a_Txty; 4525 layout(location = 1) in vec4 a_PositionSize; 4526 layout(location = 2) in vec4 a_FillColor; 4527 layout(location = 3) in vec4 a_StrokeColor; 4528 layout(location = 4) in vec4 a_ZIndexStrokeWidth; 4529 layout(location = 5) in vec4 a_Opacity; 4530 layout(location = 6) in vec4 a_InnerShadowColor; 4531 layout(location = 7) in vec4 a_InnerShadow; 4532#else 4533 layout(std140) uniform ShapeUniforms { 4534 mat3 u_ModelMatrix; 4535 vec4 u_PositionSize; 4536 vec4 u_FillColor; 4537 vec4 u_StrokeColor; 4538 vec4 u_ZIndexStrokeWidth; 4539 vec4 u_Opacity; 4540 vec4 u_InnerShadowColor; 4541 vec4 u_InnerShadow; 4542 }; 4543#endif 4544 4545out vec2 v_FragCoord; 4546#ifdef USE_INSTANCES 4547 out vec4 v_FillColor; 4548 out vec4 v_StrokeColor; 4549 out float v_StrokeWidth; 4550 out vec4 v_Opacity; 4551 out float v_CornerRadius; 4552 out float v_StrokeAlignment; 4553 out vec4 v_InnerShadowColor; 4554 out vec4 v_InnerShadow; 4555#else 4556#endif 4557out vec2 v_Radius; 4558 4559#ifdef USE_FILLIMAGE 4560 out vec2 v_Uv; 4561#endif 4562 4563void main() { 4564 mat3 model; 4565 vec2 position; 4566 vec2 size; 4567 vec4 fillColor; 4568 vec4 strokeColor; 4569 float zIndex; 4570 float strokeWidth; 4571 float strokeAlignment; 4572 4573 #ifdef USE_INSTANCES 4574 model = mat3(a_Abcd.x, a_Abcd.y, 0, a_Abcd.z, a_Abcd.w, 0, a_Txty.x, a_Txty.y, 1); 4575 position = a_PositionSize.xy; 4576 size = a_PositionSize.zw; 4577 fillColor = a_FillColor; 4578 strokeColor = a_StrokeColor; 4579 zIndex = a_ZIndexStrokeWidth.x; 4580 strokeWidth = a_ZIndexStrokeWidth.y; 4581 strokeAlignment = a_ZIndexStrokeWidth.w; 4582 4583 v_FillColor = fillColor; 4584 v_StrokeColor = strokeColor; 4585 v_StrokeWidth = strokeWidth; 4586 v_Opacity = a_Opacity; 4587 v_CornerRadius = a_ZIndexStrokeWidth.z; 4588 v_StrokeAlignment = a_ZIndexStrokeWidth.w; 4589 v_InnerShadowColor = a_InnerShadowColor; 4590 v_InnerShadow = a_InnerShadow; 4591 #else 4592 model = u_ModelMatrix; 4593 position = u_PositionSize.xy; 4594 size = u_PositionSize.zw; 4595 fillColor = u_FillColor; 4596 strokeColor = u_StrokeColor; 4597 zIndex = u_ZIndexStrokeWidth.x; 4598 strokeWidth = u_ZIndexStrokeWidth.y; 4599 strokeAlignment = u_ZIndexStrokeWidth.w; 4600 #endif 4601 4602 float strokeOffset; 4603 if (strokeAlignment < 0.5) { 4604 strokeOffset = strokeWidth / 2.0; 4605 } else if (strokeAlignment < 1.5) { 4606 strokeOffset = 0.0; 4607 } else if (strokeAlignment < 2.5) { 4608 strokeOffset = strokeWidth; 4609 } 4610 4611 vec2 radius = size + vec2(strokeOffset); 4612 4613 v_FragCoord = vec2(a_FragCoord * radius); 4614 v_Radius = radius; 4615 4616 #ifdef USE_FILLIMAGE 4617 v_Uv = (a_FragCoord * radius / size + 1.0) / 2.0; 4618 #endif 4619 4620 gl_Position = vec4((u_ProjectionMatrix 4621 * u_ViewMatrix 4622 * model 4623 * vec3(position + v_FragCoord, 1)).xy, zIndex, 1); 4624} 4625`,lWt=` 4626layout(std140) uniform SceneUniforms { 4627 mat3 u_ProjectionMatrix; 4628 mat3 u_ViewMatrix; 4629 mat3 u_ViewProjectionInvMatrix; 4630 vec4 u_BackgroundColor; 4631 vec4 u_GridColor; 4632 float u_ZoomScale; 4633 float u_CheckboardStyle; 4634}; 4635 4636#ifdef USE_INSTANCES 4637#else 4638 layout(std140) uniform ShapeUniforms { 4639 mat3 u_ModelMatrix; 4640 vec4 u_PositionSize; 4641 vec4 u_FillColor; 4642 vec4 u_StrokeColor; 4643 vec4 u_ZIndexStrokeWidth; 4644 vec4 u_Opacity; 4645 vec4 u_InnerShadowColor; 4646 vec4 u_InnerShadow; 4647 }; 4648#endif 4649 4650out vec4 outputColor; 4651 4652in vec2 v_FragCoord; 4653#ifdef USE_INSTANCES 4654 in vec4 v_FillColor; 4655 in vec4 v_StrokeColor; 4656 in float v_StrokeWidth; 4657 in vec4 v_Opacity; 4658 in float v_CornerRadius; 4659 in float v_StrokeAlignment; 4660 in vec4 v_InnerShadowColor; 4661 in vec4 v_InnerShadow; 4662#else 4663#endif 4664in vec2 v_Radius; 4665 4666#ifdef USE_FILLIMAGE 4667 in vec2 v_Uv; 4668 uniform sampler2D u_Texture; 4669#endif 4670 4671float epsilon = 0.000001; 4672 4673float sdf_circle(vec2 p, float r) { 4674 return length(p) - r; 4675} 4676 4677float sdf_ellipse(vec2 p, vec2 r) {
4678 float k0 = length(p / r); 4679 float k1 = length(p / (r * r)); 4680 return k0 * (k0 - 1.0) / k1; 4681 4682 // V1 4683 // float k1 = length(p/r); 4684 // return (k1-1.0)*min(r.x,r.y); 4685 4686 // V3 4687 // float k1 = length(p/r); 4688 // return length(p)*(1.0-1.0/k1); 4689} 4690 4691float sdf_rounded_box(vec2 p, vec2 b, float r) { 4692 vec2 q = abs(p) - b + r; 4693 return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r; 4694} 4695 4696vec4 over(vec4 below, vec4 above) { 4697 vec4 result; 4698 float alpha = above.a + below.a * (1.0 - above.a); 4699 result.rgb = 4700 (above.rgb * above.a + below.rgb * below.a * (1.0 - above.a)) / alpha; 4701 result.a = alpha; 4702 return result; 4703} 4704 4705float antialias(float distance) { 4706 return clamp(distance / -fwidth(distance), 0.0, 1.0); 4707} 4708 4709vec4 mix_border_inside(vec4 border, vec4 inside, float distance) { 4710 // Blend the border on top of the background and then linearly interpolate 4711 // between the two as we slide inside the background. 4712 return mix(border, inside, clamp(1.0 - distance, 0.0, 1.0) * antialias(distance)); 4713} 4714 4715float sigmoid(float t) { 4716 return 1.0 / (1.0 + exp(-t)); 4717} 4718 4719float make_shadow(vec2 pos, vec2 halfSize, float cornerRd, float blurRd, float distMul, float shape) { 4720 float distance; 4721 if (shape < 0.5) { 4722 distance = sdf_circle(pos, halfSize.x); 4723 } else if (shape < 1.5) { 4724 distance = sdf_ellipse(pos, halfSize); 4725 } else if (shape < 2.5) { 4726 distance = sdf_rounded_box(pos, halfSize, cornerRd + blurRd); 4727 } 4728 float dist = sigmoid(distMul * distance / blurRd); 4729 return clamp(dist, 0.0, 1.0); 4730} 4731 4732void main() { 4733 float strokeWidth; 4734 vec4 fillColor; 4735 vec4 strokeColor; 4736 float opacity; 4737 float fillOpacity; 4738 float strokeOpacity; 4739 float shape; 4740 float cornerRadius; 4741 vec4 innerShadowColor; 4742 vec4 innerShadow; 4743 float strokeAlignment; 4744 4745 #ifdef USE_INSTANCES 4746 fillColor = v_FillColor; 4747 strokeColor = v_StrokeColor; 4748 strokeWidth = v_StrokeWidth; 4749 opacity = v_Opacity.x; 4750 fillOpacity = v_Opacity.y; 4751 strokeOpacity = v_Opacity.z; 4752 shape = v_Opacity.w; 4753 cornerRadius = v_CornerRadius; 4754 strokeAlignment = v_StrokeAlignment; 4755 innerShadowColor = v_InnerShadowColor; 4756 innerShadow = v_InnerShadow; 4757 #else 4758 fillColor = u_FillColor; 4759 strokeColor = u_StrokeColor; 4760 strokeWidth = u_ZIndexStrokeWidth.y; 4761 opacity = u_Opacity.x; 4762 fillOpacity = u_Opacity.y; 4763 strokeOpacity = u_Opacity.z; 4764 shape = u_Opacity.w; 4765 cornerRadius = u_ZIndexStrokeWidth.z; 4766 strokeAlignment = u_ZIndexStrokeWidth.w; 4767 innerShadowColor = u_InnerShadowColor; 4768 innerShadow = u_InnerShadow; 4769 #endif 4770 4771 #ifdef USE_FILLIMAGE 4772 bool useFillImage = innerShadow.w > 0.5; 4773 if (useFillImage) { 4774 fillColor = texture(SAMPLER_2D(u_Texture), v_Uv); 4775 } 4776 #endif 4777 4778 float distance; 4779 // 'circle', 'ellipse', 'rect' 4780 if (shape < 0.5) { 4781 distance = sdf_circle(v_FragCoord, v_Radius.x); 4782 } else if (shape < 1.5) { 4783 distance = sdf_ellipse(v_FragCoord, v_Radius); 4784 } else if (shape < 2.5) { 4785 distance = sdf_rounded_box(v_FragCoord, v_Radius, cornerRadius); 4786 // TODO: Fast path when the quad is not rounded and doesn't have any border. 4787 } 4788 4789 // based on the target alpha compositing mode. 4790 fillColor.a *= fillOpacity; 4791 strokeColor.a *= strokeOpacity; 4792 4793 vec4 color = fillColor; 4794 if (strokeWidth > 0.0) { 4795 float d1; 4796 float d2; 4797 if (strokeAlignment < 0.5) { 4798 d1 = distance + strokeWidth; 4799 d2 = distance + strokeWidth / 2.0; 4800 color = mix_border_inside(over(fillColor, strokeColor), fillColor, d1); 4801 color = mix_border_inside(strokeColor, color, d2); 4802 } else if (strokeAlignment < 1.5) { 4803 d1 = distance + strokeWidth; 4804 d2 = distance; 4805 color = mix_border_inside(over(fillColor, strokeColor), fillColor, d1); 4806 color = mix_border_inside(strokeColor, color, d2); 4807 } else if (strokeAlignment < 2.5) { 4808 d2 = distance + strokeWidth; 4809 color = mix_border_inside(strokeColor, color, d2); 4810 } 4811 } 4812 outputColor = color; 4813 4814 float innerShadowBlurRadius = innerShadow.z / 2.0; 4815 if (innerShadowBlurRadius > 0.0) { 4816 vec2 shadowOffset = -innerShadow.xy; 4817 float blurRadius = innerShadow.z; 4818 float distMul = -1.0; 4819 float lowerShadow = make_shadow(v_FragCoord + shadowOffset, v_Radius, cornerRadius, blurRadius, distMul, shape); 4820 4821 vec3 lowerShadowColor = innerShadowColor.rgb * innerShadowColor.a; 4822 outputColor = over(vec4(color.xyz, 1.0), vec4(lowerShadowColor, 1.0 - lowerShadow)); 4823 outputColor = over(outputColor, vec4(color.xyz, clamp(distance, 0.0, 1.0))); 4824 } 4825 4826 float antialiasedBlur = -fwidth(length(v_FragCoord)); 4827 float opacity_t = clamp(distance / antialiasedBlur, 0.0, 1.0); 4828 outputColor.a *= clamp(1.0 - distance, 0.0, 1.0) * opacity * opacity_t; 4829 4830 if (outputColor.a < epsilon) 4831 discard; 4832} 4833`;var os=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},ng=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
4833return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},ag,PM,Rb,Cb,Ck,KA,qA,ZA,a8,Mk;const cWt={center:0,inner:1,outer:2};let V7=class iY extends z7{constructor(){super(...arguments),ag.set(this,void 0),PM.set(this,void 0),Rb.set(this,void 0),Cb.set(this,void 0),Ck.set(this,void 0),KA.set(this,void 0),qA.set(this,void 0),ZA.set(this,void 0),a8.set(this,void 0),Mk.set(this,void 0)}static useDash(e){const{strokeDasharray:r}=e;return r.length>0&&r.some(i=>i>0)}get useFillImage(){const{fill:e}=this.shapes[0];return!N0(e)}validate(e){if(!super.validate(e))return!1;if(this.shapes.length===0)return!0;const r=!N0(this.shapes[0].fill),i=!N0(e.fill);return r!==i?!1:r&&i?this.shapes[0].fill===e.fill:iY.useDash(e)===iY.useDash(this.shapes[0])}createGeometry(){os(this,PM,"f")||(ng(this,PM,this.device.createBuffer({viewOrSize:new Float32Array([-1,-1,1,-1,1,1,-1,1]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),ng(this,Ck,this.device.createBuffer({viewOrSize:new Uint32Array([0,1,2,0,2,3]),usage:dt.INDEX,hint:Et.STATIC}),"f")),this.instanced&&(os(this,Rb,"f")&&os(this,Rb,"f").destroy(),ng(this,Rb,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*28*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),os(this,Cb,"f")&&os(this,Cb,"f").destroy(),ng(this,Cb,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*6*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"))}createMaterial(e){let r="";this.instanced&&(r+=`#define USE_INSTANCES 4834`),this.useFillImage&&(r+=`#define USE_FILLIMAGE 4835`),os(this,ag,"f")&&(os(this,ag,"f").destroy(),os(this,ZA,"f").destroy(),os(this,qA,"f").destroy());const i=this.device.queryVendorInfo().platformString==="WebGPU"?`diagnostic(off,derivative_uniformity); 4836`:"";ng(this,ag,this.renderCache.createProgram({vertex:{glsl:r+aWt},fragment:{glsl:r+lWt,postprocess:n=>i+n}}),"f");const s=[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:0,offset:0,format:I.F32_RG}]}];this.instanced?(s.push({arrayStride:112,stepMode:ne.INSTANCE,attributes:[{shaderLocation:1,offset:0,format:I.F32_RGBA},{shaderLocation:2,offset:16,format:I.F32_RGBA},{shaderLocation:3,offset:32,format:I.F32_RGBA},{shaderLocation:4,offset:48,format:I.F32_RGBA},{shaderLocation:5,offset:64,format:I.F32_RGBA},{shaderLocation:6,offset:80,format:I.F32_RGBA},{shaderLocation:7,offset:96,format:I.F32_RGBA}]},{arrayStride:24,stepMode:ne.INSTANCE,attributes:[{shaderLocation:14,offset:0,format:I.F32_RGBA},{shaderLocation:15,offset:16,format:I.F32_RG}]}),ng(this,ZA,this.renderCache.createInputLayout({vertexBufferDescriptors:s,indexBufferFormat:I.U32_R,program:os(this,ag,"f")}),"f")):(ng(this,ZA,this.renderCache.createInputLayout({vertexBufferDescriptors:s,indexBufferFormat:I.U32_R,program:os(this,ag,"f")}),"f"),os(this,KA,"f")||ng(this,KA,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*40,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f")),ng(this,qA,this.renderCache.createRenderPipeline({inputLayout:os(this,ZA,"f"),program:os(this,ag,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],blendConstant:kn,depthWrite:!0,depthCompare:qe.GREATER,stencilWrite:!1,stencilFront:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP},stencilBack:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP}}}),"f"),this.device.setResourceName(os(this,qA,"f"),"SDFPipeline");const o={pipeline:os(this,qA,"f"),uniformBufferBindings:[{buffer:e}]};if(this.instanced||o.uniformBufferBindings.push({buffer:os(this,KA,"f")}),this.useFillImage){const n=this.shapes[0].fill,a=this.device.createTexture({format:I.U8_RGBA_NORM,width:n.width,height:n.height,usage:xr.SAMPLED});a.setImageData([n]),ng(this,Mk,a,"f");const l=this.renderCache.createSampler({addressModeU:Zn.CLAMP_TO_EDGE,addressModeV:Zn.CLAMP_TO_EDGE,minFilter:io.POINT,magFilter:io.BILINEAR,mipmapFilter:xn.LINEAR,lodMinClamp:0,lodMaxClamp:0});o.samplerBindings=[{texture:a,sampler:l}]}ng(this,a8,this.renderCache.createBindings(o),"f")}render(e,r){if(this.shapes.some(s=>s.renderDirtyFlag)||this.geometryDirty)if(this.instanced){os(this,Cb,"f").setSubData(0,new Uint8Array(new Float32Array(this.shapes.map(o=>[o.worldTransform.a,o.worldTransform.b,o.worldTransform.c,o.worldTransform.d,o.worldTransform.tx,o.worldTransform.ty]).flat()).buffer));const s=[];
4836this.shapes.forEach(o=>{const[n]=this.generateBuffer(o);s.push(...n)}),os(this,Rb,"f").setSubData(0,new Uint8Array(new Float32Array(s).buffer))}else{const{worldTransform:s}=this.shapes[0],[o,n]=this.generateBuffer(this.shapes[0]),a=s.toArray(!0);os(this,KA,"f").setSubData(0,new Uint8Array(new Float32Array([...MM(a),...o]).buffer));const l=Object.assign({u_ModelMatrix:a},n);this.useFillImage&&(l.u_FillImage=os(this,Mk,"f")),os(this,ag,"f").setUniformsLegacy(l)}const i=[{buffer:os(this,PM,"f")}];this.instanced&&i.push({buffer:os(this,Rb,"f")},{buffer:os(this,Cb,"f")}),os(this,ag,"f").setUniformsLegacy(r),e.setPipeline(os(this,qA,"f")),e.setVertexInput(os(this,ZA,"f"),i,{buffer:os(this,Ck,"f")}),e.setBindings(os(this,a8,"f")),e.drawIndexed(6,this.shapes.length)}destroy(){var e,r,i,s,o,n;os(this,ag,"f")&&((e=os(this,Cb,"f"))===null||e===void 0||e.destroy(),(r=os(this,Rb,"f"))===null||r===void 0||r.destroy(),(i=os(this,PM,"f"))===null||i===void 0||i.destroy(),(s=os(this,Ck,"f"))===null||s===void 0||s.destroy(),(o=os(this,KA,"f"))===null||o===void 0||o.destroy(),(n=os(this,Mk,"f"))===null||n===void 0||n.destroy())}generateBuffer(e){const{fillRGB:r,strokeRGB:{r:i,g:s,b:o,opacity:n},strokeWidth:a,strokeAlignment:l,opacity:c,fillOpacity:h,strokeOpacity:u,innerShadowColorRGB:{r:d,g:f,b:g,opacity:p},innerShadowOffsetX:m,innerShadowOffsetY:v,innerShadowBlurRadius:b}=e;let y=[0,0,0,0],_=0,w=0;if(e instanceof k0){const{cx:H,cy:N,r:G}=e;y=[H,N,G,G],_=0}else if(e instanceof L0){const{cx:H,cy:N,rx:G,ry:Y}=e;y=[H,N,G,Y],_=1}else if(e instanceof Km){const{x:H,y:N,width:G,height:Y,cornerRadius:q}=e;y=[H+G/2,N+Y/2,G/2,Y/2],_=2,w=q}const{r:E,g:A,b:x,opacity:S}=r||{},T=y,R=[E/255,A/255,x/255,S],B=[i/255,s/255,o/255,n],O=[e.globalRenderOrder/X7,iY.useDash(e)?0:a,w,cWt[l]],C=[c,h,u,_],F=[d/255,f/255,g/255,p],U=[m,v,b,r?0:1];return[[...T,...R,...B,...O,...C,...F,...U],{u_PositionSize:T,u_FillColor:R,u_StrokeColor:B,u_ZIndexStrokeWidth:O,u_Opacity:C,u_InnerShadowColor:F,u_InnerShadow:U}]}};ag=new WeakMap,PM=new WeakMap,Rb=new WeakMap,Cb=new WeakMap,Ck=new WeakMap,KA=new WeakMap,qA=new WeakMap,ZA=new WeakMap,a8=new WeakMap,Mk=new WeakMap;const hWt=` 4837layout(std140) uniform SceneUniforms { 4838 mat3 u_ProjectionMatrix; 4839 mat3 u_ViewMatrix; 4840 mat3 u_ViewProjectionInvMatrix; 4841 vec4 u_BackgroundColor; 4842 vec4 u_GridColor; 4843 float u_ZoomScale; 4844 float u_CheckboardStyle; 4845}; 4846 4847layout(location = 0) in vec2 a_FragCoord; 4848 4849#ifdef USE_INSTANCES 4850 layout(location = 14) in vec4 a_Abcd; 4851 layout(location = 15) in vec2 a_Txty; 4852 layout(location = 1) in vec4 a_PositionSize; 4853 layout(location = 4) in vec4 a_ZIndexStrokeWidth; 4854 layout(location = 5) in vec4 a_DropShadowColor; 4855 layout(location = 6) in vec4 a_DropShadow; 4856#else 4857 layout(std140) uniform ShapeUniforms { 4858 mat3 u_ModelMatrix; 4859 vec4 u_PositionSize; 4860 vec4 u_ZIndexStrokeWidth; 4861 vec4 u_DropShadowColor; 4862 vec4 u_DropShadow; 4863 }; 4864#endif 4865 4866out vec2 v_Origin; 4867#ifdef USE_INSTANCES 4868 out float v_CornerRadius; 4869 out vec4 v_DropShadowColor; 4870 out vec4 v_DropShadow; 4871#else 4872#endif 4873out vec2 v_Size; 4874out vec2 v_Point; 4875 4876void main() { 4877 mat3 model; 4878 vec2 origin; 4879 vec2 size; 4880 float zIndex; 4881 vec4 dropShadow; 4882 4883 #ifdef USE_INSTANCES 4884 model = mat3(a_Abcd.x, a_Abcd.y, 0, a_Abcd.z, a_Abcd.w, 0, a_Txty.x, a_Txty.y, 1); 4885 origin = a_PositionSize.xy; 4886 size = a_PositionSize.zw; 4887 zIndex = a_ZIndexStrokeWidth.x; 4888 dropShadow = a_DropShadow; 4889 v_CornerRadius = a_ZIndexStrokeWidth.z; 4890 v_DropShadowColor = a_DropShadowColor; 4891 v_DropShadow = dropShadow; 4892 #else 4893 model = u_ModelMatrix; 4894 origin = u_PositionSize.xy; 4895 size = u_PositionSize.zw; 4896 zIndex = u_ZIndexStrokeWidth.x; 4897 dropShadow = u_DropShadow; 4898 #endif 4899 4900 // Set the bounds of the shadow and adjust its size based on the shadow's 4901 // spread radius to achieve the spreading effect 4902 float margin = 3.0 * dropShadow.z; 4903 origin += dropShadow.xy; 4904 v_Origin = origin; 4905 v_Size = size; 4906 4907 origin -= margin; 4908 size += 2.0 * margin; 4909 vec2 center = origin + size / 2.0; 4910 v_Point = center + a_FragCoord * (size / 2.0); 4911 4912 gl_Position = vec4((u_ProjectionMatrix
4913 * u_ViewMatrix 4914 * model 4915 * vec3(v_Point, 1)).xy, zIndex, 1); 4916} 4917`,uWt=` 4918layout(std140) uniform SceneUniforms { 4919 mat3 u_ProjectionMatrix; 4920 mat3 u_ViewMatrix; 4921 mat3 u_ViewProjectionInvMatrix; 4922 vec4 u_BackgroundColor; 4923 vec4 u_GridColor; 4924 float u_ZoomScale; 4925 float u_CheckboardStyle; 4926}; 4927 4928#ifdef USE_INSTANCES 4929#else 4930 layout(std140) uniform ShapeUniforms { 4931 mat3 u_ModelMatrix; 4932 vec4 u_PositionSize; 4933 vec4 u_ZIndexStrokeWidth; 4934 vec4 u_DropShadowColor; 4935 vec4 u_DropShadow; 4936 }; 4937#endif 4938 4939out vec4 outputColor; 4940 4941in vec2 v_Origin; 4942#ifdef USE_INSTANCES 4943 in float v_CornerRadius; 4944 in vec4 v_DropShadowColor; 4945 in vec4 v_DropShadow; 4946#else 4947#endif 4948in vec2 v_Size; 4949in vec2 v_Point; 4950 4951float epsilon = 0.000001; 4952float PI = 3.1415926; 4953 4954// A standard gaussian function, used for weighting samples 4955float gaussian(float x, float sigma) { 4956 return exp(-(x * x) / (2. * sigma * sigma)) / (sqrt(2. * PI) * sigma); 4957} 4958 4959// This approximates the error function, needed for the gaussian integral 4960vec2 erf(vec2 x) { 4961 vec2 s = sign(x), a = abs(x); 4962 x = 1.0 + (0.278393 + (0.230389 + 0.078108 * (a * a)) * a) * a; 4963 x *= x; 4964 return s - s / (x * x); 4965} 4966 4967// @see https://raphlinus.github.io/graphics/2020/04/21/blurred-rounded-rects.html 4968// vec2 erf7(vec2 x) { 4969// x = x * sqrt(2. * PI); 4970// vec2 xx = x * x; 4971// x = x + (0.24295 + (0.03395 + 0.0104 * xx) * xx) * (x * xx); 4972// return x / sqrt(1.0 + x * x); 4973// } 4974 4975float rect_shadow(vec2 pixel_position, vec2 origin, vec2 size, float sigma) { 4976 vec2 bottom_right = origin + size; 4977 vec2 x_distance = vec2(pixel_position.x - origin.x, pixel_position.x - bottom_right.x); 4978 vec2 y_distance = vec2(pixel_position.y - origin.y, pixel_position.y - bottom_right.y); 4979 vec2 integral_x = 0.5 + 0.5 * erf(x_distance * (sqrt(0.5) / sigma)); 4980 vec2 integral_y = 0.5 + 0.5 * erf(y_distance * (sqrt(0.5) / sigma)); 4981 return (integral_x.x - integral_x.y) * (integral_y.x - integral_y.y); 4982} 4983 4984float blur_along_x(float x, float y, float sigma, float corner, vec2 half_size) { 4985 float delta = min(half_size.y - corner - abs(y), 0.0); 4986 float curved = half_size.x - corner + sqrt(max(0., corner * corner - delta * delta)); 4987 vec2 integral = 0.5 + 0.5 * erf((x + vec2(-curved, curved)) * (sqrt(0.5) / sigma)); 4988 return integral.y - integral.x; 4989} 4990 4991void main() { 4992 float cornerRadius; 4993 vec4 dropShadow; 4994 vec4 dropShadowColor; 4995 4996 #ifdef USE_INSTANCES 4997 cornerRadius = v_CornerRadius; 4998 dropShadowColor = v_DropShadowColor; 4999 dropShadow = v_DropShadow; 5000 #else 5001 cornerRadius = u_ZIndexStrokeWidth.z; 5002 dropShadowColor = u_DropShadowColor; 5003 dropShadow = u_DropShadow; 5004 #endif 5005 5006 float blur_radius = dropShadow.z; 5007 if (blur_radius > 0.0) { 5008 float alpha = 0.; 5009 vec2 point = v_Point; 5010 5011 if (cornerRadius > 0.0) { 5012 vec2 half_size = v_Size / 2.0; 5013 vec2 center = v_Origin + half_size; 5014 vec2 center_to_point = point - center; 5015 5016 // The signal is only non-zero in a limited range, so don't waste samples 5017 float low = center_to_point.y - half_size.y; 5018 float high = center_to_point.y + half_size.y; 5019 float start = clamp(-3. * blur_radius, low, high); 5020 float end = clamp(3. * blur_radius, low, high); 5021 5022 // Accumulate samples (we can get away with surprisingly few samples) 5023 float step = (end - start) / 4.; 5024 float y = start + step * 0.5; 5025 5026 for (int i = 0; i < 4; i++) { 5027 alpha += blur_along_x(center_to_point.x, center_to_point.y - y, blur_radius, 5028 cornerRadius, half_size) * 5029 gaussian(y, blur_radius) * step; 5030 y += step; 5031 } 5032 } else { 5033 alpha = rect_shadow(point, v_Origin, v_Size, blur_radius); 5034 } 5035 5036 outputColor = dropShadowColor; 5037 outputColor.a = alpha; 5038 } else { 5039 discard; 5040 } 5041} 5042`;var Fi=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},lg=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
5042return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Tf,FM,Mb,Bb,Bk,JA,Ob,Ib,NM;let dWt=class extends z7{constructor(){super(...arguments),Tf.set(this,void 0),FM.set(this,void 0),Mb.set(this,void 0),Bb.set(this,void 0),Bk.set(this,void 0),JA.set(this,void 0),Ob.set(this,void 0),Ib.set(this,void 0),NM.set(this,void 0)}static check(t){return t instanceof Km&&t.dropShadowBlurRadius>0}createGeometry(){Fi(this,FM,"f")||(lg(this,FM,this.device.createBuffer({viewOrSize:new Float32Array([-1,-1,1,-1,1,1,-1,1]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),lg(this,Bk,this.device.createBuffer({viewOrSize:new Uint32Array([0,1,2,0,2,3]),usage:dt.INDEX,hint:Et.STATIC}),"f")),this.instanced&&(Fi(this,Mb,"f")&&Fi(this,Mb,"f").destroy(),lg(this,Mb,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*16*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),Fi(this,Bb,"f")&&Fi(this,Bb,"f").destroy(),lg(this,Bb,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*6*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"))}createMaterial(t){let e="";this.instanced&&(e+=`#define USE_INSTANCES 5043`),Fi(this,Tf,"f")&&(Fi(this,Tf,"f").destroy(),Fi(this,Ib,"f").destroy(),Fi(this,Ob,"f").destroy()),lg(this,Tf,this.renderCache.createProgram({vertex:{glsl:e+hWt},fragment:{glsl:e+uWt}}),"f");const r=[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:0,offset:0,format:I.F32_RG}]}];this.instanced?(r.push({arrayStride:64,stepMode:ne.INSTANCE,attributes:[{shaderLocation:1,offset:0,format:I.F32_RGBA},{shaderLocation:4,offset:16,format:I.F32_RGBA},{shaderLocation:5,offset:32,format:I.F32_RGBA},{shaderLocation:6,offset:48,format:I.F32_RGBA}]},{arrayStride:24,stepMode:ne.INSTANCE,attributes:[{shaderLocation:14,offset:0,format:I.F32_RGBA},{shaderLocation:15,offset:16,format:I.F32_RG}]}),lg(this,Ib,this.renderCache.createInputLayout({vertexBufferDescriptors:r,indexBufferFormat:I.U32_R,program:Fi(this,Tf,"f")}),"f")):(lg(this,Ib,this.renderCache.createInputLayout({vertexBufferDescriptors:r,indexBufferFormat:I.U32_R,program:Fi(this,Tf,"f")}),"f"),Fi(this,JA,"f")||lg(this,JA,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*28,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f")),lg(this,Ob,this.renderCache.createRenderPipeline({inputLayout:Fi(this,Ib,"f"),program:Fi(this,Tf,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],blendConstant:kn,depthWrite:!1,depthCompare:qe.GREATER,stencilWrite:!1,stencilFront:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP},stencilBack:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP}}}),"f"),this.instanced?lg(this,NM,this.renderCache.createBindings({pipeline:Fi(this,Ob,"f"),uniformBufferBindings:[{buffer:t}]}),"f"):lg(this,NM,this.device.createBindings({pipeline:Fi(this,Ob,"f"),uniformBufferBindings:[{buffer:t},{buffer:Fi(this,JA,"f")}]}),"f")}render(t,e){if(this.shapes.some(i=>i.renderDirtyFlag)||this.geometryDirty)if(this.instanced){Fi(this,Bb,"f").setSubData(0,new Uint8Array(new Float32Array(this.shapes.map(s=>[s.worldTransform.a,s.worldTransform.b,s.worldTransform.c,s.worldTransform.d,s.worldTransform.tx,s.worldTransform.ty]).flat()).buffer));const i=[];this.shapes.forEach(s=>{const[o]=this.generateBuffer(s);i.push(...o)}),Fi(this,Mb,"f").setSubData(0,new Uint8Array(new Float32Array(i).buffer))}else{const{worldTransform:i}=this.shapes[0],[s,o]=this.generateBuffer(this.shapes[0]),n=i.toArray(!0);Fi(this,JA,"f").setSubData(0,new Uint8Array(new Float32Array([...MM(n),...s]).buffer));const a=Object.assign({u_ModelMatrix:n},o);Fi(this,Tf,"f").setUniformsLegacy(a)}const r=[{buffer:Fi(this,FM,"f")}];this.instanced&&r.push({buffer:Fi(this,Mb,"f")},{buffer:Fi(this,Bb,"f")}),Fi(this,Tf,"f").setUniformsLegacy(e),t.setPipeline(Fi(this,Ob,"f")),t.setVertexInput(Fi(this,Ib,"f"),r,{buffer:Fi(this,Bk,"f")}),t.setBindings(Fi(this,NM,"f")),t.drawIndexed(6,this.shapes.length)}destroy(){var t,e,r,i,s,o,n,a;Fi(this,Tf,"f")&&(Fi(this,Tf,"f").destroy(),(t=Fi(this,Bb,"f"))===null||t===void 0||t.destroy(),(e=Fi(this,Mb,"f"))===null||e===void 0||e.destroy(),(r=Fi(this,FM,"f"))===null||r===void 0||r.destroy(),(i=Fi(this,Bk,"f"))===null||i===void 0||i.destroy(),(s=Fi(this,JA,"f"))===null||s===void 0||s.destroy(),(o=Fi(this,Ob,"f"))===null||o===void 0||o.destroy(),(n=Fi(this,Ib,"f"))===null||n===void 0||n.destroy(),(a=Fi(this,NM,"f"))===null||a===void 0||a.destroy())}generateBuffer(t){const{x:e,y:r,width:i,height:s,strokeWidth:o,cornerRadius:n,dropShadowColorRGB:{r:a,g:l,b:c,opacity:h},dropShadowOffsetX:u,dropShadowOffsetY:d,dropShadowBlurRadius:f}=t,g=[e,r,i,s],p=[t.globalRenderOrder/X7,o,n,0],m=[a/255,l/255,c/255,h],v=[u,d,f,0];return[[...g,...p,...m,...v],{u_PositionSize:g,u_ZIndexStrokeWidth:p,u_DropShadowColor:m,u_DropShadow:v}]}};Tf=new WeakMap,FM=new WeakMap,Mb=new WeakMap,Bb=new WeakMap,Bk=new WeakMap,JA=new WeakMap,Ob=new WeakMap,Ib=new WeakMap,NM=new WeakMap;var th;(function(t){t[t.PREV=0]="PREV",t[t.POINTA=1]="POINTA",t[t.POINTB=2]="POINTB",t[t.NEXT=3]="NEXT",t[t.VERTEX_JOINT=4]="VERTEX_JOINT",t[t.VERTEX_NUM=5]="VERTEX_NUM",t[t.TRAVEL=6]="TRAVEL"})(th||(th={}));var hn;(function(t){t[t.NONE=0]="NONE",t[t.FILL=1]="FILL",t[t.JOINT_BEVEL=4]="JOINT_BEVEL",t[t.JOINT_MITER=8]="JOINT_MITER",t[t.JOINT_ROUND=12]="JOINT_ROUND",t[t.JOINT_CAP_BUTT=16]="JOINT_CAP_BUTT",t[t.JOINT_CAP_SQUARE=18]="JOINT_CAP_SQUARE",t[t.JOINT_CAP_ROUND=20]="JOINT_CAP_ROUND",t[t.FILL_EXPAND=24]="FILL_EXPAND",t[t.CAP_BUTT=32]="CAP_BUTT",t[t.CAP_SQUARE=64]="CAP_SQUARE",t[t.CAP_ROUND=96]="CAP_ROUND",t[t.CAP_BUTT2=128]="CAP_BUTT2"})(hn||(hn={}));const fWt=` 5044layout(std140) uniform SceneUniforms { 5045 mat3 u_ProjectionMatrix; 5046 mat3 u_ViewMatrix; 5047}; 5048 5049layout(location = ${th.PREV}) in vec2 a_Prev; 5050layout(location = ${th.POINTA}) in vec2 a_PointA; 5051layout(location = ${th.POINTB}) in vec2 a_PointB; 5052layout(location = ${th.NEXT}) in vec2 a_Next; 5053layout(location = ${th.VERTEX_JOINT}) in float a_VertexJoint; 5054layout(location = ${th.VERTEX_NUM}) in float a_VertexNum; 5055layout(location = ${th.TRAVEL}) in float a_Travel; 5056 5057layout(std140) uniform ShapeUniforms { 5058 mat3 u_ModelMatrix; 5059 vec4 u_StrokeColor; 5060 vec4 u_ZIndexStrokeWidth; 5061 vec4 u_Opacity; 5062 vec4 u_StrokeDash; 5063}; 5064 5065const float FILL = ${hn.FILL}.0; 5066const float BEVEL = ${hn.JOINT_BEVEL}.0; 5067const float MITER = ${hn.JOINT_MITER}.0; 5068const float ROUND = ${hn.JOINT_ROUND}.0; 5069const float JOINT_CAP_BUTT = ${hn.JOINT_CAP_BUTT}.0; 5070const float JOINT_CAP_SQUARE = ${hn.JOINT_CAP_SQUARE}.0; 5071const float JOINT_CAP_ROUND = ${hn.JOINT_CAP_ROUND}.0; 5072const float FILL_EXPAND = ${hn.FILL_EXPAND}.0; 5073const float CAP_BUTT = 1.0; 5074const float CAP_SQUARE = 2.0; 5075const float CAP_ROUND = 3.0; 5076const float CAP_BUTT2 = 4.0; 5077 5078const float expand = 1.0; 5079const float dpr = 2.0; 5080 5081out vec4 v_Distance; 5082out vec4 v_Arc; 5083out float v_Type; 5084out float v_Travel; 5085out float v_ScalingFactor; 5086#ifdef USE_INSTANCES 5087 out vec4 v_StrokeColor; 5088 out vec4 v_Opacity; 5089 out float v_StrokeAlignment; 5090#else 5091#endif 5092 5093vec2 doBisect( 5094 vec2 norm, float len, vec2 norm2, float len2, float dy, float inner 5095) { 5096 vec2 bisect = (norm + norm2) / 2.0; 5097 bisect /= dot(norm, bisect); 5098 if (inner > 0.5) { 5099 if (len < len2) { 5100 if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) { 5101 return dy * norm; 5102 } 5103 } else { 5104 if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) { 5105 return dy * norm; 5106 } 5107 } 5108 } 5109 return dy * bisect; 5110} 5111 5112void main() { 5113 mat3 model = u_ModelMatrix; 5114 vec4 strokeColor = u_StrokeColor; 5115 float zIndex = u_ZIndexStrokeWidth.x; 5116 float strokeWidth = u_ZIndexStrokeWidth.y; 5117 float strokeMiterlimit = u_ZIndexStrokeWidth.z; 5118 float strokeAlignment = u_ZIndexStrokeWidth.w; 5119 float sizeAttenuation = u_Opacity.w; 5120 5121 vec2 pointA = (model * vec3(a_PointA, 1.0)).xy;
5122 vec2 pointB = (model * vec3(a_PointB, 1.0)).xy; 5123 5124 vec2 xBasis = pointB - pointA; 5125 float len = length(xBasis); 5126 vec2 forward = xBasis / len; 5127 vec2 norm = vec2(forward.y, -forward.x); 5128 5129 float type = a_VertexJoint; 5130 float vertexNum = a_VertexNum; 5131 5132 float capType = floor(type / 32.0); 5133 type -= capType * 32.0; 5134 v_Arc = vec4(0.0); 5135 strokeWidth *= 0.5; 5136 float strokeAlignmentFactor = 2.0 * strokeAlignment - 1.0; 5137 5138 vec2 pos; 5139 5140 if (capType == CAP_ROUND) { 5141 if (vertexNum < 3.5) { 5142 gl_Position = vec4(0.0, 0.0, 0.0, 1.0); 5143 return; 5144 } 5145 type = JOINT_CAP_ROUND; 5146 capType = 0.0; 5147 } 5148 5149 if (type >= BEVEL) { 5150 float dy = strokeWidth + expand; 5151 float inner = 0.0; 5152 if (vertexNum >= 1.5) { 5153 dy = -dy; 5154 inner = 1.0; 5155 } 5156 5157 vec2 base, next, xBasis2, bisect; 5158 float flag = 0.0; 5159 float sign2 = 1.0; 5160 if (vertexNum < 0.5 || vertexNum > 2.5 && vertexNum < 3.5) { 5161 next = (model * vec3(a_Prev, 1.0)).xy; 5162 base = pointA; 5163 flag = type - floor(type / 2.0) * 2.0; 5164 sign2 = -1.0; 5165 } else { 5166 next = (model * vec3(a_Next, 1.0)).xy; 5167 base = pointB; 5168 if (type >= MITER && type < MITER + 3.5) { 5169 flag = step(MITER + 1.5, type); 5170 // check miter limit here? 5171 } 5172 } 5173 5174 xBasis2 = next - base; 5175 float len2 = length(xBasis2); 5176 vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2; 5177 float D = norm.x * norm2.y - norm.y * norm2.x; 5178 if (D < 0.0) { 5179 inner = 1.0 - inner; 5180 } 5181 norm2 *= sign2; 5182 5183 if (abs(strokeAlignmentFactor) > 0.01) { 5184 float shift = strokeWidth * strokeAlignmentFactor; 5185 pointA += norm * shift; 5186 pointB += norm * shift; 5187 if (abs(D) < 0.01) { 5188 base += norm * shift; 5189 } else { 5190 base += doBisect(norm, len, norm2, len2, shift, 0.0); 5191 } 5192 } 5193 5194 float collinear = step(0.0, dot(norm, norm2)); 5195 v_Type = 0.0; 5196 float dy2 = -1000.0; 5197 float dy3 = -1000.0; 5198 if (abs(D) < 0.01 && collinear < 0.5) { 5199 if (type >= ROUND && type < ROUND + 1.5) { 5200 type = JOINT_CAP_ROUND; 5201 } 5202 // TODO: BUTT here too 5203 } 5204 5205 if (vertexNum < 3.5) { 5206 if (abs(D) < 0.01) { 5207 pos = dy * norm; 5208 } else { 5209 if (flag < 0.5 && inner < 0.5) { 5210 pos = dy * norm; 5211 } else { 5212 pos = doBisect(norm, len, norm2, len2, dy, inner); 5213 } 5214 } 5215 if (capType >= CAP_BUTT && capType < CAP_ROUND) { 5216 float extra = step(CAP_SQUARE, capType) * strokeWidth; 5217 vec2 back = -forward; 5218 if (vertexNum < 0.5 || vertexNum > 2.5) { 5219 pos += back * (expand + extra); 5220 dy2 = expand; 5221 } else { 5222 dy2 = dot(pos + base - pointA, back) - extra; 5223 } 5224 } 5225 if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) { 5226 float extra = step(JOINT_CAP_SQUARE, type) * strokeWidth; 5227 if (vertexNum < 0.5 || vertexNum > 2.5) { 5228 dy3 = dot(pos + base - pointB, forward) - extra; 5229 } else { 5230 pos += forward * (expand + extra); 5231 dy3 = expand; 5232 if (capType >= CAP_BUTT) { 5233 dy2 -= expand + extra; 5234 } 5235 } 5236 } 5237 } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) { 5238 if (inner > 0.5) { 5239 dy = -dy; 5240 inner = 0.0; 5241 } 5242 vec2 d2 = abs(dy) * forward; 5243 if (vertexNum < 4.5) { 5244 dy = -dy; 5245 pos = dy * norm; 5246 } else if (vertexNum < 5.5) { 5247 pos = dy * norm; 5248 } else if (vertexNum < 6.5) { 5249 pos = dy * norm + d2; 5250 v_Arc.x = abs(dy); 5251 } else { 5252 dy = -dy; 5253 pos = dy * norm + d2; 5254 v_Arc.x = abs(dy); 5255 } 5256 dy2 = 0.0; 5257 v_Arc.y = dy; 5258 v_Arc.z = 0.0; 5259 v_Arc.w = strokeWidth; 5260 v_Type = 3.0; 5261 } else if (abs(D) < 0.01) { 5262 pos = dy * norm; 5263 } else { 5264 if (type >= ROUND && type < ROUND + 1.5) { 5265 if (inner > 0.5) { 5266 dy = -dy; 5267 inner = 0.0; 5268 } 5269 if (vertexNum < 4.5) { 5270 pos = doBisect(norm, len, norm2, len2, -dy, 1.0); 5271 } else if (vertexNum < 5.5) { 5272 pos = dy * norm; 5273 } else if (vertexNum > 7.5) { 5274 pos = dy * norm2; 5275 } else { 5276 pos = doBisect(norm, len, norm2, len2, dy, 0.0); 5277 float d2 = abs(dy); 5278 if (length(pos) > abs(dy) * 1.5) { 5279 if (vertexNum < 6.5) { 5280 pos.x = dy * norm.x - d2 * norm.y; 5281 pos.y = dy * norm.y + d2 * norm.x; 5282 } else { 5283 pos.x = dy * norm2.x + d2 * norm2.y; 5284 pos.y = dy * norm2.y - d2 * norm2.x; 5285 } 5286 } 5287 } 5288 vec2 norm3 = normalize(norm + norm2); 5289 5290 float sign = step(0.0, dy) * 2.0 - 1.0; 5291 v_Arc.x = sign * dot(pos, norm3); 5292 v_Arc.y = pos.x * norm3.y - pos.y * norm3.x; 5293 v_Arc.z = dot(norm, norm3) * strokeWidth; 5294 v_Arc.w = strokeWidth; 5295 5296 dy = -sign * dot(pos, norm); 5297 dy2 = -sign * dot(pos, norm2); 5298 dy3 = v_Arc.z - v_Arc.x; 5299 v_Type = 3.0; 5300 } else { 5301 float hit = 0.0; 5302 if (type >= BEVEL && type < BEVEL + 1.5) { 5303 if (dot(norm, norm2) > 0.0) { 5304 type = MITER; 5305 } 5306 } 5307 if (type >= MITER && type < MITER + 3.5) { 5308 if (inner > 0.5) { 5309 dy = -dy; 5310 inner = 0.0; 5311 } 5312 float sign = step(0.0, dy) * 2.0 - 1.0; 5313 pos = doBisect(norm, len, norm2, len2, dy, 0.0); 5314 if (length(pos) > abs(dy) * strokeMiterlimit) { 5315 type = BEVEL; 5316 } else { 5317 if (vertexNum < 4.5) { 5318 dy = -dy; 5319 pos = doBisect(norm, len, norm2, len2, dy, 1.0); 5320 } else if (vertexNum < 5.5) { 5321 pos = dy * norm; 5322 } else if (vertexNum > 6.5) { 5323 pos = dy * norm2; 5324 } 5325 v_Type = 1.0; 5326 dy = -sign * dot(pos, norm); 5327 dy2 = -sign * dot(pos, norm2); 5328 hit = 1.0; 5329 } 5330 } 5331 if (type >= BEVEL && type < BEVEL + 1.5) { 5332 if (inner > 0.5) { 5333 dy = -dy; 5334 inner = 0.0; 5335 } 5336 float d2 = abs(dy); 5337 vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x); 5338 vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x); 5339 if (vertexNum < 4.5) { 5340 pos = doBisect(norm, len, norm2, len2, -dy, 1.0); 5341 } else if (vertexNum < 5.5) { 5342 pos = dy * norm; 5343 } else if (vertexNum > 7.5) { 5344 pos = dy * norm2; 5345 } else { 5346 if (vertexNum < 6.5) { 5347 pos = pos3; 5348 } else { 5349 pos = pos4; 5350 } 5351 } 5352 vec2 norm3 = normalize(norm + norm2); 5353 float sign = step(0.0, dy) * 2.0 - 1.0; 5354 dy = -sign * dot(pos, norm); 5355 dy2 = -sign * dot(pos, norm2); 5356 dy3 = (-sign * dot(pos, norm3)) + strokeWidth; 5357 v_Type = 4.0; 5358 hit = 1.0; 5359 } 5360 if (hit < 0.5) { 5361 gl_Position = vec4(0.0, 0.0, 0.0, 1.0); 5362 return; 5363 } 5364 } 5365 } 5366 pos += base; 5367 v_Distance = vec4(dy, dy2, dy3, strokeWidth) * dpr; 5368 v_Arc *= dpr; 5369 v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x)); 5370 } 5371 5372 // v_ScalingFactor = sqrt(model[0][0] * model[0][0] + model[0][1] * model[0][1] + model[0][2] * model[0][2]); 5373 v_ScalingFactor = 1.0; 5374 5375 gl_Position = vec4((u_ProjectionMatrix
5376 * u_ViewMatrix 5377 * vec3(pos, 1)).xy, zIndex, 1); 5378} 5379`,pWt=` 5380layout(std140) uniform SceneUniforms { 5381 mat3 u_ProjectionMatrix; 5382 mat3 u_ViewMatrix; 5383}; 5384 5385layout(std140) uniform ShapeUniforms { 5386 mat3 u_ModelMatrix; 5387 vec4 u_StrokeColor; 5388 vec4 u_ZIndexStrokeWidth; 5389 vec4 u_Opacity; 5390 vec4 u_StrokeDash; 5391}; 5392 5393out vec4 outputColor; 5394 5395in vec4 v_Distance; 5396in vec4 v_Arc; 5397in float v_Type; 5398in float v_Travel; 5399in float v_ScalingFactor; 5400 5401float epsilon = 0.000001; 5402 5403float antialias(float distance) { 5404 return clamp(distance / fwidth(distance), 0.0, 1.0); 5405} 5406 5407float pixelLine(float x) { 5408 return clamp(x + 0.5, 0.0, 1.0); 5409} 5410// float pixelLine(float x, float A, float B) { 5411// float y = abs(x), s = sign(x); 5412// if (y * 2.0 < A - B) { 5413// return 0.5 + s * y / A; 5414// } 5415// y -= (A - B) * 0.5; 5416// y = max(1.0 - y / B, 0.0); 5417// return (1.0 + s * (1.0 - y * y)) * 0.5; 5418// //return clamp(x + 0.5, 0.0, 1.0); 5419// } 5420 5421void main() { 5422 vec4 strokeColor = u_StrokeColor; 5423 float opacity = u_Opacity.x; 5424 float strokeOpacity = u_Opacity.z; 5425 float strokeAlignment = u_ZIndexStrokeWidth.w; 5426 float alpha = 1.0; 5427 5428 float d1 = v_Distance.x; 5429 float d2 = v_Distance.y; 5430 float d3 = v_Distance.z; 5431 float w = v_Distance.w; 5432 5433 if (v_Type < 0.5) { 5434 float left = max(d1 - 0.5, -w); 5435 float right = min(d1 + 0.5, w); 5436 float near = d2 - 0.5; 5437 float far = min(d2 + 0.5, 0.0); 5438 float top = d3 - 0.5; 5439 float bottom = min(d3 + 0.5, 0.0); 5440 alpha = max(antialias(right - left), 0.0) * max(bottom - top, 0.0) * max(far - near, 0.0); 5441 } else if (v_Type < 1.5) { 5442 float a1 = pixelLine(d1 - w); 5443 float a2 = pixelLine(d1 + w); 5444 float b1 = pixelLine(d2 - w); 5445 float b2 = pixelLine(d2 + w); 5446 5447 float left = max(d1 - 0.5, -w); 5448 float right = min(d1 + 0.5, w); 5449 5450 alpha = antialias(a2 * b2 - a1 * b1); 5451 } else if (v_Type < 2.5) { 5452 alpha *= max(min(d1 + 0.5, 1.0), 0.0); 5453 alpha *= max(min(d2 + 0.5, 1.0), 0.0); 5454 alpha *= max(min(d3 + 0.5, 1.0), 0.0); 5455 } else if (v_Type < 3.5) { 5456 float a1 = pixelLine(d1 - w); 5457 float a2 = pixelLine(d1 + w); 5458 float b1 = pixelLine(d2 - w); 5459 float b2 = pixelLine(d2 + w); 5460 float alpha_miter = a2 * b2 - a1 * b1; 5461 float alpha_bevel = pixelLine(d3); 5462 5463 float r = length(v_Arc.xy); 5464 float circle_hor = pixelLine(w + r) - pixelLine(-w + r); 5465 float circle_vert = min(w * 2.0, 1.0); 5466 float alpha_circle = circle_hor * circle_vert;
5467 alpha = min(alpha_miter, max(alpha_circle, alpha_bevel)); 5468 } else { 5469 float a1 = pixelLine(d1 - w); 5470 float a2 = pixelLine(d1 + w); 5471 float b1 = pixelLine(d2 - w); 5472 float b2 = pixelLine(d2 + w); 5473 alpha = antialias(a2 * b2 - a1 * b1); 5474 alpha *= pixelLine(d3); 5475 } 5476 5477 float u_Dash = u_StrokeDash.x; 5478 float u_Gap = u_StrokeDash.y; 5479 float u_DashOffset = u_StrokeDash.z; 5480 if (u_Dash + u_Gap > 1.0) { 5481 float travel = mod(v_Travel + u_Gap * v_ScalingFactor * 0.5 + u_DashOffset, u_Dash * v_ScalingFactor + u_Gap * v_ScalingFactor) - (u_Gap * v_ScalingFactor * 0.5); 5482 float left = max(travel - 0.5, -0.5); 5483 float right = min(travel + 0.5, u_Gap * v_ScalingFactor + 0.5); 5484 alpha *= antialias(max(0.0, right - left)); 5485 } 5486 5487 outputColor = strokeColor; 5488 outputColor.a *= alpha * opacity * strokeOpacity; 5489 if (outputColor.a < epsilon) { 5490 discard; 5491 } 5492} 5493`;var si=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},U0=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},cg,QA,Db,Rf,Y7,$7,kM,tx,ex,rx,Ok;const gWt=1e-4,Ik=64,ix=2,aut=3,mWt={inner:0,center:.5,outer:1};let l8=class extends z7{constructor(){super(...arguments),cg.set(this,void 0),QA.set(this,void 0),Db.set(this,void 0),Rf.set(this,void 0),Y7.set(this,void 0),$7.set(this,void 0),kM.set(this,void 0),tx.set(this,void 0),ex.set(this,void 0),rx.set(this,void 0),Ok.set(this,void 0),this.indices=[],this.pointsBuffer=[],this.travelBuffer=[]}static check(t){return t instanceof HA||(t instanceof Km||t instanceof k0||t instanceof L0)&&t.strokeDasharray.length>0&&t.strokeDasharray.some(e=>e>0)}validate(t){return!1}get instanceCount(){const t=this.shapes[0];return t instanceof HA?this.pointsBuffer.length/aut-3:t instanceof Km?6:t instanceof k0||t instanceof L0?Ik+1:0}createGeometry(){this.instanced=!1;const t=[],e=[],r=[];let i=0;this.shapes.forEach(s=>{const{pointsBuffer:o,travelBuffer:n}=_Wt(s,!1);e.push(...o),r.push(...n),t.push(0+i,1+i,2+i,0+i,2+i,3+i,4+i,5+i,6+i,4+i,6+i,7+i,4+i,7+i,8+i),i+=9}),this.indices=t,this.pointsBuffer=e,this.travelBuffer=r,si(this,Rf,"f")&&si(this,Rf,"f").destroy(),U0(this,Rf,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*15*this.instanceCount*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),si(this,QA,"f")&&si(this,QA,"f").destroy(),U0(this,QA,this.device.createBuffer({viewOrSize:new Float32Array([0,1,2,3,4,5,6,7,8]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),si(this,Db,"f")&&si(this,Db,"f").destroy(),U0(this,Db,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*this.instanceCount,usage:dt.VERTEX,hint:Et.STATIC}),"f")}createMaterial(t){let e="";this.instanced&&(e+=`#define USE_INSTANCES 5494`),si(this,cg,"f")&&(si(this,cg,"f").destroy(),si(this,rx,"f").destroy(),si(this,ex,"f").destroy());const r=this.device.queryVendorInfo().platformString==="WebGPU"?`diagnostic(off,derivative_uniformity); 5495`:"";U0(this,cg,this.renderCache.createProgram({vertex:{glsl:e+fWt},fragment:{glsl:e+pWt,postprocess:s=>r+s}}),"f");const i=[{arrayStride:12,stepMode:ne.INSTANCE,attributes:[{format:I.F32_RG,offset:0,shaderLocation:th.PREV}]},{arrayStride:12,stepMode:ne.INSTANCE,attributes:[{format:I.F32_RG,offset:0,shaderLocation:th.POINTA}]},{arrayStride:12,stepMode:ne.INSTANCE,attributes:[{format:I.F32_R,offset:0,shaderLocation:th.VERTEX_JOINT}]},{arrayStride:12,stepMode:ne.INSTANCE,attributes:[{format:I.F32_RG,offset:0,shaderLocation:th.POINTB}]},{arrayStride:12,stepMode:ne.INSTANCE,attributes:[{format:I.F32_RG,offset:0,shaderLocation:th.NEXT}]},{arrayStride:4,stepMode:ne.VERTEX,attributes:[{format:I.F32_R,offset:0,shaderLocation:th.VERTEX_NUM}]}
5495,{arrayStride:4,stepMode:ne.INSTANCE,attributes:[{format:I.F32_R,offset:0,shaderLocation:th.TRAVEL}]}];si(this,tx,"f")||U0(this,tx,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*32,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),U0(this,rx,this.renderCache.createInputLayout({vertexBufferDescriptors:i,indexBufferFormat:I.U32_R,program:si(this,cg,"f")}),"f"),U0(this,ex,this.renderCache.createRenderPipeline({inputLayout:si(this,rx,"f"),program:si(this,cg,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],blendConstant:kn,depthWrite:!1,depthCompare:qe.GREATER,stencilWrite:!1,stencilFront:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP},stencilBack:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP}}}),"f"),U0(this,Ok,this.device.createBindings({pipeline:si(this,ex,"f"),uniformBufferBindings:[{buffer:t},{buffer:si(this,tx,"f")}]}),"f")}render(t,e){if(this.shapes.some(i=>i.renderDirtyFlag)||this.geometryDirty){const{worldTransform:i}=this.shapes[0],[s,o]=this.generateBuffer(this.shapes[0]),n=i.toArray(!0);si(this,tx,"f").setSubData(0,new Uint8Array(new Float32Array([...MM(n),...s]).buffer));const a=Object.assign({u_ModelMatrix:n},o);si(this,cg,"f").setUniformsLegacy(a),si(this,Rf,"f").setSubData(0,new Uint8Array(new Float32Array(this.pointsBuffer).buffer)),si(this,Db,"f").setSubData(0,new Uint8Array(new Float32Array(this.travelBuffer).buffer))}const r=[{buffer:si(this,Rf,"f")},{buffer:si(this,Rf,"f"),offset:12},{buffer:si(this,Rf,"f"),offset:20},{buffer:si(this,Rf,"f"),offset:24},{buffer:si(this,Rf,"f"),offset:36},{buffer:si(this,QA,"f")},{buffer:si(this,Db,"f")}];si(this,kM,"f")||U0(this,kM,this.device.createBuffer({viewOrSize:new Uint32Array(this.indices),usage:dt.INDEX,hint:Et.STATIC}),"f"),si(this,cg,"f").setUniformsLegacy(e),t.setPipeline(si(this,ex,"f")),t.setVertexInput(si(this,rx,"f"),r,{buffer:si(this,kM,"f")}),t.setBindings(si(this,Ok,"f")),t.drawIndexed(15,this.instanceCount)}destroy(){var t,e,r,i,s,o,n,a,l,c;si(this,cg,"f")&&(si(this,cg,"f").destroy(),(t=si(this,QA,"f"))===null||t===void 0||t.destroy(),(e=si(this,Db,"f"))===null||e===void 0||e.destroy(),(r=si(this,Rf,"f"))===null||r===void 0||r.destroy(),(i=si(this,$7,"f"))===null||i===void 0||i.destroy(),(s=si(this,Y7,"f"))===null||s===void 0||s.destroy(),(o=si(this,kM,"f"))===null||o===void 0||o.destroy(),(n=si(this,tx,"f"))===null||n===void 0||n.destroy(),(a=si(this,ex,"f"))===null||a===void 0||a.destroy(),(l=si(this,rx,"f"))===null||l===void 0||l.destroy(),(c=si(this,Ok,"f"))===null||c===void 0||c.destroy())}generateBuffer(t){const{strokeRGB:{r:e,g:r,b:i,opacity:s},strokeWidth:o,opacity:n,fillOpacity:a,strokeOpacity:l,strokeAlignment:c,strokeMiterlimit:h,strokeDasharray:u,strokeDashoffset:d,sizeAttenuation:f}=t,g=[e/255,r/255,i/255,s],p=[(t.globalRenderOrder+.1)/X7,o,h,mWt[c]],m=[n,a,l,f?1:0],v=[u&&u[0]||0,u&&u[1]||0,d||0,0];return[[...g,...p,...m,...v],{u_StrokeColor:g,u_ZIndexStrokeWidth:p,u_Opacity:m,u_StrokeDash:v}]}};cg=new WeakMap,QA=new WeakMap,Db=new WeakMap,Rf=new WeakMap,Y7=new WeakMap,$7=new WeakMap,kM=new WeakMap,tx=new WeakMap,ex=new WeakMap,rx=new WeakMap,Ok=new WeakMap;function yWt(t){let e;switch(t){case"bevel":e=hn.JOINT_BEVEL;break;case"round":e=hn.JOINT_ROUND;break;default:e=hn.JOINT_MITER;break}return e}function vWt(t){let e;switch(t){case"square":e=hn.CAP_SQUARE;break;case"round":e=hn.CAP_ROUND;break;default:e=hn.CAP_BUTT;break}return e}function _Wt(t,e=!1,r){const{strokeLinecap:i,strokeLinejoin:s}=t;let o=[];if(t instanceof HA)o=t.points.reduce((f,g)=>(f.push(g[0],g[1]),f),[]);else if(t instanceof Km){const{x:f,y:g,width:p,height:m}=t;o=[f,g,f+p,g,f+p,g+m,f,g+m,f,g,f+gWt,g]}else if(t instanceof k0){const{cx:f,cy:g,r:p}=t;for(let m=0;m<Ik;m++){const v=m/Ik*Math.PI*2;o.push(f+p*Math.cos(v),g+p*Math.sin(v))}o.push(f+p,g)}else if(t instanceof L0){const{cx:f,cy:g,rx:p,ry:m}=t;for(let v=0;v<Ik;v++){const b=v/Ik*Math.PI*2;o.push(f+p*Math.cos(b),g+m*Math.sin(b))}o.push(f+p,g)}const n=yWt(s),a=vWt(i);let l=a;
5495a===hn.CAP_ROUND&&(l=hn.JOINT_CAP_ROUND),a===hn.CAP_BUTT&&(l=hn.JOINT_CAP_BUTT),a===hn.CAP_SQUARE&&(l=hn.JOINT_CAP_SQUARE);const c=[];let h=0;for(let f=0;f<o.length;f+=ix)(isNaN(o[f])||isNaN(o[f+1]))&&(c.push(o.slice(h,f)),h=f+2);c.push(o.slice(h));const u=[],d=[];return c.forEach(f=>{const g=[],p=[];let m=(Math.round(0/ix)+2)*aut,v=0;for(let b=0;b<f.length;b+=ix)b>1&&(v+=Math.sqrt(Math.pow(f[b]-f[b-ix],2)+Math.pow(f[b+1]-f[b+1-ix],2))),p.push(v),g[m++]=f[b],g[m++]=f[b+1],g[m]=n,b==0?a!==hn.CAP_ROUND&&(g[m]+=a):(isNaN(f[b-2])||isNaN(f[b-1]))&&(g[m]+=hn.CAP_BUTT),b+ix*2>=f.length||isNaN(f[b+4])||isNaN(f[b+5])?g[m]+=l-n:(b+ix>=f.length||isNaN(f[b+2])||isNaN(f[b+3]))&&(g[m]=0),m++;g[m++]=f[f.length-4],g[m++]=f[f.length-3],g[m++]=0,g[0]=f[0],g[1]=f[1],g[2]=0,g[3]=f[2],g[4]=f[3],g[5]=a===hn.CAP_ROUND?a:0,u.push(...g),d.push(...p)}),{pointsBuffer:u,travelBuffer:d}}function Rs(t,e=0){return t+=e,t+=t<<10,t+=t>>>6,t>>>0}function lut(t){return t+=t<<3,t^=t>>>11,t+=t<<15,t>>>0}function H7(){return 0}let bWt=class{constructor(){this.keys=[],this.values=[]}},Dk=class{constructor(t,e){this.keyEqualFunc=t,this.keyHashFunc=e,this.buckets=new Map}findBucketIndex(t,e){for(let r=0;r<t.keys.length;r++)if(this.keyEqualFunc(e,t.keys[r]))return r;return-1}findBucket(t){const e=this.keyHashFunc(t);return this.buckets.get(e)}get(t){const e=this.findBucket(t);if(e===void 0)return null;const r=this.findBucketIndex(e,t);return r<0?null:e.values[r]}add(t,e){const r=this.keyHashFunc(t);this.buckets.get(r)===void 0&&this.buckets.set(r,new bWt);const i=this.buckets.get(r);i.keys.push(t),i.values.push(e)}delete(t){const e=this.findBucket(t);if(e===void 0)return;const r=this.findBucketIndex(e,t);r!==-1&&(e.keys.splice(r,1),e.values.splice(r,1))}clear(){this.buckets.clear()}size(){let t=0;for(const e of this.buckets.values())t+=e.values.length;return t}*values(){for(const t of this.buckets.values())for(let e=t.values.length-1;e>=0;e--)yield t.values[e]}};function cut(t,e){return t=Rs(t,e.blendMode),t=Rs(t,e.blendSrcFactor),t=Rs(t,e.blendDstFactor),t}function wWt(t,e){return t=cut(t,e.rgbBlendState),t=cut(t,e.alphaBlendState),t=Rs(t,e.channelWriteMask),t}function EWt(t,e){return t=Rs(t,e.r<<24|e.g<<16|e.b<<8|e.a),t}function AWt(t,e){var r,i,s,o,n,a,l,c;for(let h=0;h<e.attachmentsState.length;h++)t=wWt(t,e.attachmentsState[h]);return t=EWt(t,e.blendConstant||kn),t=Rs(t,e.depthCompare),t=Rs(t,e.depthWrite?1:0),t=Rs(t,(r=e.stencilFront)===null||r===void 0?void 0:r.compare),t=Rs(t,(i=e.stencilFront)===null||i===void 0?void 0:i.passOp),t=Rs(t,(s=e.stencilFront)===null||s===void 0?void 0:s.failOp),t=Rs(t,(o=e.stencilFront)===null||o===void 0?void 0:o.depthFailOp),t=Rs(t,(n=e.stencilBack)===null||n===void 0?void 0:n.compare),t=Rs(t,(a=e.stencilBack)===null||a===void 0?void 0:a.passOp),t=Rs(t,(l=e.stencilBack)===null||l===void 0?void 0:l.failOp),t=Rs(t,(c=e.stencilBack)===null||c===void 0?void 0:c.depthFailOp),t=Rs(t,e.stencilWrite?1:0),t=Rs(t,e.cullMode),t=Rs(t,e.frontFace?1:0),t=Rs(t,e.polygonOffset?1:0),t}function xWt(t){let e=0;e=Rs(e,t.program.id),t.inputLayout!==null&&(e=Rs(e,t.inputLayout.id)),e=AWt(e,t.megaStateDescriptor);for(let r=0;r<t.colorAttachmentFormats.length;r++)e=Rs(e,t.colorAttachmentFormats[r]||0);return e=Rs(e,t.depthStencilAttachmentFormat||0),lut(e)}function SWt(t){let e=0;if(t.pipeline&&(e=Rs(e,t.pipeline.id)),t.samplerBindings)for(let r=0;r<t.samplerBindings.length;r++){const i=t.samplerBindings[r];i!==null&&i.texture!==null&&(e=Rs(e,i.texture.id))}if(t.uniformBufferBindings)for(let r=0;r<t.uniformBufferBindings.length;r++){const i=t.uniformBufferBindings[r];i!==null&&i.buffer!==null&&(e=Rs(e,i.buffer.id),e=Rs(e,i.binding),e=Rs(e,i.offset),e=Rs(e,i.size))}if(t.storageBufferBindings)for(let r=0;r<t.storageBufferBindings.length;r++){const i=t.storageBufferBindings[r];i!==null&&i.buffer!==null&&(e=Rs(e,i.buffer.id),e=Rs(e,i.binding),e=Rs(e,i.offset),e=Rs(e,i.size))}if(t.storageTextureBindings)for(let r=0;r<t.storageTextureBindings.length;r++){const i=t.storageTextureBindings[r];i!==null&&i.texture!==null&&(e=Rs(e,i.texture.id),e=Rs(e,i.binding))}return lut(e)}function TWt(t,e){var r,i,s,o;return((r=t.vertex)===null||r===void 0?void 0:r.glsl)===((i=e.vertex)===null||i===void 0?void 0:i.glsl)&&((s=t.fragment)===null||s===void 0?void 0:s.glsl)===((o=e.fragment)===null||o===void 0?void 0:o.glsl)}function RWt(t){var e,r;return{vertex:{glsl:(e=t.vertex)===null||e===void 0?void 0:e.glsl},fragment:{glsl:(r=t.fragment)===null||r===void 0?void 0:r.glsl}}}let CWt=class{constructor(t){this.device=t,this.bindingsCache=new Dk(L4,SWt),this.renderPipelinesCache=new Dk(G4,xWt),this.inputLayoutsCache=new Dk(W4,H7),this.programCache=new Dk(TWt,H7),this.samplerCache=new Dk(j4,H7)}createBindings(t){let e=this.bindingsCache.get(t);if(e===null){const r=X4(t);e=this.device.createBindings(r),this.bindingsCache.add(r,e)}return e}createRenderPipeline(t){let e=this.renderPipelinesCache.get(t);if(e===null){const r=z4(t);r.colorAttachmentFormats=r.colorAttachmentFormats.filter(i=>i),e=this.device.createRenderPipeline(r),this.renderPipelinesCache.add(r,e)}return e}createInputLayout(t){t.vertexBufferDescriptors=t.vertexBufferDescriptors.filter(r=>!!r);let e=this.inputLayoutsCache.get(t);if(e===null){const r=V4(t);e=this.device.createInputLayout(r),this.inputLayoutsCache.add(r,e)}return e}createProgram(t){let e=this.programCache.get(t);if(e===null){const r=RWt(t);e=this.device.createProgram(t),this.programCache.add(r,e)}return e}createSampler(t){let e=this.samplerCache.get(t);return e===null&&(e=this.device.createSampler(t),this.samplerCache.add(t,e)),e}
5495destroy(){for(const t of this.bindingsCache.values())t.destroy();for(const t of this.renderPipelinesCache.values())t.destroy();for(const t of this.inputLayoutsCache.values())t.destroy();for(const t of this.programCache.values())t.destroy();for(const t of this.samplerCache.values())t.destroy();this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()}};var hut=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Bl=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Pb,sx,ox,c8,Pk;const Fk=new WeakMap;Fk.set(k0,[V7,l8]),Fk.set(L0,[V7,l8]),Fk.set(Km,[dWt,V7,l8]),Fk.set(HA,[l8]);let MWt=class{constructor(t){this.device=t,Pb.set(this,[]),sx.set(this,Object.create(null)),ox.set(this,Object.create(null)),c8.set(this,new WeakMap),Pk.set(this,void 0),hut(this,Pk,new CWt(t),"f")}createDrawcalls(t,e=!1){var r;return(r=Fk.get(t.constructor))===null||r===void 0?void 0:r.map(i=>{if(!i.check||i.check&&i.check(t)){const s=new i(this.device,Bl(this,Pk,"f"),e);return s.add(t),s}}).filter(i=>!!i)}getOrCreateNonBatchableDrawcalls(t){let e=Bl(this,sx,"f")[t.uid];return e||(e=this.createDrawcalls(t)||[],Bl(this,sx,"f")[t.uid]=e),e}getOrCreateBatchableDrawcalls(t){let e=Bl(this,ox,"f")[t.uid];if(!e){const r=t.constructor;let i=Bl(this,c8,"f").get(r);i||(i=[]),e=i.find(s=>s.every(o=>o.validate(t))),e||(e=this.createDrawcalls(t,!0)||[],i.push(e),Bl(this,c8,"f").set(r,i)),e.forEach(s=>{s.add(t)}),Bl(this,ox,"f")[t.uid]=e}return e}add(t){if(t.batchable){const e=this.getOrCreateBatchableDrawcalls(t);Bl(this,Pb,"f").indexOf(e[0])===-1&&Bl(this,Pb,"f").push(...e)}else Bl(this,Pb,"f").push(...this.getOrCreateNonBatchableDrawcalls(t))}remove(t){t.batchable?(this.getOrCreateBatchableDrawcalls(t).forEach(e=>{e.remove(t)}),delete Bl(this,ox,"f")[t.uid]):delete Bl(this,sx,"f")[t.uid]}destroy(){for(const t in Bl(this,sx,"f"))Bl(this,sx,"f")[t].forEach(e=>{e.destroy()});for(const t in Bl(this,ox,"f"))Bl(this,ox,"f")[t].forEach(e=>{e.destroy()});Bl(this,Pk,"f").destroy()}clear(){hut(this,Pb,[],"f")}flush(t,e,r){Bl(this,Pb,"f").forEach(i=>{i.submit(t,e,r)})}stats(){return{drawcallCount:Bl(this,Pb,"f").length}}};Pb=new WeakMap,sx=new WeakMap,ox=new WeakMap,c8=new WeakMap,Pk=new WeakMap;var uut=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},dr=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},ua=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},nx,Za,Fb,ax,lx,cx,LM,Nk,kk,Nb,Lk,hx,UM,h8,GM,Uk;(function(t){t[t.NONE=0]="NONE",t[t.GRID=1]="GRID",t[t.DOTS=2]="DOTS"})(Uk||(Uk={}));let BWt=class{constructor(){nx.set(this,void 0),Za.set(this,void 0),Fb.set(this,void 0),ax.set(this,void 0),lx.set(this,void 0),cx.set(this,void 0),LM.set(this,void 0),Nk.set(this,Uk.GRID),kk.set(this,void 0),Nb.set(this,void 0),Lk.set(this,1),hx.set(this,void 0),UM.set(this,void 0),h8.set(this,void 0),GM.set(this,void 0)}apply(t){const{hooks:e,canvas:r,renderer:i,shaderCompilerPath:s,devicePixelRatio:o,camera:n,backgroundColor:a,gridColor:l}=t,{r:c,g:h,b:u,opacity:d}=a?sr.rgb(a):{r:.986*255,g:.986*255,b:.986*255,opacity:1},{r:f,g,b:p,opacity:m}=l?sr.rgb(l):{r:.87*255,g:.87*255,b:.87*255,opacity:1},v=()=>{const b=n.projectionMatrix,y=n.viewMatrix,_=n.viewProjectionMatrixInv,w=[c/255,h/255,u/255,d],E=[f/255,g/255,p/255,m],A=n.zoom,x=dr(this,Nk,"f");return[new Float32Array([...MM(b),...MM(y),...MM(_),...w,...E,A,x,0,0]),{u_ProjectionMatrix:b,u_ViewM
5495atrix:y,u_ViewProjectionInvMatrix:_,u_BackgroundColor:w,u_GridColor:E,u_ZoomScale:A,u_CheckboardStyle:x}]};e.initAsync.tapPromise(()=>uut(this,void 0,void 0,function*(){let b;i==="webgl"?b=new hd({targets:["webgl2","webgl1"],antialias:!0,shaderDebug:!0,trackResources:!1,onContextCreationError:()=>{},onContextLost:()=>{},onContextRestored(x){}}):b=new ud({shaderCompilerPath:s,onContextLost:()=>{}});const{width:y,height:_}=r,w=yield b.createSwapChain(r);w.configureSwapChain(y,_),ua(this,nx,w,"f"),ua(this,Za,w.getDevice(),"f"),ua(this,Nb,new MWt(dr(this,Za,"f")),"f"),ua(this,Fb,dr(this,Za,"f").createRenderTargetFromTexture(dr(this,Za,"f").createTexture({format:I.U8_RGBA_RT,width:y,height:_,usage:xr.RENDER_TARGET})),"f"),ua(this,ax,dr(this,Za,"f").createRenderTargetFromTexture(dr(this,Za,"f").createTexture({format:I.D24_S8,width:y,height:_,usage:xr.RENDER_TARGET})),"f");const[E,A]=v();ua(this,cx,dr(this,Za,"f").createBuffer({viewOrSize:E,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),ua(this,LM,A,"f"),ua(this,kk,new tut,"f")})),e.resize.tap((b,y)=>{dr(this,nx,"f").configureSwapChain(b*o,y*o),dr(this,Fb,"f")&&(dr(this,Fb,"f").destroy(),ua(this,Fb,dr(this,Za,"f").createRenderTargetFromTexture(dr(this,Za,"f").createTexture({format:I.U8_RGBA_RT,width:b*o,height:y*o,usage:xr.RENDER_TARGET})),"f"),dr(this,ax,"f").destroy(),ua(this,ax,dr(this,Za,"f").createRenderTargetFromTexture(dr(this,Za,"f").createTexture({format:I.D24_S8,width:b*o,height:y*o,usage:xr.RENDER_TARGET})),"f"))}),e.destroy.tap(()=>{dr(this,Nb,"f").destroy(),dr(this,cx,"f").destroy(),dr(this,kk,"f").destroy(),dr(this,Fb,"f").destroy(),dr(this,ax,"f").destroy(),dr(this,Za,"f").destroy(),dr(this,Za,"f").checkForLeaks()}),e.beginFrame.tap(()=>{var b;const{width:y,height:_}=dr(this,nx,"f").getCanvas(),w=dr(this,nx,"f").getOnscreenTexture(),[E,A]=v();dr(this,cx,"f").setSubData(0,new Uint8Array(E.buffer)),ua(this,LM,A,"f"),dr(this,Za,"f").beginFrame(),ua(this,lx,dr(this,Za,"f").createRenderPass({colorAttachment:[dr(this,Fb,"f")],colorResolveTo:[w],colorClearColor:[kn],depthStencilAttachment:dr(this,ax,"f"),depthClearValue:1}),"f"),dr(this,lx,"f").setViewport(0,0,y,_),(!dr(this,hx,"f")||dr(this,hx,"f")&&!((b=dr(this,UM,"f"))===null||b===void 0)&&b.grid)&&dr(this,kk,"f").render(dr(this,Za,"f"),dr(this,lx,"f"),dr(this,cx,"f"),dr(this,LM,"f")),dr(this,Nb,"f").clear(),ua(this,Lk,1,"f")}),e.endFrame.tap(({all:b,removed:y})=>{if([...b.filter(_=>_.culled),...y].forEach(_=>{_.renderable&&dr(this,Nb,"f").remove(_)}),dr(this,Nb,"f").flush(dr(this,lx,"f"),dr(this,cx,"f"),dr(this,LM,"f")),dr(this,Za,"f").submitPass(dr(this,lx,"f")),dr(this,Za,"f").endFrame(),dr(this,hx,"f")&&dr(this,GM,"f")){const{type:_,encoderOptions:w}=dr(this,UM,"f")||{},E=dr(this,nx,"f").getCanvas().toDataURL(_,w);dr(this,GM,"f").call(this,E),ua(this,hx,!1,"f"),ua(this,UM,void 0,"f"),ua(this,GM,void 0,"f")}}),e.render.tap(b=>{var y,_;b.globalRenderOrder=(ua(this,Lk,(_=dr(this,Lk,"f"),y=_++,_),"f"),y),dr(this,Nb,"f").add(b)})}get checkboardStyle(){return dr(this,Nk,"f")}set checkboardStyle(t){ua(this,Nk,t,"f")}toDataURL(t){return uut(this,void 0,void 0,function*(){return ua(this,hx,!0,"f"),ua(this,UM,t,"f"),ua(this,h8,new Promise(e=>{ua(this,GM,r=>{e(r)},"f")}),"f"),dr(this,h8,"f")})}};nx=new WeakMap,Za=new WeakMap,Fb=new WeakMap,ax=new WeakMap,lx=new WeakMap,cx=new WeakMap,LM=new WeakMap,Nk=new WeakMap,kk=new WeakMap,Nb=new WeakMap,Lk=new WeakMap,hx=new WeakMap,UM=new WeakMap,h8=new WeakMap,GM=new WeakMap;var hg=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},ux=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
5495return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Gk,dx,kb,WM;const OWt=.02,IWt=4,DWt=100,Wk=[.02,.05,.1,.15,.2,.33,.5,.75,1,1.25,1.5,2,2.5,3,4],PWt=t=>Wk.find(e=>e>t)||Wk[Wk.length-1],FWt=t=>[...Wk].reverse().find(e=>e<t)||Wk[0];let NWt=class{constructor(){Gk.set(this,void 0),dx.set(this,{}),kb.set(this,void 0),WM.set(this,!1)}apply(t){const{canvas:e,camera:r,root:i,devicePixelRatio:s,api:{client2Viewport:o}}=t;i.draggable=!0;const n=Bt();let a,l,c;const h=it();let u,d=!1;function f(_){const w=e.getBoundingClientRect(),E=_.nativeEvent.clientX-w.left,A=_.nativeEvent.clientY-w.top,x=E/(e.clientWidth||e.width/s),S=A/(e.clientHeight||e.height/s),T=x*2-1,R=S*-2+1;return[T,R]}function g(_){const w=Qt(it(),f(_),n);r.x=a+h[0]-w[0],r.y=l+h[1]-w[1]}function p(_){const w=(_.nativeEvent.clientX-u[0])/100,E=Bt();bi(E,E,[h[0],h[1]]),Mo(E,E,w),bi(E,E,[-h[0],-h[1]]),r.x=a,r.y=l,r.rotation=c,us(E,E,r.matrix),r.rotation=c+w,r.x=E[6],r.y=E[7]}i.addEventListener("dragstart",_=>{hg(this,kb,"f")||(d=_.shiftKey,fp(n,r.viewProjectionMatrixInv),a=r.x,l=r.y,c=r.rotation,Qt(h,f(_),n),u=[_.nativeEvent.clientX,_.nativeEvent.clientY])}),i.addEventListener("drag",_=>{hg(this,kb,"f")||(d?p(_):g(_))}),i.addEventListener("dragend",_=>{hg(this,kb,"f")||(d=!1)});const m=(_,w)=>{const E=Math.max(OWt,Math.min(IWt,r.zoom*Math.pow(2,w*-.01))),A=o(_);r.gotoLandmark(r.createLandmark({viewportX:A.x,viewportY:A.y,zoom:E}),{duration:0})};i.addEventListener("wheel",_=>{_.preventDefault(),m({x:_.nativeEvent.clientX,y:_.nativeEvent.clientY},_.deltaY)});const v=_=>{_.pointerType==="mouse"?ux(this,Gk,!0,"f"):hg(this,dx,"f")[_.pointerId]||(hg(this,dx,"f")[_.pointerId]={last:null}),this.touchCount>=2?ux(this,kb,!0,"f"):ux(this,kb,!1,"f")},b=_=>{if(_.pointerType==="mouse"&&ux(this,Gk,!1,"f"),_.pointerType!=="mouse"&&delete hg(this,dx,"f")[_.pointerId],hg(this,WM,"f")&&this.touchCount<=1)return ux(this,WM,!1,"f"),ux(this,kb,!1,"f"),!0},y=_=>{if(this.touchCount>=2){const w=_.global.x,E=_.global.y,A=hg(this,dx,"f"),x=Object.keys(A),S=Number(x[0]),T=Number(x[1]),R=A[S],B=A[T],O=R.last&&B.last?Math.sqrt(Math.pow(B.last.x-R.last.x,2)+Math.pow(B.last.y-R.last.y,2)):null;if(S===_.pointerId?R.last={x:w,y:E}:T===_.pointerId&&(B.last={x:w,y:E}),O){const C=new ye(R.last.x+(B.last.x-R.last.x)/2,R.last.y+(B.last.y-R.last.y)/2),F=Math.sqrt(Math.pow(B.last.x-R.last.x,2)+Math.pow(B.last.y-R.last.y,2));m(C,(O/F-1)*DWt)}else hg(this,WM,"f")||ux(this,WM,!0,"f")}};i.addEventListener("pointerdown",v),i.addEventListener("pointermove",y),i.addEventListener("pointerup",b),i.addEventListener("pointerupoutside",b),i.addEventListener("pointercancel",b)}get touchCount(){return(hg(this,Gk,"f")?1:0)+Object.keys(hg(this,dx,"f")).length}};Gk=new WeakMap,dx=new WeakMap,kb=new WeakMap,WM=new WeakMap;let kWt=class{apply(t){const{canvas:e,hooks:r,globalThis:i,supportsPointerEvents:s,supportsTouchEvents:o}=t,n=y=>{y.preventDefault(),r.pointerMove.call(y)},a=y=>{r.pointerUp.call(y)},l=y=>{r.pointerDown.call(y)},c=y=>{r.pointerOver.call(y)},h=y=>{r.pointerOut.call(y)},u=y=>{r.pointerCancel.call(y)},d=y=>{r.pointerWheel.call(y)},f=y=>{i.addEventListener("pointermove",n,!0),y.addEventListener("pointerdown",l,!0),y.addEventListener("pointerleave",h,!0),y.addEventListener("pointerover",c,!0),i.addEventListener("pointerup",a,!0),i.addEventListener("pointercancel",u,!0)},g=y=>{y.addEventListener("touchstart",l,!0),y.addEventListener("touchend",a,!0),y.addEventListener("touchmove",n,!0),y.addEventListener("touchcancel",u,!0)},p=y=>{i.addEventListener("mousemove",n,!0),y.addEventListener("mousedown",l,!0),y.addEventListener("mouseout",h,!0),y.addEventListener("mouseover",c,!0),i.addEventListener("mouseup",a,!0)},m=y=>{i.removeEventListener("pointermove",n,!0),y.removeEventListener("pointerdown",l,!0),y.removeEventListener("pointerleave",h,!0),y.removeEventListener("pointerover",c,!0),i.removeEventListener("pointerup",a,!0)},v=y=>{y.removeEventListener("touchstart",l,!0),y.removeEventListener("touchend",a,!0),y.removeEventListener("touchmove",n,!0),y.removeEventListener("touchcancel",u,!0)},b=y=>{i.removeEventListener("mousemove",n,!0),y.removeEventListener("mousedown",l,!0),y.removeEventListener("mouseout",h,!0),y.removeEventListener("mouseover",c,!0),i.removeEventListener("mouseup",a,!0)};"addEventListener"in i&&(r.init.tap(()=>{s?f(e):(p(e),o&&g(e)),e.addEventListener("wheel",d,{capture:!0})}),r.destroy.tap(()=>{s?m(e):(b(e),o&&v(e)),e.removeEventListener("wheel",d,!0)}))}};var dut=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
5495return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Ol=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},K7,jk,q7,ug,G0;const LWt=1,UWt={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};let GWt=class{constructor(){K7.set(this,!0),jk.set(this,new ig(null)),q7.set(this,new k7(null)),ug.set(this,void 0),G0.set(this,void 0),this.onPointerMove=t=>{const e=this.normalizeToPointerEvent(t);for(const r of e){const i=this.bootstrapEvent(Ol(this,jk,"f"),r);Ol(this,ug,"f").mapEvent(i)}this.setCursor(Ol(this,ug,"f").cursor)}}apply(t){const{hooks:e,root:r}=t;dut(this,G0,t,"f"),dut(this,ug,new j5t(r),"f"),Ol(this,ug,"f").setPickHandler((i,s)=>{const{picked:o}=e.pickSync.call({position:{x:i,y:s},picked:[],topmost:!0});return o[0]||null}),e.pointerWheel.tap(i=>{const s=this.normalizeWheelEvent(i);Ol(this,ug,"f").mapEvent(s)}),e.pointerDown.tap(i=>{const s=this.normalizeToPointerEvent(i);Ol(this,K7,"f")&&s[0].isNormalized&&(i.cancelable||!("cancelable"in i))&&i.preventDefault();for(let o=0,n=s.length;o<n;o++){const a=s[o],l=this.bootstrapEvent(Ol(this,jk,"f"),a);Ol(this,ug,"f").mapEvent(l)}this.setCursor(Ol(this,ug,"f").cursor)}),e.pointerUp.tap(i=>{let s=i.target;i.composedPath&&i.composedPath().length>0&&(s=i.composedPath()[0]);const o=s!==Ol(this,G0,"f").canvas?"outside":"",n=this.normalizeToPointerEvent(i);for(let a=0,l=n.length;a<l;a++){const c=this.bootstrapEvent(Ol(this,jk,"f"),n[a]);c.type+=o,Ol(this,ug,"f").mapEvent(c)}this.setCursor(Ol(this,ug,"f").cursor)}),e.pointerMove.tap(this.onPointerMove),e.pointerOver.tap(this.onPointerMove),e.pointerOut.tap(this.onPointerMove),e.pointerCancel.tap(this.onPointerMove)}normalizeWheelEvent(t){const e=Ol(this,q7,"f");this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode;const{x:r,y:i}=this.getViewportXY(t);e.client.x=r,e.client.y=i;const{x:s,y:o}=Ol(this,G0,"f").api.viewport2Canvas(e.client);return e.screen.x=s,e.screen.y=o,e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null}setCursor(t){var e,r;(r=(e=Ol(this,G0,"f")).setCursor)===null||r===void 0||r.call(e,t)}normalizeToPointerEvent(t){const{supportsTouchEvents:e,supportsPointerEvents:r}=Ol(this,G0,"f"),i=[];if(e&&t instanceof TouchEvent)for(let s=0;s<t.changedTouches.length;s++){const o=t.changedTouches[s];ha(o.button)&&(o.button=0),ha(o.buttons)&&(o.buttons=1),ha(o.isPrimary)&&(o.isPrimary=t.touches.length===1&&t.type==="touchstart"),ha(o.width)&&(o.width=o.radiusX||1),ha(o.height)&&(o.height=o.radiusY||1),ha(o.tiltX)&&(o.tiltX=0),ha(o.tiltY)&&(o.tiltY=0),ha(o.pointerType)&&(o.pointerType="touch"),ha(o.pointerId)&&(o.pointerId=o.identifier||0),ha(o.pressure)&&(o.pressure=o.force||.5),ha(o.twist)&&(o.twist=0),ha(o.tangentialPressure)&&(o.tangentialPressure=0),o.isNormalized=!0,o.type=t.type,i.push(o)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!r||!(t instanceof globalThis.PointerEvent))){const s=t;ha(s.isPrimary)&&(s.isPrimary=!0),ha(s.width)&&(s.width=1),ha(s.height)&&(s.height=1),ha(s.tiltX)&&(s.tiltX=0),ha(s.tiltY)&&(s.tiltY=0),ha(s.pointerType)&&(s.pointerType="mouse"),ha(s.pointerId)&&(s.pointerId=LWt),ha(s.pressure)&&(s.pressure=.5),ha(s.twist)&&(s.twist=0),ha(s.tangentialPressure)&&(s.tangentialPressure=0),s.isNormalized=!0,i.push(s)}else i.push(t);return i}bootstrapEvent(t,e){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);const{x:r,y:i}=this.getViewportXY(e);t.client.x=r,t.client.y=i;const{x:s,y:o}=Ol(this,G0,"f").api.viewport2Canvas(t.client);return t.screen.x=s,t.screen.y=o,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=UWt[t.type]||t.type),t}getViewportXY(t){let e,r;const{offsetX:i,offsetY:s,clientX:o,clientY:n}=t;
5495if(!zht(i)&&!zht(s))e=i,r=s;else{const a=Ol(this,G0,"f").api.client2Viewport({x:o,y:n});e=a.x,r=a.y}return{x:e,y:r}}};K7=new WeakMap,jk=new WeakMap,q7=new WeakMap,ug=new WeakMap,G0=new WeakMap;const fut=new ye;let WWt=class{apply(t){const{hooks:e,root:r,api:{elementsFromBBox:i}}=t;e.pickSync.tap(s=>{const{position:{x:o,y:n}}=s,a=[r];return i(o,n,o,n).forEach(l=>{this.hitTest(l,o,n)&&a.unshift(l)}),s.picked=a,s})}hitTest(t,e,r){if(t.hitArea||t.renderable){t.worldTransform.applyInverse({x:e,y:r},fut);const{x:i,y:s}=fut;return t.hitArea?t.hitArea.contains(i,s):t.containsPoint(i,s)}return!1}};var jWt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},put=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Xk;function gut(t,e){do{if(t&&e(t))return t;t=t==null?void 0:t.parent}while(t!=null);return null}let XWt=class{constructor(t={}){Xk.set(this,void 0),jWt(this,Xk,Object.assign({overlap:"pointer",dragstartTimeThreshold:0,dragstartDistanceThreshold:0},t),"f")}apply(t){const{root:e,hooks:r,api:{elementsFromPoint:i}}=t,s=o=>{const n=o.target,a=gut(n,l=>l.draggable===!0);if(a){let l=!1;const c=o.timeStamp,h=[o.clientX,o.clientY];let u=null,d=[o.clientX,o.clientY];const f=p=>{if(!l){const y=p.timeStamp-c,_=Wht(p.clientX,p.clientY,...h);if(y<=put(this,Xk,"f").dragstartTimeThreshold||_<=put(this,Xk,"f").dragstartDistanceThreshold)return;p.type="dragstart",a.dispatchEvent(p),l=!0}p.type="drag",p.dx=p.clientX-d[0],p.dy=p.clientY-d[1],a.dispatchEvent(p),d=[p.clientX,p.clientY];const m=[p.globalX,p.globalY],v=i(m[0],m[1]),b=v[v.indexOf(n)+1];if(b){const y=gut(b,_=>_.droppable===!0);u!==y&&(u&&(p.type="dragleave",p.target=u,u.dispatchEvent(p)),y&&(p.type="dragenter",p.target=y,y.dispatchEvent(p)),u=y,u&&(p.type="dragover",p.target=u,u.dispatchEvent(p)))}};e.addEventListener("pointermove",f);const g=function(p){if(l){p.detail={preventClick:!0};const m=p;u&&(m.type="drop",m.target=u,u.dispatchEvent(m)),m.type="dragend",a.dispatchEvent(m),l=!1}e.removeEventListener("pointermove",f)};n.addEventListener("pointerup",g,{once:!0}),n.addEventListener("pointerupoutside",g,{once:!0})}};r.init.tap(()=>{e.addEventListener("pointerdown",s)}),r.destroy.tap(()=>{e.removeEventListener("pointerdown",s)})}};Xk=new WeakMap;var zWt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},jM=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},u8,fx;let VWt=class{constructor(){u8.set(this,void 0),fx.set(this,new Bd)}apply(t){const{hooks:e,rBushRoot:r}=t;zWt(this,u8,t,"f"),e.cameraChange.tap(this.updateViewport.bind(this)),this.updateViewport(),e.beginFrame.tap(({all:i,removed:s,modified:o})=>{const{minX:n,minY:a,maxX:l,maxY:c}=jM(this,fx,"f");[...s,...o].forEach(d=>{d.renderable&&r.remove({shape:d,minX:0,minY:0,maxX:0,maxY:0},(f,g)=>f.shape===g.shape)});const h=[];o.forEach(d=>{if(d.renderable){const f=d.getBounds();h.push({minX:f.minX,minY:f.minY,maxX:f.maxX,maxY:f.maxY,shape:d})}}),r.load(h);const u=r.search({minX:n,minY:a,maxX:l,maxY:c}).map(d=>d.shape);i.forEach(d=>{d.renderable&&d.cullable&&(d.culled=!u.includes(d))})})}updateViewport(){const{camera:t,api:{viewport2Canvas:e}}=jM(this,u8,"f"),{width:r,height:i}=t,s=e({x:0,y:0}),o=e({x:r,y:0}),n=e({x:r,y:i}),a=e({x:0,y:i});jM(this,fx,"f").minX=Math.min(s.x,o.x,n.x,a.x),jM(this,fx,"f").minY=Math.min(s.y,o.y,n.y,a.y),j
5495M(this,fx,"f").maxX=Math.max(s.x,o.x,n.x,a.x),jM(this,fx,"f").maxY=Math.max(s.y,o.y,n.y,a.y)}};u8=new WeakMap,fx=new WeakMap;var mut=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Cs=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},dg=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},d8,Rc,px,f8,Lb,zk,Ub,p8,gx;let yut=class{get pluginContext(){return Cs(this,Rc,"f")}get root(){return Cs(this,Lb,"f")}get camera(){return Cs(this,zk,"f")}constructor(t){d8.set(this,void 0),Rc.set(this,void 0),px.set(this,void 0),f8.set(this,void 0),Lb.set(this,new s8),zk.set(this,void 0),Ub.set(this,!0),p8.set(this,new Set),gx.set(this,new Set);const{canvas:e,renderer:r="webgl",shaderCompilerPath:i="",devicePixelRatio:s,backgroundColor:o,gridColor:n,setCursor:a}=t,l=O5t(),c=(s??l.devicePixelRatio)||1,h=!!l.PointerEvent,u="ontouchstart"in l,{width:d,height:f}=e,g=new nut(d/c,f/c);g.onchange=()=>{Cs(this,Rc,"f").hooks.cameraChange.call(),dg(this,Ub,!0,"f")},dg(this,zk,g,"f"),dg(this,Rc,{globalThis:l,canvas:e,renderer:r,shaderCompilerPath:i,devicePixelRatio:c,backgroundColor:o,gridColor:n,supportsPointerEvents:h,supportsTouchEvents:u,setCursor:a??(m=>e.style.cursor=m),hooks:{init:new Pu,initAsync:new M5t,beginFrame:new Pu,render:new Pu,endFrame:new Pu,destroy:new Pu,resize:new Pu,pointerDown:new Pu,pointerUp:new Pu,pointerMove:new Pu,pointerOut:new Pu,pointerOver:new Pu,pointerWheel:new Pu,pointerCancel:new Pu,pickSync:new B5t,cameraChange:new Pu},camera:g,root:Cs(this,Lb,"f"),rBushRoot:new TE,api:{elementsFromPoint:this.elementsFromPoint.bind(this),elementFromPoint:this.elementFromPoint.bind(this),elementsFromBBox:this.elementsFromBBox.bind(this),client2Viewport:this.client2Viewport.bind(this),viewport2Canvas:g.viewport2Canvas.bind(g),viewport2Client:this.viewport2Client.bind(this),canvas2Viewport:g.canvas2Viewport.bind(g)}},"f"),dg(this,px,new BWt,"f"),dg(this,f8,new GWt,"f");const p=[new kWt,Cs(this,f8,"f"),new WWt,new NWt,new VWt,Cs(this,px,"f"),new XWt({dragstartTimeThreshold:100,dragstartDistanceThreshold:10})];dg(this,d8,mut(this,void 0,void 0,function*(){const{hooks:m}=Cs(this,Rc,"f");return p.forEach(v=>{v==null||v.apply(Cs(this,Rc,"f"))}),m.init.call(),yield m.initAsync.promise(),this}),"f")}get initialized(){return Cs(this,d8,"f").then(()=>this)}render(){const{hooks:t}=Cs(this,Rc,"f");Cs(this,gx,"f").clear();const e=[];if(D7(Cs(this,Lb,"f"),r=>{Cs(this,gx,"f").add(r),r.transformDirtyFlag&&(r.renderDirtyFlag=!0),r.renderable&&r.renderDirtyFlag&&(e.push(r),dg(this,Ub,!0,"f")),r.transform.updateTransform(r.parent?r.parent.transform:Hht)}),Cs(this,Ub,"f")){const r=Array.from(Cs(this,gx,"f")),i=[...Cs(this,p8,"f")].filter(s=>!Cs(this,gx,"f").has(s));t.beginFrame.call({all:r,modified:e,removed:i}),D7(Cs(this,Lb,"f"),s=>{if(s.culled||!s.visible)return!0;s.renderable&&t.render.call(s)}),t.endFrame.call({all:r,modified:e,removed:i}),[...r,...i].forEach(s=>{s.renderDirtyFlag=!1}),dg(this,p8,new Set(Cs(this,gx,"f")),"f"),dg(this,Ub,!1,"f")}}resize(t,e){const{hooks:r}=Cs(this,Rc,"f");Cs(this,zk,"f").projection(t,e),r.resize.call(t,e)}destroy(){const{hooks:t}=Cs(this,Rc,"f");t.destroy.call()}getDOM(){return Cs(this,Rc,"f").canvas}getDPR(){return Cs(this,Rc,"f").devicePixelRatio}toDataURL(){return mut(this,arguments,void 0,function*(t={}){return Cs(this,px,"f").toDataURL(t)})}appendChild(t){dg(this,Ub,!0,"f"),Cs(this,Lb,"f").appendChild(t)}removeChild(t){return dg(this,Ub,!0,"f"),Cs(this,Lb,"f").removeChild(t)}set checkboardStyle(t){Cs(this,px,"f").checkboardStyle=t}
5495get checkboardStyle(){return Cs(this,px,"f").checkboardStyle}elementsFromBBox(t,e,r,i){const{rBushRoot:s}=Cs(this,Rc,"f"),o=s.search({minX:t,minY:e,maxX:r,maxY:i}),n=[];return o.forEach(({shape:a})=>{const{pointerEvents:l="auto"}=a,c=["auto","visiblepainted","visiblefill","visiblestroke","visible"].includes(l);(!c||c&&a.visible)&&!a.culled&&a.pointerEvents!=="none"&&n.push(a)}),n.sort((a,l)=>a.globalRenderOrder-l.globalRenderOrder),n}elementsFromPoint(t,e){const{picked:r}=Cs(this,Rc,"f").hooks.pickSync.call({topmost:!1,position:{x:t,y:e},picked:[]});return r}elementFromPoint(t,e){const{picked:r}=Cs(this,Rc,"f").hooks.pickSync.call({topmost:!0,position:{x:t,y:e},picked:[]});return r[0]}client2Viewport({x:t,y:e}){const{left:r,top:i}=Cs(this,Rc,"f").canvas.getBoundingClientRect();return{x:t-r,y:e-i}}viewport2Client({x:t,y:e}){const{left:r,top:i}=Cs(this,Rc,"f").canvas.getBoundingClientRect();return{x:t+r,y:e+i}}zoomIn(t,e){const{camera:r}=this;r.cancelLandmarkAnimation(e);const i=r.createLandmark({viewportX:r.width/2,viewportY:r.height/2,zoom:PWt(r.zoom)});r.gotoLandmark(i,{duration:300,easing:"ease"},t)}zoomOut(t,e){const{camera:r}=this;r.cancelLandmarkAnimation(e);const i=r.createLandmark({viewportX:r.width/2,viewportY:r.height/2,zoom:FWt(r.zoom)});r.gotoLandmark(i,{duration:300,easing:"ease"},t)}};d8=new WeakMap,Rc=new WeakMap,px=new WeakMap,f8=new WeakMap,Lb=new WeakMap,zk=new WeakMap,Ub=new WeakMap,p8=new WeakMap,gx=new WeakMap;const Z7=Symbol("canvas");var g8=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},vut=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Cf=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},_ut=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},J7,Mf,Vk;function YWt(){return vut(this,void 0,void 0,function*(){if("gpu"in navigator){if(!(yield navigator.gpu.requestAdapter()))throw new Error("No WebGPU adapter available.")}else throw new Error("WebGPU is not supported by the browser.")})}let mx=class extends Wa{constructor(){super(...arguments),this.renderer="webgl",this.shaderCompilerPath="https://unpkg.com/@antv/[email protected]/dist/pkg/glsl_wgsl_compiler_bg.wasm",this.zoom=100,J7.set(this,new eE(this,{context:Z7})),Mf.set(this,void 0),Vk.set(this,void 0),this.initCanvas=new rE(this,{task:t=>vut(this,[t],void 0,function*([e,r]){e==="webgpu"&&(yield YWt());const i=document.createElement("canvas");_ut(this,Mf,yield new yut({canvas:i,renderer:e,shaderCompilerPath:r}).initialized,"f"),Cf(this,J7,"f").setValue(Cf(this,Mf,"f")),Cf(this,Mf,"f").pluginContext.hooks.cameraChange.tap(()=>{this.zoom=Math.round(Cf(this,Mf,"f").camera.zoom*100)}),this.dispatchEvent(new CustomEvent("ic-ready",{detail:Cf(this,Mf,"f")}));const s=o=>{this.dispatchEvent(new CustomEvent("ic-frame",{detail:o})),Cf(this,Mf,"f").render(),_ut(this,Vk,window.requestAnimationFrame(s),"f")};return s(),Cf(this,Mf,"f").getDOM()}),args:()=>[this.renderer,this.shaderCompilerPath]})}connectedCallback(){super.connectedCallback(),this.addEventListener("sl-resize",this.resize)}disconnectedCallback(){var t;this.removeEventListener("sl-resize",this.resize),Cf(this,Vk,"f")&&window.cancelAnimationFrame(Cf(this,Vk,"f")),(t=Cf(this,Mf,"f"))===null||t===void 0||t.destroy(),super.disconnectedCallback()}resize(t){var e;const r=t.detail,{width:i,height:s}
5495=r.entries[0].contentRect,o=window.devicePixelRatio;if(i&&s){const n=Cf(this,Mf,"f").getDOM();n.width=i*o,n.height=s*o,(e=Cf(this,Mf,"f"))===null||e===void 0||e.resize(i,s)}}render(){return this.initCanvas.render({pending:()=>Ao`<sl-spinner></sl-spinner>`,complete:t=>Ao` 5496 <sl-resize-observer> 5497 ${t} 5498 <ic-zoom-toolbar-lesson12 5499 zoom=${this.zoom} 5500 ></ic-zoom-toolbar-lesson12> 5501 <ic-exporter-lesson12></ic-exporter-lesson12> 5502 </sl-resize-observer> 5503 `,error:t=>Ao`<sl-alert variant="danger" open> 5504 <sl-icon slot="icon" name="exclamation-octagon"></sl-icon> 5505 <strong>Initialize canvas failed</strong><br /> 5506 ${t.message} 5507 </sl-alert>`})}};J7=new WeakMap,Mf=new WeakMap,Vk=new WeakMap,mx.styles=Lc` 5508 :host { 5509 position: relative; 5510 } 5511 5512 canvas { 5513 width: 100%; 5514 height: 100%; 5515 outline: none; 5516 padding: 0; 5517 margin: 0; 5518 touch-action: none; 5519 } 5520 `,g8([Pa()],mx.prototype,"renderer",void 0),g8([Pa()],mx.prototype,"shaderCompilerPath",void 0),g8([em()],mx.prototype,"zoom",void 0),mx=g8([Vc("ic-canvas-lesson12")],mx);var Q7=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};let XM=class extends Wa{constructor(){super(...arguments),this.zoom=100}zoomOut(){this.canvas.zoomOut()}zoomIn(){this.canvas.zoomIn()}render(){return Ao` 5521 <sl-button-group label="Zoom toolbar"> 5522 <sl-tooltip content="Zoom out"> 5523 <sl-icon-button 5524 name="dash-lg" 5525 label="Zoom out" 5526 @click="${this.zoomOut}" 5527 ></sl-icon-button> 5528 </sl-tooltip> 5529 <span>${this.zoom}%</span> 5530 <sl-tooltip content="Zoom in"> 5531 <sl-icon-button 5532 name="plus-lg" 5533 label="Zoom in" 5534 @click="${this.zoomIn}" 5535 ></sl-icon-button> 5536 </sl-tooltip> 5537 </sl-button-group> 5538 `}};XM.styles=Lc` 5539 :host { 5540 position: absolute; 5541 right: 16px; 5542 bottom: 16px; 5543 box-shadow: var(--sl-shadow-medium); 5544 background: white; 5545 } 5546 5547 span { 5548 font-size: 12px; 5549 line-height: 32px; 5550 width: 32px; 5551 text-align: center; 5552 color: var(--sl-color-neutral-600); 5553 } 5554 `,Q7([cm({context:Z7,subscribe:!0})],XM.prototype,"canvas",void 0),Q7([Pa()],XM.prototype,"zoom",void 0),XM=Q7([Vc("ic-zoom-toolbar-lesson12")],XM);var $Wt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},HWt=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};let but=class{constructor(t){this.options=t}toCanvas(){return $Wt(this,arguments,void 0,function*(t={}){const{canvas:e}=this.options,{width:r,height:i}=e.getDOM(),s=e.getDPR(),{clippingRegion:o=new Ua(0,0,r,i),beforeDrawImage:n,afterDrawImage:a}=t,l=HWt(t,["clippingRegion","beforeDrawImage","afterDrawImage"]),c=yield e.toDataURL(l),h=yield this.getOrCreateImage(c),{x:u,y:d,width:f,height:g}=o,p=document.createElement("canvas");p.width=f*s,p.height=g*s;const m=p.getContext("2d");m.scale(s,s),n&&n(m);const v=h.width>r?s:1;return m.drawImage(h,u*v,d*v,f*v,g*v,0,0,f,g),a&&a(m),p})}toSVG(t={}){const{grid:e}=t,{canvas:r,document:i}=this.options,{width:s,height:o}=r.getDOM(),n=ys("svg",i);return n.setAttribute("width",`${s}`),n.setAttribute("height",`${o}`),e&&(r.checkboardStyle===Uk.GRID?this.drawLinesGrid(n,i):r.checkboardStyle===Uk.DOTS&&this.drawDotsGrid(n,i)),n.appendChild(j7(W7(r.root),i)),n}toSVGDataURL(t={}){const{document:e,xmlserializer:r}=this.options,i=this.toSVG(t),s=(e||document).implementation.createDocumentType("svg","-//W3C//DTD SVG 1.1//EN","http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"),o=(e||document).implementation.createDocument("http://www.w3.org/2000/svg","svg",s);return o.replaceChild(i,o.documentElement),`data:image/svg+xml;charset=utf8,${encodeURIComponent((r||new XMLSerializer).serializeToString(o))}`}downloadImage(t){const{defaultFilename:e,document:r}=this.options,{dataURL:i,name:s=e||"g"}=t,o=i.substring(i.indexOf(":")+1,i.indexOf(";")).split("/")[1],n=i.startsWith("data:image/svg"),a=`${s}.${n?"svg":o}`,l=(r||document).createElement("a");if(n)l.addEventListener("click",()=>{l.download=a,l.href=i});else if(window.Blob&&window.URL){const c=i.split(",");let h="";if(c&&c.length>0){const p=c[0].match(/:(.*?);/);p&&p.length>=2&&(h=p[1])}const u=atob(c[1]);let d=u.length;const f=new Uint8Array(d);for(;d--;)f[d]=u.charCodeAt(d);const g=new Blob([f],{type:h});navigator.msSaveBlob?navigator.msSaveBlob(g,a):l.addEventListener("click",()=>{l.download=a,l.href=window.URL.createObjectURL(g)})}if(l.click)l.click();else{const c=(r||document).createEvent("MouseEvents");c.initEvent("click",!1,!1),l.dispatchEvent(c)}}getOrCreateImage(t){return new Promise((e,r)=>{const i=new window.Image;i&&(i.onload=()=>{e(i)},i.onerror=s=>{r(s)},i.crossOrigin="Anonymous",i.src=t)})}drawLinesGrid(t,e){const r=ys("defs",e);t.appendChild(r);const i=ys("pattern",e);i.setAttribute("id","small-grid"),i.setAttribute("width","10"),i.setAttribute("height","10"),i.setAttribute("patternUnits","userSpaceOnUse");const s=ys("path",e);s.setAttribute("d","M 10 0 L 0 0 0 10"),s.setAttribute("fill","none"),s.setAttribute("stroke","rgba(221,221,221,1)"),s.setAttribute("stroke-width","1"),i.appendChild(s);const o=ys("pattern",e);o.setAttribute("id","grid"),o.setAttribute("width","100"),o.setAttribute("height","100"),o.setAttribute("patternUnits","userSpaceOnUse");const n=ys("rect",e);n.setAttribute("width","100"),n.setAttribute("height","100"),n.setAttribute("fill","url(#small-grid)"),o.appendChild(n);const a=ys("path",e);a.setAttribute("d","M 100 0 L 0 0 0 100"),a.setAttribute("fill","none"),a.setAttribute("stroke","rgba(221,221,221,1)"),a.setAttribute("stroke-width","2"),o.appendChild(a),r.appendChild(i),r.appendChild(o);const l=ys("rect",e);l.setAttribute("width","100%"),l.setAttribute("height","100%"),l.setAttribute("fill","url(#grid)"),t.appendChild(l)}drawDotsGrid(t,e){const r=ys("defs",e);t.appendChild(r);const i=ys("circle",e);i.setAttribute("id","dot-tl"),i.setAttribute("cx","0"),i.setAttribute("cy","0"),i.setAttribute("r","2"),i.setAttribute("fill","rgba(221,221,221,1)");
5554const s=i.cloneNode(),o=i.cloneNode(),n=i.cloneNode();s.setAttribute("id","dot-tr"),s.setAttribute("cx","20"),o.setAttribute("id","dot-bl"),o.setAttribute("cy","20"),n.setAttribute("id","dot-br"),n.setAttribute("cx","20"),n.setAttribute("cy","20"),r.appendChild(i),r.appendChild(s),r.appendChild(o),r.appendChild(n);const a=ys("pattern",e);a.setAttribute("id","dots-grid"),a.setAttribute("width","20"),a.setAttribute("height","20"),a.setAttribute("patternUnits","userSpaceOnUse");const l=ys("use",e);l.setAttribute("xlink:href","#dot-bl");const c=ys("use",e);c.setAttribute("xlink:href","#dot-br");const h=ys("use",e);h.setAttribute("xlink:href","#dot-tl");const u=ys("use",e);u.setAttribute("xlink:href","#dot-tr"),a.appendChild(l),a.appendChild(c),a.appendChild(h),a.appendChild(u),r.appendChild(a);const d=ys("rect",e);d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.setAttribute("fill","url(#dots-grid)"),t.appendChild(d)}};var tK=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},KWt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};let zM=class extends Wa{constructor(){super(...arguments),this.grid=!1}handleInputChange(){this.grid=!this.grid}connectedCallback(){super.connectedCallback();const t=new but({canvas:this.canvas});this.addEventListener("sl-select",e=>KWt(this,void 0,void 0,function*(){const r=e.detail.item;let i;r.value==="download-image-png"||r.value==="download-image-jpeg"?i=(yield t.toCanvas({grid:this.grid})).toDataURL(`image/${r.value.split("-").reverse()[0]}`):r.value==="download-image-svg"&&(i=t.toSVGDataURL({grid:this.grid})),i&&t.downloadImage({dataURL:i,name:"infinite-canvas-screenshot"})}))}render(){return Ao`<sl-dropdown> 5555 <sl-icon-button 5556 slot="trigger" 5557 name="download" 5558 label="Download" 5559 ></sl-icon-button> 5560 <sl-menu> 5561 <sl-switch 5562 size="small" 5563 .checked=${this.grid} 5564 @sl-input=${this.handleInputChange} 5565 >Grids included</sl-switch 5566 > 5567 <sl-menu-item value="download-image-png" 5568 >Download PNG image</sl-menu-item 5569 > 5570 <sl-menu-item value="download-image-jpeg" 5571 >Download JPEG image</sl-menu-item 5572 > 5573 <sl-menu-item value="download-image-svg" 5574 >Download SVG image</sl-menu-item 5575 > 5576 </sl-menu> 5577 </sl-dropdown>`}};zM.styles=Lc` 5578 :host { 5579 position: absolute; 5580 right: 16px; 5581 top: 16px; 5582 box-shadow: var(--sl-shadow-medium); 5583 background: white; 5584 } 5585 5586 sl-switch { 5587 margin-left: 24px; 5588 } 5589 5590 sl-menu-item::part(base) { 5591 font-size: 14px; 5592 } 5593 `,tK([cm({context:Z7,subscribe:!0})],zM.prototype,"canvas",void 0),tK([em()],zM.prototype,"grid",void 0),zM=tK([Vc("ic-exporter-lesson12")],zM);const qWt=Object.freeze(Object.defineProperty({__proto__:null,AABB:Bd,Camera:nut,Canvas:yut,Circle:k0,Ellipse:L0,get Exporter(){return zM},Grid:tut,Group:s8,IDENTITY_TRANSFORM:Hht,ImageExporter:but,get InfiniteCanvas(){return mx},Polyline:HA,Rect:Km,Rectangle:Ua,Shape:BM,get ZoomToolbar(){return XM},deserializeNode:sut,getBounds:L7,inLine:Jht,inPolyline:Qht,isFillOrStrokeAffected:tk,serializeNode:W7,shiftPoints:G7,strokeOffset:YA,toSVGElement:j7},Symbol.toStringTag,{value:"Module"}));var eK=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Yk;class ZWt{constructor(){Yk.set(this,[])}getCallbacksNum(){return eK(this,Yk,"f").length}tapPromise(e){eK(this,Yk,"f").push(e)}promise(...e){return Promise.all(eK(this,Yk,"f").map(r=>r(...e)))}}Yk=new WeakMap;var wut=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},m8;
5593class ku{constructor(){m8.set(this,[])}tap(e){wut(this,m8,"f").push(e)}call(...e){wut(this,m8,"f").forEach(function(r){r.apply(void 0,e)})}}m8=new WeakMap;var $k=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},yx;class JWt{constructor(){yx.set(this,[])}tap(e){$k(this,yx,"f").push(e)}call(...e){if($k(this,yx,"f").length){let r=$k(this,yx,"f")[0].apply(void 0,e);for(let i=0;i<$k(this,yx,"f").length-1;i++){const s=$k(this,yx,"f")[i];r=s(...r)}return r}return null}}yx=new WeakMap;const QWt=typeof window<"u"&&typeof window.document<"u",t6t=()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};function ns(t,e){return(e||document).createElementNS("http://www.w3.org/2000/svg",t)}function rK(t,e){e(t)||t.children.forEach(r=>{rK(r,e)})}const iK=0;function vx(t){return[t[0],t[1],t[2],iK,t[3],t[4],t[5],iK,t[6],t[7],t[8],iK]}function Eut(t,e,r,i){return Math.sqrt(Math.pow(r-t,2)+Math.pow(i-e,2))}function e6t(t,e,r,i,s,o){const n=[r-t,i-e];if(hO(n,[0,0]))return Math.sqrt((s-t)*(s-t)+(o-e)*(o-e));const a=[-n[1],n[0]];aE(a,a);const l=[s-t,o-e];return Math.abs(Yy(l,a))}function r6t(t,e,r){const i=Ea(it(),Aa(it(),t,e),.5);return Ea(i,i,1/Yy(t,i)),Ea(i,i,r)}const i6t={linear:cr(0,0,1,1),ease:cr(.25,.1,.25,1),"ease-in":cr(.42,0,1,1),"ease-out":cr(0,0,.58,1),"ease-in-out":cr(.42,0,.58,1)};var sK;(function(t){t._bytes4=new Uint8Array(4),t._float=new Float32Array(t._bytes4.buffer);function e(r){return t._float[0]=r,t._bytes4}t.floatToBytes=e})(sK||(sK={}));const Aut=256;let s6t=class{constructor(t=new Uint8Array(Aut)){this._bytes=t,this.count=0,this.capacity=Aut,this.count=this.capacity=t.length}clear(){this.count=0}bytes(){return this._bytes.subarray(0,this.count)}grow(){this.capacity*=2;const t=new Uint8Array(this.capacity);t.set(this._bytes),this._bytes=t}appendBytes(t){const e=t.length;return this.count+e>this.capacity&&this.grow(),this._bytes.set(t,this.count),this.count+=e,this}appendFloat(t){return this.appendBytes(sK.floatToBytes(t)),this}};const y8=t=>t instanceof Object,xut=t=>t===!!t,v8=t=>typeof t=="function",Vn=t=>t===void 0,Sut=t=>t==null,Bf=t=>typeof t=="string";function o6t(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function n6t(t){return t.replace(/-([a-z])/g,(e,r)=>r.toUpperCase())}const a6t=/^data:([a-z]+\/[a-z0-9\-\+]+)?(;charset=[a-z0-9\-]+)?(;base64)?,[a-z0-9\!\$&',\(\)\*\+,;=\-\._\~:@\/\?%\s]*$/i;function Tut(t){return a6t.test(t)}function l6t(t){return Object.fromEntries(Object.entries(t).filter(([e,r])=>r!==void 0))}const oK={default:-1};function Rut(t="default"){return oK[t]===void 0&&(oK[t]=-1),++oK[t]}const Cut=new uo;let eh=class{constructor(t=1/0,e=1/0,r=-1/0,i=-1/0){this.matrix=Cut,this.minX=t,this.minY=e,this.maxX=r,this.maxY=i}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Cut,this}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e||this.matrix)}addFrame(t,e,r,i,s){s||(s=this.matrix);const o=s.a,n=s.b,a=s.c,l=s.d,c=s.tx,h=s.ty;let u=this.minX,d=this.minY,f=this.maxX,g=this.maxY,p=o*t+a*e+c,m=n*t+l*e+h;p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*r+a*e+c,m=n*r+l*e+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*t+a*i+c,m=n*t+l*i+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),p=o*r+a*i+c,m=n*r+l*i+h,p<u&&(u=p),m<d&&(d=m),p>f&&(f=p),m>g&&(g=m),this.minX=u,this.minY=d,this.maxX=f,this.maxY=g}};class _8{get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=_8.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ye,this.page=new ye,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}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(e,r,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,r,i,s,o){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}
5593stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class b8 extends _8{constructor(){super(...arguments),this.client=new ye,this.movement=new ye,this.offset=new ye,this.global=new ye,this.screen=new ye}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}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,r,i,s,o,n,a,l,c,h,u,d,f,g,p){throw new Error("Method not implemented.")}}class fg extends b8{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 nK extends b8{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}var c6t=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},h6t=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},w8;const u6t=2048;class d6t{constructor(e){this.dispatch=new Uo,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,w8.set(this,void 0),this.rootTarget=e,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)}setPickHandler(e){c6t(this,w8,e,"f")}addEventMapping(e,r){this.mappingTable[e]||(this.mappingTable[e]=[]),this.mappingTable[e].push({fn:r,priority:0}),this.mappingTable[e].sort((i,s)=>i.priority-s.priority)}dispatchEvent(e,r){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,r),this.dispatch.emit(r||e.type,e)}mapEvent(e){if(!this.rootTarget)return;const r=this.mappingTable[e.type];if(r)for(let i=0,s=r.length;i<s;i++)r[i].fn(e);else console.warn(`[EventBoundary]: Event mapping not defined for ${e.type}`)}
vendor: 3,725 bytes, line 5593
5593hitTest(e,r){return h6t(this,w8,"f").call(this,e,r)}propagate(e,r){if(!e.target)return;const i=e.composedPath();e.eventPhase=e.CAPTURING_PHASE;for(let s=0,o=i.length-1;s<o;s++)if(e.currentTarget=i[s],this.notifyTarget(e,r),e.propagationStopped||e.propagationImmediatelyStopped)return;if(e.eventPhase=e.AT_TARGET,e.currentTarget=e.target,this.notifyTarget(e,r),!(e.propagationStopped||e.propagationImmediatelyStopped)){e.eventPhase=e.BUBBLING_PHASE;for(let s=i.length-2;s>=0;s--)if(e.currentTarget=i[s],this.notifyTarget(e,r),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,r,i=this._allInteractiveElements){if(i.length===0)return;e.eventPhase=e.BUBBLING_PHASE;const s=Array.isArray(r)?r:[r];for(let o=i.length-1;o>=0;o--)s.forEach(n=>{e.currentTarget=i[o],this.notifyTarget(e,n)})}propagationPath(e){const r=[e];for(let i=0;i<u6t&&e!==this.rootTarget&&e.parent;i++){if(!e.parent)throw new Error("Cannot find propagation path to disconnected target");r.push(e.parent),e=e.parent}return r.reverse(),r}notifyTarget(e,r){r=r??e.type;const i=e.eventPhase===e.CAPTURING_PHASE||e.eventPhase===e.AT_TARGET?`${r}capture`:r;this._notifyListeners(e,i),e.eventPhase===e.AT_TARGET&&this._notifyListeners(e,r)}mapPointerDown(e){if(!(e instanceof fg)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.createPointerEvent(e);if(this.dispatchEvent(r,"pointerdown"),r.pointerType==="touch")this.dispatchEvent(r,"touchstart");else if(r.pointerType==="mouse"||r.pointerType==="pen"){const s=r.button===2;this.dispatchEvent(r,s?"rightdown":"mousedown")}const i=this.trackingData(e.pointerId);i.pressTargetsByButton[e.button]=r.composedPath(),this.freeEvent(r)}mapPointerMove(e){var r,i,s;if(!(e instanceof fg)){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 o=this.createPointerEvent(e);this._isPointerMoveEvent=!1;const n=o.pointerType==="mouse"||o.pointerType==="pen",a=this.trackingData(e.pointerId),l=this.findMountedTarget(a.overTargets);if(((r=a.overTargets)===null||r===void 0?void 0:r.length)>0&&l!==o.target){const u=e.type==="mousemove"?"mouseout":"pointerout",d=this.createPointerEvent(e,u,l);if(this.dispatchEvent(d,"pointerout"),n&&this.dispatchEvent(d,"mouseout"),!o.composedPath().includes(l)){const f=this.createPointerEvent(e,"pointerleave",l);for(f.eventPhase=f.AT_TARGET;f.target&&!o.composedPath().includes(f.target);)f.currentTarget=f.target,this.notifyTarget(f),n&&this.notifyTarget(f,"mouseleave"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(d)}if(l!==o.target){const u=e.type==="mousemove"?"mouseover":"pointerover",d=this.clonePointerEvent(o,u);this.dispatchEvent(d,"pointerover"),n&&this.dispatchEvent(d,"mouseover");let f=l==null?void 0:l.parent;for(;f&&f!==this.rootTarget.parent&&f!==o.target;)f=f.parent;if(!f||f===this.rootTarget.parent){const g=this.clonePointerEvent(o,"pointerenter");for(g.eventPhase=g.AT_TARGET;g.target&&g.target!==l&&g.target!==this.rootTarget.parent;)g.currentTarget=g.target,this.notifyTarget(g),n&&this.notifyTarget(g,"mouseenter"),g.target=g.target.parent;this.freeEvent(g)}this.freeEvent(d)}const c=[],h=(i=this.enableGlobalMoveEvents)!==null&&i!==void 0?i:!0;this.moveOnAll?c.push("pointermove"):this.dispatchEvent(o,"pointermove"),h&&c.push("globalpointermove"),o.pointerType==="touch"&&(this.moveOnAll?c.splice(1,0,"touchmove"):this.dispatchEvent(o,"touchmove"),h&&c.push("globaltouchmove")),n&&(this.moveOnAll?c.splice(1,0,"mousemove"):this.dispatchEvent(o,"mousemove"),h&&c.push("globalmousemove"),this.cursor=(s=o.target)===null||s===void 0?void 0:s.cursor),
5593c.length>0&&this.all(o,c),this._allInteractiveElements.length=0,this._hitElements.length=0,a.overTargets=o.composedPath(),this.freeEvent(o)}mapPointerOver(e){var r;if(!(e instanceof fg)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const i=this.trackingData(e.pointerId),s=this.createPointerEvent(e),o=s.pointerType==="mouse"||s.pointerType==="pen";this.dispatchEvent(s,"pointerover"),o&&this.dispatchEvent(s,"mouseover"),s.pointerType==="mouse"&&(this.cursor=(r=s.target)===null||r===void 0?void 0:r.cursor);const n=this.clonePointerEvent(s,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),o&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;i.overTargets=s.composedPath(),this.freeEvent(s),this.freeEvent(n)}mapPointerOut(e){if(!(e instanceof fg)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(e.pointerId);if(r.overTargets){const i=e.pointerType==="mouse"||e.pointerType==="pen",s=this.findMountedTarget(r.overTargets),o=this.createPointerEvent(e,"pointerout",s);this.dispatchEvent(o),i&&this.dispatchEvent(o,"mouseout");const n=this.createPointerEvent(e,"pointerleave",s);for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),i&&this.notifyTarget(n,"mouseleave"),n.target=n.target.parent;r.overTargets=null,this.freeEvent(o),this.freeEvent(n)}this.cursor=null}mapPointerUp(e){var r;if(!(e instanceof fg)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const i=performance.now(),s=this.createPointerEvent(e);if(this.dispatchEvent(s,"pointerup"),s.pointerType==="touch")this.dispatchEvent(s,"touchend");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const l=s.button===2;this.dispatchEvent(s,l?"rightup":"mouseup")}const o=this.trackingData(e.pointerId),n=this.findMountedTarget(o.pressTargetsByButton[e.button]);let a=n;if(n&&!s.composedPath().includes(n)){let l=n;for(;l&&!s.composedPath().includes(l);){if(s.currentTarget=l,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch")this.notifyTarget(s,"touchendoutside");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const c=s.button===2;this.notifyTarget(s,c?"rightupoutside":"mouseupoutside")}l=l.parent}delete o.pressTargetsByButton[e.button],a=l}if(a){const l=this.clonePointerEvent(s,"click");l.target=a,l.path=null,o.clicksByButton[e.button]||(o.clicksByButton[e.button]={clickCount:0,target:l.target,timeStamp:i});const c=o.clicksByButton[e.button];if(c.target===l.target&&i-c.timeStamp<200?++c.clickCount:c.clickCount=1,c.target=l.target,c.timeStamp=i,l.detail=c.clickCount,!(!((r=s.detail)===null||r===void 0)&&r.preventClick)){if(l.pointerType==="mouse"){const h=l.button===2;this.dispatchEvent(l,h?"rightclick":"click")}else l.pointerType==="touch"&&this.dispatchEvent(l,"tap");this.dispatchEvent(l,"pointertap")}this.freeEvent(l)}this.freeEvent(s)}mapPointerUpOutside(e){if(!(e instanceof fg)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const r=this.trackingData(e.pointerId),i=this.findMountedTarget(r.pressTargetsByButton[e.button]),s=this.createPointerEvent(e);if(i){let o=i;for(;o;)s.currentTarget=o,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),o=o.parent;delete r.pressTargetsByButton[e.button]}this.freeEvent(s)}mapWheel(e){if(!(e instanceof nK)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const r=this.createWheelEvent(e);this.dispatchEvent(r),this.freeEvent(r)}findMountedTarget(e){if(!e)return null;let r=e[0];for(let i=1;i<e.length&&e[i].parent===r;i++)r=e[i];return r}createPointerEvent(e,r,i){var s;const o=this.allocateEvent(fg);return this.copyPointerData(e,o),this.copyMouseData(e,o),this.copyData(e,o),o.nativeEvent=e.nativeEvent,o.originalEvent=e,o.target=(s=i??this.hitTest(o.global.x,o.global.y))!==null&&s!==void 0?s:this._hitElements[0],typeof r=="string"&&(o.type=r),o}createWheelEvent(e){const r=this.allocateEvent(nK);return this.copyWheelData(e,r),this.copyMouseData(e,r),this.copyData(e,r),r.nativeEvent=e.nativeEvent,r.originalEvent=e,r.target=this.hitTest(r.global.x,r.global.y),r}clonePointerEvent(e,r){const i=this.allocateEvent(fg);return i.nativeEvent=e.nativeEvent,i.originalEvent=e.originalEvent,this.copyPointerData(e,i),this.copyMouseData(e,i),this.copyData(e,i),i.target=e.target,i.path=e.composedPath().slice(),i.type=r??i.type,i}copyWheelData(e,r){r.deltaMode=e.deltaMode,r.deltaX=e.deltaX,r.deltaY=e.deltaY,r.deltaZ=e.deltaZ}copyPointerData(e,r){e instanceof fg&&r instanceof fg&&(r.pointerId=e.pointerId,r.width=e.width,r.height=e.height,r.isPrimary=e.isPrimary,r.pointerType=e.pointerType,r.pressure=e.pressure,r.tangentialPressure=e.tangentialPressure,r.tiltX=e.tiltX,r.tiltY=e.tiltY,r.twist=e.twist)}copyMouseData(e,r){e instanceof b8&&r instanceof b8&&(r.altKey=e.altKey,r.button=e.button,r.buttons=e.buttons,r.client.copyFrom(e.client),r.ctrlKey=e.ctrlKey,r.metaKey=e.metaKey,r.movement.copyFrom(e.movement),r.screen.copyFrom(e.screen),r.shiftKey=e.shiftKey,r.global.copyFrom(e.global))}copyData(e,r){r.isTrusted=e.isTrusted,r.srcElement=e.srcElement,r.timeStamp=performance.now(),r.type=e.type,r.detail=e.detail,r.view=e.view,r.which=e.which,r.layer.copyFrom(e.layer),r.page.copyFrom(e.page)}trackingData(e){return this.mappingState.trackingData[e]||(this.mappingState.trackingData[e]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[e]}allocateEvent(e){this.eventPool.has(e)||this.eventPool.set(e,[]);const r=this.eventPool.get(e).pop()||new e(this);return r.eventPhase=r.NONE,r.currentTarget=null,r.path=null,r.target=null,r}freeEvent(e){if(e.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const r=e.constructor;this.eventPool.has(r)||this.eventPool.set(r,[]),this.eventPool.get(r).push(e)}_notifyListeners(e,r){const i=e.currentTarget._events[r];if(i)if("fn"in i)i.once&&e.currentTarget.removeListener(r,i.fn,void 0,!0),i.fn.call(i.context,e);else for(let s=0,o=i.length;s<o&&!e.propagationImmediatelyStopped;s++)i[s].once&&e.currentTarget.removeListener(r,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,e)}}w8=new WeakMap;class f6t extends Uo{constructor(e={}){super();const{cursor:r,hitArea:i,pointerEvents:s,draggable:o,droppable:n}=e;this.cursor=r??"default",this.hitArea=i,this.pointerEvents=s??"auto",this.draggable=o??!1,this.droppable=n??!1}addEventListener(e,r,i){const s=xut(i)&&i||y8(i)&&i.capture,o=y8(i)?i.signal:void 0,n=y8(i)&&i.once,a=v8(r)?void 0:r;e=s?`${e}capture`:e;const l=v8(r)?r:r.handleEvent;o&&o.addEventListener("abort",()=>{this.off(e,l,a)}),n?this.once(e,l,a):this.on(e,l,a)}removeEventListener(e,r,i){const s=xut(i)&&i||y8(i)&&i.capture,o=v8(r)?void 0:r;e=s?`${e}capture`:e,r=v8(r)?r:r==null?void 0:r.handleEvent,this.off(e,r,o)}dispatchEvent(e){if(!(e instanceof _8))throw new Error("Container cannot propagate events outside of the Federated Events API");return e.defaultPrevented=!1,e.path=[],e.target=this,e.manager.dispatchEvent(e),!e.defaultPrevented}}var Yi=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},da=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
5593return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r};function p6t(t){var e,r,i,s,o,n,a,l,c,h,u,d,f,g,p,m,v,b,y,_,w;return w=class extends t{constructor(E={}){super(E),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,this.sortDirtyFlag=!1,e.set(this,void 0),r.set(this,void 0),i.set(this,void 0),s.set(this,void 0),o.set(this,void 0),n.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),h.set(this,void 0),u.set(this,void 0),d.set(this,void 0),f.set(this,void 0),g.set(this,void 0),p.set(this,void 0),m.set(this,void 0),v.set(this,void 0),b.set(this,void 0),y.set(this,void 0),_.set(this,void 0);const{renderable:A,visible:x,cullable:S,batchable:T,selectable:R,sizeAttenuation:B,wireframe:O,fill:C,stroke:F,strokeWidth:U,strokeAlignment:H,strokeLinecap:N,strokeLinejoin:G,strokeMiterlimit:Y,strokeDasharray:q,strokeDashoffset:L,opacity:J,fillOpacity:tt,strokeOpacity:bt,innerShadowColor:ct,innerShadowOffsetX:Xt,innerShadowOffsetY:It,innerShadowBlurRadius:zt}=E;this.renderable=A??!0,this.visible=x??!0,this.cullable=S??!0,this.batchable=T??!0,this.selectable=R??!0,this.sizeAttenuation=B??!0,this.wireframe=O??!1,this.fill=C??"black",this.stroke=F??"none",this.strokeWidth=U??1,this.strokeAlignment=H??"center",this.strokeLinecap=N??"butt",this.strokeLinejoin=G??"miter",this.strokeMiterlimit=Y??4,this.strokeDasharray=q??[],this.strokeDashoffset=L??0,this.opacity=J??1,this.fillOpacity=tt??1,this.strokeOpacity=bt??1,this.innerShadowColor=ct??"black",this.innerShadowOffsetX=Xt??0,this.innerShadowOffsetY=It??0,this.innerShadowBlurRadius=zt??0}get visible(){return Yi(this,e,"f")}set visible(E){Yi(this,e,"f")!==E&&(da(this,e,E,"f"),this.boundsDirtyFlag=!0,this.renderDirtyFlag=!0)}get fill(){return Yi(this,r,"f")}set fill(E){Yi(this,r,"f")!==E&&(da(this,r,E,"f"),Bf(E)&&(E==="none"?da(this,i,sr.rgb(255,255,255,0),"f"):da(this,i,sr.rgb(E),"f")),this.renderDirtyFlag=!0)}get fillRGB(){return Yi(this,i,"f")}get stroke(){return Yi(this,s,"f")}set stroke(E){Yi(this,s,"f")!==E&&(da(this,s,E,"f"),E==="none"?da(this,o,sr.rgb(255,255,255,0),"f"):da(this,o,sr.rgb(E),"f"),this.renderDirtyFlag=!0)}get strokeRGB(){return Yi(this,o,"f")}get strokeWidth(){return Yi(this,n,"f")}set strokeWidth(E){Yi(this,n,"f")!==E&&(da(this,n,E,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get strokeAlignment(){return Yi(this,a,"f")}set strokeAlignment(E){Yi(this,a,"f")!==E&&(da(this,a,E,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get strokeLinecap(){return Yi(this,l,"f")}set strokeLinecap(E){Yi(this,l,"f")!==E&&(da(this,l,E,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get strokeLinejoin(){return Yi(this,c,"f")}set strokeLinejoin(E){Yi(this,c,"f")!==E&&(da(this,c,E,"f"),this.renderDirtyFlag=!0,this.renderBoundsDirtyFlag=!0)}get strokeMiterlimit(){return Yi(this,h,"f")}set strokeMiterlimit(E){Yi(this,h,"f")!==E&&(da(this,h,E,"f"),this.renderDirtyFlag=!0)}get strokeDasharray(){return Yi(this,u,"f")}set strokeDasharray(E){var A;(!(!((A=Yi(this,u,"f"))===null||A===void 0)&&A.length)||!Yi(this,u,"f").every((x,S)=>x===E[S]))&&(da(this,u,E,"f"),this.renderDirtyFlag=!0)}get strokeDashoffset(){return Yi(this,d,"f")}set strokeDashoffset(E){Yi(this,d,"f")!==E&&(da(this,d,E,"f"),this.renderDirtyFlag=!0)}get opacity(){return Yi(this,f,"f")}set opacity(E){Yi(this,f,"f")!==E&&(da(this,f,E,"f"),this.renderDirtyFlag=!0)}get fillOpacity(){return Yi(this,g,"f")}set fillOpacity(E){Yi(this,g,"f")!==E&&(da(this,g,E,"f"),this.renderDirtyFlag=!0)}get strokeOpacity(){return Yi(this,p,"f")}set strokeOpacity(E){Yi(this,p,"f")!==E&&(da(this,p,E,"f"),this.renderDirtyFlag=!0)}get innerShadowColor(){return Yi(this,m,"f")}set innerShadowColor(E){Yi(this,m,"f")!==E&&(da(this,m,E,"f"),da(this,v,sr.rgb(E),"f"),this.renderDirtyFlag=!0)}get innerShadowColorRGB(){return Yi(this,v,"f")}get innerShadowOffsetX(){return Yi(this,b,"f")}set innerShadowOffsetX(E){Yi(this,b,"f")!==E&&(da(this,b,E,"f"),this.renderDirtyFlag=!0)}get innerShadowOffsetY(){return Yi(this,y,"f")}set innerShadowOffsetY(E){Yi(this,y,"f")!==E&&(da(this,y,E,"f"),this.renderDirtyFlag=!0)}get innerShadowBlurRadius(){return Yi(this,_,"f")}set innerShadowBlurRadius(E){Yi(this,_,"f")!==E&&(da(this,_,E,"f"),this.renderDirtyFlag=!0)}},e=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap,o=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,g=new WeakMap,p=new WeakMap,m=new WeakMap,v=new WeakMap,b=new WeakMap,y=new WeakMap,_=new WeakMap,w}function g6t(t){return class extends t{constructor(){super(...arguments),this.transform=new wn}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(e){this.transform.position.copyFrom(e)}get scale(){return this.transform.scale}set scale(e){this.transform.scale.copyFrom(e)}get pivot(){return this.transform.pivot}set pivot(e){this.transform.pivot.copyFrom(e)}get skew(){return this.transform.skew}set skew(e){this.transform.skew.copyFrom(e)}get rotation(){return this.transform.rotation}set rotation(e){this.transform.rotation=e}get angle(){return this.transform.rotation*id}set angle(e){this.transform.rotation=e*eu}get transformDirtyFlag(){return this.transform._localID!==this.transform._currentLocalID||this.parent&&this.transform._parentID!==this.parent.transform._worldID}}}const Mut=new wn,But=new uo,Of=m6t(p6t(g6t(f6t)));function m6t(t){class e extends t{constructor(i={}){super(i),this.uid=Rut(),this.children=[],this.geometryDirtyFlag=!0,this.materialDirtyFlag=!0}appendChild(i){return i.parent&&i.parent.removeChild(i),i.parent=this,i.transform._parentID=-1,this.children.push(i),i}removeChild(i){const s=this.children.indexOf(i);return s===-1?null:(i.parent=void 0,i.transform._parentID=-1,this.children.splice(s,1),i)}getBounds(i){if(!this.boundsDirtyFlag&&!this.transformDirtyFlag)return this.bounds;this.bounds=this.bounds||new eh,this.bounds.clear();let s;return this.parent?i?s=this.parent.worldTransform:(But.identity(),s=Out(this,But)):s=uo.IDENTITY,aK(this,this.bounds,s,i),this.boundsDirtyFlag=!1,this.bounds}}return e}function aK(t,e,r,i){if(!t.visible)return;let s;i?s=t.worldTransform:(t.transform.updateLocalTransform(),s=new uo,s.copyFrom(t.localTransform),s.append(r)),t.renderable&&(e.matrix=s,e.addBounds(t.getRenderBounds()));for(let o=0;o<t.children.length;o++)aK(t.children[o],e,s,i)}function Out(t,e){const r=t.parent;return r&&(Out(r,e),r.transform.updateLocalTransform(),e.append(r.localTransform)),e}function _x(t,e){return t==="center"?e/2:t==="inner"?0:t==="outer"?e:0}
5593function VM(t,e,r){let i=!1,s=!1;const o=!!e&&e!=="none",n=!!r&&r!=="none";return t==="visiblepainted"||t==="painted"||t==="auto"?(i=o,s=n):t==="visiblefill"||t==="fill"?i=!0:t==="visiblestroke"||t==="stroke"?s=!0:(t==="visible"||t==="all")&&(i=!0,s=!0),[i,s]}function Iut(t,e){return!!t&&e>0}var YM=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},lK=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r};let qm=class extends cK(Of){};function cK(t){var e,r,i,s;return s=class extends t{static getGeometryBounds(o){const{cx:n=0,cy:a=0,r:l=0}=o;return new eh(n-l,a-l,n+l,a+l)}constructor(o={}){super(o),e.set(this,void 0),r.set(this,void 0),i.set(this,void 0);const{cx:n,cy:a,r:l}=o;this.cx=n??0,this.cy=a??0,this.r=l??0}get cx(){return YM(this,e,"f")}set cx(o){var n;YM(this,e,"f")!==o&&(lK(this,e,o,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,(n=this.onGeometryChanged)===null||n===void 0||n.call(this))}get cy(){return YM(this,r,"f")}set cy(o){var n;YM(this,r,"f")!==o&&(lK(this,r,o,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,(n=this.onGeometryChanged)===null||n===void 0||n.call(this))}get r(){return YM(this,i,"f")}set r(o){var n;YM(this,i,"f")!==o&&(lK(this,i,o,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,(n=this.onGeometryChanged)===null||n===void 0||n.call(this))}containsPoint(o,n){const{strokeWidth:a,strokeAlignment:l,cx:c,cy:h,r:u,pointerEvents:d,fill:f,stroke:g}=this,p=Eut(c,h,o,n),m=_x(l,a),[v,b]=VM(d,f,g);return v&&b?p<=u+m:v?p<=u:b?p>=u+m-a&&p<=u+m:!1}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.geometryBoundsDirtyFlag=!1,this.geometryBounds=qm.getGeometryBounds(this)),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){const{strokeWidth:o,strokeAlignment:n,cx:a,cy:l,r:c}=this,h=_x(n,o);this.renderBoundsDirtyFlag=!1,this.renderBounds=new eh(a-c-h,l-c-h,a+c+h,l+c+h)}return this.renderBounds}},e=new WeakMap,r=new WeakMap,i=new WeakMap,s}var Gb=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},E8=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r};let Zm=class extends hK(Of){};function hK(t){var e,r,i,s,o;return o=class extends t{static getGeometryBounds(n){const{cx:a=0,cy:l=0,rx:c=0,ry:h=0}=n;return new eh(a-c,l-h,a+c,l+h)}constructor(n={}){var a,l;super(n),e.set(this,void 0),r.set(this,void 0),i.set(this,void 0),s.set(this,void 0);const{cx:c,cy:h,rx:u,ry:d}=n;this.cx=c??0,this.cy=h??0,this.rx=(a=u??d)!==null&&a!==void 0?a:0,this.ry=(l=d??u)!==null&&l!==void 0?l:0}get cx(){return Gb(this,e,"f")}set cx(n){var a;Gb(this,e,"f")!==n&&(E8(this,e,n,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,(a=this.onGeometryChanged)===null||a===void 0||a.call(this))}get cy(){return Gb(this,r,"f")}set cy(n){var a;Gb(this,r,"f")!==n&&(E8(this,r,n,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,(a=this.onGeometryChanged)===null||a===void 0||a.call(this))}get rx(){return Gb(this,i,"f")}set rx(n){var a;Gb(this,i,"f")!==n&&(E8(this,i,n,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,(a=this.onGeometryChanged)===null||a===void 0||a.call(this))}get ry(){return Gb(this,s,"f")}set ry(n){var a;Gb(this,s,"f")!==n&&(E8(this,s,n,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,(a=this.onGeometryChanged)===null||a===void 0||a.call(this))}containsPoint(n,a){const{cx:l,cy:c,rx:h,ry:u,strokeWidth:d,strokeAlignment:f,pointerEvents:g,fill:p,stroke:m}=this,v=_x(f,d),[b,y]=VM(g,p,m);
5593return b&&y?A8(n,a,l,c,h+v,u+v):b?A8(n,a,l,c,h,u):y?!A8(n,a,l,c,h+v-d,u+v-d)&&A8(n,a,l,c,h+v,u+v):!1}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.geometryBoundsDirtyFlag=!1,this.geometryBounds=Zm.getGeometryBounds(this)),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){const{strokeWidth:n,strokeAlignment:a,cx:l,cy:c,rx:h,ry:u}=this,d=_x(a,n);this.renderBoundsDirtyFlag=!1,this.renderBounds=new eh(l-h-d,c-u-d,l+h+d,c+u+d)}return this.renderBounds}},e=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap,o}function A8(t,e,r,i,s,o){const n=t-r,a=e-i;return n*n/(s*s)+a*a/(o*o)<=1}var Il=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Jm=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r};let Qm=class extends uK(Of){};function uK(t){var e,r,i,s,o,n,a,l,c,h,u;return u=class extends t{static getGeometryBounds(d){const{x:f=0,y:g=0,width:p=0,height:m=0}=d;return new eh(f,g,f+p,g+m)}constructor(d={}){super(d),e.set(this,void 0),r.set(this,void 0),i.set(this,void 0),s.set(this,void 0),o.set(this,void 0),n.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),h.set(this,void 0);const{x:f,y:g,width:p,height:m,cornerRadius:v,dropShadowColor:b,dropShadowOffsetX:y,dropShadowOffsetY:_,dropShadowBlurRadius:w}=d;this.x=f??0,this.y=g??0,this.width=p??0,this.height=m??0,this.cornerRadius=v??0,this.dropShadowColor=b??"black",this.dropShadowOffsetX=y??0,this.dropShadowOffsetY=_??0,this.dropShadowBlurRadius=w??0}get x(){return Il(this,e,"f")}set x(d){var f;Il(this,e,"f")!==d&&(Jm(this,e,d,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,(f=this.onGeometryChanged)===null||f===void 0||f.call(this))}get y(){return Il(this,r,"f")}set y(d){var f;Il(this,r,"f")!==d&&(Jm(this,r,d,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,(f=this.onGeometryChanged)===null||f===void 0||f.call(this))}get width(){return Il(this,i,"f")}set width(d){var f;Il(this,i,"f")!==d&&(Jm(this,i,d,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,(f=this.onGeometryChanged)===null||f===void 0||f.call(this))}get height(){return Il(this,s,"f")}set height(d){var f;Il(this,s,"f")!==d&&(Jm(this,s,d,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,(f=this.onGeometryChanged)===null||f===void 0||f.call(this))}get cornerRadius(){return Il(this,o,"f")}set cornerRadius(d){Il(this,o,"f")!==d&&(Jm(this,o,d,"f"),this.renderDirtyFlag=!0)}get dropShadowColor(){return Il(this,n,"f")}set dropShadowColor(d){Il(this,n,"f")!==d&&(Jm(this,n,d,"f"),Jm(this,a,sr.rgb(d),"f"),this.renderDirtyFlag=!0)}get dropShadowColorRGB(){return Il(this,a,"f")}get dropShadowOffsetX(){return Il(this,l,"f")}set dropShadowOffsetX(d){Il(this,l,"f")!==d&&(Jm(this,l,d,"f"),this.renderDirtyFlag=!0)}get dropShadowOffsetY(){return Il(this,c,"f")}set dropShadowOffsetY(d){Il(this,c,"f")!==d&&(Jm(this,c,d,"f"),this.renderDirtyFlag=!0)}get dropShadowBlurRadius(){return Il(this,h,"f")}set dropShadowBlurRadius(d){Il(this,h,"f")!==d&&(Jm(this,h,d,"f"),this.renderDirtyFlag=!0)}containsPoint(d,f){const{x:g,y:p,width:m,height:v,strokeWidth:b,strokeAlignment:y,cornerRadius:_,pointerEvents:w,stroke:E,fill:A}=this,x=_x(y,b),[S,T]=VM(w,A,E);if(S&&T)return x8(d,f,g-x,p-x,g+m+x,p+v+x,_);if(S)return x8(d,f,g,p,g+m,p+v,_);if(T){const R=x-b;return!x8(d,f,g-R,p-R,g+m+R,p+v+R,_)&&x8(d,f,g-x,p-x,g+m+x,p+v+x,_)}return!1}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.geometryBoundsDirtyFlag=!1,this.geometryBounds=u.getGeometryBounds(this)),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){const{x:d,y:f,width:g,height:p,strokeWidth:m,strokeAlignment:v,dropShadowOffsetX:b,dropShadowOffsetY:y,dropShadowBlurRadius:_}=this,w=_x(v,m);this.renderBoundsDirtyFlag=!1,this.renderBounds=new eh(d-w,f-w,d+g+w,f+p+w),this.renderBounds.addBounds(new eh(d+b-_,f+y-_,d+b+g+_,f+y+p+_))}return this.renderBounds}},e=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap,o=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,u}function x8(t,e,r,i,s,o,n){function a(l,c,h,u,d){return Math.sqrt(Math.pow(l-h,2)+Math.pow(c-u,2))<=d}return t>=r&&t<=s&&e>=i&&e<=o?a(t,e,r+n,i+n,n)||a(t,e,s-n,i+n,n)||a(t,e,s-n,o-n,n)||a(t,e,r+n,o-n,n)?!0:!(t<=r+n||t>=s-n||e<=i+n||e>=o-n):!1}var bx=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Dut=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
5593return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r};let Wb=class extends dK(Of){};function dK(t){var e,r,i;return i=class extends t{static getGeometryBounds(s){const{points:o}=s;if(!o||o.length<2)return new eh(0,0,0,0);const n=Math.min(...o.map(h=>isNaN(h[0])?1/0:h[0])),a=Math.max(...o.map(h=>isNaN(h[0])?-1/0:h[0])),l=Math.min(...o.map(h=>isNaN(h[1])?1/0:h[1])),c=Math.max(...o.map(h=>isNaN(h[1])?-1/0:h[1]));return new eh(n,l,a,c)}constructor(s={}){super(s),e.set(this,void 0),r.set(this,[]),this.batchable=!1;const{points:o}=s;this.points=o??[[0,0],[0,0]]}get points(){return bx(this,e,"f")}set points(s){var o;(!bx(this,e,"f")||!bx(this,e,"f").every((n,a)=>n[0]===s[a][0]&&n[1]===s[a][1]))&&(Dut(this,e,s,"f"),this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,(o=this.onGeometryChanged)===null||o===void 0||o.call(this))}computeShiftedPoints(){const{strokeWidth:s,strokeAlignment:o}=this;Dut(this,r,o==="center"?bx(this,e,"f"):fK(bx(this,e,"f"),o==="inner",s),"f")}containsPoint(s,o){const{strokeWidth:n,pointerEvents:a,fill:l,stroke:c}=this;this.getGeometryBounds();const[,h]=VM(a,l,c);return h?Fut(bx(this,r,"f"),n,s,o):!1}getTotalLength(){const{points:s}=this;let o=0;for(let n=0;n<s.length-1;n++){const[a,l]=s[n],[c,h]=s[n+1];o+=Math.hypot(c-a,h-l)}return o}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.computeShiftedPoints(),this.geometryBoundsDirtyFlag=!1,this.geometryBounds=Wb.getGeometryBounds(Object.assign(Object.assign({},this),{points:bx(this,r,"f")}))),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){this.renderBoundsDirtyFlag=!1;const{strokeWidth:s,strokeLinecap:o,strokeLinejoin:n,strokeMiterlimit:a}=this;let l=.5;o==="square"&&(l=Math.SQRT1_2),l*=s;const{minX:c,minY:h,maxX:u,maxY:d}=this.getGeometryBounds();this.renderBounds=new eh(c-l,h-l,u+l,d+l)}return this.renderBounds}},e=new WeakMap,r=new WeakMap,i}function Put(t,e,r,i,s,o,n){const a=Math.min(t,r),l=Math.max(t,r),c=Math.min(e,i),h=Math.max(e,i),u=s/2;return o>=a-u&&o<=l+u&&n>=c-u&&n<=h+u?e6t(t,e,r,i,o,n)<=s/2:!1}function fK(t,e,r){const i=[];return t.forEach(([s,o],n)=>{const a=Be(s,o),l=n===0?a:Be(t[n-1][0],t[n-1][1]),c=n===t.length-1?a:Be(t[n+1][0],t[n+1][1]),h=ru(it(),a,l),u=rm(h),d=it();$y(d,h,Be(u,u));const f=Be(d[1],-d[0]),g=ru(it(),c,a),p=rm(g),m=it();$y(m,g,Be(p,p));const v=Be(m[1],-m[0]),b=f[0]*v[1]-f[1]*v[0],y=2*(e?0:1)-1,_=r/2*y;u===0?Aa(a,a,Ea(v,v,_)):p===0||Math.abs(b)<.01?Aa(a,a,Ea(f,f,_)):Aa(a,a,r6t(f,v,_)),i.push([a[0],a[1]])}),i}function Fut(t,e,r,i){const s=t.length;if(s<2)return!1;for(let o=0;o<s-1;o++){const n=t[o][0],a=t[o][1],l=t[o+1][0],c=t[o+1][1];if(Put(n,a,l,c,e,r,i))return!0}return!1}var Nut=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},y6t=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},wx;(function(t){t[t.EARCUT=0]="EARCUT",t[t.LIBTESS=1]="LIBTESS"})(wx||(wx={}));let W0=class extends pK(Of){};function pK(t){var e,r;return r=class extends t{static getGeometryBounds(i){const{d:s,points:o}=i;if(!s)return new eh(0,0,0,0);const n=o.flat(),a=Math.min(...n.map(u=>u[0])),l=Math.max(...n.map(u=>u[0])),c=Math.min(...n.map(u=>u[1])),h=Math.max(...n.map(u=>u[1]));return new eh(a,c,l,h)}constructor(i={}){super(i),e.set(this,void 0),this.points=[],this.batchable=!1;const{d:s}=i;this.d=s,this.tessellationMethod=wx.EARCUT}get d(){return Nut(this,e,"f")}set d(i){var s;if(Nut(this,e,"f")!==i){y6t(this,e,i,"f");const{subPaths:o}=vK(i),n=o.map(a=>a.getPoints().map(l=>[l[0],l[1]]));this.points=n,this.renderDirtyFlag=!0,this.geometryBoundsDirtyFlag=!0,this.renderBoundsDirtyFlag=!0,this.boundsDirtyFlag=!0,(s=this.onGeometryChanged)===null||s===void 0||s.call(this)}}containsPoint(i,s,o){const{d:n,pointerEvents:a,fill:l,stroke:c}=this;if(!o||!n)return!1;this.getGeometryBounds();const[h,u]=VM(a,l,c);return u&&!h?o.isPointInStroke(new Path2D(n),i,s):o.isPointInPath(new Path2D(n),i,s)}getTotalLength(){return 0}getGeometryBounds(){return this.geometryBoundsDirtyFlag&&(this.geometryBoundsDirtyFlag=!1,this.geometryBounds=W0.getGeometryBounds(this)),this.geometryBounds}getRenderBounds(){if(this.renderBoundsDirtyFlag){this.renderBoundsDirtyFlag=!1;const{strokeWidth:i,strokeLinecap:s}=this;let o=.5;s==="square"&&(o=Math.SQRT1_2),o*=i;const{minX:n,minY:a,maxX:l,maxY:c}=this.getGeometryBounds();this.renderBounds=new eh(n-o,a-o,l+o,c+o)}return this.renderBounds}},e=new WeakMap,r}const v6t=` 5594layout(std140) uniform SceneUniforms { 5595 mat3 u_ProjectionMatrix; 5596 mat3 u_ViewMatrix; 5597 mat3 u_ViewProjectionInvMatrix;
5598 vec4 u_BackgroundColor; 5599 vec4 u_GridColor; 5600 float u_ZoomScale; 5601 float u_CheckboardStyle; 5602}; 5603 5604layout(location = 0) in vec2 a_Position; 5605 5606out vec2 v_Position; 5607 5608vec2 project_clipspace_to_world(vec2 p) { 5609 return (u_ViewProjectionInvMatrix * vec3(p, 1)).xy; 5610} 5611 5612void main() { 5613 v_Position = project_clipspace_to_world(a_Position); 5614 gl_Position = vec4(a_Position, 0, 1); 5615} 5616`,_6t=` 5617layout(std140) uniform SceneUniforms { 5618 mat3 u_ProjectionMatrix; 5619 mat3 u_ViewMatrix; 5620 mat3 u_ViewProjectionInvMatrix; 5621 vec4 u_BackgroundColor; 5622 vec4 u_GridColor; 5623 float u_ZoomScale; 5624 float u_CheckboardStyle; 5625}; 5626 5627out vec4 outputColor; 5628 5629in vec2 v_Position; 5630 5631const int CHECKERBOARD_STYLE_NONE = 0; 5632const int CHECKERBOARD_STYLE_GRID = 1; 5633const int CHECKERBOARD_STYLE_DOTS = 2; 5634const float BASE_GRID_PIXEL_SIZE = 100.0; 5635const float BASE_DOT_SIZE = 8.0; 5636 5637vec2 scale_grid_size(float zoom) { 5638 if (zoom < 0.125) return vec2(BASE_GRID_PIXEL_SIZE * 125.0, 0.125); 5639 else if (zoom < 0.25) return vec2(BASE_GRID_PIXEL_SIZE * 25.0, 0.25); 5640 else if (zoom < 0.5) return vec2(BASE_GRID_PIXEL_SIZE * 5.0, 0.5); 5641 return vec2(BASE_GRID_PIXEL_SIZE, 4.0); 5642} 5643 5644vec4 render_grid_checkerboard(vec2 coord) { 5645 float alpha = 0.0; 5646 5647 vec2 size = scale_grid_size(u_ZoomScale); 5648 float gridSize1 = size.x; 5649 float gridSize2 = gridSize1 / 10.0; 5650 float zoomStep = size.y; 5651 int checkboardStyle = int(floor(u_CheckboardStyle + 0.5)); 5652 5653 if (checkboardStyle == CHECKERBOARD_STYLE_GRID) { 5654 vec2 grid1 = abs(fract(coord / gridSize1 - 0.5) - 0.5) / fwidth(coord) * gridSize1 / 2.0; 5655 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2; 5656 float v1 = 1.0 - min(min(grid1.x, grid1.y), 1.0); 5657 float v2 = 1.0 - min(min(grid2.x, grid2.y), 1.0); 5658 5659 if (v1 > 0.0) { 5660 alpha = v1; 5661 } else { 5662 alpha = v2 * clamp(u_ZoomScale / zoomStep, 0.0, 1.0); 5663 } 5664 } else if (checkboardStyle == CHECKERBOARD_STYLE_DOTS) { 5665 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2;
5666 alpha = 1.0 - smoothstep(0.0, 1.0, length(grid2) - BASE_DOT_SIZE * u_ZoomScale / zoomStep); 5667 } 5668 5669 return mix(u_BackgroundColor, u_GridColor, alpha); 5670} 5671 5672void main() { 5673 outputColor = render_grid_checkerboard(v_Position); 5674} 5675`;var $l=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Hk=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},jb,$M,HM,Kk,qk,Zk;let kut=class{constructor(){jb.set(this,void 0),$M.set(this,void 0),HM.set(this,void 0),Kk.set(this,void 0),qk.set(this,void 0),Zk.set(this,new s6t)}appendVertex(t,e){$l(this,Zk,"f").appendFloat(t).appendFloat(e)}render(t,e,r,i){if(!$l(this,jb,"f")){Hk(this,jb,t.createProgram({vertex:{glsl:v6t},fragment:{glsl:_6t}}),"f"),Hk(this,HM,t.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{format:I.F32_RG,offset:0,shaderLocation:0}]}],indexBufferFormat:null,program:$l(this,jb,"f")}),"f"),Hk(this,$M,t.createRenderPipeline({inputLayout:$l(this,HM,"f"),program:$l(this,jb,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,topology:Go.TRIANGLE_STRIP}),"f"),$l(this,Zk,"f").clear(),this.appendVertex(-1,-1),this.appendVertex(-1,1),this.appendVertex(1,-1),this.appendVertex(1,1);const s=$l(this,Zk,"f").bytes(),o=t.createBuffer({viewOrSize:s.byteLength,usage:dt.VERTEX,hint:Et.DYNAMIC});Hk(this,qk,o,"f"),o.setSubData(0,s),Hk(this,Kk,t.createBindings({pipeline:$l(this,$M,"f"),uniformBufferBindings:[{buffer:r}]}),"f")}$l(this,jb,"f").setUniformsLegacy(i),e.setBindings($l(this,Kk,"f")),e.setP
5675ipeline($l(this,$M,"f")),e.setVertexInput($l(this,HM,"f"),[{buffer:$l(this,qk,"f")}],null),e.draw(4)}destroy(){var t,e,r,i,s;(t=$l(this,jb,"f"))===null||t===void 0||t.destroy(),(e=$l(this,qk,"f"))===null||e===void 0||e.destroy(),(r=$l(this,$M,"f"))===null||r===void 0||r.destroy(),(i=$l(this,HM,"f"))===null||i===void 0||i.destroy(),(s=$l(this,Kk,"f"))===null||s===void 0||s.destroy()}};jb=new WeakMap,$M=new WeakMap,HM=new WeakMap,Kk=new WeakMap,qk=new WeakMap,Zk=new WeakMap;let S8=class extends Of{constructor(){super(...arguments),this.renderable=!1,this.visible=!0}containsPoint(t,e){throw new Error("Method not implemented.")}getGeometryBounds(){throw new Error("Method not implemented.")}getRenderBounds(){throw new Error("Method not implemented.")}destroy(){}};var _s=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},as=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)};function Jk(t){var e,r,i,s,o,n,a,l,c,h,u,d,f,g,p,m,v,b;class y extends t{constructor(w={}){var E;super(w),this.strokePoints=[],this.fillPoints=[],this.fillPathPoints=[],e.set(this,void 0),r.set(this,void 0),i.set(this,void 0),s.set(this,void 0),o.set(this,void 0),n.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),h.set(this,void 0),u.set(this,void 0),d.set(this,void 0),f.set(this,void 0),g.set(this,void 0),p.set(this,void 0),m.set(this,void 0),v.set(this,void 0),b.set(this,void 0);const{seed:A,bowing:x,roughness:S,fillStyle:T,fillWeight:R,hachureAngle:B,hachureGap:O,curveStepCount:C,curveFitting:F,disableMultiStroke:U,disableMultiStrokeFill:H,simplification:N,dashOffset:G,dashGap:Y,zigzagOffset:q,preserveVertices:L,fillLineDash:J,fillLineDashOffset:tt}=w;_s(this,s,A??1,"f"),_s(this,r,x??1,"f"),_s(this,e,S??1,"f"),_s(this,i,T??"hachure","f"),_s(this,o,R,"f"),_s(this,n,B??-41,"f"),_s(this,a,O,"f"),_s(this,l,C??9,"f"),_s(this,c,F??.95,"f"),_s(this,h,U,"f"),_s(this,u,H,"f"),_s(this,d,N??0,"f"),_s(this,f,G,"f"),_s(this,g,Y,"f"),_s(this,p,q,"f"),_s(this,m,L,"f"),_s(this,v,J,"f"),_s(this,b,tt,"f"),(E=this.preCreateGeometry)===null||E===void 0||E.call(this),this.geometryDirtyFlag=!1}get seed(){return as(this,s,"f")}set seed(w){as(this,s,"f")!==w&&(_s(this,s,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get roughness(){return as(this,e,"f")}set roughness(w){as(this,e,"f")!==w&&(_s(this,e,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get bowing(){return as(this,r,"f")}set bowing(w){as(this,r,"f")!==w&&(_s(this,r,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get fillStyle(){return as(this,i,"f")}set fillStyle(w){as(this,i,"f")!==w&&(_s(this,i,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get fillWeight(){return as(this,o,"f")}set fillWeight(w){as(this,o,"f")!==w&&(_s(this,o,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get hachureAngle(){return as(this,n,"f")}set hachureAngle(w){as(this,n,"f")!==w&&(_s(this,n,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get hachureGap(){return as(this,a,"f")}set hachureGap(w){as(this,a,"f")!==w&&(_s(this,a,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get curveStepCount(){return as(this,l,"f")}set curveStepCount(w){as(this,l,"f")!==w&&(_s(this,l,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get curveFitting(){return as(this,c,"f")}set curveFitting(w){as(this,c,"f")!==w&&(_s(this,c,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get disableMultiStroke(){return as(this,h,"f")}set disableMultiStroke(w){as(this,h,"f")!==w&&(_s(this,h,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get disableMultiStrokeFill(){return as(this,u,"f")}set disableMultiStrokeFill(w){as(this,u,"f")!==w&&(_s(this,u,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get simplification(){return as(this,d,"f")}set simplification(w){as(this,d,"f")!==w&&(_s(this,d,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get dashOffset(){return as(this,f,"f")}set dashOffset(w){as(this,f,"f")!==w&&(_s(this,f,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get dashGap(){return as(this,g,"f")}set dashGap(w){as(this,g,"f")!==w&&(_s(this,g,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get zigzagOffset(){return as(this,p,"f")}set zigzagOffset(w){as(this,p,"f")!==w&&(_s(this,p,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get preserveVertices(){return as(this,m,"f")}set preserveVertices(w){as(this,m,"f")!==w&&(_s(this,m,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get fillLineDash(){return as(this,v,"f")}set fillLineDash(w){var E;(!(!((E=as(this,v,"f"))===null||E===void 0)&&E.length)||!as(this,v,"f").every((A,x)=>A===w[x]))&&(_s(this,v,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get fillLineDashOffset(){return as(this,b,"f")}set fillLineDashOffset(w){as(this,b,"f")!==w&&(_s(this,b,w,"f"),this.renderDirtyFlag=!0,this.geometryDirtyFlag=!0)}get roughOptions(){const{fill:w,stroke:E,strokeWidth:A,seed:x,bowing:S,roughness:T,fillStyle:R,fillWeight:B,hachureAngle:O,hachureGap:C,curveStepCount:F,curveFitting:U,disableMultiStroke:H,disableMultiStrokeFill:N,simplification:G,dashOffset:Y,dashGap:q,zigzagOffset:L,preserveVertices:J,strokeDasharray:tt,strokeDashoffset:bt,fillLineDash:ct,fillLineDashOffset:Xt}=this;return l6t({fill:w,stroke:E,strokeWidth:A,seed:x,bowing:S,roughness:T,fillStyle:R,fillWeight:B,hachureAngle:O,hachureGap:C,curveStepCount:F,curveFitting:U,disableMultiStroke:H,disableMultiStrokeFill:N,simplification:G,dashOffset:Y,dashGap:q,zigzagOffset:L,preserveVertices:J,strokeLineDash:tt,strokeLineDashOffset:bt,fillLineDash:ct,fillLineDashOffset:Xt})}preCreateGeometry(){const w=this.generateDrawable();this.drawableSets=w.sets,this.strokePoints=[],this.fillPoints=[],this.fillPathPoints=[],this.drawableSets.forEac
5675h(E=>{const{subPaths:A}=vK(E),x=A.map(S=>S.getPoints().map(T=>[T[0],T[1]]));E.type==="path"?this.strokePoints=x:E.type==="fillPath"?this.fillPathPoints=x:E.type==="fillSketch"&&(this.fillPoints=x)})}}return e=new WeakMap,r=new WeakMap,i=new WeakMap,s=new WeakMap,o=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,g=new WeakMap,p=new WeakMap,m=new WeakMap,v=new WeakMap,b=new WeakMap,y}class ty extends Jk(cK(Of)){constructor(e={}){super(e),this.onGeometryChanged=()=>{this.geometryDirtyFlag=!0}}generateDrawable(){const{cx:e,cy:r,r:i}=this;return Qk.circle(e,r,i*2,this.roughOptions)}}class ey extends Jk(hK(Of)){constructor(e={}){super(e),this.onGeometryChanged=()=>{this.geometryDirtyFlag=!0}}generateDrawable(){const{cx:e,cy:r,rx:i,ry:s}=this;return Qk.ellipse(e,r,i*2,s*2,this.roughOptions)}}class pg extends Jk(uK(Of)){constructor(e={}){super(e),this.onGeometryChanged=()=>{this.geometryDirtyFlag=!0}}generateDrawable(){const{x:e,y:r,width:i,height:s}=this;return Qk.rectangle(e,r,i,s,this.roughOptions)}}class Xb extends Jk(dK(Of)){constructor(e={}){super(e),this.onGeometryChanged=()=>{this.geometryDirtyFlag=!0}}generateDrawable(){const{points:e}=this;return Qk.linearPath(e,this.roughOptions)}}class ry extends Jk(pK(Of)){constructor(e={}){super(e),this.onGeometryChanged=()=>{this.geometryDirtyFlag=!0}}generateDrawable(){const{d:e}=this;return Qk.path(e,this.roughOptions)}}const Qk=AG.generator();function Lut(t){const e=[];return t.ops.forEach(({op:r,data:i})=>{r==="move"?e.push(["M",i[0],i[1]]):r==="lineTo"?e.push(["L",i[0],i[1]]):r==="bcurveTo"&&e.push(["C",i[0],i[1],i[2],i[3],i[4],i[5]])}),e}var Uut=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Gut=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};const Wut=["renderable","visible"],iy=["cullable","batchable","fill","stroke","strokeWidth","strokeAlignment","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeDasharray","strokeDashoffset","opacity","fillOpacity","strokeOpacity","innerShadowColor","innerShadowOffsetX","innerShadowOffsetY","innerShadowBlurRadius"],tL=["drawableSets","seed","roughness","bowing","fillStyle","fillWeight","hachureAngle","hachureGap","curveStepCount","simplification","curveFitting","fillLineDash","fillLineDashOffset","disableMultiStroke","disableMultiStrokeFill","dashOffset","dashGap","zigzagOffset","preserveVertices"],jut=["cx","cy","r"],Xut=["cx","cy","rx","ry"],zut=["x","y","width","height","cornerRadius","dropShadowColor","dropShadowOffsetX","dropShadowOffsetY","dropShadowBlurRadius"],Vut=["points"],Yut=["d"],b6t={opacity:1,fillOpacity:1,strokeOpacity:1,fill:"black",stroke:"none",strokeWidth:1,strokeLinecap:"butt",strokeLinejoin:"miter",strokeAlignment:"center",strokeMiterlimit:4,strokeDasharray:"none",strokeDashoffset:0,innerShadowBlurRadius:0,innerShadowColor:"none",innerShadowOffsetX:0,innerShadowOffsetY:0,visibility:"visible",transform:"matrix(1,0,0,1,0,0)",cornerRadius:0,dropShadowColor:"none",dropShadowOffsetX:0,dropShadowOffsetY:0,dropShadowBlurRadius:0};function w6t(t){if(t instanceof S8)return["g",Wut];if(t instanceof qm)return["circle",[...iy,...jut]];if(t instanceof Zm)return["ellipse",[...iy,...Xut]];if(t instanceof Qm)return["rect",[...iy,...zut]];if(t instanceof Wb)return["polyline",[...iy,...Vut]];if(t instanceof W0)return["path",[...iy,...Yut]];if(t instanceof ty)return["rough-circle",[...iy,...jut,...tL]];if(t instanceof ey)return["rough-ellipse",[...iy,...Xut,...tL]];if(t instanceof pg)return["rough-rect",[...iy,...zut,...tL]];if(t instanceof Xb)return["rough-polyline",[...iy,...Vut,...tL]];if(t instanceof ry)return["rough-path",[...iy,...Yut,...tL]]}function $ut(t){return Uut(this,void 0,void 0,function*(){const{type:e,attributes:r,children:i}=t;let s;e==="g"?s=new S8:e==="circle"?s=new qm:e==="ellipse"?s=new Zm:e==="rect"?s=new Qm:e==="polyline"?s=new Wb:e==="path"?s=new W0:e==="rough-circle"?s=new ty:e==="rough-ellipse"?s=new ey:e==="rough-rect"?s=new pg:e==="rough-polyline"?s=new Xb:e==="rough-path"&&(s=new ry);const{transform:o}=r,n=Gut(r,["transform"]);Object.assign(s,n);const{fill:a,points:l,strokeDasharray:c}=n;if(a&&Bf(a)&&Tut(a)&&(s.fill=yield nu(a,Hh)),l&&Bf(l)&&(s.points=l.split(" ").map(h=>h.split(",").map(Number))),c&&Bf(c)&&(s.strokeDasharray=c.split(" ").map(Number)),o){const{position:h,scale:u,skew:d,rotation:f,pivot:g}=o;s.transform.position.set(h.x,h.y),s.transform.scale.set(u.x,u.y),s.transform.skew.set(d.x,d.y),s.transform.rotation=f,s.transform.pivot.set(g.x,g.y)}return i&&i.length>0&&(yield Promise.all(i.map(h=>Uut(this,void 0,void 0,function*(){s.appendChild(yield $ut(h))})))),s})}function gK(t){const[e,r]=w6t(t),i={uid:t.uid,type:e,attributes:[...Wut,...r].reduce((a,l)=>(Vn(t[l])||(a[l]=t[l]),a),{})},{fill:s,points:o,strokeDasharray:n}=i.attributes;return s&&!Bf(s)&&(i.attributes.fill=C6t(s)),o&&(i.attributes.points=o.map(([a,l])=>`${a},${l}`).join(" ")),n&&(i.attributes.strokeDasharray=n.join(" ")),i.attributes.transform=E6t(t.transform),i.children=t.children.map(gK),i}function E6t(t){const{a:e,b:r,c:i,d:s,tx:o,ty:n}=t.localTransform;return{matrix:{a:e,b:r,c:i,d:s,tx:o,ty:n},position:{x:t.position.x,y:t.position.y},scale:{x:t.scale.x,y:t.scale.y},skew:{x:t.skew.x,y:t.skew.y},rotation:t.rotation,pivot:{x:t.pivot.x,y:t.pivot.y}}}function A6t(t,e,r,i){const{type:s,attributes:o}=t,{strokeWidth:n,strokeAlignment:a}=o,l=a==="inner",c=n/2;
5675if(s==="polyline"){const{points:h}=o,u=h.split(" ").map(f=>f.split(",").map(Number)),d=fK(u,l,n);e.setAttribute("points",d.map(f=>f.join(",")).join(" "))}else{const h=e.cloneNode();if(e.setAttribute("stroke","none"),h.setAttribute("fill","none"),s==="circle"){const{r:u}=o,d=l?-c:c;h.setAttribute("r",`${u+d}`)}else if(s==="ellipse"){const{rx:u,ry:d}=o,f=l?-c:c;h.setAttribute("rx",`${u+f}`),h.setAttribute("ry",`${d+f}`)}else if(s==="rect"){const{x:u,y:d,width:f,height:g,strokeWidth:p}=o;h.setAttribute("x",`${u+(l?c:-c)}`),h.setAttribute("y",`${d+(l?c:-c)}`),h.setAttribute("width",`${f+(l?-p:p)}`),h.setAttribute("height",`${g+(l?-p:p)}`)}r.appendChild(h)}}function x6t(t,e,r,i){const{uid:s,attributes:{innerShadowOffsetX:o,innerShadowOffsetY:n,innerShadowBlurRadius:a,innerShadowColor:l}}=t,c=ns("defs",i),h=ns("filter",i);h.id=`filter_inner_shadow_${s}`;const u=ns("feComponentTransfer",i);u.setAttribute("in","SourceAlpha");const d=ns("feFuncA",i);d.setAttribute("type","table"),d.setAttribute("tableValues","1 0"),u.appendChild(d),h.appendChild(u);const f=ns("feGaussianBlur",i);f.setAttribute("stdDeviation",`${(a||0)/4}`),h.appendChild(f);const g=ns("feOffset",i);g.setAttribute("dx",`${(o||0)/2}`),g.setAttribute("dy",`${(n||0)/2}`),g.setAttribute("result","offsetblur"),h.appendChild(g);const p=ns("feFlood",i);p.setAttribute("flood-color",l),p.setAttribute("result","color"),h.appendChild(p);const m=ns("feComposite",i);m.setAttribute("in2","offsetblur"),m.setAttribute("operator","in"),h.appendChild(m);const v=ns("feComposite",i);v.setAttribute("in2","SourceAlpha"),v.setAttribute("operator","in"),h.appendChild(v);const b=ns("feMerge",i);h.appendChild(b);const y=ns("feMergeNode",i);y.setAttribute("in","SourceGraphic");const _=ns("feMergeNode",i);b.appendChild(y),b.appendChild(_),c.appendChild(h),e.appendChild(c);const w=e.getAttribute("filter")||"";e.setAttribute("filter",`${w} url(#${h.id})`.trim())}function S6t(t,e,r,i){const{uid:s,attributes:{dropShadowBlurRadius:o,dropShadowColor:n,dropShadowOffsetX:a,dropShadowOffsetY:l}}=t,c=ns("defs",i),h=ns("filter",i);h.id=`filter_drop_shadow_${s}`;const u=ns("feDropShadow",i);u.setAttribute("dx",`${(a||0)/2}`),u.setAttribute("dy",`${(l||0)/2}`),u.setAttribute("stdDeviation",`${(o||0)/4}`),u.setAttribute("flood-color",n),h.appendChild(u),c.appendChild(h),e.appendChild(c);const d=e.getAttribute("filter")||"";e.setAttribute("filter",`${d} url(#${h.id})`.trim())}function T6t(t,e,r,i){const s=ns("defs",i),o=ns("pattern",i);o.id=`image-fill_${t.uid}`,o.setAttribute("patternUnits","objectBoundingBox"),o.setAttribute("width","1"),o.setAttribute("height","1");const n=ns("image",i);n.setAttribute("href",t.attributes.fill),n.setAttribute("x","0"),n.setAttribute("y","0");let a;t.type==="circle"?a=qm.getGeometryBounds(t.attributes):t.type==="ellipse"?a=Zm.getGeometryBounds(t.attributes):t.type==="rect"&&(a=Qm.getGeometryBounds(t.attributes)),n.setAttribute("width",`${a.maxX-a.minX}`),n.setAttribute("height",`${a.maxY-a.minY}`),o.appendChild(n),s.appendChild(o),r.appendChild(s),e.setAttribute("fill",`url(#${o.id})`)}function R6t(t,e,r){const{attributes:{drawableSets:i,stroke:s,fill:o}}=t;i.forEach(n=>{const{type:a}=n,l=Lut(n),c=Bv(l,2),h=ns("path",r);h.setAttribute("d",c),e.appendChild(h),a==="fillSketch"?(h.setAttribute("stroke",o),h.setAttribute("fill","none")):a==="path"?(h.setAttribute("stroke",s),h.setAttribute("fill","none")):a==="fillPath"&&(h.setAttribute("fill",o),h.setAttribute("stroke","none"))})}function mK(t,e){const{type:r,attributes:i,children:s}=t,o=r.startsWith("rough-"),n=!o&&ns(r,e),{transform:a,visible:l,cullable:c,renderable:h,batchable:u,innerShadowColor:d,innerShadowOffsetX:f,innerShadowOffsetY:g,innerShadowBlurRadius:p,dropShadowColor:m,dropShadowOffsetX:v,dropShadowOffsetY:b,dropShadowBlurRadius:y,strokeAlignment:_,cornerRadius:w}=i,E=Gut(i,["transform","visible","cullable","renderable","batchable","innerShadowColor","innerShadowOffsetX","innerShadowOffsetY","innerShadowBlurRadius","dropShadowColor","dropShadowOffsetX","dropShadowOffsetY","dropShadowBlurRadius","strokeAlignment","cornerRadius"]);
5675n&&Object.entries(E).forEach(([U,H])=>{`${H}`!=""&&`${b6t[U]}`!=`${H}`&&n.setAttribute(o6t(U),`${H}`)});const A=_==="inner"||_==="outer",x=E.fill&&Bf(E.fill)&&Tut(E.fill);let S;(s&&s.length>0&&r!=="g"||A&&r!=="polyline"||o||x)&&(S=ns("g",e),n&&S.appendChild(n)),A&&A6t(t,n,S),p>0&&x6t(t,n,S,e),y>0&&S6t(t,n||S,S,e),x&&T6t(t,n,S,e),S=S||n,l===!1&&S.setAttribute("visibility","hidden"),w&&(S.setAttribute("rx",`${w}`),S.setAttribute("ry",`${w}`)),o&&R6t(t,S,e);const{a:T,b:R,c:B,d:O,tx:C,ty:F}=a.matrix;return(T!==1||R!==0||B!==0||O!==1||C!==0||F!==0)&&S.setAttribute("transform",`matrix(${T},${R},${B},${O},${C},${F})`),[...s].map(U=>mK(U,e)).forEach(U=>{S.appendChild(U)}),S}function Hut(t,e=0){const r=t.tagName.toLowerCase(),i=Array.from(t.attributes).reduce((o,n)=>{const a=n6t(n.name);let l=n.value;return a==="transform"?l=M6t(l):(a==="opacity"||a==="fillOpacity"||a==="strokeOpacity"||a==="strokeWidth"||a==="strokeMiterlimit"||a==="strokeDashoffset")&&(l=Number(l)),o[a]=l,o},{}),s=Array.from(t.children).map(o=>Hut(o,e++));return{uid:e,type:r,attributes:i,children:s}}function C6t(t){const e=document.createElement("canvas");return e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0),e.toDataURL()}function M6t(t){const e={matrix:{a:1,b:0,c:0,d:1,tx:0,ty:0},position:{x:0,y:0},scale:{x:1,y:1},skew:{x:0,y:0},rotation:0,pivot:{x:0,y:0}},r=/translate\(([^,]+),([^,]+)\)/,i=/rotate\(([^,]+)\)/,s=/scale\(([^,]+)(?:,([^,]+))?\)/,o=/skew\(([^,]+),([^,]+)\)/,n=/matrix\(([^,]+),([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)\)/,a=t.match(r);a&&(e.position.x=parseFloat(a[1]),e.position.y=parseFloat(a[2]));const l=t.match(i);l&&(e.rotation=parseFloat(l[1]));const c=t.match(s);c&&(e.scale.x=parseFloat(c[1]),c[2]&&(e.scale.y=parseFloat(c[2])));const h=t.match(o);h&&(e.skew.x=parseFloat(h[1]),e.skew.y=parseFloat(h[2]));const u=t.match(n);return u&&(e.matrix.a=parseFloat(u[1]),e.matrix.b=parseFloat(u[2]),e.matrix.c=parseFloat(u[3]),e.matrix.d=parseFloat(u[4]),e.matrix.tx=parseFloat(u[5]),e.matrix.ty=parseFloat(u[6])),e}let eL=class{constructor(){this.arcLengthDivisions=200,this.needsUpdate=!0}getPointAt(t,e){const r=this.getUtoTmapping(t);return this.getPoint(r,e)}getPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}getSpacedPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let r,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=Hy(r,i),e.push(s),i=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const r=this.getLengths();let i=0;const s=r.length;let o;e?o=e:o=t*r[s-1];let n=0,a=s-1,l;for(;n<=a;)if(i=Math.floor(n+(a-n)/2),l=r[i]-o,l<0)n=i+1;else if(l>0)a=i-1;else{a=i;break}if(i=a,r[i]===o)return i/(s-1);const c=r[i],h=r[i+1]-c,u=(o-c)/h;return(i+u)/(s-1)}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},yK=class extends eL{constructor(t=it(),e=it()){super(),this.v1=t,this.v2=e,this.v1=t,this.v2=e}getPoint(t,e=it()){const r=e;return t===1?di(r,this.v2):(ru(r,di(r,this.v2),this.v1),lG(r,this.v1,r,t)),r}getPointAt(t,e){return this.getPoint(t,e)}},Kut=class extends eL{constructor(t=0,e=0,r=1,i=1,s=0,o=Math.PI*2,n=!1,a=0){super(),this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=n,this.aRotation=a}getPoint(t,e=it()){const r=e,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);const n=this.aStartAngle+t*s;let a=this.aX+this.xRadius*Math.cos(n),l=this.aY+this.yRadius*Math.sin(n);if(this.aRotation!==0){const c=Math.cos(this.aRotation),h=Math.sin(this.aRotation),u=a-this.aX,d=l-this.aY;a=u*c-d*h+this.aX,l=u*h+d*c+this.aY}return Jn(r,a,l)}},B6t=class extends eL{constructor(){super(...arguments),this.curves=[],this.autoClose=!1,this.cacheLengths=null}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);return sd(t,e)||this.curves.push(new yK(e,t)),this}getPoint(t,e){const r=t*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=r){const o=i[s]-r,n=this.curves[s],a=n.getLength(),l=a===0?0:1-o/a;return n.getPointAt(l,e)}s++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let r=0,i=this.curves.length;r<i;r++)e+=this.curves[r].getLength(),t.push(e);return this.cacheLengths=t,t}getPoints(t=12){const e=[];let r;for(let i=0,s=this.curves;i<s.length;i++){const o=s[i],n=o instanceof Kut?t*2:o instanceof yK?1:o.isSplineCurve?t*o.points.length:t,a=o.getPoints(n);for(let l=0;l<a.length;l++){const c=a[l];r&&sd(r,c)||(e.push(c),r=c)}}return this.autoClose&&e.length>1&&!sd(e[e.length-1],e[0])&&e.push(e[0]),e}};function O6t(t,e){const r=1-t;return r*r*e}function I6t(t,e){return 2*(1-t)*t*e}function D6t(t,e){return t*t*e}function qut(t,e,r,i){return O6t(t,e)+I6t(t,r)+D6t(t,i)}function P6t(t,e){const r=1-t;return r*r*r*e}function F6t(t,e){const r=1-t;return 3*r*r*t*e}function N6t(t,e){return 3*(1-t)*t*t*e}function k6t(t,e){return t*t*t*e}
5675function Zut(t,e,r,i,s){return P6t(t,e)+F6t(t,r)+N6t(t,i)+k6t(t,s)}let L6t=class extends eL{constructor(t=it(),e=it(),r=it()){super(),this.v0=t,this.v1=e,this.v2=r,this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=it()){const r=e,{v0:i,v1:s,v2:o}=this;return Jn(r,qut(t,i[0],s[0],o[0]),qut(t,i[1],s[1],o[1])),r}getPointAt(t,e){return this.getPoint(t,e)}},U6t=class extends eL{constructor(t=it(),e=it(),r=it(),i=it()){super(),this.v0=t,this.v1=e,this.v2=r,this.v3=i,this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=it()){const r=e,{v0:i,v1:s,v2:o,v3:n}=this;return Jn(r,Zut(t,i[0],s[0],o[0],n[0]),Zut(t,i[1],s[1],o[1],n[1])),r}getPointAt(t,e){return this.getPoint(t,e)}},G6t=class extends B6t{constructor(t){super(),this.currentPoint=it(),t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0][0],t[0][1]);for(let e=1,r=t.length;e<r;e++)this.lineTo(t[e][0],t[e][1]);return this}moveTo(t,e){return Jn(this.currentPoint,t,e),this}lineTo(t,e){const r=new yK(Ta(this.currentPoint),Be(t,e));return this.curves.push(r),Jn(this.currentPoint,t,e),this}quadraticCurveTo(t,e,r,i){const s=new L6t(Ta(this.currentPoint),Be(t,e),Be(r,i));return this.curves.push(s),Jn(this.currentPoint,r,i),this}bezierCurveTo(t,e,r,i,s,o){const n=new U6t(Ta(this.currentPoint),Be(t,e),Be(r,i),Be(s,o));return this.curves.push(n),Jn(this.currentPoint,s,o),this}arc(t,e,r,i,s,o){const[n,a]=this.currentPoint;return this.absarc(t+n,e+a,r,i,s,o),this}absarc(t,e,r,i,s,o){return this.absellipse(t,e,r,r,i,s,o),this}absellipse(t,e,r,i,s,o,n,a){const l=new Kut(t,e,r,i,s,o,n,a);if(this.curves.length>0){const h=l.getPoint(0);sd(h,this.currentPoint)||this.lineTo(h[0],h[1])}this.curves.push(l);const c=l.getPoint(1);return di(this.currentPoint,c),this}},W6t=class{constructor(){this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new G6t,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,r,i){return this.currentPath.quadraticCurveTo(t,e,r,i),this}bezierCurveTo(t,e,r,i,s,o){return this.currentPath.bezierCurveTo(t,e,r,i,s,o),this}};function vK(t){const e=new W6t,r=it(),i=it(),s=it();let o=!0,n=!1;return(Bf(t)?ep(t):Lut(t)).forEach(a=>{const l=a[0],c=a.slice(1);o===!0&&(n=!0,o=!1);let h;switch(l){case"M":h=c;for(let u=0,d=h.length;u<d;u+=2)r[0]=h[u+0],r[1]=h[u+1],i[0]=r[0],i[1]=r[1],u===0?e.moveTo(r[0],r[1]):e.lineTo(r[0],r[1]),u===0&&di(s,r);break;case"H":h=c;for(let u=0,d=h.length;u<d;u++)r[0]=h[u],i[0]=r[0],i[1]=r[1],e.lineTo(r[0],r[1]),u===0&&n===!0&&di(s,r);break;case"V":h=c;for(let u=0,d=h.length;u<d;u++)r[1]=h[u],i[0]=r[0],i[1]=r[1],e.lineTo(r[0],r[1]),u===0&&n===!0&&di(s,r);break;case"L":h=c;for(let u=0,d=h.length;u<d;u+=2)r[0]=h[u+0],r[1]=h[u+1],i[0]=r[0],i[1]=r[1],e.lineTo(r[0],r[1]),u===0&&n===!0&&di(s,r);break;case"C":h=c;for(let u=0,d=h.length;u<d;u+=6)e.bezierCurveTo(h[u+0],h[u+1],h[u+2],h[u+3],h[u+4],h[u+5]),i[0]=h[u+2],i[1]=h[u+3],r[0]=h[u+4],r[1]=h[u+5],u===0&&n===!0&&di(s,r);break;case"S":h=c;for(let u=0,d=h.length;u<d;u+=4)e.bezierCurveTo(T8(r[0],i[0]),T8(r[1],i[1]),h[u+0],h[u+1],h[u+2],h[u+3]),i[0]=h[u+0],i[1]=h[u+1],r[0]=h[u+2],r[1]=h[u+3],u===0&&n===!0&&di(s,r);break;case"Q":h=c;for(let u=0,d=h.length;u<d;u+=4)e.quadraticCurveTo(h[u+0],h[u+1],h[u+2],h[u+3]),i[0]=h[u+0],i[1]=h[u+1],r[0]=h[u+2],r[1]=h[u+3],u===0&&n===!0&&di(s,r);break;case"T":h=c;for(let u=0,d=h.length;u<d;u+=2){const f=T8(r[0],i[0]),g=T8(r[1],i[1]);e.quadraticCurveTo(f,g,h[u+0],h[u+1]),i[0]=f,i[1]=g,r[0]=h[u+0],r[1]=h[u+1],u===0&&n===!0&&di(s,r)}break;case"A":h=c;for(let u=0,d=h.length;u<d;u+=7){if(h[u+5]==r[0]&&h[u+6]==r[1])continue;const f=Ta(r);r[0]=h[u+5],r[1]=h[u+6],i[0]=r[0],i[1]=r[1],j6t(e,h[u],h[u+1],h[u+2],h[u+3],h[u+4],f,r),u===0&&n===!0&&di(s,r)}break;case"Z":e.currentPath.autoClose=!0,e.currentPath.curves.length>0&&(di(r,s),di(e.currentPath.currentPoint,r),o=!0);break;default:console.warn(a)}n=!1}),e}function T8(t,e){return t-(e-t)}function j6t(t,e,r,i,s,o,n,a){if(e==0||r==0){t.lineTo(a[0],a[1]);return}i=i*Math.PI/180,e=Math.abs(e),r=Math.abs(r);const l=(n[0]-a[0])/2,c=(n[1]-a[1])/2,h=Math.cos(i)*l+Math.sin(i)*c,u=-Math.sin(i)*l+Math.cos(i)*c;let d=e*e,f=r*r;const g=h*h,p=u*u,m=g/d+p/f;if(m>1){const T=Math.sqrt(m);e=T*e,r=T*r,d=e*e,f=r*r}const v=d*p+f*g,b=(d*f-v)/v;let y=Math.sqrt(Math.max(0,b));s===o&&(y=-y);const _=y*e*u/r,w=-y*r*h/e,E=Math.cos(i)*_-Math.sin(i)*w+(n[0]+a[0])/2,A=Math.sin(i)*_+Math.cos(i)*w+(n[1]+a[1])/2,x=Jut(1,0,(h-_)/e,(u-w)/r),S=Jut((h-_)/e,(u-w)/r,(-h-_)/e,(-u-w)/r)%(Math.PI*2);t.currentPath.absellipse(E,A,e,r,x,x+S,o===0,i)}function Jut(t,e,r,i){const s=t*r+e*i,o=Math.sqrt(t*t+e*e)*Math.sqrt(r*r+i*i);let n=Math.acos(Math.max(-1,Math.min(1,s/o)));return t*i-e*r<0&&(n=-n),n}const gg=new Eo.GluTesselator;gg.gluTessCallback(Eo.gluEnum.GLU_TESS_VERTEX_DATA,X6t),gg.gluTessCallback(Eo.gluEnum.GLU_TESS_BEGIN,z6t),gg.gluTessCallback(Eo.gluEnum.GLU_TESS_ERROR,V6t),gg.gluTessCallback(Eo.gluEnum.GLU_TESS_COMBINE,Y6t),gg.gluTessCallback(Eo.gluEnum.GLU_TESS_EDGE_FLAG,$6t);function X6t(t,e){e[e.length]=t[0],e[e.length]=t[1]}function z6t(t){t!==Eo.primitiveType.GL_TRIANGLES&&console.log("expected TRIANGLES but got type: "+t)}
5675function V6t(t){console.log("error callback"),console.log("error number: "+t)}function Y6t(t,e,r){return[t[0],t[1],t[2]]}function $6t(t){}function H6t(t){gg.gluTessNormal(0,0,1);const e=[];gg.gluTessBeginPolygon(e);for(let r=0;r<t.length;r++){gg.gluTessBeginContour();const i=t[r];for(let s=0;s<i.length;s++){const o=[i[s][0],i[s][1],0];gg.gluTessVertex(o,o)}gg.gluTessEndContour()}return gg.gluTessEndPolygon(),e}var wr=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Cc=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},mg,Lu,Uu,If,rL,iL,yg,sL,oL,nL,R8,aL;const Qut=1e-4;let tdt=class C1t{constructor(e,r){this.clipSpaceNearZ=Sh.NEGATIVE_ONE,mg.set(this,1),Lu.set(this,0),Uu.set(this,0),If.set(this,0),rL.set(this,0),iL.set(this,0),yg.set(this,Bt()),sL.set(this,Bt()),oL.set(this,Bt()),nL.set(this,Bt()),R8.set(this,Bt()),aL.set(this,void 0),this.projection(e,r),this.updateMatrix()}clone(){const e=new C1t(wr(this,rL,"f"),wr(this,iL,"f"));return Cc(e,Lu,wr(this,Lu,"f"),"f"),Cc(e,Uu,wr(this,Uu,"f"),"f"),Cc(e,mg,wr(this,mg,"f"),"f"),Cc(e,If,wr(this,If,"f"),"f"),e.updateMatrix(),e}projection(e,r){Cc(this,rL,e,"f"),Cc(this,iL,r,"f"),ld(wr(this,sL,"f"),e,r),this.updateViewProjectionMatrix()}updateMatrix(){const e=1/wr(this,mg,"f");Yc(wr(this,yg,"f")),bi(wr(this,yg,"f"),wr(this,yg,"f"),[wr(this,Lu,"f"),wr(this,Uu,"f")]),Mo(wr(this,yg,"f"),wr(this,yg,"f"),wr(this,If,"f")),xh(wr(this,yg,"f"),wr(this,yg,"f"),[e,e]),_i(wr(this,oL,"f"),wr(this,yg,"f")),this.updateViewProjectionMatrix()}updateViewProjectionMatrix(){us(wr(this,nL,"f"),wr(this,sL,"f"),wr(this,oL,"f")),_i(wr(this,R8,"f"),wr(this,nL,"f")),this.onchange&&this.onchange()}get projectionMatrix(){return wr(this,sL,"f")}get viewMatrix(){return wr(this,oL,"f")}get viewProjectionMatrix(){return wr(this,nL,"f")}get viewProjectionMatrixInv(){return wr(this,R8,"f")}get matrix(){return wr(this,yg,"f")}get zoom(){return wr(this,mg,"f")}set zoom(e){wr(this,mg,"f")!==e&&(Cc(this,mg,e,"f"),this.updateMatrix())}get x(){return wr(this,Lu,"f")}set x(e){wr(this,Lu,"f")!==e&&(Cc(this,Lu,e,"f"),this.updateMatrix())}get y(){return wr(this,Uu,"f")}set y(e){wr(this,Uu,"f")!==e&&(Cc(this,Uu,e,"f"),this.updateMatrix())}get rotation(){return wr(this,If,"f")}set rotation(e){wr(this,If,"f")!==e&&(Cc(this,If,e,"f"),this.updateMatrix())}get width(){return wr(this,rL,"f")}get height(){return wr(this,iL,"f")}createLandmark(e={}){return Object.assign({zoom:wr(this,mg,"f"),x:wr(this,Lu,"f"),y:wr(this,Uu,"f"),rotation:wr(this,If,"f")},e)}gotoLandmark(e,r={},i){const{easing:s="linear",duration:o=100,onframe:n=void 0,onfinish:a=void 0}=r,{zoom:l=wr(this,mg,"f"),x:c=wr(this,Lu,"f"),y:h=wr(this,Uu,"f"),rotation:u=wr(this,If,"f"),viewportX:d=0,viewportY:f=0}=e,g=d||f,p=()=>{this.applyLandmark({x:c,y:h,zoom:l,rotation:u,viewportX:d,viewportY:f}),a&&a()};if(o===0){p();return}this.cancelLandmarkAnimation();let m;const v=[c,h],b=[l,u],y=_=>{m===void 0&&(m=_);const w=_-m;if(w>o){p();return}const E=i6t[s](w/o),A=it(),x=Be(1,0);if(ta(A,[wr(this,Lu,"f"),wr(this,Uu,"f")],v,E),ta(x,[this.zoom,wr(this,If,"f")],b,E),this.applyLandmark({x:A[0],y:A[1],zoom:x[0],rotation:x[1],viewportX:d,viewportY:f}),g?za(x,b)<=Qut:za(A,v)<=Qut){p();return}w<o&&(n&&n(E),Cc(this,aL,(i||requestAnimationFrame)(y),"f"))};(i||requestAnimationFrame)(y)}cancelLandmarkAnimation(e){wr(this,aL,"f")!==void 0&&(e||cancelAnimationFrame)(wr(this,aL,"f"))}viewport2Canvas({x:e,y:r},i){const{width:s,height:o,viewProjectionMatrixInv:n}=i||this,a=Qt(it(),[e/s*2-1,(1-r/o)*2-1],n);return{x:a[0],y:a[1]}}canvas2Viewport({x:e,y:r},i){const{width:s,height:o,viewProjectionMatrix:n}=i||this,a=Qt(it(),[e,r],n);return{x:(a[0]+1)/2*s,y:(1-(a[1]+1)/2)*o}}applyLandmark(e){const{x:r,y:i,zoom:s,rotation:o,viewportX:n,viewportY:a}=e,l=n||a;let c=0,h=0;if(l){const u=this.viewport2Canvas({x:n,y:a});c=u.x,h=u.y}if(Cc(this,mg,s,"f"),Cc(this,If,o,"f"),Cc(this,Lu,r,"f"),Cc(this,Uu,i,"f"),this.updateMatrix(),l){const{x:u,y:d}=this.viewport2Canvas({x:n,y:a});Cc(this,Lu,wr(this,Lu,"f")+(c-u),"f"),Cc(this,Uu,wr(this,Uu,"f")+(h-d),"f"),this.updateMatrix()}}};mg=new WeakMap,Lu=new WeakMap,Uu=new WeakMap,If=new WeakMap,rL=new WeakMap,iL=new WeakMap,yg=new WeakMap,sL=new WeakMap,oL=new WeakMap,nL=new WeakMap,R8=new WeakMap,aL=new WeakMap;const C8=1e5;let M8=class{constructor(t,e,r,i){this.device=t,this.renderCache=e,this.instanced=r,this.index=i,this.uid=Rut(),this.shapes=[],this.maxInstances=1/0,this.geometryDirty=!0,this.materialDirty=!0,this.destroyed=!1}destroy(){this.destroyed=!0}validate(t){return this.count()<=this.maxInstances-1}submit(t,e,r){this.geometryDirty&&this.createGeometry(),this.materialDirty&&this.createMaterial(e),this.render(t,r),this.geometryDirty&&(this.geometryDirty=!1),this.materialDirty&&(this.materialDirty=!1)}add(t){this.shapes.includes(t)||(this.shapes.push(t),this.geometryDirty=!0)}remove(t){if(this.shapes.includes(t)){const e=this.shapes.indexOf(t);this.shapes.splice(e,1),this.geometryDirty=!0}}count(){return this.shapes.length}};var fa;(function(t){t[t.FRAG_COORD=0]="FRAG_COORD",t[t.ABCD=1]="ABCD",t[t.TXTY=2]="TXTY",t[t.POSITION_SIZE=3]="POSITION_SIZE",t[t.FILL_COLOR=4]="FILL_COLOR",t[t.STROKE_COLOR=5]="STROKE_COLOR",t[t.ZINDEX_STROKE_WIDTH=6]="ZINDEX_STROKE_WIDTH",t[t.OPACITY=7]="OPACITY",t[t.INNER_SHADOW_COLOR=8]="INNER_SHADOW_COLOR",t[t.INNER_SHADOW=9]="INNER_SHADOW"})(fa||(fa={}));const K6t=` 5676layout(std140) uniform SceneUniforms { 5677 mat3 u_ProjectionMatrix; 5678 mat3 u_ViewMatrix; 5679 mat3 u_ViewProjectionInvMatrix;
5680 vec4 u_BackgroundColor; 5681 vec4 u_GridColor; 5682 float u_ZoomScale; 5683 float u_CheckboardStyle; 5684}; 5685 5686layout(location = ${fa.FRAG_COORD}) in vec2 a_FragCoord; 5687 5688#ifdef USE_INSTANCES 5689 layout(location = ${fa.ABCD}) in vec4 a_Abcd; 5690 layout(location = ${fa.TXTY}) in vec2 a_Txty; 5691 layout(location = ${fa.POSITION_SIZE}) in vec4 a_PositionSize; 5692 layout(location = ${fa.FILL_COLOR}) in vec4 a_FillColor; 5693 layout(location = ${fa.STROKE_COLOR}) in vec4 a_StrokeColor; 5694 layout(location = ${fa.ZINDEX_STROKE_WIDTH}) in vec4 a_ZIndexStrokeWidth; 5695 layout(location = ${fa.OPACITY}) in vec4 a_Opacity; 5696 layout(location = ${fa.INNER_SHADOW_COLOR}) in vec4 a_InnerShadowColor; 5697 layout(location = ${fa.INNER_SHADOW}) in vec4 a_InnerShadow; 5698#else 5699 layout(std140) uniform ShapeUniforms { 5700 mat3 u_ModelMatrix; 5701 vec4 u_PositionSize; 5702 vec4 u_FillColor; 5703 vec4 u_StrokeColor; 5704 vec4 u_ZIndexStrokeWidth; 5705 vec4 u_Opacity; 5706 vec4 u_InnerShadowColor; 5707 vec4 u_InnerShadow; 5708 }; 5709#endif 5710 5711out vec2 v_FragCoord; 5712#ifdef USE_INSTANCES 5713 out vec4 v_FillColor; 5714 out vec4 v_StrokeColor; 5715 out float v_StrokeWidth; 5716 out vec4 v_Opacity; 5717 out float v_CornerRadius; 5718 out float v_StrokeAlignment; 5719 out vec4 v_InnerShadowColor; 5720 out vec4 v_InnerShadow; 5721#else 5722#endif 5723out vec2 v_Radius; 5724 5725#ifdef USE_FILLIMAGE 5726 out vec2 v_Uv; 5727#endif 5728 5729void main() { 5730 mat3 model; 5731 vec2 position; 5732 vec2 size; 5733 vec4 fillColor; 5734 vec4 strokeColor; 5735 float zIndex; 5736 float strokeWidth; 5737 float strokeAlignment; 5738 5739 #ifdef USE_INSTANCES 5740 model = mat3(a_Abcd.x, a_Abcd.y, 0, a_Abcd.z, a_Abcd.w, 0, a_Txty.x, a_Txty.y, 1); 5741 position = a_PositionSize.xy; 5742 size = a_PositionSize.zw; 5743 fillColor = a_FillColor; 5744 strokeColor = a_StrokeColor; 5745 zIndex = a_ZIndexStrokeWidth.x; 5746 strokeWidth = a_ZIndexStrokeWidth.y; 5747 strokeAlignment = a_ZIndexStrokeWidth.w; 5748 5749 v_FillColor = fillColor; 5750 v_StrokeColor = strokeColor; 5751 v_StrokeWidth = strokeWidth; 5752 v_Opacity = a_Opacity; 5753 v_CornerRadius = a_ZIndexStrokeWidth.z; 5754 v_StrokeAlignment = a_ZIndexStrokeWidth.w; 5755 v_InnerShadowColor = a_InnerShadowColor; 5756 v_InnerShadow = a_InnerShadow; 5757 #else 5758 model = u_ModelMatrix; 5759 position = u_PositionSize.xy; 5760 size = u_PositionSize.zw; 5761 fillColor = u_FillColor; 5762 strokeColor = u_StrokeColor; 5763 zIndex = u_ZIndexStrokeWidth.x; 5764 strokeWidth = u_ZIndexStrokeWidth.y; 5765 strokeAlignment = u_ZIndexStrokeWidth.w; 5766 #endif 5767 5768 float strokeOffset; 5769 if (strokeAlignment < 0.5) { 5770 strokeOffset = strokeWidth / 2.0; 5771 } else if (strokeAlignment < 1.5) { 5772 strokeOffset = 0.0; 5773 } else if (strokeAlignment < 2.5) { 5774 strokeOffset = strokeWidth; 5775 } 5776 5777 vec2 radius = size + vec2(strokeOffset); 5778 5779 v_FragCoord = vec2(a_FragCoord * radius); 5780 v_Radius = radius; 5781 5782 #ifdef USE_FILLIMAGE 5783 v_Uv = (a_FragCoord * radius / size + 1.0) / 2.0; 5784 #endif 5785 5786 gl_Position = vec4((u_ProjectionMatrix 5787 * u_ViewMatrix 5788 * model 5789 * vec3(position + v_FragCoord, 1)).xy, zIndex, 1); 5790} 5791`,q6t=` 5792layout(std140) uniform SceneUniforms { 5793 mat3 u_ProjectionMatrix; 5794 mat3 u_ViewMatrix; 5795 mat3 u_ViewProjectionInvMatrix; 5796 vec4 u_BackgroundColor; 5797 vec4 u_GridColor; 5798 float u_ZoomScale; 5799 float u_CheckboardStyle; 5800}; 5801 5802#ifdef USE_INSTANCES 5803#else 5804 layout(std140) uniform ShapeUniforms { 5805 mat3 u_ModelMatrix; 5806 vec4 u_PositionSize; 5807 vec4 u_FillColor; 5808 vec4 u_StrokeColor; 5809 vec4 u_ZIndexStrokeWidth; 5810 vec4 u_Opacity; 5811 vec4 u_InnerShadowColor; 5812 vec4 u_InnerShadow; 5813 }; 5814#endif 5815 5816out vec4 outputColor; 5817 5818in vec2 v_FragCoord; 5819#ifdef USE_INSTANCES 5820 in vec4 v_FillColor; 5821 in vec4 v_StrokeColor; 5822 in float v_StrokeWidth; 5823 in vec4 v_Opacity; 5824 in float v_CornerRadius; 5825 in float v_StrokeAlignment; 5826 in vec4 v_InnerShadowColor; 5827 in vec4 v_InnerShadow; 5828#else 5829#endif 5830in vec2 v_Radius; 5831 5832#ifdef USE_FILLIMAGE 5833 in vec2 v_Uv; 5834 uniform sampler2D u_Texture; 5835#endif 5836 5837float epsilon = 0.000001; 5838 5839float sdf_circle(vec2 p, float r) { 5840 return length(p) - r; 5841} 5842 5843float sdf_ellipse(vec2 p, vec2 r) { 5844 float k0 = length(p / r); 5845 float k1 = length(p / (r * r)); 5846 return k0 * (k0 - 1.0) / k1; 5847 5848 // V1 5849 // float k1 = length(p/r); 5850 // return (k1-1.0)*min(r.x,r.y); 5851 5852 // V3 5853 // float k1 = length(p/r); 5854 // return length(p)*(1.0-1.0/k1); 5855} 5856
5857float sdf_rounded_box(vec2 p, vec2 b, float r) { 5858 vec2 q = abs(p) - b + r; 5859 return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r; 5860} 5861 5862vec4 over(vec4 below, vec4 above) { 5863 vec4 result; 5864 float alpha = above.a + below.a * (1.0 - above.a); 5865 result.rgb = 5866 (above.rgb * above.a + below.rgb * below.a * (1.0 - above.a)) / alpha; 5867 result.a = alpha; 5868 return result; 5869} 5870 5871float antialias(float distance) { 5872 return clamp(distance / -fwidth(distance), 0.0, 1.0); 5873} 5874 5875vec4 mix_border_inside(vec4 border, vec4 inside, float distance) { 5876 // Blend the border on top of the background and then linearly interpolate 5877 // between the two as we slide inside the background. 5878 return mix(border, inside, clamp(1.0 - distance, 0.0, 1.0) * antialias(distance)); 5879} 5880 5881float sigmoid(float t) { 5882 return 1.0 / (1.0 + exp(-t)); 5883} 5884 5885float make_shadow(vec2 pos, vec2 halfSize, float cornerRd, float blurRd, float distMul, float shape) { 5886 float distance; 5887 if (shape < 0.5) { 5888 distance = sdf_circle(pos, halfSize.x); 5889 } else if (shape < 1.5) { 5890 distance = sdf_ellipse(pos, halfSize); 5891 } else if (shape < 2.5) { 5892 distance = sdf_rounded_box(pos, halfSize, cornerRd + blurRd); 5893 } 5894 float dist = sigmoid(distMul * distance / blurRd); 5895 return clamp(dist, 0.0, 1.0); 5896} 5897 5898void main() { 5899 float strokeWidth; 5900 vec4 fillColor; 5901 vec4 strokeColor; 5902 float opacity; 5903 float fillOpacity; 5904 float strokeOpacity; 5905 float shape; 5906 float cornerRadius; 5907 vec4 innerShadowColor; 5908 vec4 innerShadow; 5909 float strokeAlignment; 5910 5911 #ifdef USE_INSTANCES 5912 fillColor = v_FillColor; 5913 strokeColor = v_StrokeColor; 5914 strokeWidth = v_StrokeWidth; 5915 opacity = v_Opacity.x; 5916 fillOpacity = v_Opacity.y; 5917 strokeOpacity = v_Opacity.z; 5918 shape = v_Opacity.w; 5919 cornerRadius = v_CornerRadius; 5920 strokeAlignment = v_StrokeAlignment; 5921 innerShadowColor = v_InnerShadowColor; 5922 innerShadow = v_InnerShadow; 5923 #else 5924 fillColor = u_FillColor; 5925 strokeColor = u_StrokeColor; 5926 strokeWidth = u_ZIndexStrokeWidth.y; 5927 opacity = u_Opacity.x; 5928 fillOpacity = u_Opacity.y; 5929 strokeOpacity = u_Opacity.z; 5930 shape = u_Opacity.w; 5931 cornerRadius = u_ZIndexStrokeWidth.z; 5932 strokeAlignment = u_ZIndexStrokeWidth.w; 5933 innerShadowColor = u_InnerShadowColor; 5934 innerShadow = u_InnerShadow; 5935 #endif 5936 5937 #ifdef USE_FILLIMAGE 5938 bool useFillImage = innerShadow.w > 0.5; 5939 if (useFillImage) { 5940 fillColor = texture(SAMPLER_2D(u_Texture), v_Uv); 5941 } 5942 #endif 5943 5944 float distance; 5945 // 'circle', 'ellipse', 'rect' 5946 if (shape < 0.5) { 5947 distance = sdf_circle(v_FragCoord, v_Radius.x); 5948 } else if (shape < 1.5) { 5949 distance = sdf_ellipse(v_FragCoord, v_Radius); 5950 } else if (shape < 2.5) { 5951 distance = sdf_rounded_box(v_FragCoord, v_Radius, cornerRadius); 5952 // TODO: Fast path when the quad is not rounded and doesn't have any border. 5953 } 5954 5955 // based on the target alpha compositing mode. 5956 fillColor.a *= fillOpacity; 5957 strokeColor.a *= strokeOpacity; 5958 5959 vec4 color = fillColor; 5960 float d1; 5961 float d2; 5962 if (strokeAlignment < 0.5) { 5963 d1 = distance + strokeWidth; 5964 d2 = distance + strokeWidth / 2.0; 5965 color = mix_border_inside(over(fillColor, strokeColor), fillColor, d1); 5966 color = mix_border_inside(strokeColor, color, d2); 5967 } else if (strokeAlignment < 1.5) { 5968 d1 = distance + strokeWidth; 5969 d2 = distance; 5970 color = mix_border_inside(over(fillColor, strokeColor), fillColor, d1); 5971 color = mix_border_inside(strokeColor, color, d2); 5972 } else if (strokeAlignment < 2.5) { 5973 d2 = distance + strokeWidth; 5974 color = mix_border_inside(strokeColor, color, d2); 5975 } 5976 outputColor = color; 5977 5978 float innerShadowBlurRadius = innerShadow.z / 2.0; 5979 if (innerShadowBlurRadius > 0.0) { 5980 vec2 shadowOffset = -innerShadow.xy; 5981 float blurRadius = innerShadow.z; 5982 float distMul = -1.0; 5983 float lowerShadow = make_shadow(v_FragCoord + shadowOffset, v_Radius, cornerRadius, blurRadius, distMul, shape); 5984 5985 vec3 lowerShadowColor = innerShadowColor.rgb * innerShadowColor.a; 5986 outputColor = over(vec4(color.xyz, 1.0), vec4(lowerShadowColor, 1.0 - lowerShadow)); 5987 outputColor = over(outputColor, vec4(color.xyz, clamp(distance, 0.0, 1.0))); 5988 } 5989 5990 float antialiasedBlur = -fwidth(length(v_FragCoord)); 5991 float opacity_t = clamp(distance / antialiasedBlur, 0.0, 1.0); 5992 outputColor.a *= clamp(1.0 - distance, 0.0, 1.0) * opacity * opacity_t; 5993 5994 if (outputColor.a < epsilon) 5995 discard; 5996} 5997`;var Ws=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},vg=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
5997return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},j0,KM,zb,Vb,lL,Ex,qM,ZM,B8,cL;const Z6t={center:0,inner:1,outer:2};let _K=class sY extends M8{constructor(){super(...arguments),j0.set(this,void 0),KM.set(this,void 0),zb.set(this,void 0),Vb.set(this,void 0),lL.set(this,void 0),Ex.set(this,void 0),qM.set(this,void 0),ZM.set(this,void 0),B8.set(this,void 0),cL.set(this,void 0)}static useDash(e){const{strokeDasharray:r}=e;return r.length>0&&r.some(i=>i>0)}get useFillImage(){const{fill:e}=this.shapes[0];return!Bf(e)}validate(e){if(!super.validate(e))return!1;if(this.shapes.length===0)return!0;const r=!Bf(this.shapes[0].fill),i=!Bf(e.fill);return r!==i?!1:r&&i?this.shapes[0].fill===e.fill:sY.useDash(e)===sY.useDash(this.shapes[0])}createGeometry(){Ws(this,KM,"f")||(vg(this,KM,this.device.createBuffer({viewOrSize:new Float32Array([-1,-1,1,-1,1,1,-1,1]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),vg(this,lL,this.device.createBuffer({viewOrSize:new Uint32Array([0,1,2,0,2,3]),usage:dt.INDEX,hint:Et.STATIC}),"f")),this.instanced&&(Ws(this,zb,"f")&&Ws(this,zb,"f").destroy(),vg(this,zb,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*28*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),Ws(this,Vb,"f")&&Ws(this,Vb,"f").destroy(),vg(this,Vb,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*6*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"))}createMaterial(e){let r="";this.instanced&&(r+=`#define USE_INSTANCES 5998`),this.useFillImage&&(r+=`#define USE_FILLIMAGE 5999`);const i=this.device.queryVendorInfo().platformString==="WebGPU"?`diagnostic(off,derivative_uniformity); 6000`:"";vg(this,j0,this.renderCache.createProgram({vertex:{glsl:r+K6t},fragment:{glsl:r+q6t,postprocess:n=>i+n}}),"f");const s=[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:fa.FRAG_COORD,offset:0,format:I.F32_RG}]}];this.instanced?(s.push({arrayStride:112,stepMode:ne.INSTANCE,attributes:[{shaderLocation:fa.POSITION_SIZE,offset:0,format:I.F32_RGBA},{shaderLocation:fa.FILL_COLOR,offset:16,format:I.F32_RGBA},{shaderLocation:fa.STROKE_COLOR,offset:32,format:I.F32_RGBA},{shaderLocation:fa.ZINDEX_STROKE_WIDTH,offset:48,format:I.F32_RGBA},{shaderLocation:fa.OPACITY,offset:64,format:I.F32_RGBA},{shaderLocation:fa.INNER_SHADOW_COLOR,offset:80,format:I.F32_RGBA},{shaderLocation:fa.INNER_SHADOW,offset:96,format:I.F32_RGBA}]},{arrayStride:24,stepMode:ne.INSTANCE,attributes:[{shaderLocation:fa.ABCD,offset:0,format:I.F32_RGBA},{shaderLocation:fa.TXTY,offset:16,format:I.F32_RG}]}),vg(this,ZM,this.renderCache.createInputLayout({vertexBufferDescriptors:s,indexBufferFormat:I.U32_R,program:Ws(this,j0,"f")}),"f")):(vg(this,ZM,this.renderCache.createInputLayout({vertexBufferDescriptors:s,indexBufferFormat:I.U32_R,program:Ws(this,j0,"f")}),"f"),Ws(this,Ex,"f")||vg(this,Ex,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*40,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f")),vg(this,qM,this.renderCache.createRenderPipeline({inputLayout:Ws(this,ZM,"f"),program:Ws(this,j0,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],blendConstant:kn,depthWrite:!0,depthCompare:qe.GREATER,stencilWrite:!1,stencilFront:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP},stencilBack:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP}}}),"f"),this.device.setResourceName(Ws(this,qM,"f"),"SDFPipeline");const o={pipeline:Ws(this,qM,"f"),uniformBufferBindings:[{buffer:e}]};if(this.instanced||o.uniformBufferBindings.push({buffer:Ws(this,Ex,"f")}),this.useFillImage){const n=this.shapes[0].fill,a=this.device.createTexture({format:I.U8_RGBA_NORM,width:n.width,height:n.height,usage:xr.SAMPLED});a.setImageData([n]),vg(this,cL,a,"f");const l=this.renderCache.createSampler({addressModeU:Zn.CLAMP_TO_EDGE,addressModeV:Zn.CLAMP_TO_EDGE,minFilter:io.POINT,magFilter:io.BILINEAR,mipmapFilter:xn.LINEAR,lodMinClamp:0,lodMaxClamp:0});o.samplerBindings=[{texture:a,sampler:l}]}vg(this,B8,this.renderCache.createBindings(o),"f")}render(e,r){if(this.shapes.some(s=>s.renderDirtyFlag)||this.geometryDirty)if(this.instanced){Ws(this,Vb,"f").setSubData(0,new Uint8Array(new Float32Array(this.shapes.map(o=>[o.worldTransform.a,o.worldTransform.b,o.worldTransform.c,o.worldTransform.d,o.worldTransform.tx,o.worldTransform.ty]).flat()).buffer));const s=[];
6000this.shapes.forEach(o=>{const[n]=this.generateBuffer(o);s.push(...n)}),Ws(this,zb,"f").setSubData(0,new Uint8Array(new Float32Array(s).buffer))}else{const{worldTransform:s}=this.shapes[0],[o,n]=this.generateBuffer(this.shapes[0]),a=s.toArray(!0);Ws(this,Ex,"f").setSubData(0,new Uint8Array(new Float32Array([...vx(a),...o]).buffer));const l=Object.assign({u_ModelMatrix:a},n);this.useFillImage&&(l.u_FillImage=Ws(this,cL,"f")),Ws(this,j0,"f").setUniformsLegacy(l)}const i=[{buffer:Ws(this,KM,"f")}];this.instanced&&i.push({buffer:Ws(this,zb,"f")},{buffer:Ws(this,Vb,"f")}),Ws(this,j0,"f").setUniformsLegacy(r),e.setPipeline(Ws(this,qM,"f")),e.setVertexInput(Ws(this,ZM,"f"),i,{buffer:Ws(this,lL,"f")}),e.setBindings(Ws(this,B8,"f")),e.drawIndexed(6,this.shapes.length)}destroy(){var e,r,i,s,o,n;super.destroy(),Ws(this,j0,"f")&&((e=Ws(this,Vb,"f"))===null||e===void 0||e.destroy(),(r=Ws(this,zb,"f"))===null||r===void 0||r.destroy(),(i=Ws(this,KM,"f"))===null||i===void 0||i.destroy(),(s=Ws(this,lL,"f"))===null||s===void 0||s.destroy(),(o=Ws(this,Ex,"f"))===null||o===void 0||o.destroy(),(n=Ws(this,cL,"f"))===null||n===void 0||n.destroy())}generateBuffer(e){const{fillRGB:r,strokeRGB:{r:i,g:s,b:o,opacity:n},strokeWidth:a,strokeAlignment:l,opacity:c,fillOpacity:h,strokeOpacity:u,innerShadowColorRGB:{r:d,g:f,b:g,opacity:p},innerShadowOffsetX:m,innerShadowOffsetY:v,innerShadowBlurRadius:b}=e;let y=[0,0,0,0],_=0,w=0;if(e instanceof qm){const{cx:H,cy:N,r:G}=e;y=[H,N,G,G],_=0}else if(e instanceof Zm){const{cx:H,cy:N,rx:G,ry:Y}=e;y=[H,N,G,Y],_=1}else if(e instanceof Qm){const{x:H,y:N,width:G,height:Y,cornerRadius:q}=e;y=[H+G/2,N+Y/2,G/2,Y/2],_=2,w=q}const{r:E,g:A,b:x,opacity:S}=r||{},T=y,R=[E/255,A/255,x/255,S],B=[i/255,s/255,o/255,n],O=[e.globalRenderOrder/C8,sY.useDash(e)?0:a,w,Z6t[l]],C=[c,h,u,_],F=[d/255,f/255,g/255,p],U=[m,v,b,r?0:1];return[[...T,...R,...B,...O,...C,...F,...U],{u_PositionSize:T,u_FillColor:R,u_StrokeColor:B,u_ZIndexStrokeWidth:O,u_Opacity:C,u_InnerShadowColor:F,u_InnerShadow:U}]}};j0=new WeakMap,KM=new WeakMap,zb=new WeakMap,Vb=new WeakMap,lL=new WeakMap,Ex=new WeakMap,qM=new WeakMap,ZM=new WeakMap,B8=new WeakMap,cL=new WeakMap;var rh;(function(t){t[t.FRAG_COORD=0]="FRAG_COORD",t[t.ABCD=1]="ABCD",t[t.TXTY=2]="TXTY",t[t.POSITION_SIZE=3]="POSITION_SIZE",t[t.ZINDEX_STROKE_WIDTH=4]="ZINDEX_STROKE_WIDTH",t[t.DROP_SHADOW_COLOR=5]="DROP_SHADOW_COLOR",t[t.DROP_SHADOW=6]="DROP_SHADOW"})(rh||(rh={}));const J6t=` 6001layout(std140) uniform SceneUniforms { 6002 mat3 u_ProjectionMatrix; 6003 mat3 u_ViewMatrix; 6004 mat3 u_ViewProjectionInvMatrix; 6005 vec4 u_BackgroundColor; 6006 vec4 u_GridColor; 6007 float u_ZoomScale; 6008 float u_CheckboardStyle; 6009}; 6010 6011layout(location = ${rh.FRAG_COORD}) in vec2 a_FragCoord; 6012 6013#ifdef USE_INSTANCES 6014 layout(location = ${rh.ABCD}) in vec4 a_Abcd; 6015 layout(location = ${rh.TXTY}) in vec2 a_Txty; 6016 layout(location = ${rh.POSITION_SIZE}) in vec4 a_PositionSize; 6017 layout(location = ${rh.ZINDEX_STROKE_WIDTH}) in vec4 a_ZIndexStrokeWidth; 6018 layout(location = ${rh.DROP_SHADOW_COLOR}) in vec4 a_DropShadowColor; 6019 layout(location = ${rh.DROP_SHADOW}) in vec4 a_DropShadow; 6020#else 6021 layout(std140) uniform ShapeUniforms { 6022 mat3 u_ModelMatrix; 6023 vec4 u_PositionSize; 6024 vec4 u_ZIndexStrokeWidth; 6025 vec4 u_DropShadowColor; 6026 vec4 u_DropShadow; 6027 }; 6028#endif 6029 6030out vec2 v_Origin; 6031#ifdef USE_INSTANCES 6032 out float v_CornerRadius; 6033 out vec4 v_DropShadowColor; 6034 out vec4 v_DropShadow; 6035#else 6036#endif 6037out vec2 v_Size; 6038out vec2 v_Point; 6039 6040void main() { 6041 mat3 model; 6042 vec2 origin; 6043 vec2 size; 6044 float zIndex; 6045 vec4 dropShadow; 6046 6047 #ifdef USE_INSTANCES 6048 model = mat3(a_Abcd.x, a_Abcd.y, 0, a_Abcd.z, a_Abcd.w, 0, a_Txty.x, a_Txty.y, 1); 6049 origin = a_PositionSize.xy; 6050 size = a_PositionSize.zw; 6051 zIndex = a_ZIndexStrokeWidth.x; 6052 dropShadow = a_DropShadow; 6053 v_CornerRadius = a_ZIndexStrokeWidth.z; 6054 v_DropShadowColor = a_DropShadowColor; 6055 v_DropShadow = dropShadow; 6056 #else 6057 model = u_ModelMatrix; 6058 origin = u_PositionSize.xy; 6059 size = u_PositionSize.zw; 6060 zIndex = u_ZIndexStrokeWidth.x; 6061 dropShadow = u_DropShadow; 6062 #endif 6063 6064 // Set the bounds of the shadow and adjust its size based on the shadow's 6065 // spread radius to achieve the spreading effect 6066 float margin = 3.0 * dropShadow.z; 6067 origin += dropShadow.xy; 6068 v_Origin = origin; 6069 v_Size = size; 6070 6071 origin -= margin; 6072 size += 2.0 * margin; 6073 vec2 center = origin + size / 2.0; 6074 v_Point = center + a_FragCoord * (size / 2.0); 6075 6076 gl_Position = vec4((u_ProjectionMatrix
6077 * u_ViewMatrix 6078 * model 6079 * vec3(v_Point, 1)).xy, zIndex, 1); 6080} 6081`,Q6t=` 6082layout(std140) uniform SceneUniforms { 6083 mat3 u_ProjectionMatrix; 6084 mat3 u_ViewMatrix; 6085 mat3 u_ViewProjectionInvMatrix; 6086 vec4 u_BackgroundColor; 6087 vec4 u_GridColor; 6088 float u_ZoomScale; 6089 float u_CheckboardStyle; 6090}; 6091 6092#ifdef USE_INSTANCES 6093#else 6094 layout(std140) uniform ShapeUniforms { 6095 mat3 u_ModelMatrix; 6096 vec4 u_PositionSize; 6097 vec4 u_ZIndexStrokeWidth; 6098 vec4 u_DropShadowColor; 6099 vec4 u_DropShadow; 6100 }; 6101#endif 6102 6103out vec4 outputColor; 6104 6105in vec2 v_Origin; 6106#ifdef USE_INSTANCES 6107 in float v_CornerRadius; 6108 in vec4 v_DropShadowColor; 6109 in vec4 v_DropShadow; 6110#else 6111#endif 6112in vec2 v_Size; 6113in vec2 v_Point; 6114 6115float epsilon = 0.000001; 6116float PI = 3.1415926; 6117 6118// A standard gaussian function, used for weighting samples 6119float gaussian(float x, float sigma) { 6120 return exp(-(x * x) / (2. * sigma * sigma)) / (sqrt(2. * PI) * sigma); 6121} 6122 6123// This approximates the error function, needed for the gaussian integral 6124vec2 erf(vec2 x) { 6125 vec2 s = sign(x), a = abs(x); 6126 x = 1.0 + (0.278393 + (0.230389 + 0.078108 * (a * a)) * a) * a; 6127 x *= x; 6128 return s - s / (x * x); 6129} 6130 6131// @see https://raphlinus.github.io/graphics/2020/04/21/blurred-rounded-rects.html 6132// vec2 erf7(vec2 x) { 6133// x = x * sqrt(2. * PI); 6134// vec2 xx = x * x; 6135// x = x + (0.24295 + (0.03395 + 0.0104 * xx) * xx) * (x * xx); 6136// return x / sqrt(1.0 + x * x); 6137// } 6138 6139float rect_shadow(vec2 pixel_position, vec2 origin, vec2 size, float sigma) { 6140 vec2 bottom_right = origin + size; 6141 vec2 x_distance = vec2(pixel_position.x - origin.x, pixel_position.x - bottom_right.x); 6142 vec2 y_distance = vec2(pixel_position.y - origin.y, pixel_position.y - bottom_right.y); 6143 vec2 integral_x = 0.5 + 0.5 * erf(x_distance * (sqrt(0.5) / sigma)); 6144 vec2 integral_y = 0.5 + 0.5 * erf(y_distance * (sqrt(0.5) / sigma)); 6145 return (integral_x.x - integral_x.y) * (integral_y.x - integral_y.y); 6146} 6147 6148float blur_along_x(float x, float y, float sigma, float corner, vec2 half_size) { 6149 float delta = min(half_size.y - corner - abs(y), 0.0); 6150 float curved = half_size.x - corner + sqrt(max(0., corner * corner - delta * delta)); 6151 vec2 integral = 0.5 + 0.5 * erf((x + vec2(-curved, curved)) * (sqrt(0.5) / sigma)); 6152 return integral.y - integral.x; 6153} 6154 6155void main() { 6156 float cornerRadius; 6157 vec4 dropShadow; 6158 vec4 dropShadowColor; 6159 6160 #ifdef USE_INSTANCES 6161 cornerRadius = v_CornerRadius; 6162 dropShadowColor = v_DropShadowColor; 6163 dropShadow = v_DropShadow; 6164 #else 6165 cornerRadius = u_ZIndexStrokeWidth.z; 6166 dropShadowColor = u_DropShadowColor; 6167 dropShadow = u_DropShadow; 6168 #endif 6169 6170 float blur_radius = dropShadow.z; 6171 if (blur_radius > 0.0) { 6172 float alpha = 0.; 6173 vec2 point = v_Point; 6174 6175 if (cornerRadius > 0.0) { 6176 vec2 half_size = v_Size / 2.0; 6177 vec2 center = v_Origin + half_size; 6178 vec2 center_to_point = point - center; 6179 6180 // The signal is only non-zero in a limited range, so don't waste samples 6181 float low = center_to_point.y - half_size.y; 6182 float high = center_to_point.y + half_size.y; 6183 float start = clamp(-3. * blur_radius, low, high); 6184 float end = clamp(3. * blur_radius, low, high); 6185 6186 // Accumulate samples (we can get away with surprisingly few samples) 6187 float step = (end - start) / 4.; 6188 float y = start + step * 0.5; 6189 6190 for (int i = 0; i < 4; i++) { 6191 alpha += blur_along_x(center_to_point.x, center_to_point.y - y, blur_radius, 6192 cornerRadius, half_size) * 6193 gaussian(y, blur_radius) * step; 6194 y += step; 6195 } 6196 } else { 6197 alpha = rect_shadow(point, v_Origin, v_Size, blur_radius); 6198 } 6199 6200 outputColor = dropShadowColor; 6201 outputColor.a = alpha; 6202 } else { 6203 discard; 6204 } 6205} 6206`;var Qs=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},_g=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
6206return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},X0,JM,Yb,$b,hL,Ax,QM,t2,uL;let edt=class extends M8{constructor(){super(...arguments),X0.set(this,void 0),JM.set(this,void 0),Yb.set(this,void 0),$b.set(this,void 0),hL.set(this,void 0),Ax.set(this,void 0),QM.set(this,void 0),t2.set(this,void 0),uL.set(this,void 0)}static check(t){return(t instanceof Qm||t instanceof pg)&&t.dropShadowBlurRadius>0}createGeometry(){Qs(this,JM,"f")||(_g(this,JM,this.device.createBuffer({viewOrSize:new Float32Array([-1,-1,1,-1,1,1,-1,1]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),_g(this,hL,this.device.createBuffer({viewOrSize:new Uint32Array([0,1,2,0,2,3]),usage:dt.INDEX,hint:Et.STATIC}),"f")),this.instanced&&(Qs(this,Yb,"f")&&Qs(this,Yb,"f").destroy(),_g(this,Yb,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*16*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),Qs(this,$b,"f")&&Qs(this,$b,"f").destroy(),_g(this,$b,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*6*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"))}createMaterial(t){let e="";this.instanced&&(e+=`#define USE_INSTANCES 6207`),_g(this,X0,this.renderCache.createProgram({vertex:{glsl:e+J6t},fragment:{glsl:e+Q6t}}),"f");const r=[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:rh.FRAG_COORD,offset:0,format:I.F32_RG}]}];this.instanced?(r.push({arrayStride:64,stepMode:ne.INSTANCE,attributes:[{shaderLocation:rh.POSITION_SIZE,offset:0,format:I.F32_RGBA},{shaderLocation:rh.ZINDEX_STROKE_WIDTH,offset:16,format:I.F32_RGBA},{shaderLocation:rh.DROP_SHADOW_COLOR,offset:32,format:I.F32_RGBA},{shaderLocation:rh.DROP_SHADOW,offset:48,format:I.F32_RGBA}]},{arrayStride:24,stepMode:ne.INSTANCE,attributes:[{shaderLocation:rh.ABCD,offset:0,format:I.F32_RGBA},{shaderLocation:rh.TXTY,offset:16,format:I.F32_RG}]}),_g(this,t2,this.renderCache.createInputLayout({vertexBufferDescriptors:r,indexBufferFormat:I.U32_R,program:Qs(this,X0,"f")}),"f")):(_g(this,t2,this.renderCache.createInputLayout({vertexBufferDescriptors:r,indexBufferFormat:I.U32_R,program:Qs(this,X0,"f")}),"f"),Qs(this,Ax,"f")||_g(this,Ax,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*28,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f")),_g(this,QM,this.renderCache.createRenderPipeline({inputLayout:Qs(this,t2,"f"),program:Qs(this,X0,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],blendConstant:kn,depthWrite:!1,depthCompare:qe.GREATER,stencilWrite:!1,stencilFront:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP},stencilBack:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP}}}),"f"),this.instanced?_g(this,uL,this.renderCache.createBindings({pipeline:Qs(this,QM,"f"),uniformBufferBindings:[{buffer:t}]}),"f"):_g(this,uL,this.device.createBindings({pipeline:Qs(this,QM,"f"),uniformBufferBindings:[{buffer:t},{buffer:Qs(this,Ax,"f")}]}),"f")}render(t,e){if(this.shapes.some(i=>i.renderDirtyFlag)||this.geometryDirty)if(this.instanced){Qs(this,$b,"f").setSubData(0,new Uint8Array(new Float32Array(this.shapes.map(s=>[s.worldTransform.a,s.worldTransform.b,s.worldTransform.c,s.worldTransform.d,s.worldTransform.tx,s.worldTransform.ty]).flat()).buffer));const i=[];this.shapes.forEach(s=>{const[o]=this.generateBuffer(s);i.push(...o)}),Qs(this,Yb,"f").setSubData(0,new Uint8Array(new Float32Array(i).buffer))}else{const{worldTransform:i}=this.shapes[0],[s,o]=this.generateBuffer(this.shapes[0]),n=i.toArray(!0);Qs(this,Ax,"f").setSubData(0,new Uint8Array(new Float32Array([...vx(n),...s]).buffer));const a=Object.assign({u_ModelMatrix:n},o);Qs(this,X0,"f").setUniformsLegacy(a)}const r=[{buffer:Qs(this,JM,"f")}];this.instanced&&r.push({buffer:Qs(this,Yb,"f")},{buffer:Qs(this,$b,"f")}),Qs(this,X0,"f").setUniformsLegacy(e),t.setPipeline(Qs(this,QM,"f")),t.setVertexInput(Qs(this,t2,"f"),r,{buffer:Qs(this,hL,"f")}),t.setBindings(Qs(this,uL,"f")),t.drawIndexed(6,this.shapes.length)}destroy(){var t,e,r,i,s;super.destroy(),Qs(this,X0,"f")&&((t=Qs(this,$b,"f"))===null||t===void 0||t.destroy(),(e=Qs(this,Yb,"f"))===null||e===void 0||e.destroy(),(r=Qs(this,JM,"f"))===null||r===void 0||r.destroy(),(i=Qs(this,hL,"f"))===null||i===void 0||i.destroy(),(s=Qs(this,Ax,"f"))===null||s===void 0||s.destroy())}generateBuffer(t){const{x:e,y:r,width:i,height:s,strokeWidth:o,cornerRadius:n,dropShadowColorRGB:{r:a,g:l,b:c,opacity:h},dropShadowOffsetX:u,dropShadowOffsetY:d,dropShadowBlurRadius:f}=t,g=[e,r,i,s],p=[t.globalRenderOrder/C8,o,n,0],m=[a/255,l/255,c/255,h],v=[u,d,f,0];return[[...g,...p,...m,...v],{u_PositionSize:g,u_ZIndexStrokeWidth:p,u_DropShadowColor:m,u_DropShadow:v}]}};X0=new WeakMap,JM=new WeakMap,Yb=new WeakMap,$b=new WeakMap,hL=new WeakMap,Ax=new WeakMap,QM=new WeakMap,t2=new WeakMap,uL=new WeakMap;var ih;(function(t){t[t.PREV=0]="PREV",t[t.POINTA=1]="POINTA",t[t.POINTB=2]="POINTB",t[t.NEXT=3]="NEXT",t[t.VERTEX_JOINT=4]="VERTEX_JOINT",t[t.VERTEX_NUM=5]="VERTEX_NUM",t[t.TRAVEL=6]="TRAVEL"})(ih||(ih={}));var un;(function(t){t[t.NONE=0]="NONE",t[t.FILL=1]="FILL",t[t.JOINT_BEVEL=4]="JOINT_BEVEL",t[t.JOINT_MITER=8]="JOINT_MITER",t[t.JOINT_ROUND=12]="JOINT_ROUND",t[t.JOINT_CAP_BUTT=16]="JOINT_CAP_BUTT",t[t.JOINT_CAP_SQUARE=18]="JOINT_CAP_SQUARE",t[t.JOINT_CAP_ROUND=20]="JOINT_CAP_ROUND",t[t.FILL_EXPAND=24]="FILL_EXPAND",t[t.CAP_BUTT=32]="CAP_BUTT",t[t.CAP_SQUARE=64]="CAP_SQUARE",t[t.CAP_ROUND=96]="CAP_ROUND",t[t.CAP_BUTT2=128]="CAP_BUTT2"})(un||(un={}));const t8t=` 6208layout(std140) uniform SceneUniforms { 6209 mat3 u_ProjectionMatrix; 6210 mat3 u_ViewMatrix; 6211}; 6212 6213layout(location = ${ih.PREV}) in vec2 a_Prev; 6214layout(location = ${ih.POINTA}) in vec2 a_PointA; 6215layout(location = ${ih.POINTB}) in vec2 a_PointB; 6216layout(location = ${ih.NEXT}) in vec2 a_Next; 6217layout(location = ${ih.VERTEX_JOINT}) in float a_VertexJoint; 6218layout(location = ${ih.VERTEX_NUM}) in float a_VertexNum; 6219layout(location = ${ih.TRAVEL}) in float a_Travel; 6220 6221layout(std140) uniform ShapeUniforms { 6222 mat3 u_ModelMatrix; 6223 vec4 u_StrokeColor; 6224 vec4 u_ZIndexStrokeWidth; 6225 vec4 u_Opacity; 6226 vec4 u_StrokeDash; 6227}; 6228 6229const float FILL = ${un.FILL}.0; 6230const float BEVEL = ${un.JOINT_BEVEL}.0; 6231const float MITER = ${un.JOINT_MITER}.0; 6232const float ROUND = ${un.JOINT_ROUND}.0; 6233const float JOINT_CAP_BUTT = ${un.JOINT_CAP_BUTT}.0; 6234const float JOINT_CAP_SQUARE = ${un.JOINT_CAP_SQUARE}.0; 6235const float JOINT_CAP_ROUND = ${un.JOINT_CAP_ROUND}.0; 6236const float FILL_EXPAND = ${un.FILL_EXPAND}.0; 6237const float CAP_BUTT = 1.0; 6238const float CAP_SQUARE = 2.0; 6239const float CAP_ROUND = 3.0; 6240const float CAP_BUTT2 = 4.0; 6241 6242const float expand = 1.0; 6243const float dpr = 2.0; 6244 6245out vec4 v_Distance; 6246out vec4 v_Arc; 6247out float v_Type; 6248out float v_Travel; 6249out float v_ScalingFactor; 6250#ifdef USE_INSTANCES 6251 out vec4 v_StrokeColor; 6252 out vec4 v_Opacity; 6253 out float v_StrokeAlignment; 6254#else 6255#endif 6256 6257vec2 doBisect( 6258 vec2 norm, float len, vec2 norm2, float len2, float dy, float inner 6259) { 6260 vec2 bisect = (norm + norm2) / 2.0; 6261 bisect /= dot(norm, bisect); 6262 if (inner > 0.5) { 6263 if (len < len2) { 6264 if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) { 6265 return dy * norm; 6266 } 6267 } else { 6268 if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) { 6269 return dy * norm; 6270 } 6271 } 6272 } 6273 return dy * bisect; 6274} 6275 6276void main() { 6277 mat3 model = u_ModelMatrix; 6278 vec4 strokeColor = u_StrokeColor; 6279 float zIndex = u_ZIndexStrokeWidth.x; 6280 float strokeWidth = u_ZIndexStrokeWidth.y; 6281 float strokeMiterlimit = u_ZIndexStrokeWidth.z; 6282 float strokeAlignment = u_ZIndexStrokeWidth.w; 6283 float sizeAttenuation = u_Opacity.w; 6284 6285 vec2 pointA = (model * vec3(a_PointA, 1.0)).xy;
6286 vec2 pointB = (model * vec3(a_PointB, 1.0)).xy; 6287 6288 vec2 xBasis = pointB - pointA; 6289 float len = length(xBasis); 6290 vec2 forward = xBasis / len; 6291 vec2 norm = vec2(forward.y, -forward.x); 6292 6293 float type = a_VertexJoint; 6294 float vertexNum = a_VertexNum; 6295 6296 float capType = floor(type / 32.0); 6297 type -= capType * 32.0; 6298 v_Arc = vec4(0.0); 6299 strokeWidth *= 0.5; 6300 float strokeAlignmentFactor = 2.0 * strokeAlignment - 1.0; 6301 6302 vec2 pos; 6303 6304 if (capType == CAP_ROUND) { 6305 if (vertexNum < 3.5) { 6306 gl_Position = vec4(0.0, 0.0, 0.0, 1.0); 6307 return; 6308 } 6309 type = JOINT_CAP_ROUND; 6310 capType = 0.0; 6311 } 6312 6313 if (type >= BEVEL) { 6314 float dy = strokeWidth + expand; 6315 float inner = 0.0; 6316 if (vertexNum >= 1.5) { 6317 dy = -dy; 6318 inner = 1.0; 6319 } 6320 6321 vec2 base, next, xBasis2, bisect; 6322 float flag = 0.0; 6323 float sign2 = 1.0; 6324 if (vertexNum < 0.5 || vertexNum > 2.5 && vertexNum < 3.5) { 6325 next = (model * vec3(a_Prev, 1.0)).xy; 6326 base = pointA; 6327 flag = type - floor(type / 2.0) * 2.0; 6328 sign2 = -1.0; 6329 } else { 6330 next = (model * vec3(a_Next, 1.0)).xy; 6331 base = pointB; 6332 if (type >= MITER && type < MITER + 3.5) { 6333 flag = step(MITER + 1.5, type); 6334 // check miter limit here? 6335 } 6336 } 6337 6338 xBasis2 = next - base; 6339 float len2 = length(xBasis2); 6340 vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2; 6341 float D = norm.x * norm2.y - norm.y * norm2.x; 6342 if (D < 0.0) { 6343 inner = 1.0 - inner; 6344 } 6345 norm2 *= sign2; 6346 6347 if (abs(strokeAlignmentFactor) > 0.01) { 6348 float shift = strokeWidth * strokeAlignmentFactor; 6349 pointA += norm * shift; 6350 pointB += norm * shift; 6351 if (abs(D) < 0.01) { 6352 base += norm * shift; 6353 } else { 6354 base += doBisect(norm, len, norm2, len2, shift, 0.0); 6355 } 6356 } 6357 6358 float collinear = step(0.0, dot(norm, norm2)); 6359 v_Type = 0.0; 6360 float dy2 = -1000.0; 6361 float dy3 = -1000.0; 6362 if (abs(D) < 0.01 && collinear < 0.5) { 6363 if (type >= ROUND && type < ROUND + 1.5) { 6364 type = JOINT_CAP_ROUND; 6365 } 6366 // TODO: BUTT here too 6367 } 6368 6369 if (vertexNum < 3.5) { 6370 if (abs(D) < 0.01) { 6371 pos = dy * norm; 6372 } else { 6373 if (flag < 0.5 && inner < 0.5) { 6374 pos = dy * norm; 6375 } else { 6376 pos = doBisect(norm, len, norm2, len2, dy, inner); 6377 } 6378 } 6379 if (capType >= CAP_BUTT && capType < CAP_ROUND) { 6380 float extra = step(CAP_SQUARE, capType) * strokeWidth; 6381 vec2 back = -forward; 6382 if (vertexNum < 0.5 || vertexNum > 2.5) { 6383 pos += back * (expand + extra); 6384 dy2 = expand; 6385 } else { 6386 dy2 = dot(pos + base - pointA, back) - extra; 6387 } 6388 } 6389 if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) { 6390 float extra = step(JOINT_CAP_SQUARE, type) * strokeWidth; 6391 if (vertexNum < 0.5 || vertexNum > 2.5) { 6392 dy3 = dot(pos + base - pointB, forward) - extra; 6393 } else { 6394 pos += forward * (expand + extra); 6395 dy3 = expand; 6396 if (capType >= CAP_BUTT) { 6397 dy2 -= expand + extra; 6398 } 6399 } 6400 } 6401 } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) { 6402 if (inner > 0.5) { 6403 dy = -dy; 6404 inner = 0.0; 6405 } 6406 vec2 d2 = abs(dy) * forward; 6407 if (vertexNum < 4.5) { 6408 dy = -dy; 6409 pos = dy * norm; 6410 } else if (vertexNum < 5.5) { 6411 pos = dy * norm; 6412 } else if (vertexNum < 6.5) { 6413 pos = dy * norm + d2; 6414 v_Arc.x = abs(dy); 6415 } else { 6416 dy = -dy; 6417 pos = dy * norm + d2; 6418 v_Arc.x = abs(dy); 6419 } 6420 dy2 = 0.0; 6421 v_Arc.y = dy; 6422 v_Arc.z = 0.0; 6423 v_Arc.w = strokeWidth; 6424 v_Type = 3.0; 6425 } else if (abs(D) < 0.01) { 6426 pos = dy * norm; 6427 } else { 6428 if (type >= ROUND && type < ROUND + 1.5) { 6429 if (inner > 0.5) { 6430 dy = -dy; 6431 inner = 0.0; 6432 } 6433 if (vertexNum < 4.5) { 6434 pos = doBisect(norm, len, norm2, len2, -dy, 1.0); 6435 } else if (vertexNum < 5.5) { 6436 pos = dy * norm; 6437 } else if (vertexNum > 7.5) { 6438 pos = dy * norm2; 6439 } else { 6440 pos = doBisect(norm, len, norm2, len2, dy, 0.0); 6441 float d2 = abs(dy); 6442 if (length(pos) > abs(dy) * 1.5) { 6443 if (vertexNum < 6.5) { 6444 pos.x = dy * norm.x - d2 * norm.y; 6445 pos.y = dy * norm.y + d2 * norm.x; 6446 } else { 6447 pos.x = dy * norm2.x + d2 * norm2.y; 6448 pos.y = dy * norm2.y - d2 * norm2.x; 6449 } 6450 } 6451 } 6452 vec2 norm3 = normalize(norm + norm2); 6453 6454 float sign = step(0.0, dy) * 2.0 - 1.0; 6455 v_Arc.x = sign * dot(pos, norm3); 6456 v_Arc.y = pos.x * norm3.y - pos.y * norm3.x; 6457 v_Arc.z = dot(norm, norm3) * strokeWidth; 6458 v_Arc.w = strokeWidth; 6459 6460 dy = -sign * dot(pos, norm); 6461 dy2 = -sign * dot(pos, norm2); 6462 dy3 = v_Arc.z - v_Arc.x; 6463 v_Type = 3.0; 6464 } else { 6465 float hit = 0.0; 6466 if (type >= BEVEL && type < BEVEL + 1.5) { 6467 if (dot(norm, norm2) > 0.0) { 6468 type = MITER; 6469 } 6470 } 6471 if (type >= MITER && type < MITER + 3.5) { 6472 if (inner > 0.5) { 6473 dy = -dy; 6474 inner = 0.0; 6475 } 6476 float sign = step(0.0, dy) * 2.0 - 1.0; 6477 pos = doBisect(norm, len, norm2, len2, dy, 0.0); 6478 if (length(pos) > abs(dy) * strokeMiterlimit) { 6479 type = BEVEL; 6480 } else { 6481 if (vertexNum < 4.5) { 6482 dy = -dy; 6483 pos = doBisect(norm, len, norm2, len2, dy, 1.0); 6484 } else if (vertexNum < 5.5) { 6485 pos = dy * norm; 6486 } else if (vertexNum > 6.5) { 6487 pos = dy * norm2; 6488 } 6489 v_Type = 1.0; 6490 dy = -sign * dot(pos, norm); 6491 dy2 = -sign * dot(pos, norm2); 6492 hit = 1.0; 6493 } 6494 } 6495 if (type >= BEVEL && type < BEVEL + 1.5) { 6496 if (inner > 0.5) { 6497 dy = -dy; 6498 inner = 0.0; 6499 } 6500 float d2 = abs(dy); 6501 vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x); 6502 vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x); 6503 if (vertexNum < 4.5) { 6504 pos = doBisect(norm, len, norm2, len2, -dy, 1.0); 6505 } else if (vertexNum < 5.5) { 6506 pos = dy * norm; 6507 } else if (vertexNum > 7.5) { 6508 pos = dy * norm2; 6509 } else { 6510 if (vertexNum < 6.5) { 6511 pos = pos3; 6512 } else { 6513 pos = pos4; 6514 } 6515 } 6516 vec2 norm3 = normalize(norm + norm2); 6517 float sign = step(0.0, dy) * 2.0 - 1.0; 6518 dy = -sign * dot(pos, norm); 6519 dy2 = -sign * dot(pos, norm2); 6520 dy3 = (-sign * dot(pos, norm3)) + strokeWidth; 6521 v_Type = 4.0; 6522 hit = 1.0; 6523 } 6524 if (hit < 0.5) { 6525 gl_Position = vec4(0.0, 0.0, 0.0, 1.0); 6526 return; 6527 } 6528 } 6529 } 6530 pos += base; 6531 v_Distance = vec4(dy, dy2, dy3, strokeWidth) * dpr; 6532 v_Arc *= dpr; 6533 v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x)); 6534 } 6535 6536 // v_ScalingFactor = sqrt(model[0][0] * model[0][0] + model[0][1] * model[0][1] + model[0][2] * model[0][2]); 6537 v_ScalingFactor = 1.0; 6538 6539 gl_Position = vec4((u_ProjectionMatrix
6540 * u_ViewMatrix 6541 * vec3(pos, 1)).xy, zIndex, 1); 6542} 6543`,e8t=` 6544layout(std140) uniform SceneUniforms { 6545 mat3 u_ProjectionMatrix; 6546 mat3 u_ViewMatrix; 6547}; 6548 6549layout(std140) uniform ShapeUniforms { 6550 mat3 u_ModelMatrix; 6551 vec4 u_StrokeColor; 6552 vec4 u_ZIndexStrokeWidth; 6553 vec4 u_Opacity; 6554 vec4 u_StrokeDash; 6555}; 6556 6557out vec4 outputColor; 6558 6559in vec4 v_Distance; 6560in vec4 v_Arc; 6561in float v_Type; 6562in float v_Travel; 6563in float v_ScalingFactor; 6564 6565float epsilon = 0.000001; 6566 6567float antialias(float distance) { 6568 return clamp(distance / fwidth(distance), 0.0, 1.0); 6569} 6570 6571float pixelLine(float x) { 6572 return clamp(x + 0.5, 0.0, 1.0); 6573} 6574// float pixelLine(float x, float A, float B) { 6575// float y = abs(x), s = sign(x); 6576// if (y * 2.0 < A - B) { 6577// return 0.5 + s * y / A; 6578// } 6579// y -= (A - B) * 0.5; 6580// y = max(1.0 - y / B, 0.0); 6581// return (1.0 + s * (1.0 - y * y)) * 0.5; 6582// //return clamp(x + 0.5, 0.0, 1.0); 6583// } 6584 6585void main() { 6586 vec4 strokeColor = u_StrokeColor; 6587 float opacity = u_Opacity.x; 6588 float strokeOpacity = u_Opacity.z; 6589 float strokeAlignment = u_ZIndexStrokeWidth.w; 6590 float alpha = 1.0; 6591 6592 float d1 = v_Distance.x; 6593 float d2 = v_Distance.y; 6594 float d3 = v_Distance.z; 6595 float w = v_Distance.w; 6596 6597 if (v_Type < 0.5) { 6598 float left = max(d1 - 0.5, -w); 6599 float right = min(d1 + 0.5, w); 6600 float near = d2 - 0.5; 6601 float far = min(d2 + 0.5, 0.0); 6602 float top = d3 - 0.5; 6603 float bottom = min(d3 + 0.5, 0.0); 6604 alpha = max(antialias(right - left), 0.0) * max(bottom - top, 0.0) * max(far - near, 0.0); 6605 } else if (v_Type < 1.5) { 6606 float a1 = pixelLine(d1 - w); 6607 float a2 = pixelLine(d1 + w); 6608 float b1 = pixelLine(d2 - w); 6609 float b2 = pixelLine(d2 + w); 6610 6611 float left = max(d1 - 0.5, -w); 6612 float right = min(d1 + 0.5, w); 6613 6614 alpha = antialias(a2 * b2 - a1 * b1); 6615 } else if (v_Type < 2.5) { 6616 alpha *= max(min(d1 + 0.5, 1.0), 0.0); 6617 alpha *= max(min(d2 + 0.5, 1.0), 0.0); 6618 alpha *= max(min(d3 + 0.5, 1.0), 0.0); 6619 } else if (v_Type < 3.5) { 6620 float a1 = pixelLine(d1 - w); 6621 float a2 = pixelLine(d1 + w); 6622 float b1 = pixelLine(d2 - w); 6623 float b2 = pixelLine(d2 + w); 6624 float alpha_miter = a2 * b2 - a1 * b1; 6625 float alpha_bevel = pixelLine(d3); 6626 6627 float r = length(v_Arc.xy); 6628 float circle_hor = pixelLine(w + r) - pixelLine(-w + r); 6629 float circle_vert = min(w * 2.0, 1.0); 6630 float alpha_circle = circle_hor * circle_vert;
6631 alpha = min(alpha_miter, max(alpha_circle, alpha_bevel)); 6632 } else { 6633 float a1 = pixelLine(d1 - w); 6634 float a2 = pixelLine(d1 + w); 6635 float b1 = pixelLine(d2 - w); 6636 float b2 = pixelLine(d2 + w); 6637 alpha = antialias(a2 * b2 - a1 * b1); 6638 alpha *= pixelLine(d3); 6639 } 6640 6641 float u_Dash = u_StrokeDash.x; 6642 float u_Gap = u_StrokeDash.y; 6643 float u_DashOffset = u_StrokeDash.z; 6644 if (u_Dash + u_Gap > 1.0) { 6645 float travel = mod(v_Travel + u_Gap * v_ScalingFactor * 0.5 + u_DashOffset, u_Dash * v_ScalingFactor + u_Gap * v_ScalingFactor) - (u_Gap * v_ScalingFactor * 0.5); 6646 float left = max(travel - 0.5, -0.5); 6647 float right = min(travel + 0.5, u_Gap * v_ScalingFactor + 0.5); 6648 alpha *= antialias(max(0.0, right - left)); 6649 } 6650 6651 outputColor = strokeColor; 6652 outputColor.a *= alpha * opacity * strokeOpacity; 6653 if (outputColor.a < epsilon) { 6654 discard; 6655 } 6656} 6657`;var ls=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},z0=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Hb,xx,Kb,Df,bK,wK,e2,Sx,dL,fL,O8;const r8t=1e-4,pL=64,Tx=2,rdt=3,i8t={inner:0,center:.5,outer:1};let Gu=class extends M8{constructor(){super(...arguments),Hb.set(this,void 0),xx.set(this,void 0),Kb.set(this,void 0),Df.set(this,void 0),bK.set(this,void 0),wK.set(this,void 0),e2.set(this,void 0),Sx.set(this,void 0),dL.set(this,void 0),fL.set(this,void 0),O8.set(this,void 0),this.indices=[],this.pointsBuffer=[],this.travelBuffer=[]}static check(t){return t instanceof Wb||t instanceof ty||t instanceof ey||t instanceof pg||t instanceof Xb||t instanceof ry||(t instanceof Qm||t instanceof qm||t instanceof Zm)&&t.strokeDasharray.length>0&&t.strokeDasharray.some(e=>e>0)||t instanceof W0&&Iut(t.stroke,t.strokeWidth)}validate(t){return!1}get instanceCount(){const t=this.shapes[0];return t instanceof Wb||t instanceof W0||t instanceof ty||t instanceof ey||t instanceof pg||t instanceof Xb||t instanceof ry?this.pointsBuffer.length/rdt-3:t instanceof Qm?6:t instanceof qm||t instanceof Zm?pL+1:0}createGeometry(){this.instanced=!1;const t=[],e=[],r=[];let i=0;this.shapes.forEach(s=>{const{pointsBuffer:o,travelBuffer:n}=n8t(s,(s instanceof ty||s instanceof ey||s instanceof ry)&&this.index===2||s instanceof pg&&this.index!==2||s instanceof Xb);e.push(...o),r.push(...n),t.push(0+i,1+i,2+i,0+i,2+i,3+i,4+i,5+i,6+i,4+i,6+i,7+i,4+i,7+i,8+i),i+=9}),this.indices=t,this.pointsBuffer=e,this.travelBuffer=r,!(this.instanceCount<=0)&&(ls(this,Df,"f")&&ls(this,Df,"f").destroy(),z0(this,Df,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*15*this.instanceCount*this.shapes.length,usage:dt.VERTEX,hint:Et.DYNAMIC}),"f"),ls(this,xx,"f")&&ls(this,xx,"f").destroy(),z0(this,xx,this.device.createBuffer({viewOrSize:new Float32Array([0,1,2,3,4,5,6,7,8]),usage:dt.VERTEX,hint:Et.STATIC}),"f"),ls(this,Kb,"f")&&ls(this,Kb,"f").destroy(),z0(this,Kb,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*this.instanceCount,usage:dt.VERTEX,hint:Et.STATIC}),"f"))}createMaterial(t){let e="";this.instanced&&(e+=`#define USE_INSTANCES 6658`);const r=this.device.queryVendorInfo().platformString==="WebGPU"?`diagnostic(off,derivative_uniformity); 6659`:"";z0(this,Hb,this.renderCache.createProgram({vertex:{glsl:e+t8t},fragment:{glsl:e+e8t,postprocess:s=>r+s}}),"f");const i=[{arrayStride:12,stepMode:ne.INSTANCE,attributes:[{format:I.F32_RG,offset:0,shaderLocation:ih.PREV}]},{arrayStride:12,stepMode:ne.INSTANCE,attributes:[{format:I.F32_RG,offset:0,shaderLocation:ih.POINTA}]},{arrayStride:12,stepMode:ne.INSTANCE,attributes:[{format:I.F32_R,offset:0,shaderLocation:ih.VERTEX_JOINT}]}
6659,{arrayStride:12,stepMode:ne.INSTANCE,attributes:[{format:I.F32_RG,offset:0,shaderLocation:ih.POINTB}]},{arrayStride:12,stepMode:ne.INSTANCE,attributes:[{format:I.F32_RG,offset:0,shaderLocation:ih.NEXT}]},{arrayStride:4,stepMode:ne.VERTEX,attributes:[{format:I.F32_R,offset:0,shaderLocation:ih.VERTEX_NUM}]},{arrayStride:4,stepMode:ne.INSTANCE,attributes:[{format:I.F32_R,offset:0,shaderLocation:ih.TRAVEL}]}];ls(this,Sx,"f")||z0(this,Sx,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*32,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),z0(this,fL,this.renderCache.createInputLayout({vertexBufferDescriptors:i,indexBufferFormat:I.U32_R,program:ls(this,Hb,"f")}),"f"),z0(this,dL,this.renderCache.createRenderPipeline({inputLayout:ls(this,fL,"f"),program:ls(this,Hb,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],blendConstant:kn,depthWrite:!1,depthCompare:qe.GREATER,stencilWrite:!1,stencilFront:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP},stencilBack:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP}}}),"f"),z0(this,O8,this.device.createBindings({pipeline:ls(this,dL,"f"),uniformBufferBindings:[{buffer:t},{buffer:ls(this,Sx,"f")}]}),"f")}render(t,e){if(this.instanceCount<=0)return;if(this.shapes.some(i=>i.renderDirtyFlag)||this.geometryDirty){const{worldTransform:i}=this.shapes[0],[s,o]=this.generateBuffer(this.shapes[0]),n=i.toArray(!0);ls(this,Sx,"f").setSubData(0,new Uint8Array(new Float32Array([...vx(n),...s]).buffer));const a=Object.assign({u_ModelMatrix:n},o);ls(this,Hb,"f").setUniformsLegacy(a),ls(this,Df,"f").setSubData(0,new Uint8Array(new Float32Array(this.pointsBuffer).buffer)),ls(this,Kb,"f").setSubData(0,new Uint8Array(new Float32Array(this.travelBuffer).buffer))}const r=[{buffer:ls(this,Df,"f")},{buffer:ls(this,Df,"f"),offset:12},{buffer:ls(this,Df,"f"),offset:20},{buffer:ls(this,Df,"f"),offset:24},{buffer:ls(this,Df,"f"),offset:36},{buffer:ls(this,xx,"f")},{buffer:ls(this,Kb,"f")}];ls(this,e2,"f")||z0(this,e2,this.device.createBuffer({viewOrSize:new Uint32Array(this.indices),usage:dt.INDEX,hint:Et.STATIC}),"f"),ls(this,Hb,"f").setUniformsLegacy(e),t.setPipeline(ls(this,dL,"f")),t.setVertexInput(ls(this,fL,"f"),r,{buffer:ls(this,e2,"f")}),t.setBindings(ls(this,O8,"f")),t.drawIndexed(15,this.instanceCount)}destroy(){var t,e,r,i,s,o,n;super.destroy(),ls(this,Hb,"f")&&((t=ls(this,xx,"f"))===null||t===void 0||t.destroy(),(e=ls(this,Kb,"f"))===null||e===void 0||e.destroy(),(r=ls(this,Df,"f"))===null||r===void 0||r.destroy(),(i=ls(this,wK,"f"))===null||i===void 0||i.destroy(),(s=ls(this,bK,"f"))===null||s===void 0||s.destroy(),(o=ls(this,e2,"f"))===null||o===void 0||o.destroy(),(n=ls(this,Sx,"f"))===null||n===void 0||n.destroy())}generateBuffer(t){const{fillRGB:{r:e,g:r,b:i,opacity:s},strokeRGB:{r:o,g:n,b:a,opacity:l},strokeWidth:c,opacity:h,fillOpacity:u,strokeOpacity:d,strokeAlignment:f,strokeMiterlimit:g,strokeDasharray:p,strokeDashoffset:m,sizeAttenuation:v}=t,b=this.shapes[0];let y=[o/255,n/255,a/255,l];const _=[(t.globalRenderOrder+.1)/C8,c,g,i8t[f]],w=[h,u,d,v?1:0],E=[p&&p[0]||0,p&&p[1]||0,m||0,0];return((b instanceof ty||b instanceof ey||b instanceof ry)&&this.index===1||b instanceof pg&&this.index===2)&&(y=[e/255,r/255,i/255,s],w[2]=u),[[...y,..._,...w,...E],{u_StrokeColor:y,u_ZIndexStrokeWidth:_,u_Opacity:w,u_StrokeDash:E}]}};Hb=new WeakMap,xx=new WeakMap,Kb=new WeakMap,Df=new WeakMap,bK=new WeakMap,wK=new WeakMap,e2=new WeakMap,Sx=new WeakMap,dL=new WeakMap,fL=new WeakMap,O8=new WeakMap;function s8t(t){let e;switch(t){case"bevel":e=un.JOINT_BEVEL;break;case"round":e=un.JOINT_ROUND;break;default:e=un.JOINT_MITER;break}return e}function o8t(t){let e;switch(t){case"square":e=un.CAP_SQUARE;break;case"round":e=un.CAP_ROUND;break;default:e=un.CAP_BUTT;break}return e}function n8t(t,e=!0){const{strokeLinecap:r,strokeLinejoin:i}=t;let s=[];if(t instanceof ty||t instanceof ey||t instanceof pg||t instanceof Xb||t instanceof ry){const{strokePoints:d,fillPoints:f}=t;s=(e?d:f).map((g,p)=>[...g].concat(p!==d.length-1?[NaN,NaN]:[])).flat(2)}else if(t instanceof Wb)s=t.points.reduce((d,f)=>(d.push(f[0],f[1]),d),[]);else if(t instanceof W0)s=t.points.map((d,f)=>[...d].concat(f!==t.points.length-1?[NaN,NaN]:[])).flat(2);else if(t instanceof Qm){const{x:d,y:f,width:g,height:p}=t;s=[d,f,d+g,f,d+g,f+p,d,f+p,d,f,d+r8t,f]}else if(t instanceof qm){const{cx:d,cy:f,r:g}=t;for(let p=0;p<pL;p++){const m=p/pL*Math.PI*2;s.push(d+g*Math.cos(m),f+g*Math.sin(m))}s.push(d+g,f)}else if(t instanceof Zm){const{cx:d,cy:f,rx:g,ry:p}=t;for(let m=0;m<pL;m++){const v=m/pL*Math.PI*2;s.push(d+g*Math.cos(v),f+p*Math.sin(v))}s.push(d+g,f)}const o=s8t(i),n=o8t(r);let a=n;n===un.CAP_ROUND&&(a=un.JOINT_CAP_ROUND),n===un.CAP_BUTT&&(a=un.JOINT_CAP_BUTT),n===un.CAP_SQUARE&&(a=un.JOINT_CAP_SQUARE);const l=[];let c=0;for(let d=0;d<s.length;d+=Tx)(isNaN(s[d])||isNaN(s[d+1]))&&(l.push(s.slice(c,d)),c=d+2);l.push(s.slice(c));const h=[],u=[];return l.forEach(d=>{const f=[],g=[];let p=(Math.round(0/Tx)+2)*rdt,m=0;for(let v=0;v<d.length;v+=Tx)v>1&&(m+=Math.sqrt(Math.pow(d[v]-d[v-Tx],2)+Math.pow(d[v+1]-d[v+1-Tx],2))),g.pu
6659sh(m),f[p++]=d[v],f[p++]=d[v+1],f[p]=o,v==0?n!==un.CAP_ROUND&&(f[p]+=n):(isNaN(d[v-2])||isNaN(d[v-1]))&&(f[p]+=un.CAP_BUTT),v+Tx*2>=d.length||isNaN(d[v+4])||isNaN(d[v+5])?f[p]+=a-o:(v+Tx>=d.length||isNaN(d[v+2])||isNaN(d[v+3]))&&(f[p]=0),p++;f[p++]=d[d.length-4],f[p++]=d[d.length-3],f[p++]=0,f[0]=d[0],f[1]=d[1],f[2]=0,f[3]=d[2],f[4]=d[3],f[5]=n===un.CAP_ROUND?n:0,h.push(...f),u.push(...g)}),{pointsBuffer:h,travelBuffer:u}}var I8;(function(t){t[t.POSITION=0]="POSITION"})(I8||(I8={}));const a8t=` 6660layout(std140) uniform SceneUniforms { 6661 mat3 u_ProjectionMatrix; 6662 mat3 u_ViewMatrix; 6663 mat3 u_ViewProjectionInvMatrix; 6664 vec4 u_BackgroundColor; 6665 vec4 u_GridColor; 6666 float u_ZoomScale; 6667 float u_CheckboardStyle; 6668}; 6669 6670layout(location = ${I8.POSITION}) in vec2 a_Position; 6671layout(std140) uniform ShapeUniforms { 6672 mat3 u_ModelMatrix; 6673 vec4 u_FillColor; 6674 vec4 u_StrokeColor; 6675 vec4 u_ZIndexStrokeWidth; 6676 vec4 u_Opacity; 6677}; 6678 6679void main() { 6680 mat3 model; 6681 vec4 fillColor; 6682 vec4 strokeColor; 6683 float zIndex; 6684 float strokeWidth; 6685 float strokeAlignment; 6686 6687 model = u_ModelMatrix; 6688 fillColor = u_FillColor; 6689 strokeColor = u_StrokeColor; 6690 zIndex = u_ZIndexStrokeWidth.x; 6691 strokeWidth = u_ZIndexStrokeWidth.y; 6692 strokeAlignment = u_ZIndexStrokeWidth.w; 6693 6694 gl_Position = vec4((u_ProjectionMatrix 6695 * u_ViewMatrix 6696 * model 6697 * vec3(a_Position, 1)).xy, zIndex, 1); 6698} 6699`,l8t=` 6700layout(std140) uniform SceneUniforms { 6701 mat3 u_ProjectionMatrix; 6702 mat3 u_ViewMatrix; 6703 mat3 u_ViewProjectionInvMatrix; 6704 vec4 u_BackgroundColor; 6705 vec4 u_GridColor; 6706 float u_ZoomScale; 6707 float u_CheckboardStyle; 6708}; 6709 6710layout(std140) uniform ShapeUniforms { 6711 mat3 u_ModelMatrix; 6712 vec4 u_FillColor; 6713 vec4 u_StrokeColor; 6714 vec4 u_ZIndexStrokeWidth; 6715 vec4 u_Opacity; 6716}; 6717 6718out vec4 outputColor; 6719 6720float epsilon = 0.000001; 6721 6722void main() { 6723 float strokeWidth; 6724 vec4 fillColor; 6725 vec4 strokeColor; 6726 float opacity; 6727 float fillOpacity; 6728 float strokeOpacity; 6729 float cornerRadius; 6730 float strokeAlignment; 6731 6732 fillColor = u_FillColor; 6733 strokeColor = u_StrokeColor; 6734 strokeWidth = u_ZIndexStrokeWidth.y; 6735 opacity = u_Opacity.x; 6736 fillOpacity = u_Opacity.y; 6737 strokeOpacity = u_Opacity.z; 6738 cornerRadius = u_ZIndexStrokeWidth.z; 6739 strokeAlignment = u_ZIndexStrokeWidth.w; 6740 6741 // based on the target alpha compositing mode. 6742 fillColor.a *= fillOpacity; 6743 strokeColor.a *= strokeOpacity; 6744 6745 outputColor = fillColor; 6746 outputColor.a *= opacity; 6747 6748 if (outputColor.a < epsilon) 6749 discard; 6750} 6751`;var Mn=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Rx=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},qb,gL,EK,AK,r2,Cx,i2,mL,D8,P8;const c8t={center:0,inner:1,outer:2};let yL=class M1t extends M8{constructor(){super(...arguments),qb.set(this,void 0),gL.set(this,void 0),EK.set(this,void 0),AK.set(this,void 0),r2.set(this,void 0),Cx.set(this,void 0),i2.set(this,void 0),mL.set(this,void 0),D8.set(this,void 0),P8.set(this,void 0),this.points=[],this.indices=[]}static useDash(e){const{strokeDasharray:r}=e;return r.length>0&&r.some(i=>i>0)}validate(e){if(!super.validate(e))return!1;if(this.shapes.length===0)return!0;if(this.shapes[0].d!==e.d)return!1;const r=!Bf(this.shapes[0].fill),i=!Bf(e.fill);return r!==i?!1:r&&i?this.shapes[0].fill===e.fill:!0}createGeometry(){this.instanced=!1;const e=this.shapes[0];let r,i;e instanceof W0?(r=e.points,i=e.tessellationMethod):(e instanceof ty||e instanceof ey||e instanceof pg||e instanceof ry)&&(r=e.fillPathPoints,i=wx.EARCUT);const s=r.flat(2);if(s.length!==0){if(i===wx.EARCUT){const{vertices:o,holes:n,dimensions:a}=ikt(r),l=rT(o,n,a);this.indices=l,this.points=s}else if(i===wx.LIBTESS){const o=H6t(r);this.indices=new Array(o.length/2).fill(void 0).map((n,a)=>a),this.points=o}Mn(this,gL,"f")||Rx(this,gL,this.device.createBuffer({viewOrSize:new Float32Array(this.points),usage:dt.VERTEX,hint:Et.STATIC}),"f"),Mn(this,r2,"f")||Rx(this,r2,this.device.createBuffer({viewOrSize:new Uint32Array(this.indices),usage:dt.INDEX,hint:Et.STATIC}),"f")}}createMaterial(e){if(this.points.length===0)return;const r="",i=this.device.queryVendorInfo().platformString==="WebGPU"?`diagnostic(off,derivative_uniformity); 6752`:"";Rx(this,qb,this.renderCache.createProgram({vertex:{glsl:r+a8t},fragment:{glsl:r+l8t,postprocess:n=>i+n}}),"f");
6752const s=[{arrayStride:8,stepMode:ne.VERTEX,attributes:[{shaderLocation:I8.POSITION,offset:0,format:I.F32_RG}]}];Rx(this,mL,this.renderCache.createInputLayout({vertexBufferDescriptors:s,indexBufferFormat:I.U32_R,program:Mn(this,qb,"f")}),"f"),Mn(this,Cx,"f")||Rx(this,Cx,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*36,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),Rx(this,i2,this.renderCache.createRenderPipeline({inputLayout:Mn(this,mL,"f"),program:Mn(this,qb,"f"),colorAttachmentFormats:[I.U8_RGBA_RT],depthStencilAttachmentFormat:I.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:Di.ALL,rgbBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.SRC_ALPHA,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:hr.ADD,blendSrcFactor:kt.ONE,blendDstFactor:kt.ONE_MINUS_SRC_ALPHA}}],blendConstant:kn,depthWrite:!0,depthCompare:qe.GREATER,stencilWrite:!1,stencilFront:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP},stencilBack:{compare:qe.ALWAYS,passOp:ce.KEEP,failOp:ce.KEEP,depthFailOp:ce.KEEP}}}),"f"),this.device.setResourceName(Mn(this,i2,"f"),"MeshPipeline");const o={pipeline:Mn(this,i2,"f"),uniformBufferBindings:[{buffer:e},{buffer:Mn(this,Cx,"f")}]};Rx(this,D8,this.renderCache.createBindings(o),"f")}render(e,r){if(this.points.length===0)return;if(this.shapes.some(s=>s.renderDirtyFlag)||this.geometryDirty){const{worldTransform:s}=this.shapes[0],[o,n]=this.generateBuffer(this.shapes[0]),a=s.toArray(!0);Mn(this,Cx,"f").setSubData(0,new Uint8Array(new Float32Array([...vx(a),...o]).buffer));const l=Object.assign({u_ModelMatrix:a},n);l.u_FillImage=Mn(this,P8,"f"),Mn(this,qb,"f").setUniformsLegacy(l)}const i=[{buffer:Mn(this,gL,"f")}];Mn(this,qb,"f").setUniformsLegacy(r),e.setPipeline(Mn(this,i2,"f")),e.setVertexInput(Mn(this,mL,"f"),i,{buffer:Mn(this,r2,"f")}),e.setBindings(Mn(this,D8,"f")),e.drawIndexed(this.indices.length,this.shapes.length)}destroy(){var e,r,i,s,o;super.destroy(),Mn(this,qb,"f")&&((e=Mn(this,AK,"f"))===null||e===void 0||e.destroy(),(r=
6752Mn(this,EK,"f"))===null||r===void 0||r.destroy(),(i=Mn(this,r2,"f"))===null||i===void 0||i.destroy(),(s=Mn(this,Cx,"f"))===null||s===void 0||s.destroy(),(o=Mn(this,P8,"f"))===null||o===void 0||o.destroy())}generateBuffer(e){const{fillRGB:r,strokeRGB:{r:i,g:s,b:o,opacity:n},strokeWidth:a,strokeAlignment:l,opacity:c,fillOpacity:h,strokeOpacity:u}=e,{r:d,g:f,b:g,opacity:p}=r||{},m=[d/255,f/255,g/255,p],v=[i/255,s/255,o/255,n],b=[e.globalRenderOrder/C8,M1t.useDash(e)?0:a,0,c8t[l]],y=[c,h,u,0];return[[...m,...v,...b,...y],{u_FillColor:m,u_StrokeColor:v,u_ZIndexStrokeWidth:b,u_Opacity:y}]}};qb=new WeakMap,gL=new WeakMap,EK=new WeakMap,AK=new WeakMap,r2=new WeakMap,Cx=new WeakMap,i2=new WeakMap,mL=new WeakMap,D8=new WeakMap,P8=new WeakMap;function Ms(t,e=0){return t+=e,t+=t<<10,t+=t>>>6,t>>>0}function idt(t){return t+=t<<3,t^=t>>>11,t+=t<<15,t>>>0}function xK(){return 0}let h8t=class{constructor(){this.keys=[],this.values=[]}},vL=class{constructor(t,e){this.keyEqualFunc=t,this.keyHashFunc=e,this.buckets=new Map}findBucketIndex(t,e){for(let r=0;r<t.keys.length;r++)if(this.keyEqualFunc(e,t.keys[r]))return r;return-1}findBucket(t){const e=this.keyHashFunc(t);return this.buckets.get(e)}get(t){const e=this.findBucket(t);if(e===void 0)return null;const r=this.findBucketIndex(e,t);return r<0?null:e.values[r]}add(t,e){const r=this.keyHashFunc(t);this.buckets.get(r)===void 0&&this.buckets.set(r,new h8t);const i=this.buckets.get(r);i.keys.push(t),i.values.push(e)}delete(t){const e=this.findBucket(t);if(e===void 0)return;const r=this.findBucketIndex(e,t);r!==-1&&(e.keys.splice(r,1),e.values.splice(r,1))}clear(){this.buckets.clear()}size(){let t=0;for(const e of this.buckets.values())t+=e.values.length;return t}*values(){for(const t of this.buckets.values())for(let e=t.values.length-1;e>=0;e--)yield t.values[e]}};function sdt(t,e){return t=Ms(t,e.blendMode),t=Ms(t,e.blendSrcFactor),t=Ms(t,e.blendDstFactor),t}function u8t(t,e){return t=sdt(t,e.rgbBlendState),t=sdt(t,e.alphaBlendState),t=Ms(t,e.channelWriteMask),t}function d8t(t,e){return t=Ms(t,e.r<<24|e.g<<16|e.b<<8|e.a),t}function f8t(t,e){var r,i,s,o,n,a,l,c;for(let h=0;h<e.attachmentsState.length;h++)t=u8t(t,e.attachmentsState[h]);return t=d8t(t,e.blendConstant||kn),t=Ms(t,e.depthCompare),t=Ms(t,e.depthWrite?1:0),t=Ms(t,(r=e.stencilFront)===null||r===void 0?void 0:r.compare),t=Ms(t,(i=e.stencilFront)===null||i===void 0?void 0:i.passOp),t=Ms(t,(s=e.stencilFront)===null||s===void 0?void 0:s.failOp),t=Ms(t,(o=e.stencilFront)===null||o===void 0?void 0:o.depthFailOp),t=Ms(t,(n=e.stencilBack)===null||n===void 0?void 0:n.compare),t=Ms(t,(a=e.stencilBack)===null||a===void 0?void 0:a.passOp),t=Ms(t,(l=e.stencilBack)===null||l===void 0?void 0:l.failOp),t=Ms(t,(c=e.stencilBack)===null||c===void 0?void 0:c.depthFailOp),t=Ms(t,e.stencilWrite?1:0),t=Ms(t,e.cullMode),t=Ms(t,e.frontFace?1:0),t=Ms(t,e.polygonOffset?1:0),t}function p8t(t){let e=0;e=Ms(e,t.program.id),t.inputLayout!==null&&(e=Ms(e,t.inputLayout.id)),e=f8t(e,t.megaStateDescriptor);for(let r=0;r<t.colorAttachmentFormats.length;r++)e=Ms(e,t.colorAttachmentFormats[r]||0);return e=Ms(e,t.depthStencilAttachmentFormat||0),idt(e)}function g8t(t){let e=0;if(t.pipeline&&(e=Ms(e,t.pipeline.id)),t.samplerBindings)for(let r=0;r<t.samplerBindings.length;r++){const i=t.samplerBindings[r];i!==null&&i.texture!==null&&(e=Ms(e,i.texture.id))}if(t.uniformBufferBindings)for(let r=0;r<t.uniformBufferBindings.length;r++){const i=t.uniformBufferBindings[r];i!==null&&i.buffer!==null&&(e=Ms(e,i.buffer.id),e=Ms(e,i.binding),e=Ms(e,i.offset),e=Ms(e,i.size))}if(t.storageBufferBindings)for(let r=0;r<t.storageBufferBindings.length;r++){const i=t.storageBufferBindings[r];i!==null&&i.buffer!==null&&(e=Ms(e,i.buffer.id),e=Ms(e,i.binding),e=Ms(e,i.offset),e=Ms(e,i.size))}if(t.storageTextureBindings)for(let r=0;r<t.storageTextureBindings.length;r++){const i=t.storageTextureBindings[r];i!==null&&i.texture!==null&&(e=Ms(e,i.texture.id),e=Ms(e,i.binding))}return idt(e)}function m8t(t,e){var r,i,s,o;return((r=t.vertex)===null||r===void 0?void 0:r.glsl)===((i=e.vertex)===null||i===void 0?void 0:i.glsl)&&((s=t.fragment)===null||s===void 0?void 0:s.glsl)===((o=e.fragment)===null||o===void 0?void 0:o.glsl)}function y8t(t){var e,r;return{vertex:{glsl:(e=t.vertex)===null||e===void 0?void 0:e.glsl},fragment:{glsl:(r=t.fragment)===null||r===void 0?void 0:r.glsl}}}let v8t=class{constructor(t){this.device=t,this.bindingsCache=new vL(L4,g8t),this.renderPipelinesCache=new vL(G4,p8t),this.inputLayoutsCache=new vL(W4,xK),this.programCache=new vL(m8t,xK),this.samplerCache=new vL(j4,xK)}createBindings(t){let e=this.bindingsCache.get(t);if(e===null){const r=X4(t);e=this.device.createBindings(r),this.bindingsCache.add(r,e)}return e}createRenderPipeline(t){let e=this.renderPipelinesCache.get(t);if(e===null){const r=z4(t);r.colorAttachmentFormats=r.colorAttachmentFormats.filter(i=>i),e=this.device.createRenderPipeline(r),this.renderPipelinesCache.add(r,e)}return e}createInputLayout(t){t.vertexBufferDescriptors=t.vertexBufferDescriptors.filter(r=>!!r);let e=this.inputLayoutsCache.get(t);if(e===null){const r=V4(t);e=this.device.createInputLayout(r),this.inputLayoutsCache.add(r,e)}return e}createProgram(t){let e=this.programCache.get(t);if(e===null){const r=y8t(t);e=this.device.createProgram(t),this.programCache.add(r,e)}return e}createSampler(t){let e=this.samplerCache.get(t);return e===null&&(e=this.device.createSampler(t),this.samplerCache.add(t,e)),e}
6752destroy(){for(const t of this.bindingsCache.values())t.destroy();for(const t of this.renderPipelinesCache.values())t.destroy();for(const t of this.inputLayoutsCache.values())t.destroy();for(const t of this.programCache.values())t.destroy();for(const t of this.samplerCache.values())t.destroy();this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()}};var odt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Ja=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},V0,Mx,Bx,F8,_L;const bg=new WeakMap;bg.set(qm,[_K,Gu]),bg.set(Zm,[_K,Gu]),bg.set(Qm,[edt,_K,Gu]),bg.set(Wb,[Gu]),bg.set(W0,[yL,Gu]),bg.set(ty,[yL,Gu,Gu]),bg.set(ey,[yL,Gu,Gu]),bg.set(pg,[edt,yL,Gu,Gu]),bg.set(Xb,[Gu]),bg.set(ry,[yL,Gu,Gu]);let _8t=class{constructor(t){this.device=t,V0.set(this,[]),Mx.set(this,Object.create(null)),Bx.set(this,Object.create(null)),F8.set(this,new WeakMap),_L.set(this,void 0),odt(this,_L,new v8t(t),"f")}collectDrawcallCtors(t){var e;return(e=bg.get(t.constructor))===null||e===void 0?void 0:e.map(r=>{if(!r.check||r.check&&r.check(t))return r}).filter(r=>!!r)}createDrawcalls(t,e=!1){return this.collectDrawcallCtors(t).map((r,i)=>{const s=new r(this.device,Ja(this,_L,"f"),e,i);return s.add(t),s})}getOrCreateNonBatchableDrawcalls(t){let e=Ja(this,Mx,"f")[t.uid];return e||(e=this.createDrawcalls(t)||[],Ja(this,Mx,"f")[t.uid]=e),e}getOrCreateBatchableDrawcalls(t){let e=Ja(this,Bx,"f")[t.uid];if(!e){const r=t.constructor;let i=Ja(this,F8,"f").get(r);i||(i=[]);const s=this.collectDrawcallCtors(t);e=i.find(o=>o.length===s.length&&o.every(n=>n.validate(t))),e||(e=this.createDrawcalls(t,!0)||[],i.push(e),Ja(this,F8,"f").set(r,i)),e.forEach(o=>{o.add(t)}),Ja(this,Bx,"f")[t.uid]=e}return e}add(t){if(t.batchable){const e=this.getOrCreateBatchableDrawcalls(t);Ja(this,V0,"f").indexOf(e[0])===-1&&Ja(this,V0,"f").push(...e)}else Ja(this,V0,"f").push(...this.getOrCreateNonBatchableDrawcalls(t))}remove(t){t.batchable?(this.getOrCreateBatchableDrawcalls(t).forEach(e=>{e.remove(t)}),delete Ja(this,Bx,"f")[t.uid]):delete Ja(this,Mx,"f")[t.uid]}destroy(){for(const t in Ja(this,Mx,"f"))Ja(this,Mx,"f")[t].forEach(e=>{e.destroyed||e.destroy()});for(const t in Ja(this,Bx,"f"))Ja(this,Bx,"f")[t].forEach(e=>{e.destroyed||e.destroy()});Ja(this,_L,"f").destroy()}clear(){odt(this,V0,[],"f")}flush(t,e,r){const i=[],s=[],o=[],n=[];Ja(this,V0,"f").forEach(a=>{a.shapes.forEach(l=>{l.geometryDirtyFlag&&(o.push(l),i.push(a)),l.materialDirtyFlag&&(n.push(l),s.push(a))})}
6752),i.forEach(a=>a.geometryDirty=!0),s.forEach(a=>a.materialDirty=!0),o.forEach(a=>{var l;a.geometryDirtyFlag&&((l=a.preCreateGeometry)===null||l===void 0||l.call(a),a.geometryDirtyFlag=!1)}),n.forEach(a=>a.materialDirtyFlag=!1),Ja(this,V0,"f").forEach(a=>{a.submit(t,e,r)})}stats(){return{drawcallCount:Ja(this,V0,"f").length}}};V0=new WeakMap,Mx=new WeakMap,Bx=new WeakMap,F8=new WeakMap,_L=new WeakMap;var ndt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},fr=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},pa=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Ox,Qa,Zb,Ix,Dx,Px,s2,bL,wL,Jb,EL,Fx,o2,N8,n2,AL;(function(t){t[t.NONE=0]="NONE",t[t.GRID=1]="GRID",t[t.DOTS=2]="DOTS"})(AL||(AL={}));class b8t{constructor(){Ox.set(this,void 0),Qa.set(this,void 0),Zb.set(this,void 0),Ix.set(this,void 0),Dx.set(this,void 0),Px.set(this,void 0),s2.set(this,void 0),bL.set(this,AL.GRID),wL.set(this,void 0),Jb.set(this,void 0),EL.set(this,1),Fx.set(this,void 0),o2.set(this,void 0),N8.set(this,void 0),n2.set(this,void 0)}apply(e){const{hooks:r,canvas:i,renderer:s,shaderCompilerPath:o,devicePixelRatio:n,camera:a,backgroundColor:l,gridColor:c}=e,{r:h,g:u,b:d,opacity:f}=l?sr.rgb(l):{r:.986*255,g:.986*255,b:.986*255,opacity:1},{r:g,g:p,b:m,opacity:v}=c?sr.rgb(c):{r:.87*255,g:.87*255,b:.87*255,opacity:1},b=()=>{const y=a.projectionMatrix,_=a.viewMatrix,w=a.viewProjectionMatrixInv,E=[h/255,u/255,d/255,f],A=[g/255,p/255,m/255,v],x=a.zoom,S=fr(this,bL,"f");return[new Float32Array([...vx(y),...vx(_),...vx(w),...E,...A,x,S,0,0]),{u_ProjectionMatrix:y,u_ViewMatrix:_,u_ViewProjectionInvMatrix:w,u_BackgroundColor:E,u_GridColor:A,u_ZoomScale:x,u_CheckboardStyle:S}]};r.initAsync.tapPromise(()=>ndt(this,void 0,void 0,function*(){let y;s==="webgl"?y=new hd({targets:["webgl2","webgl1"],antialias:!0,shaderDebug:!0,trackResources:!1,onContextCreationError:()=>{},onContextLost:()=>{},onContextRestored(S){}}):y=new ud({shaderCompilerPath:o,onContextLost:()=>{}});const{width:_,height:w}=i,E=yield y.createSwapChain(i);E.configureSwapChain(_,w),pa(this,Ox,E,"f"),pa(this,Qa,E.getDevice(),"f"),pa(this,Jb,new _8t(fr(this,Qa,"f")),"f"),pa(this,Zb,fr(this,Qa,"f").createRenderTargetFromTexture(fr(this,Qa,"f").createTexture({format:I.U8_RGBA_RT,width:_,height:w,usage:xr.RENDER_TARGET})),"f"),pa(this,Ix,fr(this,Qa,"f").createRenderTargetFromTexture(fr(this,Qa,"f").createTexture({format:I.D24_S8,width:_,height:w,usage:xr.RENDER_TARGET})),"f");const[A,x]=b();pa(this,Px,fr(this,Qa,"f").createBuffer({viewOrSize:A,usage:dt.UNIFORM,hint:Et.DYNAMIC}),"f"),pa(this,s2,x,"f"),pa(this,wL,new kut,"f")})),r.resize.tap((y,_)=>{fr(this,Ox,"f").configureSwapChain(y*n,_*n),fr(this,Zb,"f")&&(fr(this,Zb,"f").destroy(),pa(this,Zb,fr(this,Qa,"f").createRenderTargetFromTexture(fr(this,Qa,"f").createTexture({format:I.U8_RGBA_RT,width:y*n,height:_*n,usage:xr.RENDER_TARGET})),"f"),fr(this,Ix,"f").destroy(),pa(this,Ix,fr(this,Qa,"f").createRenderTargetFromTexture(fr(this,Qa,"f").createTexture({format:I.D24_S8,width:y*n,height:_*n,usage:xr.RENDER_TARGET})),"f"))}),r.destroy.tap(()=>{fr(this,Jb,"f").destroy(),fr(this,Px,"f").destroy(),fr(this,wL,"f").destroy(),fr(this,Zb,"f").destroy(),fr(this,Ix,"f").destroy(),fr(this,Qa,"f").destroy(),fr(this,Qa,"f").checkForLeaks()}),r.beginFrame.tap(()=>{var y;const{width:_,height:w}=fr(this,Ox,"f").getCanvas(),E=fr(this,Ox,"f").getOnscreenTexture(),[A,x
6752]=b();fr(this,Px,"f").setSubData(0,new Uint8Array(A.buffer)),pa(this,s2,x,"f"),fr(this,Qa,"f").beginFrame(),pa(this,Dx,fr(this,Qa,"f").createRenderPass({colorAttachment:[fr(this,Zb,"f")],colorResolveTo:[E],colorClearColor:[kn],depthStencilAttachment:fr(this,Ix,"f"),depthClearValue:1}),"f"),fr(this,Dx,"f").setViewport(0,0,_,w),(!fr(this,Fx,"f")||fr(this,Fx,"f")&&!((y=fr(this,o2,"f"))===null||y===void 0)&&y.grid)&&fr(this,wL,"f").render(fr(this,Qa,"f"),fr(this,Dx,"f"),fr(this,Px,"f"),fr(this,s2,"f")),fr(this,Jb,"f").clear(),pa(this,EL,1,"f")}),r.endFrame.tap(({all:y,removed:_})=>{if([...y.filter(w=>w.culled),..._].forEach(w=>{w.renderable&&fr(this,Jb,"f").remove(w)}),fr(this,Jb,"f").flush(fr(this,Dx,"f"),fr(this,Px,"f"),fr(this,s2,"f")),fr(this,Qa,"f").submitPass(fr(this,Dx,"f")),fr(this,Qa,"f").endFrame(),fr(this,Fx,"f")&&fr(this,n2,"f")){const{type:w,encoderOptions:E}=fr(this,o2,"f")||{},A=fr(this,Ox,"f").getCanvas().toDataURL(w,E);fr(this,n2,"f").call(this,A),pa(this,Fx,!1,"f"),pa(this,o2,void 0,"f"),pa(this,n2,void 0,"f")}}),r.render.tap(y=>{var _,w;y.globalRenderOrder=(pa(this,EL,(w=fr(this,EL,"f"),_=w++,w),"f"),_),fr(this,Jb,"f").add(y)})}get checkboardStyle(){return fr(this,bL,"f")}set checkboardStyle(e){pa(this,bL,e,"f")}toDataURL(e){return ndt(this,void 0,void 0,function*(){return pa(this,Fx,!0,"f"),pa(this,o2,e,"f"),pa(this,N8,new Promise(r=>{pa(this,n2,i=>{r(i)},"f")}),"f"),fr(this,N8,"f")})}}Ox=new WeakMap,Qa=new WeakMap,Zb=new WeakMap,Ix=new WeakMap,Dx=new WeakMap,Px=new WeakMap,s2=new WeakMap,bL=new WeakMap,wL=new WeakMap,Jb=new WeakMap,EL=new WeakMap,Fx=new WeakMap,o2=new WeakMap,N8=new WeakMap,n2=new WeakMap;var wg=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Nx=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},xL,kx,Qb,a2;const w8t=.02,E8t=4,A8t=100,SL=[.02,.05,.1,.15,.2,.33,.5,.75,1,1.25,1.5,2,2.5,3,4],x8t=t=>SL.find(e=>e>t)||SL[SL.length-1],S8t=t=>[...SL].reverse().find(e=>e<t)||SL[0];let T8t=class{constructor(){xL.set(this,void 0),kx.set(this,{}),Qb.set(this,void 0),a2.set(this,!1)}apply(t){const{canvas:e,camera:r,root:i,devicePixelRatio:s,api:{client2Viewport:o}}=t;i.draggable=!0;const n=Bt();let a,l,c;const h=it();let u,d=!1;function f(_){const w=e.getBoundingClientRect(),E=_.nativeEvent.clientX-w.left,A=_.nativeEvent.clientY-w.top,x=E/(e.clientWidth||e.width/s),S=A/(e.clientHeight||e.height/s),T=x*2-1,R=S*-2+1;return[T,R]}function g(_){const w=Qt(it(),f(_),n);r.x=a+h[0]-w[0],r.y=l+h[1]-w[1]}function p(_){const w=(_.nativeEvent.clientX-u[0])/100,E=Bt();bi(E,E,[h[0],h[1]]),Mo(E,E,w),bi(E,E,[-h[0],-h[1]]),r.x=a,r.y=l,r.rotation=c,us(E,E,r.matrix),r.rotation=c+w,r.x=E[6],r.y=E[7]}i.addEventListener("dragstart",_=>{wg(this,Qb,"f")||(d=_.shiftKey,fp(n,r.viewProjectionMatrixInv),a=r.x,l=r.y,c=r.rotation,Qt(h,f(_),n),u=[_.nativeEvent.clientX,_.nativeEvent.clientY])}),i.addEventListener("drag",_=>{wg(this,Qb,"f")||(d?p(_):g(_))}),i.addEventListener("dragend",_=>{wg(this,Qb,"f")||(d=!1)});const m=(_,w)=>{const E=Math.max(w8t,Math.min(E8t,r.zoom*Math.pow(2,w*-.01))),A=o(_);r.gotoLandmark(r.createLandmark({viewportX:A.x,viewportY:A.y,zoom:E}),{duration:0})};i.addEventListener("wheel",_=>{_.preventDefault(),m({x:_.nativeEvent.clientX,y:_.nativeEvent.clientY},_.deltaY)});const v=_=>{_.pointerType==="mouse"?Nx(this,xL,!0,"f"):wg(this,kx,"f")[_.pointerId]||(wg(this,kx,"f")[_.pointerId]={last:null}),this.touchCount>=2?Nx(this,Qb,!0,"f"):Nx(this,Qb,!1,"f")},b=_=>{if(_.pointerType==="mouse"&&Nx(this,xL,!1,"f"),_.pointerType!=="mouse"&&delete wg(this,kx,"f")[_.pointerId],wg(this,a2,"f")&&this.touchCount<=1)return Nx(this,a2,!1,"f"),Nx(this,Qb,!1,"f"),!0},y=_=>{if(this.touchCount>=2){const w=_.global.x,E=_.global.y,A=wg(this,kx,"f"),x=Object.keys(A),S=Number(x[0]),T=Number(x[1]),R=A[S],B=A[T],O=R.last&&B.last?Math.sqrt(Math.pow(B.last.x-R.last.x,2)+Math.pow(B.last.y-R.last.y,2)):null;if(S===_.pointerId?R.last={x:w,y:E}:T===_.pointerId&&(B.last={x:w,y:E}),O){const C=new ye(R.last.x+(B.last.x-R.last.x)/2,R.last.y+(B.last.y-R.last.y)/2),F=Math.sqrt(Math.pow(B.last.x-R.last.x,2)+Math.pow(B.last.y-R.last.y,2));
6752m(C,(O/F-1)*A8t)}else wg(this,a2,"f")||Nx(this,a2,!0,"f")}};i.addEventListener("pointerdown",v),i.addEventListener("pointermove",y),i.addEventListener("pointerup",b),i.addEventListener("pointerupoutside",b),i.addEventListener("pointercancel",b)}get touchCount(){return(wg(this,xL,"f")?1:0)+Object.keys(wg(this,kx,"f")).length}};xL=new WeakMap,kx=new WeakMap,Qb=new WeakMap,a2=new WeakMap;class R8t{apply(e){const{canvas:r,hooks:i,globalThis:s,supportsPointerEvents:o,supportsTouchEvents:n}=e,a=_=>{_.preventDefault(),i.pointerMove.call(_)},l=_=>{i.pointerUp.call(_)},c=_=>{i.pointerDown.call(_)},h=_=>{i.pointerOver.call(_)},u=_=>{i.pointerOut.call(_)},d=_=>{i.pointerCancel.call(_)},f=_=>{i.pointerWheel.call(_)},g=_=>{s.addEventListener("pointermove",a,!0),_.addEventListener("pointerdown",c,!0),_.addEventListener("pointerleave",u,!0),_.addEventListener("pointerover",h,!0),s.addEventListener("pointerup",l,!0),s.addEventListener("pointercancel",d,!0)},p=_=>{_.addEventListener("touchstart",c,!0),_.addEventListener("touchend",l,!0),_.addEventListener("touchmove",a,!0),_.addEventListener("touchcancel",d,!0)},m=_=>{s.addEventListener("mousemove",a,!0),_.addEventListener("mousedown",c,!0),_.addEventListener("mouseout",u,!0),_.addEventListener("mouseover",h,!0),s.addEventListener("mouseup",l,!0)},v=_=>{s.removeEventListener("pointermove",a,!0),_.removeEventListener("pointerdown",c,!0),_.removeEventListener("pointerleave",u,!0),_.removeEventListener("pointerover",h,!0),s.removeEventListener("pointerup",l,!0)},b=_=>{_.removeEventListener("touchstart",c,!0),_.removeEventListener("touchend",l,!0),_.removeEventListener("touchmove",a,!0),_.removeEventListener("touchcancel",d,!0)},y=_=>{s.removeEventListener("mousemove",a,!0),_.removeEventListener("mousedown",c,!0),_.removeEventListener("mouseout",u,!0),_.removeEventListener("mouseover",h,!0),s.removeEventListener("mouseup",l,!0)};"addEventListener"in s&&(i.init.tap(()=>{o?g(r):(m(r),n&&p(r)),r.addEventListener("wheel",f,{capture:!0})}),i.destroy.tap(()=>{o?v(r):(y(r),n&&b(r)),r.removeEventListener("wheel",f,!0)}))}}var adt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Dl=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},SK,TL,TK,Eg,Y0;const C8t=1,M8t={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};let B8t=class{constructor(){SK.set(this,!0),TL.set(this,new fg(null)),TK.set(this,new nK(null)),Eg.set(this,void 0),Y0.set(this,void 0),this.onPointerMove=t=>{const e=this.normalizeToPointerEvent(t);for(const r of e){const i=this.bootstrapEvent(Dl(this,TL,"f"),r);Dl(this,Eg,"f").mapEvent(i)}this.setCursor(Dl(this,Eg,"f").cursor)}}apply(t){const{hooks:e,root:r}=t;adt(this,Y0,t,"f"),adt(this,Eg,new d6t(r),"f"),Dl(this,Eg,"f").setPickHandler((i,s)=>{const{picked:o}=e.pickSync.call({position:{x:i,y:s},picked:[],topmost:!0});return o[0]||null}),e.pointerWheel.tap(i=>{const s=this.normalizeWheelEvent(i);Dl(this,Eg,"f").mapEvent(s)}),e.pointerDown.tap(i=>{const s=this.normalizeToPointerEvent(i);Dl(this,SK,"f")&&s[0].isNormalized&&(i.cancelable||!("cancelable"in i))&&i.preventDefault();for(let o=0,n=s.length;o<n;o++){const a=s[o],l=this.bootstrapEvent(Dl(this,TL,"f"),a);Dl(this,Eg,"f").mapEvent(l)}this.setCursor(Dl(this,Eg,"f").cursor)}),e.pointerUp.tap(i=>{let s=i.target;i.composedPath&&i.composedPath().length>0&&(s=i.composedPath()[0]);const o=s!==Dl(this,Y0,"f").canvas?"outside":"",n=this.normalizeToPointerEvent(i);for(let a=0,l=n.length;a<l;a++){const c=this.bootstrapEvent(Dl(this,TL,"f"),n[a]);c.type+=o,Dl(this,Eg,"f").mapEvent(c)}this.setCursor(Dl(this,Eg,"f").cursor)}),e.pointerMove.tap(this.onPointerMove),e.pointerOver.tap(this.onPointerMove),e.pointerOut.tap(this.onPointerMove),e.pointerCancel.tap(this.onPointerMove)}normalizeWheelEvent(t){const e=Dl(this,TK,"f");this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode;const{x:r,y:i}=this.getViewportXY(t);e.client.x=r,e.client.y=i;const{x:s,y:o}=Dl(this,Y0,"f").api.viewport2Canvas(e.client);return e.screen.x=s,e.screen.y=o,e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null}
6752setCursor(t){var e,r;(r=(e=Dl(this,Y0,"f")).setCursor)===null||r===void 0||r.call(e,t)}normalizeToPointerEvent(t){const{supportsTouchEvents:e,supportsPointerEvents:r}=Dl(this,Y0,"f"),i=[];if(e&&t instanceof TouchEvent)for(let s=0;s<t.changedTouches.length;s++){const o=t.changedTouches[s];Vn(o.button)&&(o.button=0),Vn(o.buttons)&&(o.buttons=1),Vn(o.isPrimary)&&(o.isPrimary=t.touches.length===1&&t.type==="touchstart"),Vn(o.width)&&(o.width=o.radiusX||1),Vn(o.height)&&(o.height=o.radiusY||1),Vn(o.tiltX)&&(o.tiltX=0),Vn(o.tiltY)&&(o.tiltY=0),Vn(o.pointerType)&&(o.pointerType="touch"),Vn(o.pointerId)&&(o.pointerId=o.identifier||0),Vn(o.pressure)&&(o.pressure=o.force||.5),Vn(o.twist)&&(o.twist=0),Vn(o.tangentialPressure)&&(o.tangentialPressure=0),o.isNormalized=!0,o.type=t.type,i.push(o)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!r||!(t instanceof globalThis.PointerEvent))){const s=t;Vn(s.isPrimary)&&(s.isPrimary=!0),Vn(s.width)&&(s.width=1),Vn(s.height)&&(s.height=1),Vn(s.tiltX)&&(s.tiltX=0),Vn(s.tiltY)&&(s.tiltY=0),Vn(s.pointerType)&&(s.pointerType="mouse"),Vn(s.pointerId)&&(s.pointerId=C8t),Vn(s.pressure)&&(s.pressure=.5),Vn(s.twist)&&(s.twist=0),Vn(s.tangentialPressure)&&(s.tangentialPressure=0),s.isNormalized=!0,i.push(s)}else i.push(t);return i}bootstrapEvent(t,e){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);const{x:r,y:i}=this.getViewportXY(e);t.client.x=r,t.client.y=i;const{x:s,y:o}=Dl(this,Y0,"f").api.viewport2Canvas(t.client);return t.screen.x=s,t.screen.y=o,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=M8t[t.type]||t.type),t}getViewportXY(t){let e,r;const{offsetX:i,offsetY:s,clientX:o,clientY:n}=t;if(!Sut(i)&&!Sut(s))e=i,r=s;else{const a=Dl(this,Y0,"f").api.client2Viewport({x:o,y:n});e=a.x,r=a.y}return{x:e,y:r}}};SK=new WeakMap,TL=new WeakMap,TK=new WeakMap,Eg=new WeakMap,Y0=new WeakMap;const ldt=new ye;class O8t{apply(e){const{hooks:r,root:i,api:{elementsFromBBox:s}}=e;let o;if(QWt)try{o=new OffscreenCanvas(1,1)}catch{o=document.createElement("canvas")}o&&(this.ctx=o.getContext("2d")),r.pickSync.tap(n=>{const{position:{x:a,y:l}}=n,c=[i];return s(a,l,a,l).forEach(h=>{this.hitTest(h,a,l)&&c.unshift(h)}),n.picked=c,n})}hitTest(e,r,i){if(e.hitArea||e.renderable){e.worldTransform.applyInverse({x:r,y:i},ldt);const{x:s,y:o}=ldt;return e.hitArea?e.hitArea.contains(s,o):e.containsPoint(s,o,this.ctx)}return!1}}var I8t=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},cdt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},RL;function hdt(t,e){do{if(t&&e(t))return t;t=t==null?void 0:t.parent}while(t!=null);return null}class D8t{constructor(e={}){RL.set(this,void 0),I8t(this,RL,Object.assign({overlap:"pointer",dragstartTimeThreshold:0,dragstartDistanceThreshold:0},e),"f")}apply(e){const{root:r,hooks:i,api:{elementsFromPoint:s}}=e,o=n=>{const a=n.target,l=hdt(a,c=>c.draggable===!0);if(l){let c=!1;const h=n.timeStamp,u=[n.clientX,n.clientY];let d=null,f=[n.clientX,n.clientY];const g=m=>{if(!c){const _=m.timeStamp-h,w=Eut(m.clientX,m.clientY,...u);if(_<=cdt(this,RL,"f").dragstartTimeThreshold||w<=cdt(this,RL,"f").dragstartDistanceThreshold)return;m.type="dragstart",l.dispatchEvent(m),c=!0}m.type="drag",m.dx=m.clientX-f[0],m.dy=m.clientY-f[1],l.dispatchEvent(m),f=[m.clientX,m.clientY];const v=[m.globalX,m.globalY],b=s(v[0],v[1]),y=b[b.indexOf(a)+1];if(y){const _=hdt(y,w=>w.droppable===!0);d!==_&&(d&&(m.type="dragleave",m.target=d,d.dispatchEvent(m)),_&&(m.type="dragenter",m.target=_,_.dispatchEvent(m)),d=_,d&&(m.type="dragover",m.target=d,d.dispatchEvent(m)))}};r.addEventListener("pointermove",g);const p=function(m){if(c){m.detail={preventClick:!0};const v=m;d&&(v.type="drop",v.target=d,d.dispatchEvent(v)),v.type="dragend",l.dispatchEvent(v),c=!1}r.removeEventListener("pointermove",g)};a.addEventListener("pointerup",p,{once:!0}),a.addEventListener("pointerupoutside",p,{once:!0})}};i.init.tap(()=>{r.addEventListener("pointerdown",o)}),i.destroy.tap(()=>{r.removeEventListener("pointerdown",o)})}}RL=new WeakMap;var P8t=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
6752return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},l2=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},k8,Lx;class F8t{constructor(){k8.set(this,void 0),Lx.set(this,new eh)}apply(e){const{hooks:r,rBushRoot:i}=e;P8t(this,k8,e,"f"),r.cameraChange.tap(this.updateViewport.bind(this)),this.updateViewport(),r.beginFrame.tap(({all:s,removed:o,modified:n})=>{const{minX:a,minY:l,maxX:c,maxY:h}=l2(this,Lx,"f");[...o,...n].forEach(f=>{f.renderable&&i.remove({shape:f,minX:0,minY:0,maxX:0,maxY:0},(g,p)=>g.shape===p.shape)});const u=[];n.forEach(f=>{if(f.renderable){const g=f.getBounds();u.push({minX:g.minX,minY:g.minY,maxX:g.maxX,maxY:g.maxY,shape:f})}}),i.load(u);const d=i.search({minX:a,minY:l,maxX:c,maxY:h}).map(f=>f.shape);s.forEach(f=>{f.renderable&&f.cullable&&(f.culled=!d.includes(f))})})}updateViewport(){const{camera:e,api:{viewport2Canvas:r}}=l2(this,k8,"f"),{width:i,height:s}=e,o=r({x:0,y:0}),n=r({x:i,y:0}),a=r({x:i,y:s}),l=r({x:0,y:s});l2(this,Lx,"f").minX=Math.min(o.x,n.x,a.x,l.x),l2(this,Lx,"f").minY=Math.min(o.y,n.y,a.y,l.y),l2(this,Lx,"f").maxX=Math.max(o.x,n.x,a.x,l.x),l2(this,Lx,"f").maxY=Math.max(o.y,n.y,a.y,l.y)}}k8=new WeakMap,Lx=new WeakMap;var udt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Bs=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Ag=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},L8,Mc,Ux,U8,tw,CL,ew,G8,Gx;let ddt=class{get pluginContext(){return Bs(this,Mc,"f")}get root(){return Bs(this,tw,"f")}get camera(){return Bs(this,CL,"f")}constructor(t){L8.set(this,void 0),Mc.set(this,void 0),Ux.set(this,void 0),U8.set(this,void 0),tw.set(this,new S8),CL.set(this,void 0),ew.set(this,!0),G8.set(this,new Set),Gx.set(this,new Set);const{canvas:e,renderer:r="webgl",shaderCompilerPath:i="",devicePixelRatio:s,backgroundColor:o,gridColor:n,setCursor:a}=t,l=t6t(),c=(s??l.devicePixelRatio)||1,h=!!l.PointerEvent,u="ontouchstart"in l,{width:d,height:f}=e,g=new tdt(d/c,f/c);g.onchange=()=>{Bs(this,Mc,"f").hooks.cameraChange.call(),Ag(this,ew,!0,"f")},Ag(this,CL,g,"f"),Ag(this,Mc,{globalThis:l,canvas:e,renderer:r,shaderCompilerPath:i,devicePixelRatio:c,backgroundColor:o,gridColor:n,supportsPointerEvents:h,supportsTouchEvents:u,setCursor:a??(m=>e.style.cursor=m),hooks:{init:new ku,initAsync:new ZWt,beginFrame:new ku,render:new ku,endFrame:new ku,destroy:new ku,resize:new ku,pointerDown:new ku,pointerUp:new ku,pointerMove:new ku,pointerOut:new ku,pointerOver:new ku,pointerWheel:new ku,pointerCancel:new ku,pickSync:new JWt,cameraChange:new ku},camera:g,root:Bs(this,tw,"f"),rBushRoot:new TE,api:{elementsFromPoint:this.elementsFromPoint.bind(this),elementFromPoint:this.elementFromPoint.bind(this),elementsFromBBox:this.elementsFromBBox.bind(this),client2Viewport:this.client2Viewport.bind(this),viewport2Canvas:g.viewport2Canvas.bind(g),viewport2Client:this.viewport2Client.bind(this),canvas2Viewport:g.canvas2Viewport.bind(g)}},"f"),Ag(this,Ux,new b8t,"f"),Ag(this,U8,new B8t,"f");const p=[new R8t,Bs(this,U8,"f"),new O8t,new T8t,new F8t,Bs(this,Ux,"f"),new D8t({dragstartTimeThreshold:100,dragstartDistanceThreshold:10})];Ag(this,L8,udt(this,void 0,void 0,function*(){const{hooks:m}=Bs(this,Mc,"f");return p.forEach(v=>{v==null||v.apply(Bs(this,Mc,"f"))}),m.init.call(),yield m.initAsync.promise(),this}),"f")}get initialized(){return Bs(this,L8,"f").then(()=>this)}render(){const{hooks:t}=Bs(this,Mc,"f");Bs(this,Gx,"f").clear();const e=[];
6752if(rK(Bs(this,tw,"f"),r=>{Bs(this,Gx,"f").add(r),r.transformDirtyFlag&&(r.renderDirtyFlag=!0),r.renderable&&r.renderDirtyFlag&&(e.push(r),Ag(this,ew,!0,"f")),r.transform.updateTransform(r.parent?r.parent.transform:Mut)}),Bs(this,ew,"f")){const r=Array.from(Bs(this,Gx,"f")),i=[...Bs(this,G8,"f")].filter(s=>!Bs(this,Gx,"f").has(s));t.beginFrame.call({all:r,modified:e,removed:i}),rK(Bs(this,tw,"f"),s=>{if(s.culled||!s.visible)return!0;s.renderable&&t.render.call(s)}),t.endFrame.call({all:r,modified:e,removed:i}),[...r,...i].forEach(s=>{s.renderDirtyFlag=!1}),Ag(this,G8,new Set(Bs(this,Gx,"f")),"f"),Ag(this,ew,!1,"f")}}resize(t,e){const{hooks:r}=Bs(this,Mc,"f");Bs(this,CL,"f").projection(t,e),r.resize.call(t,e)}destroy(){const{hooks:t}=Bs(this,Mc,"f");t.destroy.call()}getDOM(){return Bs(this,Mc,"f").canvas}getDPR(){return Bs(this,Mc,"f").devicePixelRatio}toDataURL(){return udt(this,arguments,void 0,function*(t={}){return Bs(this,Ux,"f").toDataURL(t)})}appendChild(t){Ag(this,ew,!0,"f"),Bs(this,tw,"f").appendChild(t)}removeChild(t){return Ag(this,ew,!0,"f"),Bs(this,tw,"f").removeChild(t)}set checkboardStyle(t){Bs(this,Ux,"f").checkboardStyle=t}get checkboardStyle(){return Bs(this,Ux,"f").checkboardStyle}elementsFromBBox(t,e,r,i){const{rBushRoot:s}=Bs(this,Mc,"f"),o=s.search({minX:t,minY:e,maxX:r,maxY:i}),n=[];return o.forEach(({shape:a})=>{const{pointerEvents:l="auto"}=a,c=["auto","visiblepainted","visiblefill","visiblestroke","visible"].includes(l);(!c||c&&a.visible)&&!a.culled&&a.pointerEvents!=="none"&&n.push(a)}),n.sort((a,l)=>a.globalRenderOrder-l.globalRenderOrder),n}elementsFromPoint(t,e){const{picked:r}=Bs(this,Mc,"f").hooks.pickSync.call({topmost:!1,position:{x:t,y:e},picked:[]});return r}elementFromPoint(t,e){const{picked:r}=Bs(this,Mc,"f").hooks.pickSync.call({topmost:!0,position:{x:t,y:e},picked:[]});return r[0]}client2Viewport({x:t,y:e}){const{left:r,top:i}=Bs(this,Mc,"f").canvas.getBoundingClientRect();return{x:t-r,y:e-i}}viewport2Client({x:t,y:e}){const{left:r,top:i}=Bs(this,Mc,"f").canvas.getBoundingClientRect();return{x:t+r,y:e+i}}zoomIn(t,e){const{camera:r}=this;r.cancelLandmarkAnimation(e);const i=r.createLandmark({viewportX:r.width/2,viewportY:r.height/2,zoom:x8t(r.zoom)});r.gotoLandmark(i,{duration:300,easing:"ease"},t)}zoomOut(t,e){const{camera:r}=this;r.cancelLandmarkAnimation(e);const i=r.createLandmark({viewportX:r.width/2,viewportY:r.height/2,zoom:S8t(r.zoom)});r.gotoLandmark(i,{duration:300,easing:"ease"},t)}};L8=new WeakMap,Mc=new WeakMap,Ux=new WeakMap,U8=new WeakMap,tw=new WeakMap,CL=new WeakMap,ew=new WeakMap,G8=new WeakMap,Gx=new WeakMap;const RK=Symbol("canvas");var W8=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},fdt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Pf=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},pdt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},CK,Ff,ML;function N8t(){return fdt(this,void 0,void 0,function*(){if("gpu"in navigator){if(!(yield navigator.gpu.requestAdapter()))throw new Error("No WebGPU adapter available.")}else throw new Error("WebGPU is not supported by the browser.")})}let Wx=class extends Wa{constructor(){super(...arguments),this.renderer="webgl",this.shaderCompilerPath="https://unpkg.com/@antv/[email protected]/dist/pkg/glsl_wgsl_compiler_bg.w
6752asm",this.zoom=100,CK.set(this,new eE(this,{context:RK})),Ff.set(this,void 0),ML.set(this,void 0),this.initCanvas=new rE(this,{task:t=>fdt(this,[t],void 0,function*([e,r]){e==="webgpu"&&(yield N8t());const i=document.createElement("canvas");pdt(this,Ff,yield new ddt({canvas:i,renderer:e,shaderCompilerPath:r}).initialized,"f"),Pf(this,CK,"f").setValue(Pf(this,Ff,"f")),Pf(this,Ff,"f").pluginContext.hooks.cameraChange.tap(()=>{this.zoom=Math.round(Pf(this,Ff,"f").camera.zoom*100)}),this.dispatchEvent(new CustomEvent("ic-ready",{detail:Pf(this,Ff,"f")}));const s=o=>{this.dispatchEvent(new CustomEvent("ic-frame",{detail:o})),Pf(this,Ff,"f").render(),pdt(this,ML,window.requestAnimationFrame(s),"f")};return s(),Pf(this,Ff,"f").getDOM()}),args:()=>[this.renderer,this.shaderCompilerPath]})}connectedCallback(){super.connectedCallback(),this.addEventListener("sl-resize",this.resize)}disconnectedCallback(){var t;this.removeEventListener("sl-resize",this.resize),Pf(this,ML,"f")&&window.cancelAnimationFrame(Pf(this,ML,"f")),(t=Pf(this,Ff,"f"))===null||t===void 0||t.destroy(),super.disconnectedCallback()}resize(t){var e;const r=t.detail,{width:i,height:s}=r.entries[0].contentRect,o=window.devicePixelRatio;if(i&&s){const n=Pf(this,Ff,"f").getDOM();n.width=i*o,n.height=s*o,(e=Pf(this,Ff,"f"))===null||e===void 0||e.resize(i,s)}}render(){return this.initCanvas.render({pending:()=>Ao`<sl-spinner></sl-spinner>`,complete:t=>Ao` 6753 <sl-resize-observer> 6754 ${t} 6755 <ic-zoom-toolbar-lesson13 6756 zoom=${this.zoom} 6757 ></ic-zoom-toolbar-lesson13> 6758 <ic-exporter-lesson13></ic-exporter-lesson13> 6759 </sl-resize-observer> 6760 `,error:t=>Ao`<sl-alert variant="danger" open> 6761 <sl-icon slot="icon" name="exclamation-octagon"></sl-icon> 6762 <strong>Initialize canvas failed</strong><br /> 6763 ${t.message} 6764 </sl-alert>`})}};CK=new WeakMap,Ff=new WeakMap,ML=new WeakMap,Wx.styles=Lc` 6765 :host { 6766 position: relative; 6767 } 6768 6769 canvas { 6770 width: 100%; 6771 height: 100%; 6772 outline: none; 6773 padding: 0; 6774 margin: 0; 6775 touch-action: none; 6776 } 6777 `,W8([Pa()],Wx.prototype,"renderer",void 0),W8([Pa()],Wx.prototype,"shaderCompilerPath",void 0),W8([em()],Wx.prototype,"zoom",void 0),Wx=W8([Vc("ic-canvas-lesson13")],Wx);var MK=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};let c2=class extends Wa{constructor(){super(...arguments),this.zoom=100}zoomOut(){this.canvas.zoomOut()}zoomIn(){this.canvas.zoomIn()}render(){return Ao` 6778 <sl-button-group label="Zoom toolbar"> 6779 <sl-tooltip content="Zoom out"> 6780 <sl-icon-button 6781 name="dash-lg" 6782 label="Zoom out" 6783 @click="${this.zoomOut}" 6784 ></sl-icon-button> 6785 </sl-tooltip> 6786 <span>${this.zoom}%</span> 6787 <sl-tooltip content="Zoom in"> 6788 <sl-icon-button 6789 name="plus-lg" 6790 label="Zoom in" 6791 @click="${this.zoomIn}" 6792 ></sl-icon-button> 6793 </sl-tooltip> 6794 </sl-button-group> 6795 `}};c2.styles=Lc` 6796 :host { 6797 position: absolute; 6798 right: 16px; 6799 bottom: 16px; 6800 box-shadow: var(--sl-shadow-medium); 6801 background: white; 6802 } 6803 6804 span { 6805 font-size: 12px; 6806 line-height: 32px; 6807 width: 32px; 6808 text-align: center; 6809 color: var(--sl-color-neutral-600); 6810 } 6811 `,MK([cm({context:RK,subscribe:!0})],c2.prototype,"canvas",void 0),MK([Pa()],c2.prototype,"zoom",void 0),c2=MK([Vc("ic-zoom-toolbar-lesson13")],c2);var k8t=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},L8t=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};class gdt{constructor(e){this.options=e}toCanvas(){return k8t(this,arguments,void 0,function*(e={}){const{canvas:r}=this.options,{width:i,height:s}=r.getDOM(),o=r.getDPR(),{clippingRegion:n=new Ua(0,0,i,s),beforeDrawImage:a,afterDrawImage:l}=e,c=L8t(e,["clippingRegion","beforeDrawImage","afterDrawImage"]),h=yield r.toDataURL(c),u=yield this.getOrCreateImage(h),{x:d,y:f,width:g,height:p}=n,m=document.createElement("canvas");m.width=g*o,m.height=p*o;const v=m.getContext("2d");v.scale(o,o),a&&a(v);const b=u.width>i?o:1;return v.drawImage(u,d*b,f*b,g*b,p*b,0,0,g,p),l&&l(v),m})}toSVG(e={}){const{grid:r}=e,{canvas:i,document:s}=this.options,{width:o,height:n}=i.getDOM(),a=ns("svg",s);return a.setAttribute("width",`${o}`),a.setAttribute("height",`${n}`),r&&(i.checkboardStyle===AL.GRID?this.drawLinesGrid(a,s):i.checkboardStyle===AL.DOTS&&this.drawDotsGrid(a,s)),a.appendChild(mK(gK(i.root),s)),a}toSVGDataURL(e={}){const{document:r,xmlserializer:i}=this.options,s=this.toSVG(e),o=(r||document).implementation.createDocumentType("svg","-//W3C//DTD SVG 1.1//EN","http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"),n=(r||document).implementation.createDocument("http://www.w3.org/2000/svg","svg",o);return n.replaceChild(s,n.documentElement),`data:image/svg+xml;charset=utf8,${encodeURIComponent((i||new XMLSerializer).serializeToString(n))}`}downloadImage(e){const{defaultFilename:r,document:i}=this.options,{dataURL:s,name:o=r||"g"}=e,n=s.substring(s.indexOf(":")+1,s.indexOf(";")).split("/")[1],a=s.startsWith("data:image/svg"),l=`${o}.${a?"svg":n}`,c=(i||document).createElement("a");if(a)c.addEventListener("click",()=>{c.download=l,c.href=s});else if(window.Blob&&window.URL){const h=s.split(",");let u="";if(h&&h.length>0){const m=h[0].match(/:(.*?);/);m&&m.length>=2&&(u=m[1])}const d=atob(h[1]);let f=d.length;const g=new Uint8Array(f);for(;f--;
6811)g[f]=d.charCodeAt(f);const p=new Blob([g],{type:u});navigator.msSaveBlob?navigator.msSaveBlob(p,l):c.addEventListener("click",()=>{c.download=l,c.href=window.URL.createObjectURL(p)})}if(c.click)c.click();else{const h=(i||document).createEvent("MouseEvents");h.initEvent("click",!1,!1),c.dispatchEvent(h)}}getOrCreateImage(e){return new Promise((r,i)=>{const s=new window.Image;s&&(s.onload=()=>{r(s)},s.onerror=o=>{i(o)},s.crossOrigin="Anonymous",s.src=e)})}drawLinesGrid(e,r){const i=ns("defs",r);e.appendChild(i);const s=ns("pattern",r);s.setAttribute("id","small-grid"),s.setAttribute("width","10"),s.setAttribute("height","10"),s.setAttribute("patternUnits","userSpaceOnUse");const o=ns("path",r);o.setAttribute("d","M 10 0 L 0 0 0 10"),o.setAttribute("fill","none"),o.setAttribute("stroke","rgba(221,221,221,1)"),o.setAttribute("stroke-width","1"),s.appendChild(o);const n=ns("pattern",r);n.setAttribute("id","grid"),n.setAttribute("width","100"),n.setAttribute("height","100"),n.setAttribute("patternUnits","userSpaceOnUse");const a=ns("rect",r);a.setAttribute("width","100"),a.setAttribute("height","100"),a.setAttribute("fill","url(#small-grid)"),n.appendChild(a);const l=ns("path",r);l.setAttribute("d","M 100 0 L 0 0 0 100"),l.setAttribute("fill","none"),l.setAttribute("stroke","rgba(221,221,221,1)"),l.setAttribute("stroke-width","2"),n.appendChild(l),i.appendChild(s),i.appendChild(n);const c=ns("rect",r);c.setAttribute("width","100%"),c.setAttribute("height","100%"),c.setAttribute("fill","url(#grid)"),e.appendChild(c)}drawDotsGrid(e,r){const i=ns("defs",r);e.appendChild(i);const s=ns("circle",r);s.setAttribute("id","dot-tl"),s.setAttribute("cx","0"),s.setAttribute("cy","0"),s.setAttribute("r","2"),s.setAttribute("fill","rgba(221,221,221,1)");const o=s.cloneNode(),n=s.cloneNode(),a=s.cloneNode();o.setAttribute("id","dot-tr"),o.setAttribute("cx","20"),n.setAttribute("id","dot-bl"),n.setAttribute("cy","20"),a.setAttribute("id","dot-br"),a.setAttribute("cx","20"),a.setAttribute("cy","20"),i.appendChild(s),i.appendChild(o),i.appendChild(n),i.appendChild(a);const l=ns("pattern",r);l.setAttribute("id","dots-grid"),l.setAttribute("width","20"),l.setAttribute("height","20"),l.setAttribute("patternUnits","userSpaceOnUse");const c=ns("use",r);c.setAttribute("xlink:href","#dot-bl");const h=ns("use",r);h.setAttribute("xlink:href","#dot-br");const u=ns("use",r);u.setAttribute("xlink:href","#dot-tl");const d=ns("use",r);d.setAttribute("xlink:href","#dot-tr"),l.appendChild(c),l.appendChild(h),l.appendChild(u),l.appendChild(d),i.appendChild(l);const f=ns("rect",r);f.setAttribute("width","100%"),f.setAttribute("height","100%"),f.setAttribute("fill","url(#dots-grid)"),e.appendChild(f)}}var BK=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},U8t=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};let h2=class extends Wa{constructor(){super(...arguments),this.grid=!1}handleInputChange(){this.grid=!this.grid}connectedCallback(){super.connectedCallback();const t=new gdt({canvas:this.canvas});this.addEventListener("sl-select",e=>U8t(this,void 0,void 0,function*(){const r=e.detail.item;let i;r.value==="download-image-png"||r.value==="download-image-jpeg"?i=(yield t.toCanvas({grid:this.grid})).toDataURL(`image/${r.value.split("-").reverse()[0]}`):r.value==="download-image-svg"&&(i=t.toSVGDataURL({grid:this.grid})),i&&t.downloadImage({dataURL:i,name:"infinite-canvas-screenshot"})}))}render(){return Ao`<sl-dropdown> 6812 <sl-icon-button 6813 slot="trigger" 6814 name="download" 6815 label="Download" 6816 ></sl-icon-button> 6817 <sl-menu> 6818 <sl-switch 6819 size="small" 6820 .checked=${this.grid}
6821 @sl-input=${this.handleInputChange} 6822 >Grids included</sl-switch 6823 > 6824 <sl-menu-item value="download-image-png" 6825 >Download PNG image</sl-menu-item 6826 > 6827 <sl-menu-item value="download-image-jpeg" 6828 >Download JPEG image</sl-menu-item 6829 > 6830 <sl-menu-item value="download-image-svg" 6831 >Download SVG image</sl-menu-item 6832 > 6833 </sl-menu> 6834 </sl-dropdown>`}};h2.styles=Lc` 6835 :host { 6836 position: absolute; 6837 right: 16px; 6838 top: 16px; 6839 box-shadow: var(--sl-shadow-medium); 6840 background: white; 6841 } 6842 6843 sl-switch { 6844 margin-left: 24px; 6845 } 6846 6847 sl-menu-item::part(base) { 6848 font-size: 14px; 6849 } 6850 `,BK([cm({context:RK,subscribe:!0})],h2.prototype,"canvas",void 0),BK([em()],h2.prototype,"grid",void 0),h2=BK([Vc("ic-exporter-lesson13")],h2);const G8t=Object.freeze(Object.defineProperty({__proto__:null,AABB:eh,Camera:tdt,Canvas:ddt,Circle:qm,CircleWrapper:cK,Ellipse:Zm,EllipseWrapper:hK,get Exporter(){return h2},Grid:kut,Group:S8,IDENTITY_TRANSFORM:Mut,ImageExporter:gdt,get InfiniteCanvas(){return Wx},Path:W0,PathWrapper:pK,Polyline:Wb,PolylineWrapper:dK,Rect:Qm,RectWrapper:uK,Rectangle:Ua,RoughCircle:ty,RoughEllipse:ey,RoughPath:ry,RoughPolyline:Xb,RoughRect:pg,Shape:Of,get TesselationMethod(){return wx},get ZoomToolbar(){return c2},deserializeNode:$ut,fromSVGElement:Hut,getBounds:aK,hasValidStroke:Iut,inLine:Put,inPolyline:Fut,isFillOrStrokeAffected:VM,parsePath:vK,serializeNode:gK,shiftPoints:fK,strokeOffset:_x,toSVGElement:mK},Symbol.toStringTag,{value:"Module"})),Bc=22,u2=9,OK=7,IK=2**Bc,Od=IK-1,j8=2**u2,X8=j8-1,DK=2**OK,W8t=DK-1;class $e extends Error{constructor(e){super(`Internal error: ${e}. Please report a bug!`)}}class Wt extends Error{}const mdt=new TextEncoder,z8=new TextDecoder;function Pl(t){throw new Wt(`Component is not writable; use entity.write(${t.type.name}) to acquire a writable version`)}function Fe(t,e){if(t.__invalid)throw new Wt(`Component instance for ${e.type.name} is no longer valid, as you already bound it to another entity`)}class ${constructor(e,r=!0){W(this,"defaultValue");W(this,"shared");this.defaultValue=e,this.shared=r}get internallyIndexed(){return!1}}W($,"boolean"),W($,"uint8"),W($,"int8"),W($,"uint16"),W($,"int16"),W($,"uint32"),W($,"int32"),W($,"float32"),W($,"float64"),W($,"vector"),W($,"staticString"),W($,"dynamicString"),W($,"object"),W($,"weakObject"),W($,"ref"),W($,"backrefs");class j8t extends ${constructor(){super(!1)}defineElastic(e,r){const i=`component.${e.type.id}.field.${r.seq}`;let s;r.updateBuffer=()=>{e.dispatcher.buffers.register(i,e.capacity,Uint8Array,o=>{s=o})},r.updateBuffer(),Object.defineProperty(e.writableMaster,r.name,{enumerable:!0,configurable:!0,get(){return Fe(this,e),!!s[e.writableIndex]},set(o){Fe(this,e),s[e.writableIndex]=o?1:0}}),Object.defineProperty(e.readonlyMaster,r.name,{enumerable:!0,configurable:!0,get(){return Fe(this,e),!!s[e.readonlyIndex]},set(o){Pl(e)}})}defineFixed(e,r){const i=`component.${e.type.id}.field.${r.seq}`,s=e.dispatcher.buffers.register(i,e.capacity,Uint8Array);Object.defineProperty(e.writableMaster,r.name,{enumerable:!0,configurable:!0,get(){return Fe(this,e),!!s[e.writableIndex]},set(o){Fe(this,e),s[e.writableIndex]=o?1:0}}),Object.defineProperty(e.readonlyMaster,r.name,{enumerable:!0,configurable:!0,get(){return Fe(this,e),!!s[e.readonlyIndex]},set(o){Pl(e)}})}}class rw extends ${constructor(r){super(0);W(this,"NumberArray");this.NumberArray=r}defineElastic(r,i){const s=`component.${r.type.id}.field.${i.seq}`;let o;i.updateBuffer=()=>{r.dispatcher.buffers.register(s,r.capacity,this.NumberArray,n=>{o=n})},i.updateBuffer(),Object.defineProperty(r.writableMaster,i.name,{enumerable:!0,configurable:!0,get(){return Fe(this,r),o[r.writableIndex]},set(n){Fe(this,r),o[r.writableIndex]=n}}),Object.defineProperty(r.readonlyMaster,i.name,{enumerable:!0,configurable:!0,get(){return Fe(this,r),o[r.readonlyIndex]},set(n){Pl(r)}})}defineFixed(r,i){const s=`component.${r.type.id}.field.${i.seq}`,o=r.dispatcher.buffers.register(s,r.capacity,this.NumberArray);Object.defineProperty(r.writableMaster,i.name,{enumerable:!0,configurable:!0,get(){return Fe(this,r),o[r.writableIndex]},set(n){Fe(this,r),o[r.writableIndex]=n}}),Object.defineProperty(r.readonlyMaster,i.name,{enumerable:!0,configurable:!0,get(){return Fe(this,r),o[r.readonlyIndex]},set(n){Pl(r)}})}}class X8t extends ${constructor(r,i,s){super(new Array(typeof i=="number"?i:i.length).fill(0));W(this,"type");W(this,"Class");W(this,"stride");W(this,"elementNames");this.type=r,this.Class=s,typeof i=="number"?this.stride=i:(this.stride=i.length,this.elementNames=i)}get internallyIndexed(){return!0}
6850defineElastic(r,i){var m;const s=this.stride,o=this.elementNames,n=`component.${r.type.id}.field.${i.seq}`;let a,l=0,c=0;i.updateBuffer=()=>{r.dispatcher.buffers.register(n,r.capacity*s,this.type.NumberArray,v=>{a=v})},i.updateBuffer();const h={value:void 0,done:!0,next(){return l<s?(this.done=!1,this.value=a[r.writableIndex*s+l],l+=1):(this.done=!0,this.value=void 0),this}},u={value:void 0,done:!0,next(){return c<s?(this.done=!1,this.value=a[r.readonlyIndex*s+c],c+=1):(this.done=!0,this.value=void 0),this}},d=this.Class?new this.Class:{},f=this.Class?new this.Class:{};Object.defineProperty(d,"length",{value:s}),Object.defineProperty(f,"length",{value:s}),this.Class&&"asTypedArray"in this.Class.prototype||(Object.defineProperty(d,"asTypedArray",{value(){return Fe(this.__becsyComponent,r),a.subarray(r.writableIndex*s,(r.writableIndex+1)*s)}}),Object.defineProperty(f,"asTypedArray",{value(){return Fe(this.__becsyComponent,r),a.subarray(r.readonlyIndex*s,(r.readonlyIndex+1)*s)}})),Object.defineProperty(d,Symbol.iterator,{value(){return Fe(this.__becsyComponent,r),l=0,h}}),Object.defineProperty(f,Symbol.iterator,{value(){return Fe(this.__becsyComponent,r),c=0,u}}),Object.defineProperty(d,"__becsyComponent",{value:void 0,writable:!0}),Object.defineProperty(f,"__becsyComponent",{value:void 0,writable:!0});let g=Object.create(d);Object.seal(g);let p=Object.create(f);Object.seal(p);for(let v=0;v<this.stride;v++)Object.defineProperty(d,`${v}`,{enumerable:!0,get(){return Fe(this.__becsyComponent,r),a[r.writableIndex*s+v]},set(b){Fe(this.__becsyComponent,r),a[r.writableIndex*s+v]=b}}),Object.defineProperty(f,`${v}`,{enumerable:!0,get(){return Fe(this.__becsyComponent,r),a[r.readonlyIndex*s+v]},set(b){Pl(r)}}),(m=this.elementNames)!=null&&m[v]&&(Object.defineProperty(d,this.elementNames[v],{enumerable:!0,get(){return Fe(this.__becsyComponent,r),a[r.writableIndex*s+v]},set(b){Fe(this.__becsyComponent,r),a[r.writableIndex*s+v]=b}}),Object.defineProperty(f,this.elementNames[v],{enumerable:!0,get(){return Fe(this.__becsyComponent,r),a[r.readonlyIndex*s+v]},set(b){Pl(r)}}));Object.defineProperty(r.writableMaster,i.name,{enumerable:!0,configurable:!0,get(){return Fe(this,r),g=Object.create(d),g.__becsyComponent=this,Object.seal(g),g},set(v){if(Fe(this,r),v.length){if(v.length!==s)throw new Wt(`Value of length ${v.length} doesn't match vector of length ${s}`);for(let b=0;b<s;b++)a[r.writableIndex*s+b]=v[b]}else{if(!o)throw new Wt(`Value assigned to ${r.type.name}.${i.name} must be an array`);for(let b=0;b<s;b++){if(typeof v[o[b]]!="number")throw new Wt(`Value assigned to ${r.type.name}.${i.name} is missing element "${o[b]}`);a[r.writableIndex*s+b]=v[o[b]]}}}}),Object.defineProperty(r.readonlyMaster,i.name,{enumerable:!0,configurable:!0,get(){return Fe(this,r),p=Object.create(f),p.__becsyComponent=this,Object.seal(p),p},set(v){Pl(r)}})}defineFixed(r,i){var m;const s=this.stride,o=this.elementNames,n=`component.${r.type.id}.field.${i.seq}`,a=r.dispatcher.buffers.register(n,r.capacity*s,this.type.NumberArray);let l=0,c=0;const h={value:void 0,done:!0,next(){return l<s?(this.done=!1,this.value=a[r.writableIndex*s+l],l+=1):(this.done=!0,this.value=void 0),this}},u={value:void 0,done:!0,next(){return c<s?(this.done=!1,this.value=a[r.readonlyIndex*s+c],c+=1):(this.done=!0,this.value=void 0),this}},d=this.Class?new this.Class:{},f=this.Class?new this.Class:{};Object.defineProperty(d,"length",{value:s}),Object.defineProperty(f,"length",{value:s}),this.Class&&"asTypedArray"in this.Class.prototype||(Object.defineProperty(d,"asTypedArray",{value(){return Fe(this.__becsyComponent,r),a.subarray(r.writableIndex*s,(r.writableIndex+1)*s)}}),Object.defineProperty(f,"asTypedArray",{value(){return Fe(this.__becsyComponent,r),a.subarray(r.readonlyIndex*s,(r.readonlyIndex+1)*s)}})),Object.defineProperty(d,Symbol.iterator,{value(){return Fe(this.__becsyComponent,r),l=0,h}}),Object.defineProperty(f,Symbol.iterator,{value(){return Fe(this.__becsyComponent,r),c=0,u}}),Object.defineProperty(d,"__becsyComponent",{value:void 0,writable:!0}),Object.defineProperty(f,"__becsyComponent",{value:void 0,writable:!0});let g=Object.create(d);Object.seal(g);let p=Object.create(f);Object.seal(p);for(let v=0;v<this.stride;v++)Object.defineProperty(d,`${v}`,{enumerable:!0,get(){return Fe(this.__becsyComponent,r),a[r.writableIndex*s+v]},set(b){Fe(this.__becsyComponent,r),a[r.writableIndex*s+v]=b}}),Object.defineProperty(f,`${v}`,{enumerable:!0,get(){return Fe(this.__becsyComponent,r),a[r.readonlyIndex*s+v]},set(b){Pl(r)}}),(m=this.elementNames)!=null&&m[v]&&(Object.defineProperty(d,this.elementNames[v],{enumerable:!0,get(){return Fe(this.__becsyComponent,r),a[r.writableIndex*s+v]},set(b){Fe(this.__becsyComponent,r),a[r.writableIndex*s+v]=b}}),Object.defineProperty(f,this.elementNames[v],{enumerable:!0,get(){return Fe(this.__becsyComponent,r),a[r.readonlyIndex*s+v]},set(b){Pl(r)}}));Object.defineProperty(r.writableMaster,i.name,{enumerable:!0,configurable:!0,get(){return Fe(this,r),g=Object.create(d),g.__becsyComponent=this,Object.seal(g),g},set(v){if(Fe(this,r),v.length){if(v.length!==s)throw new Wt(`Value of length ${v.length} doesn't match vector of length ${s}`);for(let b=0;b<s;b++)a[r.writableIndex*s+b]=v[b]}
6850else{if(!o)throw new Wt(`Value assigned to ${r.type.name}.${i.name} must be an array`);for(let b=0;b<s;b++){if(typeof v[o[b]]!="number")throw new Wt(`Value assigned to ${r.type.name}.${i.name} is missing element "${o[b]}`);a[r.writableIndex*s+b]=v[o[b]]}}}}),Object.defineProperty(r.readonlyMaster,i.name,{enumerable:!0,configurable:!0,get(){return Fe(this,r),p=Object.create(f),p.__becsyComponent=this,Object.seal(p),p},set(v){Pl(r)}})}}class z8t extends ${constructor(r){super(r[0]);W(this,"choices");W(this,"choicesIndex",new Map);W(this,"TypedArray");if(this.choices=r,!(r!=null&&r.length))throw new Wt("No choices specified for Type.staticString");r.length<256?this.TypedArray=Uint8Array:r.length<65536?this.TypedArray=Uint16Array:this.TypedArray=Uint32Array;for(let i=0;i<r.length;i++)this.choicesIndex.set(r[i],i)}defineElastic(r,i){const s=`component.${r.type.id}.field.${i.seq}`;let o;const n=this.choices,a=this.choicesIndex;i.updateBuffer=()=>{r.dispatcher.buffers.register(s,r.capacity,this.TypedArray,l=>{o=l})},i.updateBuffer(),Object.defineProperty(r.writableMaster,i.name,{enumerable:!0,configurable:!0,get(){Fe(this,r);const l=o[r.writableIndex],c=n[l];if(c===void 0)throw new Wt(`Invalid static string index: ${l}`);return c},set(l){Fe(this,r);const c=a.get(l);if(c===void 0)throw new Wt(`Static string not in set: "${l}"`);o[r.writableIndex]=c}}),Object.defineProperty(r.readonlyMaster,i.name,{enumerable:!0,configurable:!0,get(){Fe(this,r);const l=o[r.readonlyIndex],c=n[l];if(c===void 0)throw new Wt(`Invalid static string index: ${l}`);return c},set(l){Pl(r)}})}defineFixed(r,i){const s=`component.${r.type.id}.field.${i.seq}`,o=this.choices,n=this.choicesIndex,a=r.dispatcher.buffers.register(s,r.capacity,this.TypedArray);Object.defineProperty(r.writableMaster,i.name,{enumerable:!0,configurable:!0,get(){Fe(this,r);const l=a[r.writableIndex],c=o[l];if(c===void 0)throw new Wt(`Invalid static string index: ${l}`);return c},set(l){Fe(this,r);const c=n.get(l);if(c===void 0)throw new Wt(`Static string not in set: "${l}"`);a[r.writableIndex]=c}}),Object.defineProperty(r.readonlyMaster,i.name,{enumerable:!0,configurable:!0,get(){Fe(this,r);const l=a[r.readonlyIndex],c=o[l];if(c===void 0)throw new Wt(`Invalid static string index: ${l}`);return c},set(l){Pl(r)}})}}class V8t extends ${constructor(r){super("");W(this,"maxUtf8Length");W(this,"lengthsStride");W(this,"bytesStride");this.maxUtf8Length=r+r%2,this.bytesStride=this.maxUtf8Length+2,this.lengthsStride=this.bytesStride/2}defineElastic(r,i){const s=`component.${r.type.id}.field.${i.seq}`;let o,n;const a=this.maxUtf8Length,l=this.lengthsStride,c=this.bytesStride;i.updateBuffer=()=>{const h=r.capacity*(this.maxUtf8Length+Uint16Array.BYTES_PER_ELEMENT);r.dispatcher.buffers.register(s,h,Uint8Array,u=>{n=u,o=new Uint16Array(n.buffer)})},i.updateBuffer(),Object.defineProperty(r.writableMaster,i.name,{enumerable:!0,configurable:!0,get(){Fe(this,r);const h=o[r.writableIndex*l];return z8.decode(new Uint8Array(n.buffer,r.writableIndex*c+2,h))},set(h){Fe(this,r);const u=mdt.encode(h);if(u.byteLength>a)throw new Wt(`Dynamic string length > ${a} after encoding: ${h}`);o[r.writableIndex*l]=u.byteLength,n.set(u,r.writableIndex*c+2)}}),Object.defineProperty(r.readonlyMaster,i.name,{enumerable:!0,configurable:!0,get(){Fe(this,r);const h=o[r.readonlyIndex*l];return z8.decode(new Uint8Array(n.buffer,r.readonlyIndex*c+2,h))},set(h){Pl(r)}})}defineFixed(r,i){const s=`component.${r.type.id}.field.${i.seq}`,o=this.maxUtf8Length,n=this.lengthsStride,a=this.bytesStride,l=r.capacity*(this.maxUtf8Length+Uint16Array.BYTES_PER_ELEMENT),c=r.dispatcher.buffers.register(s,l,Uint8Array),h=new Uint16Array(c.buffer);Object.defineProperty(r.writableMaster,i.name,{enumerable:!0,configurable:!0,get(){Fe(this,r);const u=h[r.writableIndex*n];return z8.decode(new Uint8Array(c.buffer,r.writableIndex*a+2,u))},set(u){Fe(this,r);const d=mdt.encode(u);if(d.byteLength>o)throw new Wt(`Dynamic string length > ${o} after encoding: ${u}`);h[r.writableIndex*n]=d.byteLength,c.set(d,r.writableIndex*a+2)}}),Object.defineProperty(r.readonlyMaster,i.name,{enumerable:!0,configurable:!0,get(){Fe(this,r);const u=h[r.readonlyIndex*n];return z8.decode(new Uint8Array(c.buffer,r.readonlyIndex*a+2,u))},set(u){Pl(r)}})}}const sy=2**31;class Y8t extends ${constructor(){super(void 0)}defineElastic(e,r){const i=`component.${e.type.id}.field.${r.seq}`;let s;const o=e.dispatcher.indexer,n=e.dispatcher.registry,a=n.pool;o.registerSelector(),r.updateBuffer=()=>{e.dispatcher.buffers.register(i,e.capacity,Int32Array,l=>{s=l},-1)},r.updateBuffer(),r.clearRef=(l,c,h)=>{if(h)throw new $e("Ref fields have no internal index");if(s[e.writableIndex]===-1)return;const u=(s[e.writableIndex]&sy)!==0;if(u&&!l)return;if(!u&&l)throw new $e("Wrong ref stale state");const d=s[e.writableIndex]&Od;c!==void 0&&d!==c||(l?s[e.writableIndex]=-1:s[e.writableIndex]|=sy,o.trackRefChange(e.writableEntityId,e.type,r.seq,void 0,d,-1,!l,l))},Object.defineProperty(e.writableMaster,r.name,{enumerable:!0,configurable:!0,get(){Fe(this,e);const l=s[e.writableIndex];if(!(l===-1||l&sy&&!n.includeRecentlyDeleted))return a.borrowTemporarily(l&Od)},set(l){if(Fe(this,e),l&&!n.hasShape(l.__id,n.Alive,!1))throw new Wt("Referencing a deleted entity is not allowed");let c=s[e.writableIndex];c!==-1&&(c=c&Od);const h=c!==-1&&!!(s[e.writableIndex]&sy),u=(l==null?void 0:l.__id)??-1;c===u&&!h||(s[e.writableIndex]=u,o.trackRefChange(e.writableEntityId,e.type,r.seq,void 0,c,u,!h,!0))}}),Object.defineProperty(e.readonlyMaster,r.name,{enumerable:!0,configurable:!0,get(){Fe(this,e);const l=s[e.readonlyIndex];if(!(l===-1||l&sy&&!n.includeRecentlyDeleted))return a.borrowTemporarily(l&Od)},set(l){Pl(e)}})}defineFixed(e,r){const i=`component.${e.type.id}.field.${r.seq}`,s=e.dispatcher.buffers.register(i,e.capacity,Int32Array,void 0,-1),o=e.dispatcher.indexer,n=e.dispatcher.registry,a=n.pool;o.registerSelector(),r.clearRef=(l,c,h)=>{if(h)throw new $e("Ref fields have no internal index");if(s[e.writableIndex]===-1)return;const u=(s[e.writableIndex]&sy)!==0;if(u&&!l)return;if(!u&&l)throw new $e("Wrong ref stale state");const d=s[e.writableIndex]&Od;c!==void 0&&d!==c||(l?s[e.writableIndex]=-1:s[e.writableIndex]|=sy,o.trackRefChange(e.writableEntityId,e.type,r.seq,void 0,d,-1,!l,l))},Object.defineProperty(e.writableMaster,r.name,{enumerable:!0,configurable:!0,get(){Fe(this,e);const l=s[e.writableIndex];if(!(l===-1||l&sy&&!n.includeRecentlyDeleted))return a.borrowTemporarily(l&Od)},set(l){if(Fe(this,e),l&&!n.hasShape(l.__id,n.Alive,!1))throw new Wt("Referencing a deleted entity is not allowed");let c=s[e.writableIndex];c!==-1&&(c=c&Od);const h=c!==-1&&!!(s[e.writableIndex]&sy),u=(l==null?void 0:l.__id)??-1;c===u&&!h||(s[e.writableIndex]=u,o.trackRefChange(e.writableEntityId,e.type,r.seq,void 0,c,u,!h,!0))}}),Object.defineProperty(e.readonlyMaster,r.name,{enumerable:!0,configurable:!0,get(){Fe(this,e);const l=s[e.readonlyIndex];if(!(l===-1||l&sy&&!n.includeRecentlyDeleted))return a.borrowTemporarily(l&Od)},set(l){Pl(e)}})}}const d2=[];class $8t extends ${constructor(r,i,s){super(d2);W(this,"type");W(this,"fieldName");W(this,"trackDeletedBackrefs");this.type=r,this.fieldName=i,this.trackDeletedBackrefs=s}
6850defineElastic(r,i){var l;i.updateBuffer=()=>{};const s=this.fieldName?(l=this.type)==null?void 0:l.__binding.fields.find(c=>c.name===this.fieldName):void 0;{if(this.fieldName&&!s)throw new Wt(`Backrefs field ${r.type.name}.${i.name} refers to an unknown field ${this.type.name}.${this.fieldName}`);if(s&&s.type!==$.ref)throw new Wt(`Backrefs field ${r.type.name}.${i.name} refers to a field ${this.type.name}.${this.fieldName} that is not a ref`);if(this.fieldName&&!this.type)throw new Wt(`Backrefs selector has field but no component in ${r.type.name}.${i.name}`);if(this.type&&!this.fieldName&&!this.type.__binding.refFields.length)throw new Wt(`Backrefs field ${r.type.name}.${i.name} refers to component ${this.type.name} that has no ref fields`)}const o=this.trackDeletedBackrefs,n=r.dispatcher.indexer;n.registerSelector();const a=n.registerSelector(r.type,this.type,s==null?void 0:s.seq,this.trackDeletedBackrefs);Object.defineProperty(r.writableMaster,i.name,{enumerable:!0,configurable:!0,get(){if(Fe(this,r),!o&&r.dispatcher.registry.includeRecentlyDeleted)throw new Wt(`Backrefs field ${r.type.name}.${i.name} not configured to track recently deleted refs`);return n.getBackrefs(r.writableEntityId,a)},set(c){if(Fe(this,r),c!==d2)throw new Wt("Backrefs properties are computed automatically, you cannot set them")}}),Object.defineProperty(r.readonlyMaster,i.name,{enumerable:!0,configurable:!0,get(){if(Fe(this,r),!o&&r.dispatcher.registry.includeRecentlyDeleted)throw new Wt(`Backrefs field ${r.type.name}.${i.name} not configured to track recently deleted refs`);return n.getBackrefs(r.readonlyEntityId,a)},set(c){if(Fe(this,r),c!==d2)throw new Wt("Backrefs properties are computed automatically, you cannot set them")}})}defineFixed(r,i){this.defineElastic(r,i)}}class H8t extends ${constructor(){super(void 0,!1)}defineElastic(e,r){const i=[];r.updateBuffer=()=>{},Object.defineProperty(e.writableMaster,r.name,{enumerable:!0,configurable:!0,get(){return Fe(this,e),i[e.writableIndex]},set(s){Fe(this,e),i[e.writableIndex]=s}}),Object.defineProperty(e.readonlyMaster,r.name,{enumerable:!0,configurable:!0,get(){return Fe(this,e),i[e.readonlyIndex]},set(s){Pl(e)}})}defineFixed(e,r){const i=new Array(e.capacity);r.updateBuffer=()=>{},Object.defineProperty(e.writableMaster,r.name,{enumerable:!0,configurable:!0,get(){return Fe(this,e),i[e.writableIndex]},set(s){Fe(this,e),i[e.writableIndex]=s}}),Object.defineProperty(e.readonlyMaster,r.name,{enumerable:!0,configurable:!0,get(){return Fe(this,e),i[e.readonlyIndex]},set(s){Pl(e)}})}}class K8t extends ${constructor(){super(void 0,!1);W(this,"finalizers")}defineElastic(r,i){const s=[];i.updateBuffer=()=>{};const o=this.initFinalizers(r);Object.defineProperty(r.writableMaster,i.name,{enumerable:!0,configurable:!0,get(){Fe(this,r);const n=s[r.writableIndex];return n==null?n:n.deref()},set(n){if(Fe(this,r),n!=null){const a=new WeakRef(n);o==null||o.register(n,{type:r.type,data:s,weakRef:a,id:r.writableEntityId,index:r.writableIndex}),n=a}s[r.writableIndex]=n}}),Object.defineProperty(r.readonlyMaster,i.name,{enumerable:!0,configurable:!0,get(){Fe(this,r);const n=s[r.readonlyIndex];return n==null?n:n.deref()},set(n){Pl(r)}})}defineFixed(r,i){this.defineElastic(r,i)}initFinalizers(r){if(!r.trackedWrites)return;if(this.finalizers)return this.finalizers;const i=r.dispatcher;if(!(!i.writeLog||typeof FinalizationRegistry>"u"))return this.finalizers=new FinalizationRegistry(({type:s,data:o,weakRef:n,id:a,index:l})=>{o[l]===n&&i.registry.trackWrite(a,s)}),this.finalizers}}$.boolean=new j8t,$.uint8=new rw(Uint8Array),$.int8=new rw(Int8Array),$.uint16=new rw(Uint16Array),$.int16=new rw(Int16Array),$.uint32=new rw(Uint32Array),$.int32=new rw(Int32Array),$.float32=new rw(Float32Array),$.float64=new rw(Float64Array),$.vector=(t,e,r)=>new X8t(t,e,r),$.staticString=t=>new z8t(t),$.dynamicString=t=>new V8t(t),$.ref=new Y8t,$.backrefs=(t,e,r=!1)=>new $8t(t,e,r),$.object=new H8t,$.weakObject=new K8t;let q8t=class{constructor(t,e,r,i,s,o,n){W(this,"type");W(this,"fields");W(this,"dispatcher");W(this,"capacity");W(this,"storage");W(this,"elastic");this.type=t,this.fields=e,this.dispatcher=i,this.capacity=s,this.storage=o,this.elastic=n,this.readonlyMaster=this.readonlyInstance=new t,this.writableMaster=this.writableInstance=new t,this.readonlyInstance=Object.create(this.readonlyMaster),this.readonlyInstance.__invalid=!this.elastic&&this.capacity>1,this.writableInstance=Object.create(this.writableMaster),this.writableInstance.__invalid=!this.elastic&&this.capacity>1,this.shapeOffset=r.offset,this.shapeMask=r.mask,this.shapeValue=r.value,this.refFields=e.filter(l=>l.type===$.ref),this.trackedWrites=!1,this.writableEntityId=0,this.writableIndex=0,this.readonlyEntityId=0,this.readonlyIndex=0,this.initDefault=new Function("c
6850omponent",e.filter(l=>l.default!==d2).map(l=>`component.${l.name} = ${JSON.stringify(l.default)};`).join(` 6851`));let a=[];a=e.filter(l=>l.default===d2).map(l=>` 6852 if (${JSON.stringify(l.name)} in values) { 6853 component.${l.name} = values.${l.name}; 6854 } 6855 `),this.init=new Function("component","values",e.filter(l=>l.default!==d2).map(l=>` 6856 component.${l.name} = values.${l.name} === undefined ? 6857 ${JSON.stringify(l.default)} : values.${l.name}; 6858 `).concat(a).join(` 6859`))}resetWritableInstance(t,e){if(e===-1)throw new $e(`Attempt to bind unacquired entity ${t} to ${this.type.name}`);return this.writableEntityId=t,this.writableIndex=e,(this.elastic||this.capacity>1)&&(this.writableInstance.__invalid=!0,this.writableInstance=Object.create(this.writableMaster)),this.writableInstance}resetReadonlyInstance(t,e){if(e===-1)throw new $e(`Attempt to bind unacquired entity ${t} to ${this.type.name}`);return this.readonlyEntityId=t,this.readonlyIndex=e,(this.elastic||this.capacity>1)&&(this.readonlyInstance.__invalid=!0,this.readonlyInstance=Object.create(this.readonlyMaster)),this.readonlyInstance}};function jx(t){if(!t.__binding)throw new Wt(`Component ${t.name} not defined; add to world defs`)}class Z8t{constructor(e,r,i){W(this,"maxEntities");W(this,"binding");W(this,"fields");this.maxEntities=e,this.binding=r,this.fields=i,this.growSpares(),this.growCapacity()}acquireIndex(e){let r=this.index[e];if(r===-1){if(this.spares[3]>0)r=this.spares[--this.spares[3]+4];else{if(this.spares[1]===this.spares[2]){if(!this.binding.elastic)throw new Wt(`Storage exhausted for component ${this.binding.type.name}; raise its capacity above ${this.binding.capacity}`);if(this.binding.capacity===this.maxEntities)throw new $e(`Trying to grow storage index for component ${this.binding.type.name} beyond maxEntities`);this.binding.capacity=Math.min(this.maxEntities,this.binding.capacity*2),this.growCapacity()}r=this.spares[1]++}this.index[e]=r}return r}releaseIndex(e){if(this.index[e]===-1)throw new $e(`Index for entity ${e} in component ${this.binding.type.name} not allocated`);this.spares[3]===this.spares.length-4&&this.growSpares(),this.spares[this.spares[3]+++4]=this.index[e],this.index[e]=-1}growCapacity(){var s;const e=this.binding.capacity;this.binding.dispatcher.stats.forComponent(this.binding.type).capacity=e;const r=this.ArrayType,i=r.BYTES_PER_ELEMENT!==((s=this.spares)==null?void 0:s[0]);if((!this.index||i)&&this.binding.dispatcher.buffers.register(`component.${this.binding.type.id}.storage.index`,this.maxEntities,r,o=>{this.index=o},-1),i?this.binding.dispatcher.buffers.register(`component.${this.binding.type.id}.storage.spares`,this.spares.length,r,this.updateSpares.bind(this)):this.spares[2]=e,this.binding.elastic)for(const o of this.fields)o.updateBuffer()}growSpares(){const e=this.spares?Math.min(this.maxEntities,(this.spares.length-4)*2):8;this.binding.dispatcher.buffers.register(`component.${this.binding.type.id}.storage.spares`,4+e,this.ArrayType,this.updateSpares.bind(this))}updateSpares(e){e[2]=this.binding.capacity=Math.max(this.binding.capacity,e[2]),e[0]=this.ArrayType.BYTES_PER_ELEMENT,this.spares=e}get ArrayType(){var r;const e=Math.max(((r=this.spares)==null?void 0:r[2])??0,this.binding.capacity);return e<128?Int8Array:e<32768?Int16Array:Int32Array}}class J8t{constructor(e,r,i){W(this,"maxEntities");W(this,"binding");W(this,"fields");this.maxEntities=e,this.binding=r,this.fields=i,this.growCapacity()}findIndex(e){for(let r=0;r<this.index.length;r++)if(this.index[r]===e)return r;return-1}acquireIndex(e){let r;for(let i=0;i<this.index.length;i++){if(this.index[i]===e)return i;r===void 0&&this.index[i]===-1&&(r=i)}if(r===void 0){if(!this.binding.elastic)throw new Wt(`Storage exhausted for component ${this.binding.type.name}; raise its capacity above ${this.binding.capacity}`);if(this.binding.capacity===this.maxEntities)throw new $e(`Trying to grow storage index for component ${this.binding.type.name} beyond maxEntities`);r=this.index.length,this.binding.capacity=Math.min(this.maxEntities,this.binding.capacity*2),this.growCapacity()}return this.index[r]=e,r}releaseIndex(e){for(let r=0;r<this.index.length;r++)if(this.index[r]===e){this.index[r]=-1;return}throw new $e(`Index for entity ${e} in component ${this.binding.type.name} not allocated`)}growCapacity(){const e=this.binding.capacity;if(this.binding.dispatcher.stats.forComponent(this.binding.type).
6859capacity=e,this.binding.dispatcher.buffers.register(`component.${this.binding.type.id}.storage.index`,e,Int32Array,this.updateIndex.bind(this),-1),this.binding.elastic)for(const r of this.fields)r.updateBuffer()}updateIndex(e){this.index=e,this.binding.capacity=this.index.length}}function ydt(t,e,r){var s;if(jx(t),r!==void 0){for(const o in r)if(!((s=t.schema)!=null&&s[o]))throw new Wt(`Property ${o} not defined for component ${t.name}`)}const i=t.__allocate(e);r?t.__binding.init(i,r):t.__binding.initDefault(i)}function Q8t(t){const e=t.schema,r=[];if(e){let i=0;for(const s in e){let o=e[s];(o instanceof $||typeof o=="function")&&(o={type:o}),typeof o.type=="function"&&(o.type=o.type()),"default"in o||(o.default=o.type.defaultValue),r.push({name:s,seq:i++,type:o.type,default:o.default})}if(i>DK)throw new Wt(`Component ${t.name} declares too many fields`)}return r}function vdt(t,e,r,i){var c,h,u,d,f;const s=Q8t(e),o=s.length?((c=e.options)==null?void 0:c.storage)??i.defaultComponentStorage:"sparse",n=o==="sparse"?i.maxEntities:Math.min(i.maxEntities,((h=e.options)==null?void 0:h.capacity)??0),a=((u=e.options)==null?void 0:u.initialCapacity)??8;{if(typeof((d=e.options)==null?void 0:d.capacity)<"u"){if(o==="sparse")throw new Wt(`Component type ${e.name} cannot combine custom capacity with sparse storage`);if(e.options.capacity<=0)throw new Wt(`Component type ${e.name} capacity option must be great than zero: got ${n}`);if(typeof e.options.initialCapacity<"u")throw new Wt(`Component type ${e.name} cannot have both capacity and initialCapacity options`)}if((f=e.options)!=null&&f.restrictedToMainThread&&s.every(g=>g.type.shared))throw new Wt(`Component type ${e.name} is restrictedToMainThread but has no thread-exclusive fields`);if(e.__bind)throw new Wt(`Component type ${e.name} is already in use in another world`)}e.id=t;const l=new q8t(e,s,r,i,n||a,o,!n);e.__binding=l}function tjt(t){const e=t.__binding;for(const r of e.fields)e.elastic?r.type.defineElastic(e,r):r.type.defineFixed(e,r);switch(e.storage){case"sparse":e.dispatcher.stats.forComponent(t).capacity=e.capacity,t.__bind=(r,i)=>i?e.resetWritableInstance(r,r):e.resetReadonlyInstance(r,r),t.__allocate=r=>e.resetWritableInstance(r,r);break;case"packed":{const r=new Z8t(e.dispatcher.maxEntities,e,e.fields);t.__bind=(i,s)=>s?e.resetWritableInstance(i,r.index[i]):e.resetReadonlyInstance(i,r.index[i]),t.__allocate=i=>e.resetWritableInstance(i,r.acquireIndex(i)),t.__free=i=>{r.releaseIndex(i)};break}case"compact":{const r=new J8t(e.dispatcher.maxEntities,e,e.fields);t.__bind=(i,s)=>s?e.resetWritableInstance(i,r.findIndex(i)):e.resetReadonlyInstance(i,r.findIndex(i)),t.__allocate=i=>e.resetWritableInstance(i,r.acquireIndex(i)),t.__free=i=>{r.releaseIndex(i)};break}default:throw new Wt(`Invalid storage type "${e.storage}`)}}function ejt(t){delete t.id,delete t.__binding,delete t.__bind,delete t.__allocate,delete t.__free}function _dt(t){t.options||(t.options={});{if(t.options.storage&&t.options.storage!=="compact")throw new Wt(`Component ${t.name} ${t.options.storage} storage is incompatible with singletons`);if(t.options.capacity&&t.options.capacity!==1)throw new Wt(`Component ${t.name} capacity of ${t.options.capacity} is incompatible with singletons`);if(t.options.initialCapacity)throw new Wt(`Component ${t.name} initial capacity of ${t.options.initialCapacity} is incompatible with singletons`)}t.options.storage="compact",t.options.capacity=1}class bdt{constructor(e){W(this,"__registry");this.__registry=e,this.__id=void 0,this.__sortKey=void 0,this.__valid=!0}get alive(){return this.__checkValid(),this.__registry.hasShape(this.__id,this.__registry.Alive,!1)}get ordinal(){return this.__registry.entityOrdinals[this.__id]}add(e,r){{if(this.__checkValid(),this.__checkMask(e,"write"),!this.__registry.hasShape(this.__id,this.__registry.Alive,!1))throw new Wt("Entity has been deleted");if(this.__registry.hasShape(this.__id,e,!1))throw new Wt(`Entity already has a ${e.name} component`)}this.__registry.setShape(this.__id,e),this.__registry.dispatcher.stats.forComponent(e).numEntities+=1,ydt(e,this.__id,r)}addAll(...e){this.__checkValid();{const r=new Set;for(const i of e)if(typeof i=="function"&&i.enum){if(r.has(i.enum))throw new Wt("Can't add multiple components from the same enum");r.add(i.enum)}}for(let r=0;r<e.length;r++){const i=e[r];if(typeof i!="function")throw new Wt(`Bad arguments to addAll: expected component type, got: ${i}`);let s=e[r+1];typeof s=="function"?s=void 0:r++,this.add(i,s)}}remove(e){if(this.__checkValid(),this.__checkMask(e,"write"),typeof e=="function"&&this.__checkHas(e,!1),typeof e!="function"){const r=this.__registry.getEnumShape(this.__id,e,!1);if(!r)throw new Wt(`Entity doesn't have any components from ${e.name} enumeration`);e=r}this.__registry.clearShape(this.__id,e)}removeAll(...e){for(const r of e)this.remove(r)}has(e){return this.__checkValid(),this.__checkMask(e,"check"),typeof e=="function"?this.__registry.hasShape(this.__id,e,!0):!!this.__registry.getEnumShape(this.__id,e,!0)}hasSomeOf(...e){this.__checkValid();for(const r of e)if(this.has(r))return!0;return!1}hasAllOf(...e){this.__checkValid();for(const r of e)if(!this.has(r))return!1;return!0}hasAnyOtherThan(...e){this.__checkValid();const r=new Set(e);for(const i of this.__registry.types)if(this.__checkMask(i,"check"),!(r.has(i)||i.enum&&r.has(i.enum))&&this.__registry.hasShape(this.__id,i,!0))return!0;return!1}countHas(...e){this.__checkValid();let r=0;for(const i of e)this.has(i)&&(r+=1);return r}hasWhich(e){return this.__checkValid(),this.__checkMask(e,"check"),this.__registry.getEnumShape(this.__id,e,!0)}read(e){return this.__checkValid(),this.__checkMask(e,"read"),this.__checkHas(e,!0),e.__bind(this.__id,!1)}write(e){return this.__checkValid(),this.__checkMask(e,"write"),this.__checkHas(e,!0),e.__binding.trackedWrites&&this.__registry.trackWrite(this.__id,e),e.__bind(this.__id,!0)}delete(){this.__checkValid();const e=this.__registry.Alive;if(!this.__registry.hasShape(this.__id,e,!1))throw new Wt("Entity already deleted");for(const r of this.__registry.types)this.__registry.hasShape(this.__id,r,!1)&&(r!==e&&this.__checkMask(r,"write"),this.__registry.clearShape(this.__id,r));this.__registry.dispatcher.indexer.clearAllRefs(this.__id,!1)}hold(){return this.__checkValid(),this.__registry.holdEntity(this.__id)}isSame(e){return this.__checkValid(),this.__id===e.__id}__checkMask(e,r){PK(e,this.__registry.executingSystem,r)}__checkHas(e,r){if(!this.__registry.hasShape(this.__id,e,r))throw new Wt(`Entity doesn't have a ${e.name} component`)}__checkValid(){if(!this.__valid)throw new Wt("Entity handle no longer valid")}}function PK(t,e,r){jx(t);const i=e==null?void 0:e.accessMasks[r];if(!i)return;const s=t.__binding;if(((i[s.shapeOffset]??0)&s.shapeMask)===0)throw new Wt(`System ${e.name} didn't mark component ${t.name} as ${r}able`)}function FK(t,e){const r=e.__binding;return((t[r.shapeOffset]??0)&r.shapeMask)!==0}function V8(t,e,r=!1){jx(e);const i=e.__binding.shapeOffset;if(i>=t.length){const s=t.length;t.length=i+1,t.fill(0,s,i)}t[i]|=r?e.__binding.shapeValue:e.__binding.shapeMask}const ga=2,wdt=[];class Y8{constructor(e,r,i,s={localProcessingAllowed:!1,sortedByComponentType:!1,numComponentTypes:0}){W(this,"maxEntries");W(this,"configParamName");W(this,"options");W(this,"data");W(this,"corral");W(this,"staging");W(this,"typeCounters");if(this.maxEntries=e,this.configParamName=r,this.options=s,i.register(`log.${r}.buffer`,e+ga,Uint32Array,o=>{this.data=o}),i.register(`log.${r}.corral`,e+ga,Uint32Array,o=>
6859{this.corral=o}),s.sortedByComponentType){if(s.numComponentTypes===void 0)throw new $e(`numComponentTypes required when ${this.configParamName} is sortedByComponentType`);i.register(`log.${r}.staging`,e+ga,Uint32Array,o=>{this.staging=o}),this.typeCounters=new Uint32Array(this.options.numComponentTypes)}}push(e,r){const i=this.corral[0];if(i>=this.maxEntries&&this.throwCapacityExceeded(),!(i&&this.corral[i]===e)){if(this.corral[i+ga]=e,this.corral[0]+=1,!!r!=!!this.options.sortedByComponentType)throw new $e(`Pushing value ${r?"with":"without"} type to log ${this.configParamName} ${this.options.sortedByComponentType?"":"not "}sorted by component type`);r&&(this.typeCounters[r.id]+=1)}}commit(e){if(!e&&this.options.localProcessingAllowed)throw new $e(`Cannot use blind commit when local processing is allowed in log ${this.configParamName}`);return this.corral[0]?e&&!(e.generation===this.data[1]&&e.index===this.data[0]&&e.corralGeneration===this.corral[1]&&e.corralIndex===this.corral[0])?!1:(this.copyToData(this.staging?this.sortCorral():this.corral),this.corral[0]=0,this.corral[1]+=1,e&&(e.index=this.data[0],e.generation=this.data[1]),!0):!0}sortCorral(){let e=ga,r=-1,i=0,s=0;for(let n=0;n<this.typeCounters.length;n++){const a=this.typeCounters[n];a&&(s+=1,r===-1?(r=n,i=a):r>=0&&(r=-2),a===1?(this.typeCounters[n]=e,e+=1):(this.typeCounters[n]=e+1,this.staging[e]=a|n<<Bc|2**31,e+=a+1))}if(r>=0)return i>1&&(this.corral[0]===this.maxEntries&&this.throwCapacityExceeded(),this.corral[this.corral[0]+ga]=this.corral[ga],this.corral[ga]=this.corral[0]|r<<Bc|2**31,this.corral[0]+=1),this.typeCounters.fill(0),this.corral;this.corral[0]+s>this.maxEntries&&this.throwCapacityExceeded();const o=this.corral[0]+ga;for(let n=ga;n<o;n++){const a=this.corral[n],l=a>>>Bc;this.staging[this.typeCounters[l]++]=a}return this.staging[0]=e-ga,this.typeCounters.fill(0),this.staging}copyToData(e){let r=this.data[0];const i=e[0],s=Math.min(i,this.maxEntries-r);for(this.data.set(e.subarray(ga,s+ga),r+ga),s<i&&this.data.set(e.subarray(s+ga,i+ga),ga),r+=i;r>=this.maxEntries;)r-=this.maxEntries,this.data[1]+=1;this.data[0]=r}createPointer(e){return e?(e.index=this.data[0],e.generation=this.data[1],e.corralIndex=this.corral[0],e.corralGeneration=this.corral[1],e):{index:this.data[0],generation:this.data[1],corralIndex:this.corral[0],corralGeneration:this.corral[1]}}copyPointer(e){return{index:e.index,generation:e.generation,corralIndex:e.corralIndex,corralGeneration:e.corralGeneration}}hasUpdatesSince(e){return this.checkPointer(e),!(e.index===this.data[0]&&e.generation===this.data[1]&&(e.corralGeneration===this.corral[1]?e.corralIndex===this.corral[0]:this.corral[0]===0))}processSince(e,r){this.checkPointers(e,r);let i=wdt;const s=(r==null?void 0:r.index)??this.data[0],o=(r==null?void 0:r.generation)??this.data[1];if(e.generation===o)if(e.index<s)i=[this.data,e.index+ga,s+ga,!1],e.index=s;else{const n=this.corral[0],a=this.corral[1];(e.corralGeneration===a?e.corralIndex<n:n)&&(i=[this.corral,e.corralIndex+ga,n+ga,!0],e.corralIndex=n,e.corralGeneration=a)}else i=[this.data,e.index+ga,this.data.length,!1],e.index=0,e.generation=o;return i}processAndCommitSince(e){const r=this.processSince(e);return r[0]?r:this.commit(e)?wdt:this.processSince(e)}countSince(e,r){if(this.checkPointers(e,r),this.corral[0])throw new $e(`Should commit log ${this.configParamName} before counting`);const i=e.index,s=e.generation,o=(r==null?void 0:r.index)??this.data[0],n=(r==null?void 0:r.generation)??this.data[1];return e.index=o,e.generation=n,i===o&&s===n?0:i<o?o-i:this.maxEntries-(i-o)}checkPointers(e,r){if(this.checkPointer(e),r&&(this.checkPointer(r),e.index>r.index&&e.generation>=r.generation))throw new $e(`Start pointer exceeds end pointer in log ${this.configParamName}`)}checkPointer(e){const r=this.data[0];let i=e.generation;e.index===r?i+1<this.data[1]&&this.throwCapacityExceeded():(e.index>r&&(i+=1),i!==this.data[1]&&this.throwCapacityExceeded());{if(e.corralGeneration>this.corral[1])throw new $e(`Pointer corral generation older than corral in log ${this.configParamName}`);if(e.corralGeneration===this.corral[1]&&e.corralIndex>this.corral[0])throw new $e(`Pointer past end of corral area in log ${this.configParamName}`)}}throwCapacityExceeded(){throw new Wt(`Log capacity exceeded, please raise ${this.configParamName} above ${this.maxEntries}`)}}class NK{constructor(e){W(this,"size");W(this,"bytes");this.size=e,this.bytes=new Uint32Array(Math.ceil(e/32))}get(e){if(e<0||e>=this.size)throw new $e(`Bit index out of bounds: ${e}`);return(this.bytes[e>>>5]&1<<(e&31))!==0}set(e){if(e<0||e>=this.size)throw new $e(`Bit index out of bounds: ${e}`);this.bytes[e>>>5]|=1<<(e&31)}unset(e){if(e<0||e>=this.size)throw new $e(`Bit index out of bounds: ${e}`);this.bytes[e>>>5]&=~(1<<(e&31))}clear(){this.bytes.fill(0)}}class rjt{constructor(e,r){W(this,"pool");W(this,"orderBy");W(this,"entities",[]);W(this,"maxOrderKey",-1/0);W(this,"sorted",!0);this.pool=e,this.orderBy=r}add(e){const r=this.pool.borrowTemporarily(e);if(this.orderBy){const i=this.orderBy(r);i>=this.maxOrderKey?this.maxOrderKey=i:this.sorted=!1}this.entities.push(r)}clear(){this.entities.length&&(this.entities.length=0),this.maxOrderKey=-1/0,this.sorted=!0}
6859sort(){if(this.sorted)return;const e=this.orderBy;for(const r of this.entities)r.__sortKey=e(r);this.entities.sort((r,i)=>r.__sortKey<i.__sortKey?-1:r.__sortKey>i.__sortKey?1:0),this.sorted=!0}}class ijt{constructor(e,r,i){W(this,"pool");W(this,"orderBy");W(this,"entities",[]);W(this,"lookupTable");W(this,"maxOrderKey",-1/0);W(this,"sorted",!0);this.pool=e,this.orderBy=r,this.lookupTable=new Int32Array(i),this.lookupTable.fill(-1)}add(e){const r=this.pool.borrow(e);if(this.orderBy){const s=this.orderBy(r);s>=this.maxOrderKey?this.maxOrderKey=s:this.sorted=!1}const i=this.entities.push(r)-1;this.lookupTable[e]=i}remove(e){const r=this.lookupTable[e];if(r<0)throw new $e("Entity not in list");this.pool.return(e),this.lookupTable[e]=-1;const i=this.entities.pop();r<this.entities.length&&(this.entities[r]=i,this.lookupTable[i.__id]=r,this.orderBy&&(this.sorted=!1))}has(e){return this.lookupTable[e]>=0}clear(){for(const e of this.entities)this.pool.return(e.__id);this.entities=[],this.lookupTable.fill(-1),this.maxOrderKey=-1/0,this.sorted=!0}sort(){if(this.sorted)return;const e=this.orderBy;for(const r of this.entities)r.__sortKey=e(r);this.entities.sort((r,i)=>r.__sortKey<i.__sortKey?-1:r.__sortKey>i.__sortKey?1:0);for(let r=0;r<this.entities.length;r++)this.lookupTable[this.entities[r].__id]=r;this.sorted=!0}}var to;(function(t){t[t.current=1]="current",t[t.added=2]="added",t[t.removed=4]="removed",t[t.changed=8]="changed",t[t.addedOrChanged=16]="addedOrChanged",t[t.changedOrRemoved=32]="changedOrRemoved",t[t.addedChangedOrRemoved=64]="addedChangedOrRemoved"})(to||(to={}));const sjt=to.added|to.removed|to.changed|to.addedOrChanged|to.changedOrRemoved|to.addedChangedOrRemoved,ojt=to.changed|to.addedOrChanged|to.changedOrRemoved|to.addedChangedOrRemoved,njt=to.added|to.removed|to.addedOrChanged|to.changedOrRemoved|to.addedChangedOrRemoved;class ajt{constructor(e,r){W(this,"system");W(this,"results",{});W(this,"flavors",0);W(this,"withMask");W(this,"withValues");W(this,"withAnyRecords");W(this,"withoutMask");W(this,"withoutEnumTypes");W(this,"trackWritesMask");W(this,"orderBy");W(this,"hasTransientResults");W(this,"hasChangedResults");W(this,"hasShapeResults");W(this,"hasMatchTracking");W(this,"currentEntities");W(this,"processedEntities");W(this,"changedEntities");this.system=r,e.__results=this.results,e.__systemName=r.name}complete(){var r,i;const e=this.system.dispatcher;this.hasTransientResults=!!(this.flavors&sjt),this.hasChangedResults=!!(this.flavors&ojt),this.hasShapeResults=!!(this.flavors&njt),this.hasMatchTracking=!!((r=this.withAnyRecords)!=null&&r.some(s=>s.lastMatches));{if(this.withMask&&this.withoutMask){const o=Math.min(this.withMask.length,this.withoutMask.length);for(let n=0;n<o;n++)if((this.withMask[n]&this.withoutMask[n])!==0)throw new Wt("Query must not list a component type in both `with` and `without` clauses")}if(this.withAnyRecords&&this.withoutMask)for(const{mask:o}of this.withAnyRecords){const n=Math.min(o.length,this.withoutMask.length);for(let a=0;a<n;a++)if((o[a]&this.withoutMask[a])!==0)throw new Wt("Query must not list a component type in both `withAny` and `without` clauses")}const s=!!this.trackWritesMask||((i=this.withAnyRecords)==null?void 0:i.some(o=>o.lastMatches));if(this.hasChangedResults&&!s)throw new Wt("Query for changed entities must track at least one component");if(!this.hasChangedResults&&s)throw new Wt("You can only track components if you have a query for changed entities")}this.flavors&to.current?this.results.current=new ijt(e.registry.pool,this.orderBy,e.maxEntities):this.currentEntities=new NK(e.maxEntities),this.processedEntities=new NK(e.maxEntities),this.hasTransientResults&&this.allocateTransientResultLists(),this.flavors&&this.system.shapeQueries.push(this),this.hasChangedResults&&(this.changedEntities=new NK(e.maxEntities),this.system.writeQueries.push(this))}allocateTransientResultLists(){this.flavors&to.added&&this.allocateResult("added"),this.flavors&to.removed&&this.allocateResult("removed"),this.flavors&to.changed&&this.allocateResult("changed"),this.flavors&to.addedOrChanged&&this.allocateResult("addedOrChanged"),this.flavors&to.changedOrRemoved&&this.allocateResult("changedOrRemoved"),this.flavors&to.addedChangedOrRemoved&&this.allocateResult("addedChangedOrRemoved")}allocateResult(e){const r=this.system.dispatcher;this.results[e]=new rjt(r.registry.pool,this.orderBy)}clearTransientResults(){var e,r,i,s,o,n,a;this.hasTransientResults&&((e=this.results.added)==null||e.clear(),(r=this.results.removed)==null||r.clear(),(i=this.results.changed)==null||i.clear(),(s=this.results.addedOrChanged)==null||s.clear(),(o=this.results.changedOrRemoved)==null||o.clear(),(n=this.results.addedChangedOrRemoved)==null||n.clear(),(a=this.changedEntities)==null||a.clear())}clearAllResults(){var e;this.clearTransientResults(),(e=this.results.current)==null||e.clear()}clearProcessedEntities(){this.processedEntities.clear()}handleShapeUpdate(e){var o,n,a,l,c,h,u,d,f,g,p,m,v,b,y,_,w;if(this.processedEntities.get(e))return;this.processedEntities.set(e);const r=this.system.dispatcher.registry,i=((o=this.results.current)==null?void 0:o.has(e))??this.currentEntities.get(e),s=r.matchSh
6859ape(e,this.withMask,this.withValues,this.withAnyRecords,this.withoutMask,this.withoutEnumTypes);if(s&&!i)(n=this.currentEntities)==null||n.set(e),(a=this.changedEntities)==null||a.set(e),(l=this.results.current)==null||l.add(e),(c=this.results.added)==null||c.add(e),(h=this.results.addedOrChanged)==null||h.add(e),(u=this.results.addedChangedOrRemoved)==null||u.add(e);else if(!s&&i)(d=this.currentEntities)==null||d.unset(e),(f=this.changedEntities)==null||f.set(e),(g=this.results.current)==null||g.remove(e),(p=this.results.removed)==null||p.add(e),(m=this.results.changedOrRemoved)==null||m.add(e),(v=this.results.addedChangedOrRemoved)==null||v.add(e);else if(s&&i&&this.hasMatchTracking){for(const E of this.withAnyRecords)if(E.changed){this.changedEntities.set(e),(b=this.results.changed)==null||b.add(e),(y=this.results.addedOrChanged)==null||y.add(e),(_=this.results.changedOrRemoved)==null||_.add(e),(w=this.results.addedChangedOrRemoved)==null||w.add(e);break}}}handleWrite(e,r,i){var s,o,n,a,l;!this.changedEntities.get(e)&&(this.hasShapeResults?((s=this.results.current)==null?void 0:s.has(e))??this.currentEntities.get(e):this.system.dispatcher.registry.matchShape(e,this.withMask,this.withValues,this.withAnyRecords,this.withoutMask,this.withoutEnumTypes))&&(this.trackWritesMask[r]??0)&i&&(this.changedEntities.set(e),(o=this.results.changed)==null||o.add(e),(n=this.results.addedOrChanged)==null||n.add(e),(a=this.results.changedOrRemoved)==null||a.add(e),(l=this.results.addedChangedOrRemoved)==null||l.add(e))}sort(){var e,r,i,s,o,n,a;(e=this.results.current)==null||e.sort(),(r=this.results.added)==null||r.sort(),(i=this.results.removed)==null||i.sort(),(s=this.results.changed)==null||s.sort(),(o=this.results.addedOrChanged)==null||o.sort(),(n=this.results.changedOrRemoved)==null||n.sort(),(a=this.results.addedChangedOrRemoved)==null||a.sort()}}class ljt{constructor(e,r){W(this,"__callback");W(this,"__userQuery");W(this,"__query");W(this,"__system");W(this,"__lastTypes");W(this,"__lastWasWithAny");this.__callback=e,this.__userQuery=r}__build(e){try{this.__system=e,this.__query=new ajt(this.__userQuery,e),this.__callback(this),!this.__query.withMask&&this.__query.flavors&&this.set("withMask",[this.__system.dispatcher.registry.Alive]),this.__query.complete()}catch(r){throw r.message=`Failed to build query in system ${e.name}: ${r.message}`,r}}get and(){return this}get but(){return this}get also(){return this}get current(){return this.__query.flavors|=to.current,this}get added(){return this.__query.flavors|=to.added,this}get removed(){return this.__query.flavors|=to.removed,this}get changed(){return this.__query.flavors|=to.changed,this}get addedOrChanged(){return this.__query.flavors|=to.addedOrChanged,this}get changedOrRemoved(){return this.__query.flavors|=to.changedOrRemoved,this}get addedChangedOrRemoved(){return this.__query.flavors|=to.addedChangedOrRemoved,this}orderBy(e){return this.__query.orderBy=e,this}with(...e){return this.set(this.__system.accessMasks.read,e),this.set("withMask"),this}withAny(...e){for(const i of e)if(typeof i=="function"&&i.enum)throw new Wt(`Cannot use enum types in a withAny clause: ${i.name}`);this.set(this.__system.accessMasks.read,e),this.__query.withAnyRecords||(this.__query.withAnyRecords=[]);const r=[];return this.__query.withAnyRecords.push({mask:r,lastMatches:void 0,changed:!1}),this.set(r),this}without(...e){return this.set(this.__system.accessMasks.read,e),this.set("withoutMask"),this}using(...e){return this.__lastTypes=e,this}get usingAll(){return this.__lastTypes=this.__system.dispatcher.registry.types.slice(1),this}get trackWrites(){this.set("trackWritesMask");for(const e of this.__lastTypes)if(typeof e=="function")e.__binding.trackedWrites=!0;else for(const r of e.__types)r.__binding.trackedWrites=!0;return this}get trackMatches(){if(!this.__lastWasWithAny)throw new Error("You can only apply trackMatches to a withAny clause");return this.__query.withAnyRecords[this.__query.withAnyRecords.length-1].lastMatches=[],this}get read(){return this.set(this.__system.accessMasks.read),this}get create(){return this.set(this.__system.accessMasks.create),this}get update(){return this.set(this.__system.accessMasks.update),this}get write(){return this.set(this.__system.accessMasks.write),this.set(this.__system.accessMasks.read),this.set(this.__system.accessMasks.create),this.set(this.__system.accessMasks.update),this}set(e,r){var d;if(!e)return;if(r)for(const f of r)jx(f);if(r||(r=this.__lastTypes),!r)throw new $e("No component type to apply query modifier to");this.__lastTypes=r,typeof e=="string"&&(this.__query[e]||(this.__query[e]=[]),e=this.__query[e]),this.__lastWasWithAny=((d=this.__query.withAnyRecords)==null?void 0:d.some(f=>f.mask===e))??!1;const i=e===this.__system.accessMasks.read,s=e===this.__system.accessMasks.update,o=e===this.__system.accessMasks.create,n=e===this.__system.accessMasks.write,a=e===this.__query.withMask,l=e===this.__query.withoutMask,c=e===this.__query.withMask||e===this.__query.withoutMask||this.__lastWasWithAny,h=e===this.__query.trackWritesMask,u=i?this.__system.dispatcher.planner.readers:n||o||s?this.__system.dispatcher.planner.writers:void 0;for(const f of r){if(!FK(this.__system.accessMasks.write,f)&&(i&&FK(this.__system.accessMasks.create,f)||o&&FK(this.__system.accessMasks.read,f)))throw new Wt(`Cannot combine create and read entitlements for component type ${f.name}; just use a write entitlement instead`);if(l&&typeof f=="function"&&f.enum?(this.__query.withoutEnumTypes=this.__query.withoutEnumTypes??[],this.__query.withoutEnumTypes.push(f)):(V8(e,f),a&&(this.__query.withValues||(this.__query.withValues=[]),V8(this.__query.withValues,f,!0))),i&&V8(this.__system.accessMasks.check,f),typeof f=="function")u&&u.get(f).add(this.__system),c&&this.categorize(this.__system.shapeQueriesByComponent,f),h&&this.categorize(this.__system.writeQueriesByComponent,f);else for(const g of f.__types)u&&u.get(g).add(this.__system),c&&this.categorize(this.__system.shapeQueriesByComponent,g),h&&this.categorize(this.__system.writeQueriesByComponent,g)}}categorize(e,r){const i=r.id;
6859e[i]||(e[i]=[]),e[i].includes(this.__query)||e[i].push(this.__query)}}class cjt{constructor(){W(this,"__results");W(this,"__systemName")}get current(){return this.__checkList("current"),this.__results.current.entities}get added(){return this.__checkList("added"),this.__results.added.entities}get removed(){return this.__checkList("removed"),this.__results.removed.entities}get changed(){return this.__checkList("changed"),this.__results.changed.entities}get addedOrChanged(){return this.__checkList("addedOrChanged"),this.__results.addedOrChanged.entities}get changedOrRemoved(){return this.__checkList("changedOrRemoved"),this.__results.changedOrRemoved.entities}get addedChangedOrRemoved(){return this.__checkList("addedChangedOrRemoved"),this.__results.addedChangedOrRemoved.entities}__checkList(e){if(!this.__results[e])throw new Wt(`Query '${e}' not configured, please add .${e} to your query definition in system ${this.__systemName}`)}}const f2=typeof window<"u"&&typeof window.performance<"u"?performance.now.bind(performance):Date.now.bind(Date);class Edt{constructor(e,r){W(this,"__callback");W(this,"__schedule");W(this,"__systems");W(this,"__dispatcher");this.__callback=e,this.__schedule=r}__build(e,r){try{this.__systems=e,this.__dispatcher=e[0].dispatcher,this.__callback(this)}catch(i){throw i.message=`Failed to build schedule in ${r}: ${i.message}`,i}}get allSystems(){return this.__dispatcher.defaultGroup}get onMainThread(){var e;return this.__checkNoLaneAssigned(),(e=this.__dispatcher.planner.mainLane)==null||e.add(...this.__systems),this}get onOneThread(){return this.__checkNoLaneAssigned(),this.__dispatcher.planner.createLane().add(...this.__systems),this}get onManyThreads(){var e;this.__checkNoLaneAssigned(),(e=this.__dispatcher.planner.replicatedLane)==null||e.add(...this.__systems);for(const r of this.__systems)r.stateless=!0;return this}__checkNoLaneAssigned(){if(this.__systems.some(e=>e.lane))throw new Wt("Threading semantics already specified")}before(...e){const r=new Set(this.__systems);for(const i of e)for(const s of this.__dispatcher.getSystems(i))if(!r.has(s))for(const o of this.__systems)this.__dispatcher.planner.graph.addEdge(o,s,5);return this}after(...e){const r=new Set(this.__systems);for(const i of e)for(const s of this.__dispatcher.getSystems(i))if(!r.has(s))for(const o of this.__systems)this.__dispatcher.planner.graph.addEdge(s,o,5);return this}inAnyOrderWith(...e){for(const r of e)for(const i of this.__dispatcher.getSystems(r))for(const s of this.__systems)this.__dispatcher.planner.graph.denyEdge(s,i,4);return this}beforeReadersOf(...e){for(const r of e)for(const i of this.__dispatcher.planner.readers.get(r))for(const s of this.__systems)this.__dispatcher.planner.graph.addEdge(s,i,3);return this}afterReadersOf(...e){for(const r of e)for(const i of this.__dispatcher.planner.readers.get(r))for(const s of this.__systems)this.__dispatcher.planner.graph.addEdge(i,s,3);return this}beforeWritersOf(...e){for(const r of e)for(const i of this.__dispatcher.planner.writers.get(r))for(const s of this.__systems)this.__dispatcher.planner.graph.addEdge(s,i,3);return this}afterWritersOf(...e){for(const r of e)for(const i of this.__dispatcher.planner.writers.get(r))for(const s of this.__systems)this.__dispatcher.planner.graph.addEdge(i,s,3);return this}inAnyOrderWithReadersOf(...e){for(const r of e)for(const i of this.__dispatcher.planner.readers.get(r))for(const s of this.__systems)this.__dispatcher.planner.graph.denyEdge(i,s,2);return this}inAnyOrderWithWritersOf(...e){for(const r of e)for(const i of this.__dispatcher.planner.writers.get(r))for(const s of this.__systems)this.__dispatcher.planner.graph.denyEdge(i,s,2);return this}}class Adt{}class p2{constructor(e){W(this,"__contents");W(this,"__plan");W(this,"__executed",!1);W(this,"__systems");W(this,"__scheduleBuilder");this.__contents=e}__collectSystems(e){if(!this.__systems){this.__systems=[];for(const r of this.__contents)r instanceof Function&&r.__system?this.__systems.push(e.systemsByClass.get(r)):r instanceof p2&&this.__systems.push(...r.__collectSystems(e))}return this.__systems}__buildSchedule(){var e;(e=this.__scheduleBuilder)==null||e.__build(this.__systems,"a group"),this.__scheduleBuilder=null}schedule(e){if(this.__scheduleBuilder===null)throw new Wt("Attempt to define group schedule after world initialized");if(this.__scheduleBuilder)throw new Wt("Attempt to define multiple schedules in a group");return this.__scheduleBuilder=new Edt(e,new Adt),this}}class xdt{constructor(e,r){W(this,"dispatcher");W(this,"groups");W(this,"executing");W(this,"time",f2()/1e3);W(this,"delta");if(this.dispatcher=e,this.groups=r,r.length===0)throw new Wt("At least one system group needed");for(const i of r)if(!e.systemGroups.includes(i))throw new Wt("Some groups in the frame are not parts of the world defs")}async begin(){if(this.executing)throw new Wt("Frame already executing");this.executing=!0;const e=this.dispatcher.lastTime??this.time;this.time=f2()/1e3,this.delta=this.time-e,this.dispatcher.startFrame(this.time)}async end(){if(!this.executing)throw new Wt("Frame not executing");this.executing=!1;t:{for(const e of this.groups)if(!e.__executed)break t;for(const e of this.groups)e.__executed=!1;this.dispatcher.completeCycle()}await this.dispatcher.completeFrame()}execute(e,r,i){if(!this.groups.includes(e))throw new Wt("Group not included in this frame");
6859if(!this.executing)throw new Wt("Frame not executing");return e.__plan.execute(r??this.time,i??this.delta)}}class Sdt extends Error{constructor(){super("Canceled");W(this,"canceled",!0)}}let xg;class hjt{constructor(e,r,i){W(this,"__generator");W(this,"__fn");W(this,"__supervisor");W(this,"__cancellers",[]);W(this,"__blocker");W(this,"__scope");W(this,"__done",!1);W(this,"__awaited",!1);W(this,"__error");W(this,"__value");W(this,"__firstRun",!0);this.__generator=e,this.__fn=r,this.__supervisor=i}__checkCancelation(){if(!this.__done){for(const e of this.__cancellers)if(e()){this.cancel();break}}}__step(){var e,r,i,s,o,n;xg=this;try{if(!this.__done&&(((e=this.__blocker)==null?void 0:e.isReady())??!0))try{let a;if((r=this.__blocker)!=null&&r.error)a=this.__generator.throw(this.__blocker.error);else if(this.__firstRun)try{a=this.__generator.next((i=this.__blocker)==null?void 0:i.value)}finally{this.__firstRun=!1,this.__supervisor.cancelMatching(this,this.__scope,this.__fn)}else a=this.__generator.next((s=this.__blocker)==null?void 0:s.value);a.done?(this.__done=!0,this.__value=a.value,this.__blocker=void 0):(this.__blocker=a.value,(n=(o=this.__blocker)==null?void 0:o.markAwaited)==null||n.call(o))}catch(a){this.__done=!0,this.__error||(this.__error=a),this.__blocker=void 0}if(this.__error&&!(this.__awaited||this.__error instanceof Sdt))throw this.__error}finally{xg=void 0}}isReady(){return this.__done}get value(){return this.__value}get error(){return this.__error}markAwaited(){this.__awaited=!0}waitForFrames(e){if(e<=0)throw new Wt("Number of frames to wait for must be >0");return{isReady(){return--e<=0}}}waitForSeconds(e){const r=this.__supervisor.system,i=r.time+e;return{isReady(){return r.time>=i}}}waitUntil(e){return{isReady:e}}cancel(){var e;return(e=this.__blocker)!=null&&e.cancel?this.__blocker.cancel():(this.__error=new Sdt,this.__done=!0),this}cancelIf(e){return this.__cancellers.push(e),this}scope(e){if(this.__scope)throw new Wt("Scope already set for this coroutine");if(this.__cancellers.length)throw new Wt("Scope must be set before any cancelation conditions");return this.__scope=e,this.cancelIf(()=>!e.alive),this}cancelIfComponentMissing(e){if(!this.__scope)throw new Wt("Required scope not set for this coroutine");return this.cancelIf(()=>{var r;return!((r=this.__scope)!=null&&r.has(e))}),this}cancelIfCoroutineStarted(e){return this.__supervisor.registerCancelIfStarted(this,this.__scope,e===Sg.self?this.__fn:e),this}return(e){throw new Wt("Generator methods not available for coroutines")}throw(e){throw new Wt("Generator methods not available for coroutines")}next(...e){throw new Wt("Generator methods not available for coroutines")}[Symbol.iterator](){throw new Wt("Generator methods not available for coroutines")}}function Sg(t,e,r){const i=r.value;return{value(...s){return this.start(i,...s)}}}Sg.waitForFrames=function(t){return iw(),xg.waitForFrames(t)},Sg.waitForSeconds=function(t){return iw(),xg.waitForSeconds(t)},Sg.waitUntil=function(t){return iw(),xg.waitUntil(t)},Sg.cancel=function(){iw(),xg.cancel()},Sg.cancelIf=function(t){return iw(),xg.cancelIf(t)},Sg.scope=function(t){return iw(),xg.scope(t)},Sg.cancelIfComponentMissing=function(t){return iw(),xg.cancelIfComponentMissing(t)},Sg.cancelIfCoroutineStarted=function(t){return iw(),xg.cancelIfCoroutineStarted(t)},Sg.self=function*(){yield};function iw(){if(!xg)throw new Wt("Cannot call co methods outside coroutine context")}bO=Sg;class ujt{constructor(e){W(this,"system");W(this,"coroutines",[]);W(this,"mutuallyExclusiveCoroutines",new Map);this.system=e}start(e,...r){const i=new hjt(e.apply(this.system,r),e,this);return this.coroutines.push(i),i}execute(){let e=0;for(;e<this.coroutines.length;){const r=e;e=this.coroutines.length;for(let i=e-1;i>=r;i--)this.system.accessRecentlyDeletedData(!1),this.coroutines[i].__checkCancelation();for(let i=e-1;i>=r;i--){this.system.accessRecentlyDeletedData(!1);const s=this.coroutines[i];s.__step(),s.isReady()&&(this.coroutines.splice(i,1),e-=1)}}}registerCancelIfStarted(e,r,i){var o;const s=((r==null?void 0:r.__id)??"")+((i==null?void 0:i.name)??"");
6859this.mutuallyExclusiveCoroutines.has(s)||this.mutuallyExclusiveCoroutines.set(s,[]),(o=this.mutuallyExclusiveCoroutines.get(s))==null||o.push(e)}cancelMatching(e,r,i){this.cancelMatchingKey(e,""),this.cancelMatchingKey(e,i.name),r&&(this.cancelMatchingKey(e,""+r.__id),this.cancelMatchingKey(e,""+r.__id+i.name))}cancelMatchingKey(e,r){const i=this.mutuallyExclusiveCoroutines.get(r);if(i){let s=!1;for(const o of i)o===e?s=!0:o.cancel();i.length=0,s&&i.push(e)}}}var Nf;(function(t){t[t.RUNNING=0]="RUNNING",t[t.STOPPED=1]="STOPPED"})(Nf||(Nf={}));class kK{constructor(e,r,i){W(this,"access");W(this,"type");W(this,"initialValues");this.access=e,this.type=r,this.initialValues=i}}class Tdt{constructor(e){W(this,"type");this.type=e}}We=(zQ=class{constructor(){W(this,"__queryBuilders",[]);W(this,"__scheduleBuilder");W(this,"__attachPlaceholders",[]);W(this,"__singletonPlaceholders",[]);W(this,"__supervisor",new ujt(this));W(this,"__dispatcher");W(this,"id");W(this,"time");W(this,"delta")}static group(...t){return new p2(t)}get name(){return this.constructor.name}query(t){const e=new cjt,r=new ljt(t,e);if(!this.__queryBuilders)throw new Wt(`Attempt to create a new query after world initialized in system ${this.name}`);return this.__queryBuilders.push(r),e}schedule(t){if(this.__scheduleBuilder===null)throw new Wt(`Attempt to define schedule after world initialized in system ${this.name}`);if(this.__scheduleBuilder)throw new Wt(`Attempt to define multiple schedules in system ${this.name}`);const e=new Adt;return this.__scheduleBuilder=new Edt(t,e),e}attach(t){if(!this.__attachPlaceholders)throw new Wt(`Attempt to attach a system after world initialized in system ${this.name}`);const e=new Tdt(t);return this.__attachPlaceholders.push(e),e}createEntity(...t){return this.__dispatcher.createEntity(t)}accessRecentlyDeletedData(t=!0){this.__dispatcher.registry.includeRecentlyDeleted=t}start(t,...e){return this.__supervisor.start(t,...e)}async prepare(){}initialize(){}execute(){}finalize(){}},W(zQ,"__system",!0),zQ),Object.defineProperty(We.prototype,"singleton",{get(){const t=this,e={read(r){if(!t.__singletonPlaceholders)throw new Wt(`Attempt to declare a singleton after world initialized in system ${t.name}`);_dt(r),t.query(s=>s.using(r).read);const i=new kK("read",r);return t.__singletonPlaceholders.push(i),i},write(r,i){if(!t.__singletonPlaceholders)throw new Wt(`Attempt to declare a singleton after world initialized in system ${t.name}`);_dt(r),t.query(o=>o.using(r).write);const s=new kK("write",r,i);return t.__singletonPlaceholders.push(s),s}};return Object.defineProperty(this,"singleton",{value:e,configurable:!0}),e}});class LK{constructor(e,r){W(this,"system");W(this,"dispatcher");this.system=e,this.dispatcher=r,e.__dispatcher=r,this.accessMasks={read:[],update:[],create:[],write:[],check:[]},this.shapeQueries=[],this.shapeQueriesByComponent=[],this.writeQueries=[],this.writeQueriesByComponent=[],this.state=Nf.RUNNING,this.propsAssigned=!1,this.stateless=!1,this.weight=1,this.shapeLogPointer=r.shapeLog.createPointer(),this.stats=r.stats.forSystem(e.constructor),this.attachedSystems=this.system.__attachPlaceholders.map(i=>this.dispatcher.systemsByClass.get(i.type)),this.singletonComponentDefs=this.system.__singletonPlaceholders.flatMap(i=>i.initialValues?[i.type,i.initialValues]:[i.type]),this.singletonStandingWrites=this.system.__singletonPlaceholders.filter(i=>i.access==="write").map(i=>i.type)}get id(){return this.system.id}get name(){return this.system.name}toString(){return this.name}assignProps(e){if(this.propsAssigned)throw new Wt(`System ${this.name} has multiple props assigned in world defs`);Object.assign(this.system,e),this.propsAssigned=!0}buildQueries(){for(const e of this.system.__queryBuilders)e.__build(this);this.system.__queryBuilders=null,this.hasNegativeQueries=!!this.shapeQueriesByComponent[this.dispatcher.registry.Alive.id],this.hasWriteQueries=!!this.writeQueries.length,this.hasTransientQueries=this.shapeQueries.some(e=>e.hasTransientResults)}buildSchedule(){var r;const e=this.system.constructor.__staticScheduler;e&&this.system.schedule(e),(r=this.system.__scheduleBuilder)==null||r.__build([this],`system ${this.name}`),this.system.__scheduleBuilder=null}finishConstructing(){var e;this.writeLogPointer=(e=this.dispatcher.writeLog)==null?void 0:e.createPointer(),this.singletonStandingWrites=this.singletonStandingWrites.filter(r=>r.__binding.trackedWrites)}replacePlaceholders(){const e=this.system;for(const r in this.system){const i=e[r];if(i instanceof Tdt){const s=i.type,o=this.dispatcher.systemsByClass.get(s);if(!o)throw new Wt(`Attached system ${s.name} not defined in this world`);e[r]=o.system}else i instanceof kK&&(e[r]=this.dispatcher.singleton[i.access](i.type))}this.system.__attachPlaceholders=null,this.system.__singletonPlaceholders=null,this.dispatcher.singleton&&Object.defineProperty(this.system,"singleton",{value:this.dispatcher.singleton})}prepare(){return this.system.prepare()}initialize(){this.dispatcher.registry.executingSystem=this,this.system.initialize(),this.trackStandingWrites()}finalize(){this.dispatcher.registry.executingSystem=this,this.system.finalize(),this.trackStandingWrites()}execute(e,r){if(this.state!==Nf.RUNNING)return;this.dispatcher.registry.executingSystem=this,this.system.time=e,this.system.delta=r;let i,s,o,n;i=f2(),this.runQueries(),s=f2(),this.system.execute(),o=f2(),this.system.__supervisor.execute(),this.trackStandingWrites(),n=f2(),this.stats.lastQueryUpdateDuration=s-i,this.stats.lastExecutionDuration=o-s,this.stats.lastCoroutinesDuration=n-o}trackStandingWrites(){const e=this.dispatcher.singleton;for(const r of this.singletonStandingWrites)this.dispatcher.registry.trackWrite(e.__id,r)}runQueries(){const e=this.ranQueriesLastFrame;this.ranQueriesLastFrame=!1;const r=this.dispatcher.shapeLog.hasUpdatesSince(this.shapeLogPointer),i=this.hasWriteQueries&&this.dispatcher.writeLog.hasUpdatesSince(this.writeLogPointer);if(r||i||this.hasTransientQueries&&e){if(this.hasTransientQueries)for(const s of this.shapeQueries)s.clearTransientResults();if(r||i){this.ranQueriesLastFrame=!0,r&&this.__updateShapeQueries(),i&&this.__updateWriteQueries();for(const s of this.shapeQueries)s.sort()}}}__updateShapeQueries(){const e=this.dispatcher.shapeLog;if(!this.shapeQueries.length){e.createPointer(this.shapeLogPointer);return}for(const a of this.shapeQueries)a.clearProcessedEntities();let r,i=0,s,o,n;for(;[s,o,n]=e.processSince(this.shapeLogPointer),!!s;){i&&!r&&(o+=i,i=0);for(let a=o;a<n;a++){const l=s[a],c=l&Od;if(!r){const h=l>>>Bc&X8,u=l&2**31;if(r=this.shapeQueriesByComponent[h],u){if(i=c,!r){const d=Math.min(i,n-a);a+=d,i-=d}continue}if(!r)continue;i=1}if(l&2**31)throw new $e("Trying to process run header as entry in shape log");for(let h=0;h<r.length;h++)r[h].handleShapeUpdate(c);--i===0&&(r=void 0)}}}__updateWriteQueries(){const e=this.dispatcher.writeLog;if(!this.writeQueries.length){e.createPointer(this.writeLogPointer);return}let r,i=0,s,o,n,a,l;for(;[n,a,l]=e.processSince(this.writeLogPointer),!!n;
6859){i&&!r&&(a+=i,i=0);for(let c=a;c<l;c++){const h=n[c],u=h&Od;if(!r){const d=h>>>Bc&X8,f=h&2**31;if(s=d>>5,o=1<<(d&31),r=this.writeQueriesByComponent[d],f){if(i=u,!r){const g=Math.min(i,l-c);c+=g,i-=g}continue}if(!r)continue;i=1}if(h&2**31)throw new $e("Trying to process run header as entry in write log");for(let d=0;d<r.length;d++)r[d].handleWrite(u,s,o);--i===0&&(r=void 0)}}}stop(){if(this.state!==Nf.STOPPED){this.state=Nf.STOPPED;for(const e of this.shapeQueries)e.clearAllResults()}}restart(){var e;if(this.state===Nf.STOPPED){const r=this.dispatcher.registry,i=r.Alive;for(const s of this.shapeQueries)s.clearProcessedEntities();for(let s=0;s<this.dispatcher.maxEntities;s++)if(r.hasShape(s,i,!1))for(const o of this.shapeQueries)o.handleShapeUpdate(s);for(const s of this.shapeQueries)s.clearTransientResults(),s.sort();this.dispatcher.shapeLog.createPointer(this.shapeLogPointer),(e=this.dispatcher.writeLog)==null||e.createPointer(this.writeLogPointer)}this.state=Nf.RUNNING}}class $8{constructor(e,r){W(this,"name");W(this,"__types");W(this,"__binding");this.name=e,this.__types=Array.from(new Set(r))}}const Wu=2;class djt{constructor(e,r){W(this,"maxItems");W(this,"configParamName");W(this,"data");this.maxItems=e,this.configParamName=r,this.data=new Uint32Array(new ArrayBuffer((e+Wu)*Uint32Array.BYTES_PER_ELEMENT))}get length(){return this.data[0]}take(){const e=--this.data[0];if(e<0)throw new RangeError(`Pool capacity exceeded, please raise ${this.configParamName} above ${this.maxItems}`);return this.data[e+Wu]}return(e){if(this.length>=this.maxItems)throw new $e("Internal error, returned entity ID exceeded pool capacity");this.data[this.length+Wu]=e,this.data[0]+=1}mark(){this.data[1]=this.data[0]}peekSinceMark(e){const r=this.data[1]+e;if(r<this.data[0])return this.data[r+Wu]}refill(e){if(!e.length)return;const r=this.length,i=r+e.length;if(i>this.maxItems)throw new $e("Internal error, returned entity ID exceeded pool capacity");this.data.set(e,r+Wu),this.data[0]=i}fillWithDescendingIntegers(e){const r=this.length+Wu;for(let i=this.data.length-1;i>=r;i--)this.data[i]=e++;this.data[0]=this.data.length-Wu}}class fjt{constructor(e,r,i){W(this,"maxItems");W(this,"configParamName");W(this,"data");this.maxItems=e,this.configParamName=r,i.register(`pool.${r}`,e+Wu,Uint32Array,s=>{this.data=s})}get length(){return this.data[0]}take(){const e=Atomics.sub(this.data,0,1);if(e<0)throw new RangeError(`Pool capacity exceeded, please raise ${this.configParamName} above ${this.maxItems}`);return this.data[e+Wu]}return(e){if(this.length>=this.maxItems)throw new $e("Internal error, returned entity ID exceeded pool capacity");this.data[this.length+Wu]=e,this.data[0]+=1}mark(){this.data[1]=this.data[0]}peekSinceMark(e){const r=this.data[1]+e;if(r<this.data[0])return this.data[r+Wu]}refill(e){if(!e.length)return;const r=this.length,i=r+e.length;if(i>this.maxItems)throw new $e("Internal error, returned entity ID exceeded pool capacity");this.data.set(e,r+Wu),this.data[0]=i}fillWithDescendingIntegers(e){const r=this.length+Wu;for(let i=this.data.length-1;i>=r;i--)this.data[i]=e++;this.data[0]=this.data.length-Wu}}class pjt{constructor(e,r,i,s){W(this,"stride");W(this,"array");this.stride=Math.ceil(r/32),s.register(e,i*this.stride,Uint32Array,o=>{this.array=o})}syncThreads(){}set(e,r){const i=r.__binding,s=e*this.stride+i.shapeOffset,o=i.shapeMask,n=i.shapeValue;this.array[s]&=~o,this.array[s]|=n}unset(e,r){const i=r.__binding,s=e*this.stride+i.shapeOffset,o=i.shapeMask;this.array[s]&=~o}isSet(e,r){const i=r.__binding,s=e*this.stride+i.shapeOffset,o=i.shapeMask,n=i.shapeValue;return(this.array[s]&o)===n}get(e,r){const i=r.__binding,s=e*this.stride+i.shapeOffset,o=i.shapeMask;return(this.array[s]&o)>>>i.shapeShift}clear(){this.array.fill(0)}match(e,r,i){if(r.length!==i.length)throw new $e(`Mismatched mask and value lengths: ${r.length} vs ${i.length}`);const s=this.array,o=e*this.stride;for(let n=0;n<r.length;n++)if((s[o+n]&r[n])!==i[n])return!1;return!0}matchNot(e,r){const i=this.array,s=e*this.stride;for(let o=0;o<r.length;o++)if((i[s+o]&r[o])!==0)return!1;return!0}matchAny(e,r){r.changed=!1;const i=r.mask,s=r.lastMatches[e]=r.lastMatches[e]||[],o=this.array,n=e*this.stride;let a=!1;for(let l=0;l<i.length;l++){const c=o[n+l]&i[l];c!==0&&(a=!0),c!==s[l]&&(r.changed=!0),s[l]=c}return a||delete r.lastMatches[e],a}}class gjt{constructor(e,r,i,s){W(this,"stride");W(this,"array");this.stride=Math.ceil(r/32),s.register(e,i*this.stride,Uint32Array,o=>{this.array=o})}syncThreads(){Atomics.load(this.array,0)}set(e,r){const i=r.__binding,s=e*this.stride+i.shapeOffset,o=i.shapeMask,n=i.shapeValue;o!==n&&Atomics.and(this.array,s,~o),Atomics.or(this.array,s,n)}unset(e,r){const i=r.__binding,s=e*this.stride+i.shapeOffset,o=i.shapeMask;Atomics.and(this.array,s,~o)}isSet(e,r){const i=r.__binding,s=e*this.stride+i.shapeOffset,o=i.shapeMask,n=i.shapeValue;return r.id===0?(Atomics.load(this.array,s)&o)===n:(this.array[s]&o)===n}get(e,r){const i=r.__binding,s=e*this.stride+i.shapeOffset,o=i.shapeMask;return(this.array[s]&o)>>>i.shapeShift}clear(){this.array.fill(0)}match(e,r,i){if(r.length!==i.length)throw new $e(`Mismatched mask and value lengths: ${r.length} vs ${i.length}`);const s=this.array,o=e*this.stride;for(let n=0;n<r.length;n++)if((s[o+n]&r[n])!==i[n])return!1;return!0}matchNot(e,r){const i=this.array,s=e*this.stride;for(let o=0;o<r.length;o++)if((i[s+o]&r[o])!==0)return!1;return!0}matchAny(e,r){r.changed=!1;const i=r.mask,s=r.lastMatches[e]=r.lastMatches[e]||[],o=this.array,n=e*this.stride;for(let a=0;a<i.length;a++){const l=o[n+a]&i[a];if(l===0)return delete r.lastMatches[e],!1;l!==s[a]&&(r.changed=!0),s[a]=l}return!0}}const mjt=[EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError,Wt,$e];class yjt{constructor(e,r){W(this,"registry");W(this,"borrowed");W(this,"borrowCounts");W(this,"spares",[]);W(this,"temporarilyBorrowedIds",[]);this.registry=e,this.borrowed=Array.from({length:r}),this.borrowCounts=new Int32Array(r)}borrow(e){this.borrowCounts[e]+=1;let r=this.borrowed[e];return r||(r=this.borrowed[e]=this.spares.pop()??new bdt(this.registry),r.__id=e),r}borrowTemporarily(e){const r=this.borrow(e);return this.temporarilyBorrowedIds.push(e),r}returnTemporaryBorrows(){for(const e of this.temporarilyBorrowedIds)this.return(e);this.temporarilyBorrowedIds.length=0}return(e){if(!this.borrowCounts[e])throw new $e("Returning entity with no borrows");if(--this.borrowCounts[e]<=0){const r=this.borrowed[e];this.borrowed[e]=void 0;
6859{r.__valid=!1;return}}}}class vjt{constructor(e,r,i,s,o){W(this,"types");W(this,"enums");W(this,"dispatcher");W(this,"allocationItems");W(this,"numShapeBits",0);W(this,"shapes");W(this,"staleShapes");W(this,"removedShapes");W(this,"entityIdPool");W(this,"pool");W(this,"heldEntities");W(this,"validators");W(this,"reshapedEntityIds",[]);W(this,"validateSystem");W(this,"executingSystem");W(this,"includeRecentlyDeleted",!1);W(this,"hasNegativeQueries",!1);W(this,"nextEntityOrdinal",0);W(this,"entityOrdinals");W(this,"removalLog");W(this,"prevRemovalPointer");W(this,"oldRemovalPointer");W(this,"Alive",(VQ=class{},W(VQ,"__internal",!0),VQ));this.types=i,this.enums=s,this.dispatcher=o,this.allocationItems=this.prepareComponentTypesAndEnums();for(const a of this.allocationItems)this.numShapeBits+=a.size;const n=o.threaded?gjt:pjt;this.shapes=new n("registry.shapes",this.numShapeBits,e,o.buffers),this.staleShapes=new n("registry.staleShapes",this.numShapeBits,e,o.buffers),this.removedShapes=new n("registry.removedShapes",this.numShapeBits,e,o.buffers),this.entityIdPool=o.threaded?new fjt(e,"maxEntities",o.buffers):new djt(e,"maxEntities"),this.entityOrdinals=o.buffers.register("registry.entityOrdinals",e,Uint32Array,a=>{this.entityOrdinals=a}),this.entityIdPool.fillWithDescendingIntegers(0),this.pool=new yjt(this,e),this.heldEntities=[],this.validators=[],this.removalLog=new Y8(r,"maxLimboComponents",o.buffers),this.prevRemovalPointer=this.removalLog.createPointer(),this.oldRemovalPointer=this.removalLog.createPointer()}initializeComponentTypes(){let e=0,r=0;for(;this.allocationItems.length;){const i=e%32,s=this.removeBiggestNoLargerThan(32-i);if(!s){e+=32-i;continue}const o={offset:e>>>5,mask:(1<<s.size)-1<<i,value:1<<i};if(e+=s.size,s.typeOrEnum instanceof $8){const n=s.typeOrEnum;n.__binding={shapeOffset:o.offset,shapeMask:o.mask,shapeShift:i};for(const a of n.__types)vdt(r++,a,o,this.dispatcher),a.validate&&this.validators.push(a),o.value+=1<<i}else{const n=s.typeOrEnum;vdt(r++,n,o,this.dispatcher),n.validate&&this.validators.push(n)}}for(const i of this.types)tjt(i);{const i=this.Alive.__binding;if(!(i.shapeOffset===0&&i.shapeMask===1&&i.shapeValue===1))throw new $e("Alive component was not assigned first available shape mask")}}prepareComponentTypesAndEnums(){const e=[],r=new Set,i=new Set;let s=0;for(const o of this.types){if(o.name||Object.defineProperty(o,"name",{value:`Anonymous_${s++}`}),!o.__internal){if(i.has(o.name))throw new Wt(`Multiple component types named ${o.name}; names must be unique`);i.add(o.name)}if(o.enum){if(!this.enums.includes(o.enum))throw new Wt(`Component type ${o.name} references an enum that's not in the world's defs`);o.enum.__types.includes(o)||o.enum.__types.push(o)}this.dispatcher.stats.forComponent(o)}for(const o of this.enums){if(o.__types.length>2**31)throw new Wt(`Too many types in enum: ${o.__types.length}`);e.push({typeOrEnum:o,size:Math.ceil(Math.log2(o.__types.length+1))});for(const n of o.__types){if(r.has(n))throw new Wt(`Component type ${n.name} is a member of more than one enum`);n.enum=o,r.add(n)}}for(const o of this.types)r.has(o)||e.push({typeOrEnum:o,size:1});return e.sort((o,n)=>n.size-o.size),this.types.unshift(this.Alive),e.unshift({typeOrEnum:this.Alive,size:1}),e}removeBiggestNoLargerThan(e){const r=this.allocationItems.findIndex(i=>i.size<=e);if(r!==-1)return this.allocationItems.splice(r,1)[0]}releaseComponentTypes(){for(const e of this.types)ejt(e);for(const e of this.enums)delete e.__binding}createEntity(e){const r=this.entityIdPool.take();this.entityOrdinals[r]=this.nextEntityOrdinal++,this.setShape(r,this.Alive);const i=this.pool.borrowTemporarily(r);return this.createComponents(r,e),this.dispatcher.stats.numEntities+=1,i}createComponents(e,r){var i,s;for(let o=0;o<r.length;o++){const n=r[o];{if(typeof n!="function")throw new Wt(`Bad arguments to createEntity: expected component type, got: ${n}`);jx(n);const l=(i=this.executingSystem)==null?void 0:i.accessMasks.create;if(l){const c=n.__binding;if(((l[c.shapeOffset]??0)&c.shapeMask)===0)throw new Wt(`System ${(s=this.executingSystem)==null?void 0:s.name} didn't mark component ${n.name} as createable`)}if(n.enum){if(this.getEnumShape(e,n.enum,!1))throw new Wt("Can't add multiple components from the same enum when creating entity: "+n.name)}else if(this.hasShape(e,n,!1))throw new Wt(`Duplicate ${n.name} component when creating entity`)}let a=r[o+1];typeof a=="function"?a=void 0:o++,this.setShape(e,n),this.dispatcher.stats.forComponent(n).numEntities+=1,ydt(n,e,a)}}flush(){const e=this.executingSystem;this.includeRecentlyDeleted=!1,this.validateShapes(e),this.executingSystem=void 0,this.pool.returnTemporaryBorrows(),this.removalLog.commit()}completeCycle(){this.processRemovalLog(),this.invalidateDeletedHeldEntities()}validateShapes(e){this.executingSystem=this.validateSystem;for(const r of this.reshapedEntityIds)for(const i of this.validators)try{i.validate(this.pool.borrowTemporarily(r))}catch(s){if(!mjt.includes(s.constructor)){const o=e?` after system ${e.name} executed`:"",n=this.types.filter(a=>a!==this.Alive&&this.hasShape(r,a,!1)).map(a=>a.name).join(", ")||"none";s.message=`An entity failed to satisfy ${i.name}.validate${o}: ${s.message} (components: ${n})`}throw s}this.reshapedEntityIds.length=0}processRemovalLog(){var n;const e=this.dispatcher.indexer;
6859this.removalLog.commit(),this.entityIdPool.mark();let r=0,i,s,o;for(this.dispatcher.stats.maxLimboComponents=this.removalLog.countSince(this.removalLog.copyPointer(this.oldRemovalPointer));[i,s,o]=this.removalLog.processSince(this.oldRemovalPointer,this.prevRemovalPointer),!!i;)for(let a=s;a<o;a++){const l=i[a],c=l&Od,h=l>>>Bc&X8,u=this.types[h];!this.shapes.isSet(c,u)&&!this.removedShapes.isSet(c,u)&&(this.staleShapes.unset(c,u),u===this.Alive?(e.clearAllRefs(c,!0),this.entityIdPool.return(c),r+=1):this.clearRefs(c,u,!0),(n=u.__free)==null||n.call(u,c),this.removedShapes.set(c,u))}this.dispatcher.stats.numEntities-=r,this.removedShapes.clear(),this.removalLog.createPointer(this.prevRemovalPointer)}invalidateDeletedHeldEntities(){let e=0,r;for(;(r=this.entityIdPool.peekSinceMark(e++))!==void 0;){const i=this.heldEntities[r];i&&(i.__valid=!1,delete this.heldEntities[r])}}holdEntity(e){let r;return r=this.heldEntities[e],r||(r=new bdt(this),r.__id=e,this.heldEntities[e]=r),r}hasShape(e,r,i){return!!(this.shapes.isSet(e,r)||i&&this.includeRecentlyDeleted&&this.staleShapes.isSet(e,r))}getEnumShape(e,r,i){let s=this.shapes.get(e,r);if(s===0&&i&&this.includeRecentlyDeleted&&(s=this.staleShapes.get(e,r)),s>0)return r.__types[s-1]}setShape(e,r){if(r.enum){const i=this.getEnumShape(e,r.enum,!1);i&&this.clearShape(e,i)}this.shapes.set(e,r),this.staleShapes.set(e,r),this.reshapedEntityIds.push(e),(r!==this.Alive||this.hasNegativeQueries)&&this.dispatcher.shapeLog.push(e|r.id<<Bc,r)}clearShape(e,r){this.clearRefs(e,r,!1),this.shapes.unset(e,r),this.removedShapes.set(e,r),this.reshapedEntityIds.push(e);const i=e|r.id<<Bc;this.removalLog.push(i),(r!==this.Alive||this.hasNegativeQueries)&&this.dispatcher.shapeLog.push(i,r),this.dispatcher.stats.forComponent(r).numEntities-=1}trackWrite(e,r){this.dispatcher.writeLog.push(e|r.id<<Bc,r)}
6859clearRefs(e,r,i){if(r.__binding.refFields.length){r.__bind(e,!0);for(const s of r.__binding.refFields)s.clearRef(i)}}matchShape(e,r,i,s,o,n){if(r&&i&&!this.shapes.match(e,r,i)||o&&!this.shapes.matchNot(e,o))return!1;if(n){for(const a of n)if(this.shapes.isSet(e,a))return!1}if(s){for(const a of s)if(a.lastMatches){if(!this.shapes.matchAny(e,a))return!1}else if(this.shapes.matchNot(e,a.mask))return!1}return!0}}const Rdt=.05;function UK(t,e){return e*Rdt+t*(1-Rdt)}class _jt{constructor(e){W(this,"type");W(this,"_numEntities",0);W(this,"maxEntities",0);W(this,"capacity",0);this.type=e}get numEntities(){return this._numEntities}set numEntities(e){this._numEntities=e,e>this.maxEntities&&(this.maxEntities=e)}toString(){return`${this.numEntities.toLocaleString()} of ${this.maxEntities.toLocaleString()} peak (capacity ${this.capacity.toLocaleString()})`}}class bjt{constructor(e){W(this,"type");W(this,"worker");W(this,"_lastQueryUpdateDuration",0);W(this,"averageQueryUpdateDuration",0);W(this,"_lastExecutionDuration",0);W(this,"averageExecutionDuration",0);W(this,"_lastCoroutinesDuration",0);W(this,"averageCoroutinesDuration",0);this.type=e}get lastQueryUpdateDuration(){return this._lastQueryUpdateDuration}set lastQueryUpdateDuration(e){this._lastQueryUpdateDuration=e,this.averageQueryUpdateDuration=UK(this.averageQueryUpdateDuration,e)}get lastExecutionDuration(){return this._lastExecutionDuration}set lastExecutionDuration(e){this._lastExecutionDuration=e,this.averageExecutionDuration=UK(this.averageExecutionDuration,e)}get lastCoroutinesDuration(){return this._lastCoroutinesDuration}set lastCoroutinesDuration(e){this._lastCoroutinesDuration=e,this.averageCoroutinesDuration=UK(this.averageCoroutinesDuration,e)}}class wjt{constructor(){W(this,"frames",0);W(this,"_numEntities",0);W(this,"_maxEntities",0);W(this,"_maxLimboComponents",0);W(this,"_maxRefChangesPerFrame",0);W(this,"_maxShapeChangesPerFrame",0);W(this,"_maxWritesPerFrame",0);W(this,"components",Object.create(null));W(this,"systems",Object.create(null))}get maxEntities(){return this._maxEntities}get numEntities(){return this._numEntities}set numEntities(e){this._numEntities=e,e>this._maxEntities&&(this._maxEntities=e)}get maxLimboComponents(){return this._maxLimboComponents}set maxLimboComponents(e){e>this._maxLimboComponents&&(this._maxLimboComponents=e)}get maxRefChangesPerFrame(){return this._maxRefChangesPerFrame}set maxRefChangesPerFrame(e){e>this._maxRefChangesPerFrame&&(this._maxRefChangesPerFrame=e)}get maxShapeChangesPerFrame(){return this._maxShapeChangesPerFrame}set maxShapeChangesPerFrame(e){e>this._maxShapeChangesPerFrame&&(this._maxShapeChangesPerFrame=e)}get maxWritesPerFrame(){return this._maxWritesPerFrame}set maxWritesPerFrame(e){e>this._maxWritesPerFrame&&(this._maxWritesPerFrame=e)}forComponent(e){const r=this.components[e.name]??new _jt(e);return e.__internal||(this.components[e.name]=r),r}forSystem(e){const r=this.systems[e.name]??new bjt(e);return e.__internal||(this.systems[e.name]=r),r}toString(){return`World stats: 6860 frames: ${this.frames.toLocaleString()} 6861 entities: ${this.numEntities.toLocaleString()} of ${this.maxEntities.toLocaleString()} max 6862 refs: ${this.maxRefChangesPerFrame.toLocaleString()} ref changes/frame max 6863 logs: ${this.maxShapeChangesPerFrame.toLocaleString()} shape changes/frame max, ${this.maxWritesPerFrame.toLocaleString()} writes/frame max 6864 components: (${this.maxLimboComponents.toLocaleString()} limbo max) 6865`+Object.keys(this.components).map(e=>{const r=this.components[e];return` ${e}: ${r.numEntities} (max ${r.maxEntities})`}).join(` 6866`)}}var kf;(function(t){t[t.REFERENCE=0]="REFERENCE",t[t.UNREFERENCE=1073741824]="UNREFERENCE",t[t.RELEASE=2147483648]="RELEASE",t[t.UNREFERENCE_AND_RELEASE=-1073741824]="UNREFERENCE_AND_RELEASE"})(kf||(kf={}));const Ejt=kf.UNREFERENCE_AND_RELEASE;class Cdt{constructor(e,r,i,s){W(this,"targetEntityId");W(this,"selector");W(this,"trackStale");W(this,"dispatcher");W(this,"entities",[]);W(this,"tags");W(this,"entityIndex");W(this,"clearing",!1);W(this,"registry");var n;this.targetEntityId=e,this.selector=r,this.trackStale=i,this.dispatcher=s;const o=(n=r.sourceType)==null?void 0:n.__binding;r.matchType&&(r.matchSeq&&!o.fields[r.sourceSeq].type.internallyIndexed||o.refFields.length===1&&!o.refFields[0].type.internallyIndexed)||(this.tags=[]),this.registry=s.registry}clearAllRefs(e){if(!this.tags)throw new $e("Unreferencing an untagged tracker");this.clearing=!0;for(let r=0;r<this.entities.length;r++){const i=this.entities[r].__id,s=this.tags[r];if(typeof s=="number")this.clearRef(i,s,e);else for(const o of s)this.clearRef(i,o,e)}
6866this.entities=[],this.tags&&(this.tags=[]),this.entityIndex=void 0,this.clearing=!1}clearRef(e,r,i){const s=r&X8,o=r>>>u2&W8t,n=r>>>u2+OK,a=this.registry.types[s];PK(a,this.registry.executingSystem,"write"),a.__bind(e,!0),a.__binding.fields[o].clearRef(i,this.targetEntityId,n),a.__binding.trackedWrites&&this.registry.trackWrite(e,a)}trackReference(e,r,i,s,o){if(this.clearing)throw new $e("Cannot track a new reference while clearing tracker");o&&this.checkUpdateMask();let n=this.getEntityIndex(e);n===void 0&&(n=this.addEntity(e,o)),this.addTag(n,this.makeTag(r,i,s))}trackUnreference(e,r,i,s,o){if(this.clearing)return;o&&this.checkUpdateMask();const n=this.getEntityIndex(e);if(n===void 0)throw new $e("Entity backref not tracked");this.removeTag(n,this.makeTag(r,i,s))&&this.removeEntity(n,e,o)}getEntityIndex(e){if(this.entityIndex)return this.entityIndex[e];const r=this.entities.findIndex(i=>i.__id===e);if(r>=0)return r}indexEntities(){if(this.entityIndex)throw new $e("Entities already indexed");this.entityIndex=new Array(this.dispatcher.maxEntities);for(let e=0;e<this.entities.length;e++)this.entityIndex[this.entities[e].__id]=e}addTag(e,r){if(!this.tags)return;const i=this.tags[e];if(i===void 0)this.tags[e]=r;else if(typeof i=="number"){if(i===r)throw new $e(`Ref ${r} already tracked (single)`);this.tags[e]=[i,r]}else if(Array.isArray(i)){if(i.includes(r))throw new $e(`Ref ${r} already tracked (array)`);i.length>=1e3?(this.tags[e]=new Set(i)).add(r):i.push(r)}else{if(i.has(r))throw new $e(`Ref ${r} already tracked (set)`);i.add(r)}}removeTag(e,r){if(!this.tags)return!0;const i=this.tags[e];if(i===void 0)throw new $e(`Ref ${r} not tracked (none)`);if(typeof i=="number"){if(i!==r)throw new $e(`Ref ${r} not tracked (single ${i})`);return delete this.tags[e],!0}if(Array.isArray(i)){const s=i.indexOf(r);if(s===-1)throw new $e(`Ref ${r} not tracked (array ${i})`);return i.splice(s,1),!this.tags.length}if(!i.has(r))throw new $e(`Ref ${r} not tracked (set ${new Array(...i)})`);return i.delete(r),!i.size}makeTag(e,r,i){return e|r<<u2|(i===void 0?0:i<<u2+OK)}addEntity(e,r){const i=this.entities.length;return this.entities.push(this.registry.pool.borrow(e)),this.entityIndex?this.entityIndex[e]=i:i>100&&this.indexEntities(),r&&this.trackBackrefsChange(),i}removeEntity(e,r,i){this.registry.pool.return(r);const s=this.entities.pop();if(this.entityIndex&&delete this.entityIndex[r],this.entities.length>e&&(this.entities[e]=s,this.entityIndex&&(this.entityIndex[s.__id]=e)),this.tags){const o=this.tags.pop();this.tags.length>e&&(this.tags[e]=o)}i&&this.trackBackrefsChange()}trackBackrefsChange(){for(const e of this.selector.targetTypes)e.__binding.trackedWrites&&this.registry.trackWrite(this.targetEntityId,e)}checkUpdateMask(){const e=this.registry.executingSystem;for(const r of this.selector.targetTypes)this.registry.hasShape(this.targetEntityId,r,this.trackStale)&&PK(r,e,"update")}}class Ajt{constructor(e,r){W(this,"dispatcher");W(this,"maxRefChangesPerFrame");W(this,"refLog");W(this,"refLogPointer");W(this,"refLogStatsPointer");W(this,"selectorIdsBySourceKey",new Map);W(this,"selectors",[]);W(this,"trackers",new Map);W(this,"registry");this.dispatcher=e,this.maxRefChangesPerFrame=r,this.registry=e.registry}completeCycle(){var e;this.flush(),this.dispatcher.stats.maxRefChangesPerFrame=((e=this.refLog)==null?void 0:e.countSince(this.refLogStatsPointer))??0}registerSelector(e,r,i,s=!1){e&&jx(e),r&&jx(r),this.refLog||(this.refLog=new Y8(this.maxRefChangesPerFrame,"maxRefChangesPerFrame",this.dispatcher.buffers,{localProcessingAllowed:!0}),this.refLogPointer=this.refLog.createPointer(),this.refLogStatsPointer=this.refLog.createPointer());const o=r?i===void 0?-2-r.id:r.id|i<<u2:-1;let n=this.selectorIdsBySourceKey.get(o);if(n===void 0){this.selectors.length||(s=!0);const a={id:this.selectors.length,targetTypes:e?[e]:[],sourceType:r,matchType:!!r,matchSeq:i!==void 0,sourceTypeId:r==null?void 0:r.id,sourceSeq:i,trackStale:s};if(this.selectors.push(a),n=a.id,this.selectorIdsBySourceKey.set(o,n),n>j8)throw new Wt("Too many distinct backrefs selectors")}else{const a=this.selectors[n];a.trackStale=a.trackStale||s,e&&a.targetTypes.push(e)}return n}getBackrefs(e,r=0){const i=this.selectors[r];return this.getOrCreateTracker(i,e,this.registry.includeRecentlyDeleted).entities}trackRefChange(e,r,i,s,o,n,a,l){if(!this.refLog)throw new $e("Trying to trackRefChange without a refLog");
6866if(o===n&&a)throw new $e("No-op call to trackRefChange");if(o!==-1){const c=(a?kf.UNREFERENCE:0)|(l?kf.RELEASE:0);if(!c)throw new $e("Called trackRefChange with neither unreference nor release");this.pushRefLogEntry(e,r,i,s,o,c)}n!==-1&&this.pushRefLogEntry(e,r,i,s,n,kf.REFERENCE)}clearAllRefs(e,r){var i;this.selectors.length&&((i=this.getTracker(this.selectors[0],e,r))==null||i.clearAllRefs(r))}pushRefLogEntry(e,r,i,s,o,n){const a=typeof s<"u";if(a&&!r.__binding.fields[i].type.internallyIndexed)throw new $e("Inconsistent internally indexed flag");this.refLog.push(e|r.id<<Bc),this.refLog.push(o|i<<Bc|n|(a?2**29:0)),a&&this.refLog.push(s),this.processEntry(e,r.id,i,s,o,n,!0)}getOrCreateTracker(e,r,i){let s=this.getTracker(e,r,i);if(s)return s;if(i&&!e.trackStale)throw new $e("Selector not configured for stale tracking");let o;return s=new Cdt(r,e,!1,this.dispatcher),this.trackers.set(r|e.id<<Bc,s),e.trackStale&&(o=new Cdt(r,e,!0,this.dispatcher),this.trackers.set(r|e.id<<Bc|2**31,o)),i?o:s}getTracker(e,r,i){return this.trackers.get(r|e.id<<Bc|(i?2**31:0))}flush(){if(this.refLog)for(;;){const[e,r,i,s]=this.refLog.processAndCommitSince(this.refLogPointer);if(!e)break;if(!s)for(let o=r;o<i;o+=2){const n=e[o],a=e[o+1],l=n&Od,c=n>>>Bc,h=a&Od,u=a>>>Bc&DK-1,d=a&Ejt,f=(a&2**29)!==0,g=f?e[o+2]:void 0;f&&(o+=1),this.processEntry(l,c,u,g,h,d,!1)}}}processEntry(e,r,i,s,o,n,a){for(let l=0;l<this.selectors.length;l++){const c=this.selectors[l];if((!c.matchType||c.sourceTypeId===r)&&(!c.matchSeq||c.sourceSeq===i)){if(n===kf.REFERENCE||n&kf.UNREFERENCE){const h=this.getOrCreateTracker(c,o,!1);n===kf.REFERENCE?h.trackReference(e,r,i,s,a):h.trackUnreference(e,r,i,s,a)}if(c.trackStale&&(n===kf.REFERENCE||n&kf.RELEASE)){const h=this.getOrCreateTracker(c,o,!0);n===kf.REFERENCE?h.trackReference(e,r,i,s,a):h.trackUnreference(e,r,i,s,a)}}}}}class Mdt{constructor(){W(this,"buffer");W(this,"array");W(this,"update")}}const xjt=new Map([[Uint8Array,"u8"],[Int8Array,"i8"],[Uint16Array,"u16"],[Int16Array,"i16"],[Uint32Array,"u32"],[Int32Array,"i32"],[Float32Array,"f32"],[Float64Array,"f64"]]),Sjt=new Map([["u8",Uint8Array],["i8",Int8Array],["u16",Uint16Array],["i16",Int16Array],["u32",Uint32Array],["i32",Int32Array],["f32",Float32Array],["f64",Float64Array]]);class Tjt{constructor(e){W(this,"threaded");W(this,"items",new Map);W(this,"changes");this.threaded=e}register(e,r,i,s,o){const n=r*i.BYTES_PER_ELEMENT;let a=this.items.get(e);const l=!a||a.buffer.byteLength<n,c=l||a.array.constructor!==i;if(!a||l||c){const h=new Mdt;h.buffer=l?this.threaded?new SharedArrayBuffer(n):new ArrayBuffer(n):a.buffer,h.array=new i(h.buffer),a?(h.array.set(a.array),o!==void 0&&h.array.length>a.array.length&&h.array.fill(o,a.array.length)):o!==void 0&&h.array.fill(o),a=h,this.items.set(e,a),this.threaded&&(this.changes||(this.changes=new Map),this.changes.set(e,{buffer:a.buffer,arrayKind:xjt.get(i)})),s==null||s(a.array)}return a.update=s,a.array}makePatch(){if(!this.changes)return;const e=this.changes;return this.changes=void 0,e}applyPatch(e){var r,i;for(const[s,o]of e.entries()){const n=new Mdt;n.update=(r=this.items.get(s))==null?void 0:r.update,n.buffer=o.buffer;const a=Sjt.get(o.arrayKind);n.array=new a(n.buffer),this.items.set(s,n),(i=n.update)==null||i.call(n,n.array)}}}function Tg(t,e,r){e.constructor.schema||(e.constructor.schema={}),e.constructor.schema[r]=t}function P(t){return function(e,r){const i="type"in t?t:{type:t};Tg(i,e,r)}}function sw(t){const e=Tg.bind(null,{type:t});return e.vector=(r,i)=>(s,o)=>{Tg({type:$.vector(t,r,i)},s,o)},e}function Rjt(...t){if(typeof t[0]=="function"||t[0]===void 0)return Tg.bind(null,{type:$.backrefs(...t)});Tg({type:$.backrefs},t[0],t[1])}P.boolean=Tg.bind(null,{type:$.boolean}),P.uint8=sw($.uint8),P.int8=sw($.int8),P.uint16=sw($.uint16),P.int16=sw($.int16),P.uint32=sw($.uint32),P.int32=sw($.int32),P.float32=sw($.float32),P.float64=sw($.float64),P.staticString=function(t){return Tg.bind(null,{type:$.staticString(t)})},P.dynamicString=function(t){return Tg.bind(null,{type:$.dynamicString(t)})},P.ref=Tg.bind(null,{type:$.ref}),P.backrefs=Rjt,P.object=Tg.bind(null,{type:$.object}),P.weakObject=Tg.bind(null,{type:$.weakObject});const H8=[];
6866te=function(t,e){if(typeof t=="function")H8.push(t);else return t instanceof $8?r=>{t.__types.includes(r)||t.__types.push(r),H8.push(t),e&&(r.options=e)}:r=>{r.options=t,H8.push(r)}};const BL=[];Ve=function(t,e){if(typeof t=="function"&&!t.__system&&(e=t,t=void 0),typeof t=="function")BL.push(t);else return t&&!BL.includes(t)&&BL.push(t),r=>{t&&t.__contents.push(r),e&&(r.__staticScheduler=e),BL.push(r)}};class K8{constructor(e){W(this,"vertices");W(this,"numVertices");W(this,"edges");W(this,"paths");W(this,"vertexIndexMap",new Map);W(this,"sealed",!1);W(this,"sortedVertices");W(this,"dependencyCounts");W(this,"traversalCounts");W(this,"numTraversedVertices");this.vertices=e,this.numVertices=e.length;for(let r=0;r<e.length;r++)this.vertexIndexMap.set(e[r],r);this.edges=new Array(this.numVertices**2).fill(0),this.dependencyCounts=new Array(this.numVertices),this.traversalCounts=new Array(this.numVertices)}get topologicallySortedVertices(){if(!this.sealed)throw new $e("Graph not yet sealed");return this.sortedVertices||(this.sortedVertices=this.sortTopologically()),this.sortedVertices}getEdgeIndex(e,r){const i=this.vertexIndexMap.get(e),s=this.vertexIndexMap.get(r);if(i===void 0)throw new $e(`Unknown vertex: ${e}`);if(s===void 0)throw new $e(`Unknown vertex: ${r}`);return i*this.numVertices+s}setEdge(e,r,i){if(this.sealed)throw new $e("Graph already sealed");if(e===r)return;const s=this.getEdgeIndex(e,r),o=this.getEdgeIndex(r,e),n=Math.abs(i);n<Math.abs(this.edges[s])||n<Math.abs(this.edges[o])||(this.edges[s]=i,n>Math.abs(this.edges[o])&&(this.edges[o]=0))}addEdge(e,r,i){if(i<=0)throw new $e(`Edge has non-positive weight: ${i}`);this.setEdge(e,r,i)}denyEdge(e,r,i){if(i<=0)throw new $e(`Edge has non-positive weight: ${i}`);this.setEdge(e,r,-i)}hasEdge(e,r){return this.edges[this.getEdgeIndex(e,r)]>0}hasPath(e,r){if(!this.sealed)throw new $e("Graph not yet sealed");return this.paths[this.getEdgeIndex(e,r)]>0}hasEdgeBetweenIds(e,r){if(e>
6866this.numVertices)throw new $e(`Vertex id out of range: ${e} > ${this.numVertices}`);if(r>this.numVertices)throw new $e(`Vertex id out of range: ${r} > ${this.numVertices}`);return this.edges[e*this.numVertices+r]>0}seal(){if(this.sealed)throw new $e("Graph already sealed");this.sealed=!0,this.derivePaths(),this.checkForCycles(),this.simplify(),this.countDependencies()}checkForCycles(){const e=this.findCycles();if(e.length)throw e.sort((r,i)=>r.length-i.length),new Wt("Precedence cycles detected for the following systems, please resolve by adjusting their schedules: "+e.map(r=>r.map(i=>i.toString()).join("\u2014")).join(", "))}findCycles(){const e=new Array(this.numVertices).fill(!1),r=[],i=[],s=[];let o,n;for(let c=0;c<this.numVertices;c++)r[c]=new Set;const a=c=>{e[c]=!1;for(const h of r[c])r[c].delete(h),e[h]&&a(h)},l=c=>{let h=!1;i.push(c),e[c]=!0;for(let u=0;u<this.numVertices;u++)!n.has(u)||!this.hasEdgeBetweenIds(c,u)||(u===o?(s.push(i.map(d=>this.vertices[d])),h=!0):!e[u]&&l(u)&&(h=!0));if(h)a(c);else for(let u=0;u<this.numVertices;u++)!n.has(u)||!this.hasEdgeBetweenIds(c,u)||r[u].add(c);return i.pop(),h};for(o=0;o<this.numVertices;o++){const c=this.findLeastStronglyConnectedComponent(o);o=c[0];for(const h of c)e[h]=!1,r[h].clear();n=new Set(c),l(o)}return s}findLeastStronglyConnectedComponent(e){let r;const i=[],s=[],o=[],n=[];let a=0;const l=c=>{i[c]=++a,s.push(c),o.push(c);for(let h=e;h<this.numVertices;h++)if(this.hasEdgeBetweenIds(c,h))if(i[h]){if(!n[h])for(;o.length&&i[o[o.length-1]]>i[h];)o.pop()}else l(h);if(o[o.length-1]===c){const h=[];for(;;){const u=s.pop();if(h.push(u),n[u]=!0,u===c)break}o.pop(),h.sort((u,d)=>u-d),(!r||h[0]<r[0])&&(r=h)}};for(let c=e;c<this.numVertices;c++)i[c]||l(c);return r}induceSubgraph(e){const r=new K8(e);for(const i of e){if(!this.vertexIndexMap.has(i))throw new $e(`Vertex not in graph: ${i}`);for(const s of e){const o=this.getEdgeIndex(i,s),n=this.edges[o];n>0?r.addEdge(i,s,n):n<0&&r.denyEdge(i,s,-n)}}return this.sealed&&r.seal(),r}sortTopologically(){const e=new Array(this.numVertices).fill(0);for(let s=0;s<this.numVertices;s++)for(let o=0;o<this.numVertices;o++)this.hasEdgeBetweenIds(s,o)&&(e[o]+=1);const r=[];let i;for(;r.length<this.numVertices;){i=!1;for(let s=0;s<e.length;s++)if(e[s]===0){i=!0,e[s]=-1,r.push(this.vertices[s]);for(let o=0;o<this.numVertices;o++)this.hasEdgeBetweenIds(s,o)&&(e[o]-=1)}if(!i)throw new $e("Graph has a cycle, topological sort not possible")}return r}derivePaths(){const e=this.numVertices;for(let i=0;i<this.edges.length;i++)this.edges[i]<0&&(this.edges[i]=0);const r=this.edges.slice();for(let i=0;i<e;i++)for(let s=0;s<e;s++)if(i!==s)for(let o=0;o<e;o++){if(o===i||o===s)continue;const n=r[i*e+o],a=r[o*e+s];if(n&&a){const l=Math.min(n,a);r[i*e+s]<l&&r[s*e+i]<l&&(r[i*e+s]=l,r[s*e+i]=0)}}this.paths=r;for(let i=0;i<e;i++)for(let s=0;s<e;s++)this.edges[i*e+s]&&(this.edges[i*e+s]=r[i*e+s])}simplify(){const e=this.numVertices,r=this.paths.slice();for(let i=0;i<e;i++)for(let s=0;s<e;s++)if(r[s*e+i])for(let o=0;o<e;o++)r[i*e+o]&&(r[s*e+o]=0);this.edges=r}countDependencies(){for(let e=0;e<this.numVertices;e++){let r=0;for(let i=0;i<this.numVertices;i++)this.edges[i*this.numVertices+e]&&(r+=1);this.dependencyCounts[e]=r}}traverse(e){if(!this.sealed)throw new $e("Graph not yet sealed");const r=[];if(e){this.numTraversedVertices+=1;const i=this.vertexIndexMap.get(e);if(i===void 0)throw new $e(`Unknown vertex: ${e}`);for(let s=0;s<this.numVertices;s++)this.edges[i*this.numVertices+s]&&--this.traversalCounts[s]===0&&r.push(this.vertices[s])}else{this.numTraversedVertices=0;for(let i=0;i<this.numVertices;i++)(this.traversalCounts[i]=this.dependencyCounts[i])===0&&r.push(this.vertices[i])}if(this.numTraversedVertices!==this.numVertices)return r}printMatrix(e){const r=this.numVertices,i=[];for(let s=0;s<r;s++){const o=[];for(let n=0;n<r;n++)o.push(e[s*r+n]);i.push(o.join(" "))}return i.join(` 6867`)}static fromMatrix(e){typeof e=="string"&&(e=e.trim().split(/\s+/).map(o=>parseInt(o,10)));const r=Math.sqrt(e.length),i=[];for(let o=1;o<=r;o++)i.push(`v${o}`);const s=new K8(i);return s.edges=e,s}}class Bdt{constructor(e,r){W(this,"planner");W(this,"group");W(this,"graph");this.planner=e,this.group=r,this.graph=e.graph.induceSubgraph(r.__systems)}}class Cjt extends Bdt{constructor(r,i){super(r,i);W(this,"planner");W(this,"group");W(this,"systems");if(this.planner=r,this.group=i,this.systems=this.graph.topologicallySortedVertices,this.systems.length>1&&typeof process>"u"){console.log("System execution order:");for(const s of this.systems)console.log(" ",s.name)}}
6867execute(r,i){const s=this.planner.dispatcher,o=this.systems;this.group.__executed=!0;for(let n=0;n<o.length;n++)o[n].execute(r,i),s.flush();return Promise.resolve()}async initialize(){const r=this.planner.dispatcher;return this.group.__executed=!0,new Promise((i,s)=>{let o=!1;const n=async l=>{try{if(await l.prepare(),o)return;l.initialize(),r.flush();const c=this.graph.traverse(l);if(!c)return i();for(let h=0;h<c.length;h++)n(c[h])}catch(c){o=!0,s(c)}},a=this.graph.traverse();if(!a)return i();for(let l=0;l<a.length;l++)n(a[l])})}async finalize(){const r=this.planner.dispatcher;return this.group.__executed=!0,new Promise((i,s)=>{const o=a=>{try{a.finalize(),r.flush();const l=this.graph.traverse(a);if(!l)return i();for(let c=0;c<l.length;c++)o(l[c])}catch(l){s(l)}},n=this.graph.traverse();if(!n)return i();for(let a=0;a<n.length;a++)o(n[a])})}}class Mjt extends Bdt{execute(e,r){return Promise.resolve()}initialize(){return Promise.resolve()}finalize(){return Promise.resolve()}}class Odt{constructor(e){W(this,"id");W(this,"systems",[]);this.id=e}add(...e){for(const r of e)r.lane=this;this.systems.push(...e)}merge(e){return this===e?this:this.id===-1||e.id!==-1&&e.id<this.id?e.merge(this):(this.add(...e.systems),e.systems.length=0,this)}}class Bjt{constructor(e,r,i){W(this,"dispatcher");W(this,"systems");W(this,"groups");W(this,"graph");W(this,"readers",new Map);W(this,"writers",new Map);W(this,"lanes",[]);W(this,"replicatedLane");W(this,"laneCount",0);this.dispatcher=e,this.systems=r,this.groups=i,this.graph=new K8(r);for(const s of e.registry.types)this.readers.set(s,new Set),this.writers.set(s,new Set);e.threaded&&(this.createLane(),this.replicatedLane=new Odt(-1))}get mainLane(){return this.lanes[0]}createLane(){const e=new Odt(this.laneCount++);return this.lanes.push(e),e}organize(){var e;for(const r of this.groups)r.__collectSystems(this.dispatcher);for(const r of this.systems)r.buildQueries();for(const r of this.systems)r.buildSchedule();for(const r of this.groups)r.__buildSchedule();this.addComponentEntitlementDependencies(),this.graph.seal(),this.dispatcher.threaded&&this.assignSystemsToLanes();for(const r of this.systems)r.stats.worker=((e=r.lane)==null?void 0:e.id)??0;delete this.readers,delete this.writers;for(const r of this.groups)r.__plan=this.dispatcher.threaded?new Mjt(this,r):new Cjt(this,r)}addComponentEntitlementDependencies(){for(const[e,r]of this.readers.entries())for(const i of r)for(const s of this.writers.get(e))this.graph.addEdge(s,i,1)}assignSystemsToLanes(){this.initSystemLanes(),this.mergeAccessorsOfUnsharedComponentTypes(),this.mergeAttachedSystems(),this.pruneEmptyLanes(),this.reduceLanes(this.dispatcher.threads+1),this.pruneEmptyLanes()}initSystemLanes(){for(const e of this.systems)e.lane||this.createLane().add(e)}mergeAccessorsOfUnsharedComponentTypes(){var e;for(const r of this.dispatcher.registry.types){if(r.__binding.fields.every(n=>n.type.shared))continue;const i=this.readers.get(r),s=this.writers.get(r);if(!i&&!s)continue;let o=(e=r.options)!=null&&e.restrictedToMainThread?this.mainLane:this.createLane();i==null||i.forEach(n=>{o=o.merge(n.lane)}),s==null||s.forEach(n=>{o=o.merge(n.lane)})}}mergeAttachedSystems(){for(const e of this.systems)for(const r of e.attachedSystems)r&&e.lane.merge(r.lane)}reduceLanes(e){if(this.lanes.length<=e)return;let r=[];for(let s=1;s<this.lanes.length-1;s++){const o=this.lanes[s];for(let n=s+1;n<this.lanes.length;n++){const a=this.lanes[n];r.push({laneA:o,laneB:a,independence:this.computeIndependence(o,a)})}}let i=this.lanes.length;for(;i>e;){r.sort((a,l)=>l.independence-a.independence);const s=r.pop(),o=s.laneA.merge(s.laneB),n=o===s.laneA?s.laneB:s.laneA;i-=1,i>e&&(r=r.filter(a=>a.laneA===n||a.laneB===n?!1:((a.laneA===o||a.laneB===o)&&(a.independence=this.computeIndependence(a.laneA,a.laneB)),!0)))}}computeIndependence(e,r){return Math.min(this.computeIndependentWeight(e,r),this.computeIndependentWeight(r,e))}computeIndependentWeight(e,r){let i=0;for(const s of e.systems){let o=0;for(const n of r.systems)!this.graph.hasPath(s,n)&&!this.graph.hasPath(n,s)&&(o+=n.weight);i+=Math.min(s.weight,o)}return i}pruneEmptyLanes(){this.lanes=this.lanes.filter(e=>e.id===0||e.systems.length);for(let e=1;e<this.lanes.length;e++)this.lanes[e].id=e}}class q8 extends We{constructor(){super(...arguments);W(this,"__callback")}start(r,...i){throw new Wt("The build system cannot run coroutines")}execute(){this.__callback(this)}}W(q8,"__internal",!0);class GK extends We{}W(GK,"__internal",!0);var Oc;(function(t){t[t.init=0]="init",t[t.setup=1]="setup",t[t.run=2]="run",t[t.finish=3]="finish",t[t.done=4]="done"})(Oc||(Oc={}));class Ojt{constructor({defs:e,threads:r=1,maxEntities:i=1e4,maxLimboComponents:s=Math.ceil(i/5),maxShapeChangesPerFrame:o=i*2,maxWritesPerFrame:n=i*4,maxRefChangesPerFrame:a=i,defaultComponentStorage:l="packed"}){W(this,"maxEntities");W(this,"defaultComponentStorage");W(this,"registry");W(this,"systems");W(this,"systemsByClass",new Map);W(this,"systemGroups");W(this,"default");W(this,"lastTime");W(this,"executing");W(this,"executingSyncFrame");W(this,"state",Oc.init);W(this,"shapeLog");W(this,"writeLog");W(this,"shapeLogFramePointer");W(this,"writeLogFramePointer");W(this,"stats");W(this,"indexer");W(this,"planner");W(this,"threads");W(this,"buffers");W(this,"singleton");W(this,"buildSystem");W(this,"deferredControls",new Map);if(r<1)throw new Wt("Minimum of one thread");if(r>1)throw new Wt("Multithreading not yet implemented");if(i>IK)throw new Wt(`maxEntities too high, the limit is ${IK}`);const{componentTypes:c,componentEnums:h,systemTypes:u,systemGroups:d}=this.splitDefs([e??[],H8,BL]);if(c.length>j8)throw new Wt(`Too many component types, the limit is ${j8}`);this.stats=new wjt,this.threads=r,this.buffers=new Tjt(r>1),this.maxEntities=i,this.defaultComponentStorage=l,this.registry=new vjt(i,s,c,h,this),this.indexer=new Ajt(this,a),this.shapeLog=new Y8(o,"maxShapeChangesPerFrame",this.buffers,{sortedByComponentType:!0,numComponentTypes:this.registry.types.length}),this.shapeLogFramePointer=this.shapeLog.createPointer(),this.systemGroups=d,this.systems=this.createSystems(u),this.createBuildSystem(
6867),this.registry.initializeComponentTypes(),this.registry.validateSystem=this.createValidateSystem(c),this.singleton=this.createSingletons();for(const f of this.systems)f.replacePlaceholders();this.planner=new Bjt(this,this.systems,this.systemGroups),this.planner.organize(),this.registry.hasNegativeQueries=this.systems.some(f=>f.hasNegativeQueries),this.systems.some(f=>f.hasWriteQueries)&&(this.writeLog=new Y8(n,"maxWritesPerFrame",this.buffers,{sortedByComponentType:!0,numComponentTypes:this.registry.types.length}),this.writeLogFramePointer=this.writeLog.createPointer());for(const f of this.systems)f.finishConstructing();this.state=Oc.setup}get threaded(){return this.threads>1}get defaultGroup(){return this.default.group}createSystems(e){const r=[],i=[],s=new Set;let o=0;for(let n=0;n<e.length;n++){const a=e[n];let l=this.systemsByClass.get(a);if(!l){if(a.name||Object.defineProperty(a,"name",{value:`Anonymous_${o++}`}),!a.__internal){if(s.has(a.name))throw new Wt(`Multiple component types named ${a.name}; names must be unique`);s.add(a.name)}this.stats.forSystem(a),i.push(a);const h=new a;h.id=n+2,l=new LK(h,this),r.push(l),this.systemsByClass.set(a,l)}const c=e[n+1];c&&typeof c!="function"&&(l.assignProps(c),n++)}return this.default=this.createSingleGroupFrame(i),r}createBuildSystem(){this.buildSystem=new q8,this.buildSystem.id=0;const e=new LK(this.buildSystem,this);e.accessMasks.read=void 0,e.accessMasks.update=void 0,e.accessMasks.create=void 0,e.accessMasks.write=void 0,e.accessMasks.check=void 0,this.systems.push(e),this.systemsByClass.set(q8,e)}createValidateSystem(e){const r=new GK;r.id=1;const i=new LK(r,this);for(const s of e)V8(i.accessMasks.check,s);return this.systems.push(i),this.systemsByClass.set(GK,i),i}createSingleGroupFrame(e){const r=new p2(e);this.systemGroups.push(r);const i=new xdt(this,[r]);return{group:r,frame:i}}createSingletons(){const e=new Set,r=this.systems.flatMap(s=>s.singletonComponentDefs.filter((o,n)=>{let a=!0;return typeof o=="function"&&(a=n<s.singletonComponentDefs.length-1&&typeof s.singletonComponentDefs[n+1]!="function",a&&e.add(o)),a})).concat(this.systems.flatMap(s=>s.singletonComponentDefs.filter(o=>typeof o=="function"&&!e.has(o)?(e.add(o),!0):!1)));if(!r.length)return;this.executing=!0;const i=this.createEntity(r).hold();return this.executing=!1,this.flush(),i}splitDefs(e){const r=[],i=new Set,s=new Set,o=[],n=[];let a=!1;for(const c of e.flat(1/0))if(c instanceof p2){n.push(c);const{componentTypes:h,systemTypes:u,systemGroups:d}=this.splitDefs(c.__contents);for(const f of h)l(f);o.push(...u),n.push(...d)}else if(typeof c=="function")a=!!c.__system,a?o.push(c):l(c);else if(c instanceof $8){s.add(c);for(const h of c.__types)l(h)}else{if(!a)throw new Wt("Unexpected value in world defs: "+c);o.push(c),a=!1}return{componentTypes:r,componentEnums:Array.from(s),systemTypes:o,systemGroups:n};function l(c){if(c.enum&&!s.has(c.enum)){s.add(c.enum);for(const h of c.enum.__types)l(h)}else i.has(c)||(r.push(c),i.add(c))}}getSystems(e){if(e instanceof p2)return e.__systems;const r=this.systemsByClass.get(e);if(!r)throw new Wt(`System ${e.name} not registered in world`);return[r]}async initialize(){await this.default.frame.begin(),this.state=Oc.setup,await this.default.group.__plan.initialize(),await this.default.frame.end(),this.stats.frames-=1}async finalize(){await this.default.frame.begin(),this.state=Oc.done,await this.default.group.__plan.finalize(),await this.default.frame.end(),this.stats.frames-=1,this.registry.releaseComponentTypes()}async execute(e,r){await this.default.frame.begin(),await this.default.frame.execute(this.default.group,e,r),await this.default.frame.end()}executeFunction(e){this.startFrame(this.lastTime),this.executingSyncFrame=!0,this.buildSystem.__callback=e,this.systemsByClass.get(q8).execute(this.lastTime,0),this.flush(),this.completeCycle(),this.completeFrame(),this.executingSyncFrame=!1,this.stats.frames-=1}completeCycle(){var e;this.registry.completeCycle(),this.indexer.completeCycle(),(e=this.writeLog)==null||e.commit()}startFrame(e){if(this.executing)throw new Wt("Another frame already executing");if(this.executing=!0,this.state!==Oc.setup&&this.state!==Oc.run&&this.state!==Oc.finish)throw new Wt("World terminated");this.state=Oc.run,this.lastTime=e}completeFrame(){if(!this.executing)throw new $e("No frame executing");return this.executing=!1,this.gatherFrameStats(),this.processDeferredControls(),this.state===Oc.finish?this.finalize():Promise.resolve()}gatherFrameStats(){var e;this.stats.frames+=1,this.stats.maxShapeChangesPerFrame=this.shapeLog.countSince(this.shapeLogFramePointer),this.stats.maxWritesPerFrame=((e=this.writeLog)==null?void 0:e.countSince(this.writeLogFramePointer))??0}flush(){var e;this.indexer.flush(),this.registry.flush(),this.shapeLog.commit(),(e=this.writeLog)==null||e.commit()}async terminate(){{if(this.state!==Oc.setup&&this.state!==Oc.run)throw new Wt("World terminated");if(this.executingSyncFrame)throw new Wt("Cannot terminate world from within build callback")}this.state=Oc.finish,this.executing||await this.finalize()}createEntity(e){const r=this.registry.createEntity(e);return this.executing||this.flush(),r}control(e){this.checkControlOverlap(e),this.deferRequestedRunState(e.stop,Nf.STOPPED),this.deferRequestedRunState(e.restart,Nf.RUNNING),this.executing||this.processDeferredControls()}deferRequestedRunState(e,r){for(const i of this.splitDefs(e).systemTypes){if(!i.__system)continue;const s=this.systemsByClass.get(i);if(!s)throw new Wt(`System ${i.name} not defined for this world`);this.deferredControls.set(s,r)}}checkControlOverlap(e){const r=new Set;for(const i of this.splitDefs(e.stop).systemTypes)i.__system&&r.add(i);for(const i of this.splitDefs(e.restart).systemTypes)if(i.__system&&r.has(i))throw new Wt(`Request to both stop and restart system ${i.name}`)}
6867processDeferredControls(){if(this.deferredControls.size){for(const[e,r]of this.deferredControls.entries())switch(r){case Nf.STOPPED:e.stop();break;case Nf.RUNNING:e.restart();break}this.deferredControls.clear()}}}const Idt={};class Z8{constructor(e,r){W(this,"__dispatcher");if(r!==Idt)throw new Wt("Don't call World constructor directly; use World.create instead");this.__dispatcher=new Ojt(e)}static async create(e={}){const r=new Z8(e,Idt);return await r.__dispatcher.initialize(),r}static defineEnum(e,...r){return typeof e=="function"&&(r.unshift(e),e=""),e=e||"<anonymous>",new $8(e,r)}build(e){if(this.__dispatcher.state!==Oc.setup&&(typeof process>"u"||!0))throw new Wt("This method cannot be called after the world has started executing");this.__dispatcher.executeFunction(e)}createEntity(...e){if(this.__dispatcher.state!==Oc.setup&&(typeof process>"u"||!0))throw new Wt("This method cannot be called after the world has started executing");this.__dispatcher.createEntity(e)}execute(e,r){return this.__dispatcher.execute(e,r)}control(e){this.__dispatcher.control(e)}createCustomExecutor(...e){return new xdt(this.__dispatcher,e)}async terminate(){await this.__dispatcher.terminate()}get stats(){return this.__dispatcher.stats}get alive(){return this.__dispatcher.state!==Oc.done}}class OL{}var Ijt=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};jt=class{constructor(t){Object.assign(this,t)}},Ijt([P.ref],jt.prototype,"canvas",void 0);class Ri{static splat(e){return new Ri(e,e,e)}static from_array(e){return new Ri(e[0],e[1],e[2])}static copy(e){return new Ri(e.x,e.y,e.z)}constructor(e,r,i){this.x=e??0,this.y=r??0,this.z=i??0}xxx(){return new Ri(this.x,this.x,this.x)}yyy(){return new Ri(this.y,this.y,this.y)}zzz(){return new Ri(this.z,this.z,this.z)}add(e){return typeof e=="number"?new Ri(this.x+e,this.y+e,this.z+e):new Ri(this.x+e.x,this.y+e.y,this.z+e.z)}mul(e){return typeof e=="number"?new Ri(this.x*e,this.y*e,this.z*e):new Ri(this.x*e.x,this.y*e.y,this.z*e.z)}}Ri.ZERO=Ri.splat(0),Ri.ONE=Ri.splat(1),Ri.MAX=Ri.splat(Number.MAX_VALUE),Ri.MIN=Ri.splat(Number.MIN_VALUE),Ri.NEG_Z=new Ri(0,0,-1),Ri.X=new Ri(1,0,0),Ri.Y=new Ri(0,1,0),Ri.Z=new Ri(0,0,1);const Djt=$.vector($.float32,["x","y","z"],Ri);class tl{static splat(e){return new tl(e,e)}constructor(e,r){this.x=e??0,this.y=r??0}}tl.ZERO=tl.splat(0),tl.ONE=tl.splat(1),tl.X=new tl(1,0),tl.Y=new tl(0,1);const WK=$.vector($.float32,["x","y"],tl);class ie{get x_axis(){return new Ri(this.m00,this.m01,this.m02)}get y_axis(){return new Ri(this.m10,this.m11,this.m12)}get z_axis(){return new Ri(this.m20,this.m21,this.m22)}static fromTransform(e){return ie.from_scale_angle_translation(new tl(e.scale.x,e.scale.y),e.rotation,new tl(e.translation.x,e.translation.y))}static fromGLMat3(e){return new ie(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])}static toGLMat3(e){return SOt(e.m00,e.m01,e.m02,e.m10,e.m11,e.m12,e.m20,e.m21,e.m22)}static copy(e){const{m00:r,m01:i,m02:s,m10:o,m11:n,m12:a,m20:l,m21:c,m22:h}=e;return new ie(r,i,s,o,n,a,l,c,h)}static from_cols(e,r,i){return new ie(e.x,e.y,e.z,r.x,r.y,r.z,i.x,i.y,i.z)}static from_scale_angle_translation(e,r,i){const s=Math.sin(r),o=Math.cos(r);return ie.from_cols(new Ri(e.x*o,e.x*s,0),new Ri(-e.y*s,e.y*o,0),new Ri(i.x,i.y,1))}constructor(e,r,i,s,o,n,a,l,c){this.m00=e,this.m01=r,this.m02=i,this.m10=s,this.m11=o,this.m12=n,this.m20=a,this.m21=l,this.m22=c}mul_vec3(e){let r=this.x_axis.mul(e.xxx());return r=r.add(this.y_axis.mul(e.yyy())),r=r.add(this.z_axis.mul(e.zzz())),r}mul_mat3(e){return ie.from_cols(this.mul_vec3(e.x_axis),this.mul_vec3(e.y_axis),this.mul_vec3(e.z_axis))}}ie.ZERO=ie.from_cols(Ri.ZERO,Ri.ZERO,Ri.ZERO),ie.IDENTITY=ie.from_cols(Ri.X,Ri.Y,Ri.Z);const Xx=$.vector($.float32,["m00","m01","m02","m10","m11","m12","m20","m21","m22"],ie);var ow=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
6867a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Pe=class{},ow([P({type:$.float32,default:0})],Pe.prototype,"x",void 0),ow([P({type:$.float32,default:0})],Pe.prototype,"y",void 0),ow([P({type:$.float32,default:0})],Pe.prototype,"rotation",void 0),ow([P({type:$.float32,default:1})],Pe.prototype,"zoom",void 0),ow([P({type:Xx,default:ie.IDENTITY})],Pe.prototype,"projectionMatrix",void 0),ow([P({type:Xx,default:ie.IDENTITY})],Pe.prototype,"viewMatrix",void 0),ow([P({type:Xx,default:ie.IDENTITY})],Pe.prototype,"viewProjectionMatrix",void 0),ow([P({type:Xx,default:ie.IDENTITY})],Pe.prototype,"viewProjectionMatrixInv",void 0);var Rg=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};so=class{},Rg([P({type:$.object,default:Bt()})],so.prototype,"startInvertViewProjectionMatrix",void 0),Rg([P({type:$.float32,default:0})],so.prototype,"startCameraX",void 0),Rg([P({type:$.float32,default:0})],so.prototype,"startCameraY",void 0),Rg([P({type:$.float32,default:0})],so.prototype,"startCameraRotation",void 0),Rg([P({type:$.object,default:it()})],so.prototype,"startPos",void 0),Rg([P({type:$.object,default:it()})],so.prototype,"startMousePos",void 0),Rg([P({type:$.boolean,default:!1})],so.prototype,"rotate",void 0),Rg([P.float32],so.prototype,"pointerDownViewportX",void 0),Rg([P.float32],so.prototype,"pointerDownViewportY",void 0),Rg([P.float32],so.prototype,"pointerDownCanvasX",void 0),Rg([P.float32],so.prototype,"pointerDownCanvasY",void 0);var Pjt=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};dl=class{},Pjt([P.object],dl.prototype,"value",void 0);var Vo=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};le=class{},Vo([P.int32.vector(2)],le.prototype,"pointerClient",void 0),Vo([P.int32.vector(2)],le.prototype,"pointerViewport",void 0),Vo([P.boolean],le.prototype,"pointerDownTrigger",void 0),Vo([P.boolean],le.prototype,"pointerUpTrigger",void 0),Vo([P.boolean],le.prototype,"pointerCancelled",void 0),Vo([P.int32.vector(2)],le.prototype,"pointerDownViewport",void 0),Vo([P.boolean],le.prototype,"pointerInside",void 0),Vo([P.int32],le.prototype,"pointerButton",void 0),Vo([P({type:$.staticString(["mouse","touch","pen"]),default:"mouse"})],le.prototype,"pointerType",void 0),Vo([P.boolean],le.prototype,"doubleClickTrigger",void 0),Vo([P.float32],le.prototype,"lastPointerDownTime",void 0),Vo([P.object],le.prototype,"key",void 0),Vo([P.boolean],le.prototype,"keyShiftKey",void 0),Vo([P.boolean],le.prototype,"ctrlKey",void 0),Vo([P.boolean],le.prototype,"shiftKey",void 0),Vo([P.boolean],le.prototype,"altKey",void 0),Vo([P.boolean],le.prototype,"metaKey",void 0),Vo([P.boolean],le.prototype,"wheelTrigger",void 0),Vo([P.float32],le.prototype,"deltaX",void 0),Vo([P.float32],le.prototype,"deltaY",void 0),Vo([P.float32],le.prototype,"touchPanDeltaX",void 0),Vo([P.float32],le.prototype,"touchPanDeltaY",void 0),Vo([P.float32],le.prototype,"pressure",void 0),Vo([P.object],le.prototype,"event",void 0),xa=class{},Vo([P.int32.vector(2)],xa.prototype,"prevPoint",void 0),Vo([P.ref],xa.prototype,"canvas",void 0);var jK=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
6867a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Xy=class{constructor(t){Object.assign(this,t)}},jK([P.ref],Xy.prototype,"canvas",void 0),jK([P({type:$.staticString(["bitmap"]),default:"bitmap"})],Xy.prototype,"type",void 0),jK([P.object],Xy.prototype,"bitmapFont",void 0);let Id;Id=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},(function(t){t.SELECT="select",t.HAND="hand",t.DRAW_POINT="draw-point",t.DRAW_RECT="draw-rect",t.DRAW_TRIANGLE="draw-triangle",t.DRAW_PENTAGON="draw-pentagon",t.DRAW_HEXAGON="draw-hexagon",t.DRAW_ELLIPSE="draw-ellipse",t.DRAW_LINE="draw-line",t.DRAW_ARROW="draw-arrow",t.DRAW_ROUGH_RECT="draw-rough-rect",t.DRAW_ROUGH_ELLIPSE="draw-rough-ellipse",t.DRAW_ROUGH_LINE="draw-rough-line",t.DRAW_ICONFONT="draw-iconfont",t.IMAGE="image",t.TEXT="text",t.PENCIL="pencil",t.BRUSH="brush",t.VECTOR_NETWORK="vector-network",t.COMMENT="comment",t.ERASER="eraser",t.LASSO="lasso",t.LASER_POINTER="laser-pointer"})(vt||(vt={})),(function(t){t.MOVE="move",t.BEND="bend",t.CUT="cut",t.FILL="fill"})(So||(So={})),wt=class{constructor(t){Object.assign(this,t)}},Id([P.object],wt.prototype,"element",void 0),Id([P.object],wt.prototype,"htmlLayer",void 0),Id([P.object],wt.prototype,"svgLayer",void 0),Id([P({type:$.float32,default:0})],wt.prototype,"width",void 0),Id([P({type:$.float32,default:0})],wt.prototype,"height",void 0),Id([P({type:$.staticString(["webgl","webgpu"]),default:"webgl"})],wt.prototype,"renderer",void 0),Id([P.object],wt.prototype,"shaderCompilerPath",void 0),Id([P({type:$.float32,default:1})],wt.prototype,"devicePixelRatio",void 0),Id([P.backrefs(jt,"canvas")],wt.prototype,"cameras",void 0),Id([P.backrefs(xa,"canvas")],wt.prototype,"inputPoints",void 0),Id([P.backrefs(Xy,"canvas")],wt.prototype,"fonts",void 0),Id([P.object],wt.prototype,"api",void 0);let Ddt;Ddt=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},(function(t){t.NONE="none",t.GRID="grid",t.DOTS="dots"})(wh||(wh={})),rd=class{},Ddt([P({type:$.staticString([wh.NONE,wh.GRID,wh.DOTS]),default:wh.GRID})],rd.prototype,"checkboardStyle",void 0);function XK(t,e){return(t[0]-e[0])**2+(t[1]-e[1])**2}function Fjt(t,e,r){const i=XK(e,r);if(i===0)return XK(t,e);let s=((t[0]-e[0])*(r[0]-e[0])+(t[1]-e[1])*(r[1]-e[1]))/i;return s=Math.max(0,Math.min(1,s)),XK(t,[e[0]+s*(r[0]-e[0]),e[1]+s*(r[1]-e[1])])}function zx(t,e,r){return Math.sqrt(Fjt(t,e,r))}class Njt{constructor(e,r){this.parent=e,this.child=r}apply(e){this.parent.has(ze)||this.parent.add(ze),this.child.add(be,{parent:this.parent})}}class kjt{constructor(e,r){this.id=e,this.bundles=r}apply(e){this.bundles.forEach(r=>{this.addBundle(r)})}addBundle(e){e instanceof OL?Object.keys(e).forEach(r=>{e[r]instanceof OL?this.addBundle(e[r]):e[r]&&this.id.add(e[r].constructor,e[r])}):e&&this.id.add(e.constructor,e)}}class Ljt{constructor(e,r){this.id=e,this.bundles=r}apply(e){this.bundles.forEach(r=>{this.removeBundle(r)})}removeBundle(e){try{e instanceof OL?Object.keys(e).forEach(r=>{e[r]instanceof OL?this.removeBundle(e[r]):e[r]&&this.id.remove(e[r].constructor,e[r])}):this.id.remove(e.constructor,e)}catch(r){console.log(r)}}}class Ujt{constructor(e,r){this.parent=e,this.child=r}apply(e){this.child.remove(be),this.parent.read(ze).children.length===0&&this.parent.remove(ze)}}class J8 extends Uo{constructor(e,r){super(),this.entity=e,this.commands=r}id(){return this.entity}insert(...e){return this.commands.add(new kjt(this.entity,e)),this}remove(...e){this.commands.add(new Ljt(this.entity,e))}despawn(){}appendChild(e){return this.commands.add(new Njt(this.id(),e.id())),this}removeChild(e){return this.commands.add(new Ujt(this.id(),e.id())),this}}class Gjt{constructor(e){this.resource=e}apply(){}}
6867class Wjt{constructor(e){this.resource=e}apply(){}}nE=class{constructor(t){this.system=t,this.queue=[]}execute(){this.queue.forEach(t=>{t.apply(this.system)}),this.queue=[]}entity(t){return new J8(t,this)}add(t){this.queue.push(t)}spawnEmpty(){return new J8(this.system.createEntity(),this)}getOrSpawn(t){return new J8(t,this)}spawn(...t){const e=this.spawnEmpty();return e.insert(...t),e}insertResource(t){this.queue.push(new Gjt(t))}removeResource(t){this.queue.push(new Wjt(t))}};function zK(t,e=!0){if(!t.has(_e))return;const r=t.read(_e);e&&!t.has(Ae)&&t.add(Ae,new Ae),t.write(Ae).matrix=ie.fromTransform(r)}tT=class extends We{constructor(){super(),this.queries=this.query(t=>t.addedOrChanged.with(_e).but.without(ze,be).trackWrites),this.cameras=this.query(t=>t.addedOrChanged.with(_e,ze).without(be).trackWrites),this.orphaned=this.query(t=>t.removed.with(ze)),this.query(t=>t.using(Ae).write)}execute(){this.cameras.addedOrChanged.forEach(t=>{zK(t)}),this.queries.addedOrChanged.forEach(t=>{zK(t)}),this.orphaned.removed.forEach(t=>{zK(t,!1)})}},eT=class extends We{constructor(){super(),this.queries=this.query(t=>t.without(jt).with(_e).addedOrChanged.trackWrites.using(Ae).write),this.missingGlobalTransform=this.query(t=>t.current.with(_e).without(jt).without(Ae).read),this.sceneCameras=this.query(t=>t.current.with(jt,ze).read),this.query(t=>t.using(wt,jt,ze,be).read)}execute(){this.missingGlobalTransform.current.length>0&&this.sceneCameras.current.forEach(t=>{if(t.has(ze))for(const e of t.read(ze).children)Sr(e)}),this.queries.addedOrChanged.forEach(t=>{Sr(t)})}};function nr(t){if(!t)return!1;try{return t.has(jt),!0}catch{return!1}}En=function(t){if(!nr(t)||!t.has(be))return t;const e=t.read(be).parent;return e&&nr(e)?En(e):t},Ov=function(t,e){if(!t.has(ze))return[];const r=[...t.read(ze).children];return e&&r.sort(e),r.flatMap(i=>[i,...Ov(i,e)])},Sr=function(t){if(!nr(t)||!t.has(_e))return;let e=ie.IDENTITY;if(t.has(be)){const s=t.read(be).parent;s&&nr(s)&&(e=s.has(jt)?ie.IDENTITY:s.has(Ae)?s.read(Ae).matrix:ie.IDENTITY)}const r=t.read(_e),i=e.mul_mat3(ie.fromTransform(r));t.has(Ae)?t.write(Ae).matrix=i:t.add(Ae,new Ae(i)),t.has(ze)&&t.read(ze).children.forEach(s=>{nr(s)&&Sr(s)})};function Pdt(t,e){const r=t[0],i=t[1];let s=!1;for(let o=0,n=e.length-1;o<e.length;n=o++){const a=e[o][0],l=e[o][1],c=e[n][0],h=e[n][1];l>i!=h>i&&r<(c-a)*(i-l)/(h-l)+a&&(s=!s)}return s}function jjt(t,e,r){const i=Ea(it(),Aa(it(),t,e),.5);return Ea(i,i,1/Yy(t,i)),Ea(i,i,r)}const Xjt=new snt(Date.now()),VK=()=>Math.floor(Xjt.next()*Math.pow(2,31));function Q8(t){let e=t[0],r=t[1],i=t[3],s=t[4],o=Math.sqrt(e*e+r*r),n=Math.sqrt(i*i+s*s);if(e*s-r*i<0&&(e<s?o=-o:n=-n),o){const l=1/o;e*=l,r*=l}if(n){const l=1/n;i*=l,s*=l}const a=Math.atan2(r,e);return{translation:[t[6],t[7]],scale:[o,n],rotation:a}}function oy(t,e){return Math.round(t/e)*e}const tj=([t,e],[r,i])=>t<=r?e>=r:t>=r?i>=t:!1,ej=([t,e],[r,i])=>{const s=Math.max(t,r),o=Math.min(e,i);return s<=o?[s,o]:null};Hd=function(t){return Math.round(t*1e4)/1e4};function rj(t,e,r,i,s,o){const n=t-r,a=e-i;return n*n/(s*s)+a*a/(o*o)<=1}function zjt(t,e,r,i,s,o){const n=[r-t,i-e];if(hO(n,[0,0]))return Math.sqrt((s-t)*(s-t)+(o-e)*(o-e));const a=[-n[1],n[0]];aE(a,a);const l=[s-t,o-e];return Math.abs(Yy(l,a))}function Fdt(t,e,r,i,s,o,n){const a=Math.min(t,r),l=Math.max(t,r),c=Math.min(e,i),h=Math.max(e,i),u=s/2;return o>=a-u&&o<=l+u&&n>=c-u&&n<=h+u?zjt(t,e,r,i,o,n)<=s/2:!1}function Vjt(t,e,r,i){for(let s=0;s<t.length-1;s++){const o=t[s][0],n=t[s][1],a=t[s+1][0],l=t[s+1][1];if(Fdt(o,n,a,l,e,r,i))return!0}return!1}const YK=0;function sh(t){return[t.m00,t.m01,t.m02,YK,t.m10,t.m11,t.m12,YK,t.m20,t.m21,t.m22,YK]}Sa=function(t,e,r,i){return Math.sqrt(Math.pow(r-t,2)+Math.pow(i-e,2))},(function(t){t.SHOW_LAYERS_PANEL="show-layers-panel",t.SHOW_PROPERTIES_PANEL="show-properties-panel",t.SHOW_CHAT_PANEL="show-chat-panel",t.SHOW_ANIMATION_PANEL="show-animation-panel",t.SHOW_TIMELINE_PANEL="show-timeline-panel"})(fE||(fE={}));let nw,ij,g2;yO=()=>{const t="system",e=ZU(t);return{language:"en",variables:{},themePreference:t,themeMode:e,theme:{mode:e,colors:{[Tr.LIGHT]:Object.assign(Object.assign({},Ty[Tr.LIGHT]),{swatches:[Zs,Kh,"black","white","red","green","yellow"]}),[Tr.DARK]:Object.assign(Object.assign({},Ty[Tr.DARK]),{swatches:[Zs,Kh,"black","white","red","green","yellow"]})}},checkboardStyle:wh.GRID,cameraZoom:1,cameraX:0,cameraY:0,cameraRotation:0,
6867cameraZoomFactor:.02,contextBarVisible:!0,contextMenuVisible:!0,topbarVisible:!0,penbarVisible:!0,penbarAll:[vt.HAND,vt.SELECT,vt.DRAW_RECT,vt.DRAW_TRIANGLE,vt.DRAW_PENTAGON,vt.DRAW_HEXAGON,vt.DRAW_ELLIPSE,vt.DRAW_LINE,vt.DRAW_ARROW,vt.DRAW_ROUGH_RECT,vt.DRAW_ROUGH_ELLIPSE,vt.DRAW_ROUGH_LINE,vt.DRAW_ICONFONT,vt.IMAGE,vt.TEXT,vt.PENCIL,vt.BRUSH,vt.VECTOR_NETWORK,vt.ERASER,vt.COMMENT,vt.LASER_POINTER],penbarSelected:vt.HAND,penbarDrawSizeLabelVisible:!0,penbarNameLabelVisible:!1,penbarDrawRect:{fills:[{type:"solid",value:Kh,opacity:.5}],strokes:[{type:"solid",value:Zs,opacity:1}],strokeWidth:1},penbarDrawTriangle:{fills:[{type:"solid",value:Kh,opacity:.5}],strokes:[{type:"solid",value:Zs,opacity:1}],strokeWidth:1},penbarDrawPentagon:{fills:[{type:"solid",value:Kh,opacity:.5}],strokes:[{type:"solid",value:Zs,opacity:1}],strokeWidth:1},penbarDrawHexagon:{fills:[{type:"solid",value:Kh,opacity:.5}],strokes:[{type:"solid",value:Zs,opacity:1}],strokeWidth:1},penbarDrawEllipse:{fills:[{type:"solid",value:Kh,opacity:.5}],strokes:[{type:"solid",value:Zs,opacity:1}],strokeWidth:1},penbarDrawLine:{fills:[{type:"solid",value:"none",opacity:1}],strokes:[{type:"solid",value:Zs,opacity:1}],strokeWidth:1},penbarDrawArrow:{fills:[{type:"solid",value:"none",opacity:1}],strokes:[{type:"solid",value:Zs,opacity:1}],strokeWidth:1,markerStart:"none",markerEnd:"line",markerFactor:3},penbarDrawRoughRect:{fills:[{type:"solid",value:Zs,opacity:1}],strokes:[{type:"solid",value:Zs,opacity:1}],strokeWidth:4,roughBowing:1,roughRoughness:1,roughFillStyle:"hachure"},penbarDrawRoughEllipse:{fills:[{type:"solid",value:Zs,opacity:1}],strokes:[{type:"solid",value:Zs,opacity:1}],strokeWidth:4,roughBowing:1,roughRoughness:1,roughFillStyle:"hachure"},penbarDrawRoughLine:{fills:[{type:"solid",value:"none",opacity:1}],strokes:[{type:"solid",value:Zs,opacity:1}],strokeWidth:1,roughBowing:1,roughRoughness:4},penbarPencil:{fills:[{type:"solid",value:"none",opacity:1}],strokes:[{type:"solid",value:Zs,opacity:1}],strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"},penbarVectorNetwork:{fills:[{type:"solid",value:"none",opacity:1}],strokes:[{type:"solid",value:Zs,opacity:1}],strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},penbarBrush:{stamps:[{src:"/stamp1.png",name:"Stamp 1",preview:"/stamp1.png",active:!0},{src:"/stamp2.png",name:"Stamp 2",preview:"/stamp2.png"}],brushType:Qw.STAMP,stampInterval:.4,stampMode:jw.RATIO_DISTANCE,stampNoiseFactor:.4,stampRotationFactor:.75,strokes:[{type:"solid",value:Zs,opacity:1}],strokeWidth:20},penbarText:{fontFamily:"system-ui",fontFamilies:["system-ui","serif","monospace"],fontSize:16,fontStyle:"normal",fills:[{type:"solid",value:"#000",opacity:1}]},penbarLasso:{mode:"select",trailFill:Kh,trailFillOpacity:.5,trailStroke:Zs,fills:[{type:"solid",value:Kh,opacity:.5}],strokes:[{type:"solid",value:Zs,opacity:1}],strokeWidth:1},penbarDrawIconfont:{fills:[{type:"solid",value:"black",opacity:1}],strokes:[{type:"solid",value:"black",opacity:1}],strokeWidth:1,iconFontFamily:"lucide",iconFontName:"search"},taskbarVisible:!0,taskbarAll:[fE.SHOW_LAYERS_PANEL,fE.SHOW_PROPERTIES_PANEL,fE.SHOW_ANIMATION_PANEL,fE.SHOW_TIMELINE_PANEL],taskbarSelected:[],taskbarChatMessages:[],layersSelected:[],layersHighlighted:[],layersCropping:[],layersLassoing:[],propertiesOpened:[],propertiesPanelSectionsOpen:{fillSection:!0,strokeSection:!0,typographySection:!0,shape:!0,transform:!0,layout:!0,flexItem:!0,effects:!0,multiSelectAlignment:!0,multiSelectEffects:!0,exportSection:!0,iconFont:!0},layersExpanded:[],rotateEnabled:!0,flipEnabled:!1,snapToPixelGridEnabled:!1,snapToPixelGridSize:10,snapToObjectsEnabled:!1,snapToObjectsDistance:8,snapLineStroke:"orange",snapLineStrokeWith:1,editingPoints:[],vectorNetworkEditMode:So.MOVE,vectorNetworkSelectedVertex:null,loading:!1,loadingMessage:"",filter:"",giEnabled:!1,giStrength:.
68671,animationEditing:!1,animationCurrentTime:0,animationPlaying:!1,animationLoop:!0,timelinePanelHeight:220}},_O=1e6,mG=-1e6,nw=_O*10,ij=nw-1,g2=ij-10;var ny=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Vx,Yx;class m2{constructor(e){this.onChange=e,Vx.set(this,[]),Yx.set(this,[])}static pop(e){if(!e.length)return null;const r=e.pop();return r!==void 0?r:null}static push(e,r,i){const s=r.inverse().applyLatestChanges(i);return e.push(s)}get isUndoStackEmpty(){return ny(this,Vx,"f").length===0}get isRedoStackEmpty(){return ny(this,Yx,"f").length===0}clear(){var e;ny(this,Vx,"f").length=0,ny(this,Yx,"f").length=0,(e=this.onChange)===null||e===void 0||e.call(this)}record(e,r){var i;const s=IL.create(r,e);s.isEmpty()||(ny(this,Vx,"f").push(s.inverse()),s.elementsChange.isEmpty()||(ny(this,Yx,"f").length=0),(i=this.onChange)===null||i===void 0||i.call(this))}undo(e,r,i){return this.perform(e,r,i,()=>m2.pop(ny(this,Vx,"f")),s=>m2.push(ny(this,Yx,"f"),s,e))}redo(e,r,i){return this.perform(e,r,i,()=>m2.pop(ny(this,Yx,"f")),s=>m2.push(ny(this,Vx,"f"),s,e))}perform(e,r,i,s,o){var n;try{let a=s();if(a===null)return;let l=e,c=r,h=!1;for(;a;){try{[l,c,h]=a.applyTo(l,c,i)}finally{o(a)}if(h)break;a=s()}return[l,c]}finally{(n=this.onChange)===null||n===void 0||n.call(this)}}}Vx=new WeakMap,Yx=new WeakMap;class IL{constructor(e,r){this.appStateChange=e,this.elementsChange=r}static create(e,r){return new IL(e,r)}inverse(){return new IL(this.appStateChange.inverse(),this.elementsChange.inverse())}applyTo(e,r,i){const[s,o]=this.elementsChange.applyTo(e,i.elements),[n,a]=this.appStateChange.applyTo(r,s);return[s,n,o||a]}applyLatestChanges(e){const r=this.elementsChange.applyLatestChanges(e);return IL.create(this.appStateChange,r)}isEmpty(){return this.appStateChange.isEmpty()&&this.elementsChange.isEmpty()}}var sj=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};let $K;function Yjt(){return sj(this,void 0,void 0,function*(){return $K||($K=(yield JB(()=>import("./heic2any.BWPokBzK.js").then(t=>t.h),[])).default),$K})}function HK(t){return/^image\/hei[cf](?:-sequence)?$/i.test(t.trim())}function $jt(t){try{const e=new URL(t,"https://placeholder.invalid");return/\.hei[cf]$/i.test(e.pathname)}catch{return/\.hei[cf](\?|#|$)/i.test(t)}}function oj(t){if(t.byteLength<12)return!1;const e=new Uint8Array(t);if(String.fromCharCode(e[4],e[5],e[6],e[7])!=="ftyp")return!1;const r=String.fromCharCode(e[8],e[9],e[10],e[11]);return/^(avif|avis)/i.test(r)?!1:/^(heic|heix|hevc|hevx|mif1|msf1|hevm|hevs)/i.test(r)}function Ndt(t){return sj(this,void 0,void 0,function*(){if(HK(t.type))return!0;const e=yield t.slice(0,16).arrayBuffer();return oj(e)})}function $x(t){return sj(this,void 0,void 0,function*(){const e=yield Yjt(),r=(o,n)=>e({blob:t,toType:o,quality:o==="image/jpeg"?.92:1});let i=yield r("image/png"),s=Array.isArray(i)?i[0]:i;if(s&&s.size>0)try{return yield createImageBitmap(s)}catch{}if(i=yield r("image/jpeg"),s=Array.isArray(i)?i[0]:i,!s||s.size===0)throw new Error("heic2any: empty output");return createImageBitmap(s)})}function Hjt(t){if(!t.startsWith("data:"))return null;const e=t.indexOf(",");if(e<0)return null;const r=t.substring(5,e);if(!/;base64/i.test(r))return null;const i=r.split(";")[0].trim()||"text/plain",s=t.slice(e+1).replace(/\s/g,"");try{const o=atob(s),n=o.length,a=new Uint8Array(n);for(let l=0;l<n;l++)a[l]=o.charCodeAt(l);return{mime:i,data:a.buffer}}catch{return null}}function nj(t){return sj(this,void 0,void 0,function*(){var e,r,i;if(typeof t!="string"){const o=t instanceof File?t.name:"";if(HK(t.type)||/\.hei[cf]$/i.test(o)||(!t.type||t.type==="application/octet-stream")&&(yield Ndt(t)))return $x(t);try{return yield nu(t,Hh)}catch(n){const a=yield t.arrayBuffer();if(oj(a.slice(0,12)))return $x(new Blob([a],{type:"image/heic"}));throw n}}const s=t;if(s.startsWith("data:")){const o=Hjt(s);if(o){if(HK(o.mime))return $x(new Blob([o.data],{type:o.mime}));if(oj(o.data.slice(0,12)))return $x(new Blob([o.data],{type:"image/heic"}))}return yield nu(s,Hh)}if(s.startsWith("blob:")){const o=yield fetch(s).then(n=>n.blob());return(yield Ndt(o))?$x(o):yield nu(o,Hh)}if($jt(s)){const o=yield(yield fetch(s,{mode:"cors"})).blob();return $x(o)}try{return yield nu(s,Hh)}catch(o){const n=yield fetch(s,{mode:"cors"}),a=yield n.arrayBuffer();if(oj(a)){const l=(i=(r=(e=n.headers.get("content-type"))===null||e===void 0?void 0:e.split(";")[0])===null||r===void 0?void 0:r.trim())!==null&&i!==void 0?i:"image/heic";return $x(new Blob([a],{type:l}))}throw o}})}const kdt={createCanvas:(t,e)=>{const r=document.createElement("canvas");return r.width=t,r.height=e,r},createTexImageSource:t=>t,createImage:t=>nj(t),getWindow:()=>window,getDocument:()=>document,getXMLSerializer:()=>new XMLSerializer,getDOMParser:()=>new DOMParser,splitGraphemes:t=>typeof(Intl==null?void 0:Intl.Segmenter)=="function"?[...new Intl.Segmenter().segment(t)].map(e=>e.segment):[...t],requestAnimationFrame:t=>requestAnimationFrame(t),cancelAnimationFrame:t=>cancelAnimationFrame(t)};let Ldt=kdt;Pr={get(){return Ldt},set(t){Ldt=t}},Zo=typeof window<"u"&&typeof window.document<"u",we=function(t){return Pr.get().getDocument().createElementNS("http://www.w3.org/2000/svg",t)};function Udt(t){var e;const r=(e=t.getBoundingClientRect)===null||e===void 0?void 0:e.call(t);let i=1,s=1;if(t&&r){const{offsetWidth:o,offsetHeight:n}=t;o&&n&&(i=r.width/o,s=r.height/n)}return{scaleX:i,scaleY:s,bbox:r}}const Kjt=(t,e)=>{try{return new URL(t,e)}catch{return}},qjt=t=>Object.entries(t).filter(([e,r])=>r).map(([e])=>e).join(" "),Zjt={"allow-downloads-without-user-activation":!1,"allow-downloads":!1,"allow-modals":!1,"allow-orientation-lock":!1,"allow-pointer-lock":!1,"allow-popups":!0,"allow-popups-to-escape-sandbox":!1,"allow-presentation":!1,"allow-storage-access-by-user-activation":!1,"allow-top-navigation":!1,"allow-top-navigation-by-user-activation":!1,"allow-scripts":!0,"allow-same-origin":!0,"allow-forms":!0};var KK;
6867(function(t){t._bytes4=new Uint8Array(4),t._float=new Float32Array(t._bytes4.buffer);function e(r){return t._float[0]=r,t._bytes4}t.floatToBytes=e})(KK||(KK={}));const Gdt=256;class Jjt{constructor(e=new Uint8Array(Gdt)){this._bytes=e,this.count=0,this.capacity=Gdt,this.count=this.capacity=e.length}clear(){this.count=0}bytes(){return this._bytes.subarray(0,this.count)}grow(){this.capacity*=2;const e=new Uint8Array(this.capacity);e.set(this._bytes),this._bytes=e}appendBytes(e){const r=e.length;return this.count+r>this.capacity&&this.grow(),this._bytes.set(e,this.count),this.count+=r,this}appendFloat(e){return this.appendBytes(KK.floatToBytes(e)),this}}Wo=function(t){var e;if(!t)return sr.rgb(0,0,0,0);let r;t==="none"?r=sr.rgb(255,255,255,0):r=((e=sr.rgb(t))===null||e===void 0?void 0:e.rgb())||sr.rgb(0,0,0,1);const i=r;return Number.isNaN(i.r)||Number.isNaN(i.g)||Number.isNaN(i.b)?sr.rgb(Number.isNaN(i.r)?0:i.r,Number.isNaN(i.g)?0:i.g,Number.isNaN(i.b)?0:i.b,i.opacity):i},ret=function(t){if(!t||t==="none")return"#000000";const e=Wo(t),r=sr.rgb(e.r,e.g,e.b,e.opacity);return r.opacity<1?r.formatHex8():r.formatHex()};function Qjt(t){let e=0;const r=[];t.forEach(s=>{if(lc(s)||Array.isArray(s)||s instanceof Float32Array){const o=lc(s)?[s]:s,n=o.length>4?4:o.length,a=4-e%4;if(a!==4&&!(a>=n)){e+=a;for(let l=0;l<a;l++)r.push(0)}e+=o.length,r.push(...o)}});const i=4-r.length%4;if(i!==4)for(let s=0;s<i;s++)r.push(0);return r}let Wdt;Wdt=10,wG=[[0,0],[.5,0],[1,0],[0,.5],[.5,.5],[1,.5],[0,1],[.5,1],[1,1],[0,0]];function tXt(t){var e,r;const i=[];for(let s=0;s<Wdt;s++){const o=(e=t.pointColors[s])!==null&&e!==void 0?e:[0,0,0],n=(r=t.pointPositions[s])!==null&&r!==void 0?r:[0,0];i.push([o[0],o[1],o[2]],[n[0],n[1]])}return i.push([t.backgroundRgb[0],t.backgroundRgb[1],t.backgroundRgb[2]],t.pointsNum,t.noiseRatio,t.noiseTime,t.warpShapeIndex,t.warpSize,t.warpRatio,t.gradientTypeIndex,t.time),Qjt(i)}const jdt=96;function qK(t){const{type:e,value:r}=t;return e==="hex"?`#${r}`:e==="literal"?r:e==="rgb"?`rgb(${r.join(",")})`:`rgba(${r.join(",")})`}const eXt=(function(){const t={linearGradient:/^(linear\-gradient)/i,repeatingLinearGradient:/^(repeating\-linear\-gradient)/i,radialGradient:/^(radial\-gradient)/i,repeatingRadialGradient:/^(repeating\-radial\-gradient)/i,conicGradient:/^(conic\-gradient)/i,meshGradient:/^(mesh\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})/i,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/};let e="";function r(L){throw new Error(`${e}: ${L}`)}function i(){const L=s();return e.length>0&&r("Invalid input not EOF"),L}function s(){return x(h)}function o(){const L=e.replace(/^\s+/,"");return/^warp\s*\(/i.test(L)||/^gtype\s*\(/i.test(L)||/^wshape\s*\(/i.test(L)||/^time\s*\(/i.test(L)||/^points\s*\(/i.test(L)}function n(){const L={};function J(){if(!Y(/^warp\s*\(/i))return!1;const ct=a();ct===null&&r("mesh-gradient: warp() expects a number"),Y(t.comma)||r("mesh-gradient: warp() expected comma between numbers");const Xt=a();return Xt===null&&r("mesh-gradient: warp() expects two numbers"),Y(t.endCall)||r("mesh-gradient: warp() expected )"),L.warpSize=ct,L.warpRatio=Xt,!0}function tt(ct,Xt){if(!Y(ct))return!1;const It=a();return It===null&&r("mesh-gradient: expected number in ()"),Y(t.endCall)||r("mesh-gradient: expected )"),L[Xt]=It,!0}let bt=!0;for(;;){if(/^\s*\)/.test(e))return{extras:L};if(bt){if(bt=!1,!Y(t.comma)&&!o()){if(/^\s*\)/.test(e))return{extras:L};r("mesh-gradient: expected color / tail options or )")}}
6867else if(!Y(t.comma)){if(/^\s*\)/.test(e))return{extras:L};r("mesh-gradient: expected , or )")}J()||tt(/^gtype\s*\(/i,"gradientTypeIndex")||tt(/^wshape\s*\(/i,"warpShapeIndex")||tt(/^time\s*\(/i,"time")||tt(/^points\s*\(/i,"pointsNum")||r("mesh-gradient: expected warp(), gtype(), wshape(), time() or points()")}}function a(){const L=Y(t.number);return L?Number(L[1]):null}function l(){const L=T();if(!L)return null;const J=e,tt=a();if(tt===null)return{color:L};const bt=a();return bt===null&&(e=J,r("mesh-gradient: after a corner color, either omit U V or provide two numbers")),{color:L,uv:[tt,bt]}}function c(){return d(t.meshGradient,function(){const L=T();L||r("mesh-gradient: expected background color"),Y(t.comma)||r("mesh-gradient: expected comma after background color");const J=l();J||r("mesh-gradient: expected at least one corner color");const tt=[J];for(;tt.length<9&&!(!Y(t.comma)||o());){const ct=l();ct||r("mesh-gradient: expected color or tail options after comma"),tt.push(ct)}const{extras:bt}=n();return Object.assign({type:"mesh-gradient",background:L,corners:tt},bt)})}function h(){return c()||u("linear-gradient",t.linearGradient,f)||u("repeating-linear-gradient",t.repeatingLinearGradient,f)||u("radial-gradient",t.radialGradient,m)||u("repeating-radial-gradient",t.repeatingRadialGradient,m)||u("conic-gradient",t.conicGradient,m)}function u(L,J,tt){return d(J,function(bt){const ct=tt();return ct&&(Y(t.comma)||r("Missing comma before color stops")),{type:L,orientation:ct,colorStops:x(S)}})}function d(L,J){const tt=Y(L);if(tt){Y(t.startCall)||r("Missing (");const bt=J(tt);return Y(t.endCall)||r("Missing )"),bt}}function f(){return g()||p()}function g(){return G("directional",t.sideOrCorner,1)}function p(){return G("angular",t.angleValue,1)}function m(){let L,J=v(),tt;return J&&(L=[],L.push(J),tt=e,Y(t.comma)&&(J=v(),J?L.push(J):e=tt)),L}function v(){let L=b()||y();if(L)L.at=w();else{const J=_();if(J){L=J;const tt=w();tt&&(L.at=tt)}else{const tt=E();tt&&(L={type:"default-radial",at:tt})}}return L}function b(){const L=G("shape",/^(circle)/i,0);return L&&(L.style=N()||_()),L}function y(){const L=G("shape",/^(ellipse)/i,0);return L&&(L.style=U()||_()),L}function _(){return G("extent-keyword",t.extentKeywords,1)}function w(){if(G("position",/^at/,0)){const L=E();return L||r("Missing positioning value"),L}}function E(){const L=A();if(L.x||L.y)return{type:"position",value:L}}function A(){return{x:U(),y:U()}}function x(L){let J=L();const tt=[];if(J)for(tt.push(J);Y(t.comma);)J=L(),J?tt.push(J):r("One extra comma");return tt}function S(){const L=T();return L||r("Expected color definition"),L.length=U(),L}function T(){return B()||C()||O()||R()}function R(){return G("literal",t.literalColor,0)}function B(){return G("hex",t.hexColor,1)}function O(){return d(t.rgbColor,function(){return{type:"rgb",value:x(F)}})}function C(){return d(t.rgbaColor,function(){return{type:"rgba",value:x(F)}})}function F(){return Y(t.number)[1]}function U(){return G("%",t.percentageValue,1)||H()||N()}function H(){return G("position-keyword",t.positionKeywords,1)}function N(){return G("px",t.pixelValue,1)||G("em",t.emValue,1)}function G(L,J,tt){const bt=Y(J);if(bt)return{type:L,value:bt[tt]}}function Y(L){const J=/^[\n\r\t\s]+/.exec(e);J&&q(J[0].length);const tt=L.exec(e);return tt&&q(tt[0].length),tt}function q(L){e=e.substring(L)}return function(L){return e=L,i()}})();dE=function(t,e,r,i){const s=eu*i,o=0,n=0,a=o+e/2,l=n+r/2,c=Math.abs(e*Math.cos(s))+Math.abs(r*Math.sin(s)),h=t[0]+a-Math.cos(s)*c/2,u=t[1]+l-Math.sin(s)*c/2,d=t[0]+a+Math.cos(s)*c/2,f=t[1]+l+Math.sin(s)*c/2;return{x1:h,y1:u,x2:d,y2:f}};function rXt(t){const{type:e,value:r}=t.offset;return e==="%"?r/100:r<=1?r:r/100}function iXt(t){return t.map(e=>{const r=Wo(e.color);return{t:rXt(e),r:r.r/255,g:r.g/255,b:r.b/255,a:r.opacity}}).sort((e,r)=>e.t-r.t)}function sXt(t,e){const r=Math.max(0,Math.min(1,e));if(t.length===0)return{t:r,r:0,g:0,b:0,a:0};if(r<=t[0].t)return Object.assign(Object.assign({},t[0]),{t:r});const i=t[t.length-1];if(r>=i.t)return Object.assign(Object.assign({},i),{t:r});for(let s=0;s<t.length-1;s++){const o=t[s],n=t[s+1];if(r<o.t||r>n.t)continue;if(n.t===o.t)return Object.assign(Object.assign({},n),{t:r});const a=(r-o.t)/(n.t-o.t),l=o.r*o.a,c=o.g*o.a,h=o.b*o.a,u=n.r*n.a,d=n.g*n.a,f=n.b*n.a,g=o.a+(n.a-o.a)*a,p=l+(u-l)*a,m=c+(d-c)*a,v=h+(f-h)*a;return g<=1e-6?{t:r,r:0,g:0,b:0,a:0}:{t:r,r:p/g,g:m/g,b:v/g,a:g}}return Object.assign(Object.assign({},i),{t:r})}function Xdt(t,e,r,i,s,o){if(i<=0||s<=0)return;const n=iXt(o.steps),{x1:a,y1:l,x2:c,y2:h}=dE([e,r],i,s,o.angle),u=c-a,d=h-l,f=u*u+d*d,g=f>1e-10?1/f:0,p=t.createImageData(i,s),m=p.data;for(let v=0;v<s;v++)for(let b=0;b<i;b++){const y=e+b+.5,_=r+v+.5;
6867let w=((y-a)*u+(_-l)*d)*g;w=Math.max(0,Math.min(1,w));const{r:E,g:A,b:x,a:S}=sXt(n,w),T=(v*i+b)*4;m[T]=Math.round(E*255),m[T+1]=Math.round(A*255),m[T+2]=Math.round(x*255),m[T+3]=Math.round(S*255)}t.putImageData(p,e,r)}dG=function(t,e,r,i,s){let o=i.value,n=s.value;return i.type==="%"&&(o=i.value/100*e),s.type==="%"&&(n=s.value/100*r),{x:o+t[0],y:n+t[1]}},pO=function(t,e,r,i,s,o){let n=i.value,a=s.value;i.type==="%"&&(n=i.value/100*e),s.type==="%"&&(a=s.value/100*r);let l=Math.max(qn([0,0],[n,a]),qn([0,r],[n,a]),qn([e,r],[n,a]),qn([e,0],[n,a]));return o&&(o.type==="extent-keyword"?o.value==="closest-side"?l=Math.min(n,e-n,a,r-a):o.value==="farthest-side"?l=Math.max(n,e-n,a,r-a):o.value==="closest-corner"&&(l=Math.min(qn([0,0],[n,a]),qn([0,r],[n,a]),qn([e,r],[n,a]),qn([e,0],[n,a]))):l=Number(o.value)),{x:n+t[0],y:a+t[1],r:l}};function oXt(t){var e,r,i;const{length:s}=t;t[s-1].length=(e=t[s-1].length)!==null&&e!==void 0?e:{type:"%",value:"100"},s>1&&(t[0].length=(r=t[0].length)!==null&&r!==void 0?r:{type:"%",value:"0"});let o=0,n=Number(t[0].length.value);for(let a=1;a<s;a++){const l=(i=t[a].length)===null||i===void 0?void 0:i.value;if(!me(l)&&!me(n)){for(let c=1;c<a-o;c++)t[o+c].length={type:"%",value:`${n+(Number(l)-n)*c/(a-o)}`};o=a,n=Number(l)}}}const nXt={left:180,top:-90,bottom:90,right:0,"left top":225,"top left":225,"left bottom":135,"bottom left":135,"right top":-45,"top right":-45,"right bottom":45,"bottom right":45};function zdt(t){let e;return t.type==="angular"?e=Number(t.value):e=nXt[t.value]||0,e}function Vdt(t){let e=50,r=50,i="%",s="%";if((t==null?void 0:t.type)==="position"){const{x:o,y:n}=t.value;(o==null?void 0:o.type)==="position-keyword"&&(o.value==="left"?e=0:o.value==="center"?e=50:o.value==="right"?e=100:o.value==="top"?r=0:o.value==="bottom"&&(r=100)),(n==null?void 0:n.type)==="position-keyword"&&(n.value==="left"?e=0:n.value==="center"?r=50:n.value==="right"?e=100:n.value==="top"?r=0:n.value==="bottom"&&(r=100)),((o==null?void 0:o.type)==="px"||(o==null?void 0:o.type)==="%"||(o==null?void 0:o.type)==="em")&&(i=o==null?void 0:o.type,e=Number(o.value)),((n==null?void 0:n.type)==="px"||(n==null?void 0:n.type)==="%"||(n==null?void 0:n.type)==="em")&&(s=n==null?void 0:n.type,r=Number(n.value))}return{cx:{value:e,type:i},cy:{value:r,type:s}}}Zy=function(t){return t.type==="mesh-gradient"};function aXt(t,e){return t.replace(/\s/g,"").toLowerCase()===e.replace(/\s/g,"").toLowerCase()}function Ydt(t){if(t.pointsNum!=null)return Math.min(9,Math.max(1,t.pointsNum));if(t.colors.length<9)return Math.max(1,t.colors.length);const e=t.backgroundColor;for(let r=0;r<9;r++){const i=t.colors[r];if(i==null||aXt(i,e))return Math.max(1,r)}return 9}oet=function(t){var e,r;const i=[];if(t.gradientTypeIndex!=null&&t.gradientTypeIndex!==2&&i.push(`gtype(${t.gradientTypeIndex})`),t.warpShapeIndex!=null&&t.warpShapeIndex!==0&&i.push(`wshape(${t.warpShapeIndex})`),t.warpSize!=null&&t.warpSize!==.5||t.warpRatio!=null&&t.warpRatio!==0){const s=(e=t.warpSize)!==null&&e!==void 0?e:.5,o=(r=t.warpRatio)!==null&&r!==void 0?r:0;i.push(`warp(${s}, ${o})`)}return t.time!=null&&t.time!==0&&i.push(`time(${t.time})`),t.pointsNum===10&&i.push("points(10)"),i.length===0?"":`, ${i.join(", ")}`},sT=function(t){return Na(t)&&(t.indexOf("linear")>-1||t.indexOf("radial")>-1||t.indexOf("conic")>-1||t.indexOf("mesh-gradient")>-1)},nm=function(t){return!t||!sT(t)?void 0:eXt(t).map(e=>{if(e.type==="mesh-gradient"){const n=qK(e.background),a=wG,l=[],c=[];for(let u=0;u<9;u++){const d=e.corners[u];d?(l.push(qK(d.color)),c[u]=d.uv?[d.uv[0],d.uv[1]]:[a[u][0],a[u][1]]):(l.push(n),c[u]=[a[u][0],a[u][1]])}c[9]=[a[9][0],a[9][1]];const h={type:"mesh-gradient",backgroundColor:n,colors:l,positions:c};return e.gradientTypeIndex!=null&&(h.gradientTypeIndex=e.gradientTypeIndex),e.warpShapeIndex!=null&&(h.warpShapeIndex=e.warpShapeIndex),e.warpSize!=null&&(h.warpSize=e.warpSize),e.warpRatio!=null&&(h.warpRatio=e.warpRatio),e.time!=null&&(h.time=e.time),h.pointsNum=e.pointsNum!=null?e.pointsNum:Math.min(9,Math.max(1,e.corners.length)),h}const{type:r,colorStops:i}=e;let{orientation:s}=e;oXt(i);const o=i.map(n=>({offset:{type:n.length.type,value:Number(n.length.value)},color:qK(n)}));if(r==="linear-gradient")return{type:r,angle:s?zdt(s):0,steps:o};if(r==="radial-gradient"){if(s||(s=[{type:"shape",value:"circle"}]),s[0].type==="shape"&&s[0].value==="circle"){const{cx:n,cy:a}=Vdt(s[0].at);let l;if(s[0].style){const{type:c,value:h}=s[0].style;l={value:h,type:c}}return{type:r,cx:n,cy:a,size:l,steps:o}}}else if(r==="conic-gradient"&&(s||(s=[{type:"shape",value:"circle"}]),s[0].type==="shape"&&s[0].value==="circle")){const{cx:n,cy:a}=Vdt(s[0].at);return{type:r,cx:n,cy:a,angle:s?zdt(s):0,steps:o}}}).filter(e=>e!=null)};function ZK(t){const e=t===Tr.DARK;return{mode:e?"dark":"light",Mode:e?"Dark":"Light"}}function $dt(t,e){return t.trim().toLowerCase()===e.trim().toLowerCase()}function lXt(t,e){for(const[r,i]of Object.entries(t))if($dt(r,e))return i}function JK(t,e){if(!t||Object.keys(t).length===0)return!0;for(const[r,i]of Object.entries(t)){const s=lXt(e,r);if(s===void 0||!$dt(s,String(i)))return!1}return!0}function Hdt(t,e){if(t.length===0)return"";if(e==null)return(t.find(n=>!n.theme||Object.keys(n.theme).length===0)??t[0]).value;const r=ZK(e),i=[];for(let o=0;o<t.length;o++){const n=t[o];n.theme&&Object.keys(n.theme).length>0&&JK(n.theme,r)&&i.push({i:o,n:Object.keys(n.theme).length,e:n})}if(i.length>0){const o=Math.max(...i.map(a=>a.n)),n=i.filter(a=>a.n===o);return n.sort((a,l)=>
6867a.i-l.i),n[n.length-1].e.value}return(t.find(o=>!o.theme||Object.keys(o.theme).length===0)??t[0]).value}function DL(t,e){return Array.isArray(t.value)?Hdt(t.value,e):t.value}function Kdt(t,e){if(t.length===0)return 0;const r=ZK(e),i=[];for(let o=0;o<t.length;o++){const n=t[o];n.theme&&Object.keys(n.theme).length>0&&JK(n.theme,r)&&i.push({i:o,n:Object.keys(n.theme).length})}if(i.length>0){const o=Math.max(...i.map(a=>a.n)),n=i.filter(a=>a.n===o);return n.sort((a,l)=>a.i-l.i),n[n.length-1].i}const s=t.findIndex(o=>!o.theme||Object.keys(o.theme).length===0);return s>=0?s:0}function cXt(t,e,r){if(!Array.isArray(t.value))return Object.assign(Object.assign({},t),{value:r});const i=t.value.map(o=>Object.assign({},o));if(i.length===0)return Object.assign(Object.assign({},t),{value:r});const s=Kdt(i,e);return i[s]=Object.assign(Object.assign({},i[s]),{value:r}),Object.assign(Object.assign({},t),{value:i})}function qdt(t,e){if(t==="color")return typeof e=="string"?e:String(e);if(t==="number"){if(typeof e=="number"&&Number.isFinite(e))return e;const r=parseFloat(String(e));return Number.isFinite(r)?r:0}return String(e)}function hXt(t,e){return Array.isArray(t.value)?{type:e,value:t.value.map(r=>Object.assign(Object.assign({},r),{value:qdt(e,r.value)}))}:{type:e,value:qdt(e,t.value)}}$V=function(t){return{light:DL(t,Tr.LIGHT),dark:DL(t,Tr.DARK)}},iet=function(t,e,r){const{light:i,dark:s}=$V(t);return Object.assign(Object.assign({},t),{value:[{value:e===Tr.LIGHT?r:i,theme:{Mode:"Light"}},{value:e===Tr.DARK?r:s,theme:{Mode:"Dark"}}]})};const aj=["fills","strokes","stroke","fontSize","decorationColor","dropShadowColor","innerShadowColor","strokeWidth","cornerRadius","cornerRadius","letterSpacing","lineHeight","iconFontName","iconFontFamily"],uXt=["filter","opacity","fontFamily","fontWeight","fontStyle","fontKerning","textAlign","textBaseline","dropShadowBlurRadius","dropShadowOffsetX","dropShadowOffsetY","innerShadowBlurRadius","innerShadowOffsetX","innerShadowOffsetY","markerStart","markerEnd"];function Zdt(t){const e=new Set([...aj,...uXt]),r=t,i={};
6867for(const s of e)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s]);return i}Pv=function(t){return typeof t=="string"&&t.startsWith("$")&&t.length>1},qy=function(t){return t===void 0?"":typeof t=="string"&&Pv(t)?t.slice(1):""};function y2(t){return`--${t.replace(/\./g,"-")}`}function Jdt(t,e,r){if(!Array.isArray(t))return{next:t,changed:!1};let i=!1;return{next:t.map(s=>{if(!s||typeof s!="object")return s;const o=Object.assign({},s);if(typeof o.value=="string"){const n=ds(o.value,e,r);n!==o.value&&(o.value=n,i=!0)}if(typeof o.opacity=="string"){const n=ds(o.opacity,e,r);n!==o.opacity&&(o.opacity=n,i=!0)}return o}),changed:i}}function dXt(t,e,r){return Jdt(t,e,r)}function fXt(t,e,r){return Jdt(t,e,r)}function Qdt(t){if(!Array.isArray(t))return{next:t,changed:!1};let e=!1;return{next:t.map(r=>{if(!r||typeof r!="object")return r;const i=Object.assign({},r);let s=!1;return typeof i.value=="string"&&Pv(i.value)&&(i.value=`var(${y2(i.value.slice(1))})`,s=!0),typeof i.opacity=="string"&&Pv(i.opacity)&&(i.opacity=`var(${y2(i.opacity.slice(1))})`,s=!0),s&&(e=!0),i}),changed:e}}function pXt(t){return Qdt(t)}function gXt(t){return Qdt(t)}function mXt(t){const e=t,r=Object.assign({},e);let i=!1;for(const s of aj){if(!Object.prototype.hasOwnProperty.call(t,s))continue;const o=e[s];if(s==="fills"){const{next:n,changed:a}=pXt(o);a&&(r[s]=n,i=!0);continue}if(s==="strokes"){const{next:n,changed:a}=gXt(o);a&&(r[s]=n,i=!0);continue}typeof o=="string"&&Pv(o)&&(r[s]=`var(${y2(o.slice(1))})`,i=!0)}return i?r:t}function QK(t,e){const r=[];for(const[i,s]of Object.entries(t)){const o=y2(i),n=DL(s,e),a=s.type==="number"?`${n}px`:typeof n=="string"?n:String(n);r.push(`${o}:${a}`)}return`:root{${r.join(";")}}`}function tq(t,e,r,i){return r==="preserve-token"?{nodes:t}:r==="resolved"?{nodes:eq(t,e,i)}:!e||Object.keys(e).length===0?{nodes:t}:{nodes:t.map(s=>mXt(s)),cssRootStyle:QK(e,i)}}ds=function(t,e,r){if(e==null||!Pv(t))return t;const i=t.slice(1),s=e[i];return s?DL(s,r):t};function PL(t,e,r){return t.map(i=>{const s=Object.assign({},i);if(typeof s.value=="string"&&(s.value=ds(s.value,e,r)),s.type==="pattern"&&typeof s.value=="string"&&(s.value=ds(s.value,e,r)),typeof s.opacity=="string"&&(s.opacity=ds(s.opacity,e,r)),s.type==="image"){const o=i;o.objectFit!==void 0&&(s.objectFit=o.objectFit),o.objectPosition!==void 0&&(s.objectPosition=o.objectPosition)}return s})}function eq(t,e,r){return!e||Object.keys(e).length===0?t:t.map(i=>{let s=!1;const o=i,n=Object.assign({},o);for(const a of aj){if(!Object.prototype.hasOwnProperty.call(i,a))continue;const l=o[a];if(a==="fills"){const{next:h,changed:u}=dXt(l,e,r);u&&(n[a]=h,s=!0);continue}if(a==="strokes"){const{next:h,changed:u}=fXt(l,e,r);u&&(n[a]=h,s=!0);continue}const c=ds(l,e,r);c!==l&&(n[a]=c,s=!0)}return s?n:i})}var yXt=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};const vXt="__";function tft(t,e){if(e==null||typeof e!="object")return;const r=Object.assign({},e);delete r.id,delete r.type,delete r.parentId,delete r.ref,delete r.reusable,delete r.descendants,Object.assign(t,r)}function lj(t,e){const r=new Map;for(const i of e??[])r.set(i.id,i);for(const i of t)r.set(i.id,i);return[...r.values()]}function _Xt(t,e){const r=new Set([t]);let i=!0;for(;i;){i=!1;for(const s of e)s.parentId&&r.has(s.parentId)&&!r.has(s.id)&&(r.add(s.id),i=!0)}return r}function eft(t,e,r){return r===t?e:`${e}${vXt}${r}`}function FL(t,e){const r=new Map(e.map(s=>[s.id,s])),i=[];for(const s of t){if(s.type!=="ref"){i.push(s);continue}const o=s,n=o.ref;if(n==null||n==="")throw new Error(`ref node "${o.id}" must set "ref" to a template id`);if(n===o.id)throw new Error(`ref node "${o.id}" cannot reference itself`);const a=r.get(n);if(!(a!=null&&a.type))throw new Error(`ref node "${o.id}": template id "${n}" not found in the graph`);if(a.type==="ref")throw new Error(`ref node "${o.id}": template "${n}" is also a ref; nested ref expansion is not supported yet`);const l=o.id,c=_Xt(n,e),h=o,{type:u,ref:d,descendants:f}=h,g=yXt(h,["type","ref","descendants"]);
6867for(const p of c){const m=r.get(p);if(!m)continue;const v=Object.assign({},m),b=eft(n,l,p);v.id=b,m.parentId!=null&&c.has(m.parentId)&&(v.parentId=eft(n,l,m.parentId)),p===n?(Object.assign(v,g,{id:l,type:a.type,parentId:o.parentId}),v.ref=void 0,"reusable"in v&&delete v.reusable,f&&tft(v,f[n]),delete v.descendants):f&&tft(v,f[p]),i.push(v)}}return i}function rft(t,e){const r=lj(t,e);return FL(t,r)}function bXt(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Za-z])([0-9])/g,"$1 $2").replace(/([0-9])([A-Za-z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean)}function rq(t){const e=bXt(t);return e.length===0?"":e.map((r,i)=>i===0?r.toLowerCase():r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join("")}function NL(t){const e=rq(t);return e?e.charAt(0).toUpperCase()+e.slice(1):""}function wXt(t,e){const r=NL(t??"");if(r&&/^[A-Za-z]/.test(r))return r;const i=NL(e)||"Component";return/^[A-Za-z]/.test(i)?i:`C${i}`}function EXt(t,e){const r=rq(t??"");if(r&&/^[A-Za-z]/.test(r))return r;const i=rq(e)||"prop";return/^[A-Za-z]/.test(i)?i:`p${NL(i)}`}const kL={content:"text",fontSize:"fontSize",cornerRadius:"borderRadius"};function v2(t){return Array.isArray(t)?t:[]}function ju(t){if(!(t==null||t===""))return typeof t=="string"&&Pv(t)?{token:qy(t)}:{literal:t}}function cj(t){if(!(!t||t.length===0)){for(const e of t)if(e.enabled!==!1&&e.type==="solid")return ju(e.value)}}function AXt(t){if(t){for(const e of t)if(e.enabled!==!1&&e.type==="image")return ju(e.value)}}function ift(t){if(t!==void 0){if(typeof t=="number")return[t,t,t,t];if(t.length===2)return[t[0],t[1],t[0],t[1]];if(t.length===4)return[t[0],t[1],t[2],t[3]];if(t.length===1)return[t[0],t[0],t[0],t[0]]}}function sft(t){switch(t.type){case"text":return"text";case"iconfont":return"icon";case"g":return"container";case"rect":case"rough-rect":return v2(t.fills).some(e=>e.type==="image"&&e.enabled!==!1)?"image":"container";default:return"shape"}}function xXt(t,e){var r,i,s,o;const n={};t.display==="flex"&&(n.display="flex",t.flexDirection&&(n.flexDirection=t.flexDirection),t.alignItems&&(n.alignItems=t.alignItems),t.justifyContent&&(n.justifyContent=t.justifyContent),t.flexWrap&&t.flexWrap!=="nowrap"&&(n.flexWrap=t.flexWrap),typeof t.gap=="number"&&(n.gap=t.gap),typeof t.rowGap=="number"&&(n.rowGap=t.rowGap),typeof t.columnGap=="number"&&(n.columnGap=t.columnGap
6867)),typeof t.flexGrow=="number"&&t.flexGrow&&(n.flexGrow=t.flexGrow),typeof t.flexShrink=="number"&&(n.flexShrink=t.flexShrink);const a=ift(t.padding);a&&(n.padding=a);const l=ift(t.margin);l&&(n.margin=l),e!=="text"&&(typeof t.width=="number"&&(n.width=t.width),typeof t.height=="number"&&(n.height=t.height)),typeof t.minWidth=="number"&&(n.minWidth=t.minWidth),typeof t.maxWidth=="number"&&(n.maxWidth=t.maxWidth),typeof t.minHeight=="number"&&(n.minHeight=t.minHeight),typeof t.maxHeight=="number"&&(n.maxHeight=t.maxHeight);const c=v2(t.fills),h=cj(c);e==="text"||e==="icon"?h&&(n.color=h):e!=="image"&&h&&(n.backgroundColor=h);const u=v2(t.strokes),d=(r=cj(u))!==null&&r!==void 0?r:ju(t.stroke);if(typeof t.strokeWidth=="number"&&t.strokeWidth>0&&(n.borderWidth={literal:t.strokeWidth},d&&(n.borderColor=d)),t.cornerRadius!==void 0){const f=ju(t.cornerRadius);f&&(n.borderRadius=f)}if(typeof t.dropShadowColor=="string"||typeof t.dropShadowBlurRadius=="number"){const f=ju(t.dropShadowColor);f&&(n.boxShadow={offsetX:(i=t.dropShadowOffsetX)!==null&&i!==void 0?i:0,offsetY:(s=t.dropShadowOffsetY)!==null&&s!==void 0?s:0,blur:(o=t.dropShadowBlurRadius)!==null&&o!==void 0?o:0,color:f})}if(typeof t.opacity=="number"&&t.opacity!==1&&(n.opacity=t.opacity),e==="text"){const f=ju(t.fontSize);f&&(n.fontSize=f),t.fontWeight!==void 0&&(n.fontWeight=t.fontWeight),t.fontStyle&&t.fontStyle!=="normal"&&(n.fontStyle=t.fontStyle),typeof t.fontFamily=="string"&&(n.fontFamily=t.fontFamily),t.textAlign&&(n.textAlign=t.textAlign);const g=ju(t.letterSpacing);g&&(n.letterSpacing=g);const p=ju(t.lineHeight);p&&(n.lineHeight=p)}return n}function iq(t){return[...t].sort((e,r)=>{var i,s;return((i=e.zIndex)!==null&&i!==void 0?i:0)-((s=r.zIndex)!==null&&s!==void 0?s:0)})}function hj(t,e,r){var i,s,o,n,a;const l=sft(t),c=xXt(t,l),h={role:l,id:t.id,name:typeof t.name=="string"?t.name:void 0,style:c,children:[]};if(l==="text"){const d=t.content;h.text=(i=ju(d))!==null&&i!==void 0?i:{literal:""}}else if(l==="icon"){const d=t;h.icon={name:(s=ju(d.iconFontName))!==null&&s!==void 0?s:{literal:""},family:typeof d.iconFontFamily=="string"?d.iconFontFamily:"lucide"}}else l==="image"&&(h.image=AXt(v2(t.fills)));if(r&&r.size)for(const d of r){const[f,g]=d.split("::");if(f!==t.id)continue;const p=(o=kL[g])!==null&&o!==void 0?o:oft(g,l);p&&(h.bindings=(n=h.bindings)!==null&&n!==void 0?n:[],h.bindings.push({target:p,prop:sq(t,g)}))}const u=iq((a=e.childrenByParent.get(t.id))!==null&&a!==void 0?a:[]);return h.children=u.map(d=>hj(d,e,r)),h}function oft(t,e){if(t==="fills"||t==="fill")return e==="text"||e==="icon"?"color":"backgroundColor"}function sq(t,e){const r=EXt(typeof t.name=="string"?t.name:void 0,t.id);return e==="content"?r:`${r}${e.charAt(0).toUpperCase()}${e.slice(1)}`}function SXt(t,e){var r;if(t){if(e==="fills"||e==="fill"){const i=v2(t.fills);return(r=cj(i))!==null&&r!==void 0?r:ju(t.fill)}return ju(t[e])}}function TXt(t,e,r,i){var s,o,n;const a=i.get(e);if(a)return r==="content"?(s=ju(a.content))!==null&&s!==void 0?s:{literal:""}:r==="fills"||r==="fill"?(o=cj(v2(a.fills)))!==null&&o!==void 0?o:{literal:"#000000"}:(n=ju(a[r]))!==null&&n!==void 0?n:{literal:0}}function RXt(t,e){const r=new Set([t]);let i=!0;for(;i;){i=!1;for(const s of e.values())s.parentId&&r.has(s.parentId)&&!r.has(s.id)&&(r.add(s.id),i=!0)}return r}function nft(t,e={}){var r,i,s;const o=(r=e.variablesMode)!==null&&r!==void 0?r:"resolved",n=(i=e.componentStructure)!==null&&i!==void 0?i:"preserve",a=(s=e.variables)!==null&&s!==void 0?s:{},l=e.themeMode;let c=t;if(o==="resolved"&&(c=eq(t,a,l)),n==="flatten"){const h=FL(c,c);return{components:[],roots:CXt(h),variables:a,themeMode:l,variablesMode:o}}return MXt(c,a,l,o)}function CXt(t){var e;const r=new Map(t.map(o=>[o.id,o])),i=new Map;for(const o of t){const n=(e=i.get(o.parentId))!==null&&e!==void 0?e:[];n.push(o),i.set(o.parentId,n)}const s={childrenByParent:i};return iq(t.filter(o=>!o.parentId||!r.has(o.parentId))).filter(o=>!o.reusable).map(o=>hj(o,s))}function MXt(t,e,r,i){var s,o,n,a;const l=new Map(t.map(b=>[b.id,b])),c=new Map;for(const b of t){const y=(s=c.get(b.parentId))!==null&&s!==void 0?s:[];y.push(b),c.set(b.parentId,y)}const h=new Map;for(const b of t){if(b.type!=="ref")continue;const y=b,_=y.ref;if(!_||!l.has(_))continue;const w=(o=h.get(_))!==null&&o!==void 0?o:new Set;for(const A of Object.keys(b))["id","type","parentId","ref","reusable","descendants"].includes(A)||(A in kL||A==="fills"||A==="fill")&&w.add(`${_}::${A}`);const E=(n=y.descendants)!==null&&n!==void 0?n:{};
6867for(const[A,x]of Object.entries(E))for(const S of Object.keys(x))(S in kL||S==="fills"||S==="fill")&&w.add(`${A}::${S}`);h.set(_,w)}const u={childrenByParent:c},d=[],f=new Set,g=new Map;for(const b of t){if(!b.reusable)continue;let y=wXt(typeof b.name=="string"?b.name:void 0,b.id);for(;f.has(y);)y=`${y}_`;f.add(y),g.set(b.id,y);const _=(a=h.get(b.id))!==null&&a!==void 0?a:new Set,w=hj(b,u,_),E=BXt(b,_,l);d.push({name:y,templateId:b.id,root:w,props:E})}const p=new Set;for(const b of t)if(b.reusable)for(const y of RXt(b.id,l))p.add(y);const m=iq(t.filter(b=>!(b.parentId&&l.has(b.parentId)||b.reusable))),v=[];for(const b of m){if(b.type==="ref"){const y=OXt(b,g,l);if(y){v.push(y);continue}}p.has(b.id)||v.push(hj(b,u))}return{components:d,roots:v,variables:e,themeMode:r,variablesMode:i}}function BXt(t,e,r){var i,s;const o=[],n=new Set;for(const a of e){const[l,c]=a.split("::"),h=r.get(l);if(!h)continue;const u=sft(h),d=(i=kL[c])!==null&&i!==void 0?i:oft(c,u);if(!d)continue;const f=sq(h,c);n.has(f)||(n.add(f),o.push({name:f,target:d,defaultValue:(s=TXt(t,l,c,r))!==null&&s!==void 0?s:{literal:""}}))}return o}function OXt(t,e,r){var i;const s=e.get(t.ref);if(!s)return;const o={},n=(i=t.descendants)!==null&&i!==void 0?i:{},a=r.get(t.ref),l={},c=t;for(const u of Object.keys(t))["id","type","parentId","ref","reusable","descendants"].includes(u)||(l[u]=c[u]);const h=(u,d)=>{const f=r.get(u);for(const g of Object.keys(d)){if(!(g in kL)&&g!=="fills"&&g!=="fill")continue;const p=SXt(d,g);p&&f&&(o[sq(f,g)]=p)}};a&&h(t.ref,l);for(const[u,d]of Object.entries(n))h(u,d);return{role:"container",id:t.id,name:typeof t.name=="string"?t.name:void 0,style:{},children:[],instanceOf:s,props:o}}Zt=function(t){return Number.isInteger(t)?t.toString():t.toFixed(2)},ip=function(t){return t.map(([e,r])=>`${Zt(e)},${Zt(r)}`).join(" ")};function oq(t){return t.map(({x:e,y:r,radius:i})=>`${Zt(e)},${Zt(r)},${Zt(i)}`).join(" ")}function Yo(t,e,r=!1){if(t.token)return e==="css-var"?`var(${y2(t.token)})`:`$${t.token}`;const i=t.literal;return typeof i=="number"?r?`${Zt(i)}px`:Zt(i):String(i??"")}function aft(t){const[e,r,i,s]=t;return e===r&&r===i&&i===s?`${Zt(e)}px`:e===i&&r===s?`${Zt(e)}px ${Zt(r)}px`:`${Zt(e)}px ${Zt(r)}px ${Zt(i)}px ${Zt(s)}px`}function IXt(t,e){const r=[],i=(s,o)=>r.push([s,o]);if(t.display==="flex"&&(i("display","flex"),t.flexDirection&&i("flex-direction",t.flexDirection),t.alignItems&&i("align-items",t.alignItems),t.justifyContent&&i("justify-content",t.justifyContent),t.flexWrap&&i("flex-wrap",t.flexWrap),t.gap!==void 0&&i("gap",`${Zt(t.gap)}px`),t.rowGap!==void 0&&i("row-gap",`${Zt(t.rowGap)}px`),t.columnGap!==void 0&&i("column-gap",`${Zt(t.columnGap)}px`)),t.flexGrow!==void 0&&i("flex-grow",Zt(t.flexGrow)),t.flexShrink!==void 0&&i("flex-shrink",Zt(t.flexShrink)),t.padding&&i("padding",aft(t.padding)),t.margin&&i("margin",aft(t.margin)),t.width!==void 0&&i("width",`${Zt(t.width)}px`),t.height!==void 0&&i("height",`${Zt(t.height)}px`),t.minWidth!==void 0&&i("min-width",`${Zt(t.minWidth)}px`),t.maxWidth!==void 0&&i("max-width",`${Zt(t.maxWidth)}px`),t.minHeight!==void 0&&i("min-height",`${Zt(t.minHeight)}px`),t.maxHeight!==void 0&&i("max-height",`${Zt(t.maxHeight)}px`),t.backgroundColor&&i("background-color",Yo(t.backgroundColor,e)),t.borderRadius&&i("border-radius",Yo(t.borderRadius,e,!0)),t.borderWidth){const s=Yo(t.borderWidth,e,!0),o=t.borderColor?Yo(t.borderColor,e):"#000000";i("border",`${s} solid ${o}`)}if(t.boxShadow){const s=t.boxShadow;i("box-shadow",`${Zt(s.offsetX)}px ${Zt(s.offsetY)}px ${Zt(s.blur)}px ${Yo(s.color,e)}`)}return t.opacity!==void 0&&i("opacity",Zt(t.opacity)),t.color&&i("color",Yo(t.color,e)),t.fontSize&&i("font-size",Yo(t.fontSize,e,!0)),t.fontWeight!==void 0&&i("font-weight",String(t.fontWeight)),t.fontStyle&&i("font-style",t.fontStyle),t.fontFamily&&i("font-family",t.fontFamily),t.textAlign&&i("text-align",t.textAlign),t.letterSpacing&&i("letter-spacing",Yo(t.letterSpacing,e,!0)),t.lineHeight&&i("line-height",Yo(t.lineHeight,e,!0)),r}const DXt={text:"content",backgroundColor:"backgroundColor",color:"color",fontSize:"fontSize",borderRadius:"borderRadius"};function _2(t,e){return!!(t!=null&&t.token)&&e==="preserve-token"}function ay(t){return t.replace(/ /g,"_")}function PXt(t,e,r){const i=[],s=[],o=(n,a)=>s.push([n,JSON.stringify(Yo(a,e))]);if(t.display==="flex"){switch(i.push("flex"),t.flexDirection){case"row-reverse":i.push("flex-row-reverse");break;case"column":i.push("flex-col");break;case"column-reverse":i.push("flex-col-reverse");break;case"row":i.push("flex-row");break}const n={center:"items-center","flex-start":"items-start","flex-end":"items-end",stretch:"items-stretch",baseline:"items-baseline"};t.alignItems&&n[t.alignItems]&&i.push(n[t.alignItems]);const a={center:"justify-center","flex-start":"justify-start","flex-end":"justify-end","space-between":"justify-between","space-around":"justify-around","space-evenly":"justify-evenly"};t.justifyContent&&a[t.justifyContent]&&i.push(a[t.justifyContent]),t.flexWrap==="wrap"?i.push("flex-wrap"):t.flexWrap==="wrap-reverse"&&i.push("flex-wrap-reverse"),t.gap!==void 0&&i.push(`gap-[${Zt(t.gap)}px]`),t.rowGap!==void 0&&i.push(`gap-y-[${Zt(t.rowGap)}
6867px]`),t.columnGap!==void 0&&i.push(`gap-x-[${Zt(t.columnGap)}px]`)}if(t.flexGrow!==void 0&&i.push(t.flexGrow===1?"grow":`grow-[${t.flexGrow}]`),t.flexShrink===0&&i.push("shrink-0"),lft(i,"p",t.padding),lft(i,"m",t.margin),t.width!==void 0&&i.push(`w-[${Zt(t.width)}px]`),t.height!==void 0&&i.push(`h-[${Zt(t.height)}px]`),t.minWidth!==void 0&&i.push(`min-w-[${Zt(t.minWidth)}px]`),t.maxWidth!==void 0&&i.push(`max-w-[${Zt(t.maxWidth)}px]`),t.minHeight!==void 0&&i.push(`min-h-[${Zt(t.minHeight)}px]`),t.maxHeight!==void 0&&i.push(`max-h-[${Zt(t.maxHeight)}px]`),t.backgroundColor&&!r.has("backgroundColor")&&(_2(t.backgroundColor,e)?o("backgroundColor",t.backgroundColor):i.push(`bg-[${ay(Yo(t.backgroundColor,e))}]`)),t.borderRadius&&!r.has("borderRadius")&&(_2(t.borderRadius,e)?o("borderRadius",t.borderRadius):i.push(`rounded-[${ay(Yo(t.borderRadius,e,!0))}]`)),t.borderWidth&&(i.push(`border-[${ay(Yo(t.borderWidth,e,!0))}]`),t.borderColor&&(_2(t.borderColor,e)?o("borderColor",t.borderColor):i.push(`border-[${ay(Yo(t.borderColor,e))}]`))),t.boxShadow){const n=t.boxShadow;_2(n.color,e)?s.push(["boxShadow",JSON.stringify(`${Zt(n.offsetX)}px ${Zt(n.offsetY)}px ${Zt(n.blur)}px ${Yo(n.color,e)}`)]):i.push(`shadow-[${Zt(n.offsetX)}px_${Zt(n.offsetY)}px_${Zt(n.blur)}px_${ay(Yo(n.color,e))}]`)}return t.opacity!==void 0&&i.push(`opacity-[${Zt(t.opacity)}]`),t.color&&!r.has("color")&&(_2(t.color,e)?o("color",t.color):i.push(`text-[${ay(Yo(t.color,e))}]`)),t.fontSize&&!r.has("fontSize")&&(_2(t.fontSize,e)?o("fontSize",t.fontSize):i.push(`text-[${ay(Yo(t.fontSize,e,!0))}]`)),t.fontWeight!==void 0&&i.push(`font-[${t.fontWeight}]`),t.fontStyle==="italic"&&i.push("italic"),t.fontFamily&&i.push(`font-[${ay(t.fontFamily)}]`),t.textAlign&&i.push(`text-${t.textAlign}`),t.letterSpacing&&i.push(`tracking-[${ay(Yo(t.letterSpacing,e,!0))}]`),t.lineHeight&&i.push(`leading-[${ay(Yo(t.lineHeight,e,!0))}]`),{classes:i,inline:s}}function lft(t,e,r){if(!r)return;const[i,s,o,n]=r;if(i===s&&s===o&&o===n){t.push(`${e}-[${Zt(i)}px]`);return}if(i===o&&s===n){t.push(`${e}y-[${Zt(i)}
6867px]`),t.push(`${e}x-[${Zt(s)}px]`);return}t.push(`${e}t-[${Zt(i)}px]`),t.push(`${e}r-[${Zt(s)}px]`),t.push(`${e}b-[${Zt(o)}px]`),t.push(`${e}l-[${Zt(n)}px]`)}function FXt(t,e){var r,i;const s=new Set;for(const c of(r=t.bindings)!==null&&r!==void 0?r:[])c.target!=="text"&&s.add(c.target);const{classes:o,inline:n}=PXt(t.style,e.mode,s);for(const c of(i=t.bindings)!==null&&i!==void 0?i:[])c.target!=="text"&&n.push([DXt[c.target],c.prop]);const a=o.length?` className="${o.join(" ")}"`:"";let l="";return n.length&&(l=` style={{ ${n.map(([c,h])=>`${c}: ${h}`).join(", ")} }}`),{className:a,styleExpr:l}}function cft(t,e){var r,i;const s=((r=t.bindings)!==null&&r!==void 0?r:[]).find(n=>n.target==="text");if(s)return`{${s.prop}}`;const o=t.text;return o?o.token?hft(Yo(o,e.mode)):hft(String((i=o.literal)!==null&&i!==void 0?i:"")):""}function hft(t){return t.replace(/[{}<>&]/g,e=>`{'${e}'}`)}function uj(t,e,r){var i,s;const o=e.indent.repeat(r);if(t.instanceOf){const d=Object.entries((i=t.props)!==null&&i!==void 0?i:{}).map(([f,g])=>{const p=Yo(g,e.mode);return typeof g.literal=="number"?`${f}={${p}}`:`${f}=${JSON.stringify(p)}`}).join(" ");return`${o}<${t.instanceOf}${d?" "+d:""} />`}const{className:n,styleExpr:a}=FXt(t,e);if(t.role==="icon"&&t.icon)return NXt(t,e,o,n,a);if(t.role==="image"){const d=t.image?Yo(t.image,e.mode):"";return`${o}<img src=${JSON.stringify(d)} alt=${JSON.stringify((s=t.name)!==null&&s!==void 0?s:"")}${n}${a} />`}if(t.role==="text"&&t.children.length===0)return`${o}<span${n}${a}>${cft(t,e)}</span>`;const l="div",c=cft(t,e);if(t.children.length===0)return`${o}<${l}${n}${a}>${c}</${l}>`;const h=t.children.map(d=>uj(d,e,r+1)).join(` 6868`),u=c?`${e.indent.repeat(r+1)}${c} 6869`:"";return`${o}<${l}${n}${a}> 6870${u}${h} 6871${o}</${l}>`}function NXt(t,e,r,i,s){var o;const n=t.icon,a=n.name.literal?String(n.name.literal):"",l=(o=t.style.width)!==null&&o!==void 0?o:t.style.height,c=typeof l=="number"?` size={${Zt(l)}}`:"";if(n.family==="lucide"){const h=NL(a)||"HelpCircle";return e.lucideIcons.add(h),`${r}<${h}${c}${i}${s} />`}return e.usesIconify=!0,`${r}<Icon icon=${JSON.stringify(`${n.family}:${a}`)}${i}${s} />`}function kXt(t,e){const r=t.props.map(n=>{const a=n.target==="fontSize"?"number":"string";return`${e.indent}${n.name}?: ${a};`}).join(` 6872`),i=t.props.map(n=>{const a=Yo(n.defaultValue,e.mode);return typeof n.defaultValue.literal=="number"?`${n.name} = ${a}`:`${n.name} = ${JSON.stringify(a)}`}).join(", "),s=t.props.length?`interface ${t.name}Props { 6873${r} 6874} 6875 6876export function ${t.name}({ ${i} }: ${t.name}Props) {`:`export function ${t.name}() {`,o=uj(t.root,e,2);return`${s} 6877${e.indent}return ( 6878${o} 6879${e.indent}); 6880}`}function uft(t,e=" ",r="Design"){const i={mode:t.variablesMode,indent:e,lucideIcons:new Set,usesIconify:!1},s=t.components.map(h=>kXt(h,i)),o=t.roots.map(h=>uj(h,i,2)).join(` 6881`),n=t.roots.length===1?o:`${e.repeat(2)}<> 6882${t.roots.map(h=>uj(h,i,3)).join(` 6883`)} 6884${e.repeat(2)}</>`,a=`export function ${NL(r)||"Design"}() { 6885${e}return ( 6886${n} 6887${e}); 6888}`,l=[];i.lucideIcons.size&&l.push(`import { ${[...i.lucideIcons].sort().join(", ")} } from 'lucide-react';`),i.usesIconify&&l.push("import { Icon } from '@iconify/react';");const c=[];return l.length&&c.push(l.join(` 6889`)),s.length&&c.push(s.join(` 6890 6891`)),c.push(a),c.join(` 6892 6893`)+` 6894`}function LXt(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function dj(t){return t.replace(/&/g,"&").replace(/"/g,""")}function UXt(t,e){const r=IXt(t.style,e.mode);if(!r.length)return"";const i=r.map(([s,o])=>`${s}: ${o}`).join("; ");return` style="${dj(i)}"`}function dft(t,e,r){var i;const s=e.indent.repeat(r),o=UXt(t,e);if(t.role==="icon"&&t.icon){const c=t.icon.name.literal?String(t.icon.name.literal):"";return`${s}<iconify-icon icon="${dj(`${t.icon.family}:${c}`)}"${o}></iconify-icon>`}if(t.role==="image"){const c=t.image?Yo(t.image,e.mode):"";return`${s}<img src="${dj(c)}" alt="${dj((i=t.name)!==null&&i!==void 0?i:"")}"${o} />`}const n=t.text?LXt(t.text.literal!==void 0?String(t.text.literal):Yo(t.text,e.mode)):"";if(t.role==="text"&&t.children.length===0)return`${s}<span${o}>${n}</span>`;if(t.children.length===0)return`${s}<div${o}>${n}</div>`;const a=t.children.map(c=>dft(c,e,r+1)).join(` 6895`),l=n?`${e.indent.repeat(r+1)}${n} 6896`:"";return`${s}<div${o}> 6897${l}${a} 6898${s}</div>`}
6898function fft(t,e=" "){const r={mode:t.variablesMode,indent:e},i=[];if(t.variablesMode==="css-var"&&Object.keys(t.variables).length){const s=QK(t.variables,t.themeMode);i.push(`<style> 6899${e}${s} 6900</style>`)}for(const s of t.roots)i.push(dft(s,r,0));return i.join(` 6901`)+` 6902`}function pft(t,e={}){var r,i,s,o;const n=(r=e.framework)!==null&&r!==void 0?r:"react-tailwind",a=(i=e.indent)!==null&&i!==void 0?i:" ",l=(s=e.componentStructure)!==null&&s!==void 0?s:n==="html-css"?"flatten":"preserve",c=nft(t,Object.assign(Object.assign({},e),{componentStructure:l}));return n==="html-css"?fft(c,a):uft(c,a,(o=e.componentName)!==null&&o!==void 0?o:"Design")}var nq=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Ce=class{constructor(t){t&&(this.layers=t)}},nq([P({type:$.object,default:()=>[]})],Ce.prototype,"layers",void 0),Fs=class{constructor(t){t&&(this.layers=t)}},nq([P({type:$.object,default:()=>[]})],Fs.prototype,"layers",void 0),yh=class{constructor(t){this.value=t}},nq([P.object],yh.prototype,"value",void 0),JU=class{};function Dd(t){return t.enabled!==!1}function gft(t){return t!=null&&t.length?t.filter(Dd):[]}function Nh(t){return t.has(Ce)?gft(t.read(Ce).layers):[]}function $0(t){if(!t.has(Ce))return null;const e=t.read(Ce).layers;if(!e||e.length<2)return null;const r=gft(e);return r.length<2?null:r}function fj(t){var e;const r=Nh(t);return r.length===1&&(e=r[0])!==null&&e!==void 0?e:null}function aw(t){return t.some(e=>e.type==="gradient"||e.type==="image"||e.type==="pattern")}function LL(t){return t.some(e=>{const r=e.blendMode;return r!=null&&r!=="normal"})}function Cg(t){if(t==null||t==="")return 1;if(typeof t=="number")return Number.isNaN(t)?1:Math.min(1,Math.max(0,t));const e=parseFloat(String(t));return Number.isFinite(e)?Math.min(1,Math.max(0,e)):1}function mft(t){if(!(t!=null&&t.length))return null;for(const e of t)if(Dd(e)&&e.type==="solid")return e.value;return null}function Hx(t){return mft(Nh(t))}function pj(t){const e=Nh(t)[0];return e?Cg(e.opacity):1}function GXt(t){for(const e of Nh(t))if(e.type==="gradient")return e.value;return null}function WXt(t){if(!t.has(Ce))return!0;const e=Nh(t);return e.length===0?!0:e.length!==1?!1:e[0].type==="solid"}var ly=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Gt=class{constructor(t){Object.assign(this,t)}},ly([P({type:$.float32,default:1})],Gt.prototype,"width",void 0),ly([P({type:$.staticString(["center","inner","outer"]),default:"center"})],Gt.prototype,"alignment",void 0),ly([P({type:$.staticString(["butt","round","square"]),default:"butt"})],Gt.prototype,"linecap",void 0),ly([P({type:$.staticString(["miter","round","bevel"]),default:"miter"})],Gt.prototype,"linejoin",void 0),ly([P({type:$.float32,default:4})],Gt.prototype,"miterlimit",void 0),ly([P({type:$.vector($.float32,2),default:[0,0]})],Gt.prototype,"dasharray",void 0),ly([P({type:$.float32,default:0})],Gt.prototype,"dashoffset",void 0),ly([P({type:$.staticString(["none","square","round"]),default:"none"})],Gt.prototype,"dashcap",void 0),ly([P({type:$.dynamicString(200),default:""})],Gt.prototype,"colorVariableRef",void 0),ly([P({type:$.dynamicString(200),default:""})],Gt.prototype,"widthVariableRef",void 0);function jXt(t){return t!=null&&t.length?t.filter(Dd):[]}function UL(t){return t.has(Fs)?jXt(t.read(Fs).layers):[]}function XXt(t){var e;if(!(t!=null&&t.length))return null;for(const r of t)if(r.type==="solid"&&r.enabled!==!1){const i=String((e=r.value)!==null&&e!==void 0?e:"").trim();if(i!==""&&i.toLowerCase()!=="none")return r.value}return null}function zXt(t){return XXt(UL(t))}function VXt(t){const e=UL(t)[0];if(!e)return null;if(e.type==="solid"||e.type==="gradient"){const r=e.value;return typeof r=="string"?r:null}return null}
6902function H0(t){return zXt(t)}function kh(t){for(const e of UL(t))if(e.type==="gradient"){const r=e.value;return typeof r=="string"?r:null}return null}function yft(t){return t.has(Gt)&&t.read(Gt).width>0}function vft(t){var e;const r=UL(t)[0];if(!r)return!1;if(r.type==="solid"){const i=String((e=r.value)!==null&&e!==void 0?e:"").trim().toLowerCase();return i!==""&&i!=="none"}return!0}function _ft(t){return yft(t)&&vft(t)}function b2(t){if(!t.has(Fs))return{strokeColorAlphaMul:1,strokeUniformOpacityMul:1};const e=UL(t)[0];if(!e)return{strokeColorAlphaMul:1,strokeUniformOpacityMul:1};const r=Cg(e.opacity);return kh(t)!=null?{strokeColorAlphaMul:1,strokeUniformOpacityMul:r}:{strokeColorAlphaMul:r,strokeUniformOpacityMul:1}}function YXt(t){return Hx(t)??void 0}function $Xt(t){if(t.has(Gt)){const r=t.read(Gt).colorVariableRef;if(r)return`$${r}`}return VXt(t)??void 0}function HXt(t){if(!t.has(Gt))return;const e=t.read(Gt);return e.widthVariableRef?`$${e.widthVariableRef}`:e.width}function KXt(t){if(!t.has(Yt))return;const e=t.read(Yt);return e.fontSizeVariableRef?`$${e.fontSizeVariableRef}`:e.fontSize}Dv=function(t){return t&&!!t.image};var K;(function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411
6902]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.ALWAYS=519]="ALWAYS",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.GEQUAL=518]="GEQUAL",t[t.NOTEQUAL=517]="NOTEQUAL
vendor: 17,522 bytes, line 6902
6902",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.
6902VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.UNSIGNED_INT_24_8_WEBGL=34042]="UNSIGNED_INT_24_8_WEBGL",t[t.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",t[t.RGBA32F_EXT=34836]="RGBA32F_EXT",t[t.RGB32F_EXT=34837]="RGB32F_EXT",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT",t[t.UNSIGNED_NORMALIZED_EXT=35863]="UNSIGNED_NORMALIZED_EXT",t[t.MIN_EXT=32775]="MIN_EXT",t[t.MAX_EXT=32776]="MAX_EXT",t[t.SRGB_EXT=35904]="SRGB_EXT",t[t.SRGB_ALPHA_EXT=35906]="SRGB_ALPHA_EXT",t[t.SRGB8_ALPHA8_EXT=35907]="SRGB8_ALPHA8_EXT",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT_OES=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT_OES",t[t.COLOR_ATTACHMENT0_WEBGL=36064]="COLOR_ATTACHMENT0_WEBGL",t[t.COLOR_ATTACHMENT1_WEBGL=36065]="COLOR_ATTACHMENT1_WEBGL",t[t.COLOR_ATTACHMENT2_WEBGL=36066]="COLOR_ATTACHMENT2_WEBGL",t[t.COLOR_ATTACHMENT3_WEBGL=36067]="COLOR_ATTACHMENT3_WEBGL",t[t.COLOR_ATTACHMENT4_WEBGL=36068]="COLOR_ATTACHMENT4_WEBGL",t[t.COLOR_ATTACHMENT5_WEBGL=36069]="COLOR_ATTACHMENT5_WEBGL",t[t.COLOR_ATTACHMENT6_WEBGL=36070]="COLOR_ATTACHMENT6_WEBGL",t[t.COLOR_ATTACHMENT7_WEBGL=36071]="COLOR_ATTACHMENT7_WEBGL",t[t.COLOR_ATTACHMENT8_WEBGL=36072]="COLOR_ATTACHMENT8_WEBGL",t[t.COLOR_ATTACHMENT9_WEBGL=36073]="COLOR_ATTACHMENT9_WEBGL",t[t.COLOR_ATTACHMENT10_WEBGL=36074]="COLOR_ATTACHMENT10_WEBGL",t[t.COLOR_ATTACHMENT11_WEBGL=36075]="COLOR_ATTACHMENT11_WEBGL",t[t.COLOR_ATTACHMENT12_WEBGL=36076]="COLOR_ATTACHMENT12_WEBGL",t[t.COLOR_ATTACHMENT13_WEBGL=36077]="COLOR_ATTACHMENT13_WEBGL",t[t.COLOR_ATTACHMENT14_WEBGL=36078]="COLOR_ATTACHMENT14_WEBGL",t[t.COLOR_ATTACHMENT15_WEBGL=36079]="COLOR_ATTACHMENT15_WEBGL",t[t.DRAW_BUFFER0_WEBGL=34853]="DRAW_BUFFER0_WEBGL",t[t.DRAW_BUFFER1_WEBGL=34854]="DRAW_BUFFER1_WEBGL",t[t.DRAW_BUFFER2_WEBGL=34855]="DRAW_BUFFER2_WEBGL",t[t.DRAW_BUFFER3_WEBGL=34856]="DRAW_BUFFER3_WEBGL",t[t.DRAW_BUFFER4_WEBGL=34857]="DRAW_BUFFER4_WEBGL",t[t.DRAW_BUFFER5_WEBGL=34858]="DRAW_BUFFER5_WEBGL",t[t.DRAW_BUFFER6_WEBGL=34859]="DRAW_BUFFER6_WEBGL",t[t.DRAW_BUFFER7_WEBGL=34860]="DRAW_BUFFER7_WEBGL",t[t.DRAW_BUFFER8_WEBGL=34861]="DRAW_BUFFER8_WEBGL",t[t.DRAW_BUFFER9_WEBGL=34862]="DRAW_BUFFER9_WEBGL",t[t.DRAW_BUFFER10_WEBGL=34863]="DRAW_BUFFER10_WEBGL",t[t.DRAW_BUFFER11_WEBGL=34864]="DRAW_BUFFER11_WEBGL",t[t.DRAW_BUFFER12_WEBGL=34865]="DRAW_BUFFER12_WEBGL",t[t.DRAW_BUFFER13_WEBGL=34866]="DRAW_BUFFER13_WEBGL",t[t.DRAW_BUFFER14_WEBGL=34867]="DRAW_BUFFER14_WEBGL",t[t.DRAW_BUFFER15_WEBGL=34868]="DRAW_BUFFER15_WEBGL",t[t.MAX_COLOR_ATTACHMENTS_WEBGL=36063]="MAX_COLOR_ATTACHMENTS_WEBGL",t[t.MAX_DRAW_BUFFERS_WEBGL=34852]="MAX_DRAW_BUFFERS_WEBGL",t[t.VERTEX_ARRAY_BINDING_OES=34229]="VERTEX_ARRAY_BINDING_OES",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT"})(K||(K={}));var $i;(function(t){t[t.Buffer=0]="Buffer",t[t.Texture=1]="Texture",t[t.RenderTarget=2]="RenderTarget",t[t.Sampler=3]="Sampler",t[t.Program=4]="Program",t[t.Bindings=5]="Bindings",t[t.InputLayout=6]="InputLayout",t[t.RenderPipeline=7]="RenderPipeline",t[t.ComputePipeline=8]="ComputePipeline",t[t.Readback=9]="Readback",t[t.QueryPool=10]="QueryPool",t[t.RenderBundle=11]="RenderBundle"})($i||($i={})),(function(t){t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS"})(li||(li={}));var GL;(function(t){t[t.CCW=2305]="CCW",t[t.CW=2304]="CW"})(GL||(GL={})),(function(t){t[t.NONE=0]="NONE",t[t.FRONT=1]="FRONT",t[t.BACK=2]="BACK",t[t.FRONT_AND_BACK=3]="FRONT_AND_BACK"})(jl||(jl={})),(function(t){t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC=768]="SRC",t[t.ONE_MINUS_SRC=769]="ONE_MINUS_SRC",t[t.DST=774]="DST",t[t.ONE_MINUS_DST=775]="ONE_MINUS_DST",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.CONST=32769]="CONST",t[t.ONE_MINUS_CONSTANT=32770]="ONE_MINUS_CONSTANT",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"})(Re||(Re={})),(function(t){t[t.ADD=32774]="ADD",t[t.SUBSTRACT=32778]="SUBSTRACT",t[t.REVERSE_SUBSTRACT=32779]="REVERSE_SUBSTRACT",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX"})(Li||(Li={})),(function(t){t[t.CLAMP_TO_EDGE=0]="CLAMP_TO_EDGE",t[t.REPEAT=1]="REPEAT",t[t.MIRRORED_REPEAT=2]="MIRRORED_REPEAT"})(ho||(ho={})),(function(t){t[t.POINT=0]="POINT",t[t.BILINEAR=1]="BILINEAR"})(hs||(hs={})),(function(t){t[t.NO_MIP=0]="NO_MIP",t[t.NEAREST=1]="NEAREST",t[t.LINEAR=2]="LINEAR"})(Ro||(Ro={}));var Ia;(function(t){t[t.POINTS=0]="POINTS",t[t.TRIANGLES=1]="TRIANGLES",t[t.TRIANGLE_STRIP=2]="TRIANGLE_STRIP",t[t.LINES=3]="LINES",t[t.LINE_STRIP=4]="LINE_STRIP"}
6902)(Ia||(Ia={})),(function(t){t[t.MAP_READ=1]="MAP_READ",t[t.MAP_WRITE=2]="MAP_WRITE",t[t.COPY_SRC=4]="COPY_SRC",t[t.COPY_DST=8]="COPY_DST",t[t.INDEX=16]="INDEX",t[t.VERTEX=32]="VERTEX",t[t.UNIFORM=64]="UNIFORM",t[t.STORAGE=128]="STORAGE",t[t.INDIRECT=256]="INDIRECT",t[t.QUERY_RESOLVE=512]="QUERY_RESOLVE"})(Ee||(Ee={})),(function(t){t[t.STATIC=1]="STATIC",t[t.DYNAMIC=2]="DYNAMIC"})(rr||(rr={})),(function(t){t[t.VERTEX=1]="VERTEX",t[t.INSTANCE=2]="INSTANCE"})(Pi||(Pi={}));var bft;(function(t){t.LOADED="loaded"})(bft||(bft={})),(function(t){t[t.TEXTURE_2D=0]="TEXTURE_2D",t[t.TEXTURE_2D_ARRAY=1]="TEXTURE_2D_ARRAY",t[t.TEXTURE_3D=2]="TEXTURE_3D",t[t.TEXTURE_CUBE_MAP=3]="TEXTURE_CUBE_MAP"})(Xr||(Xr={})),(function(t){t[t.SAMPLED=1]="SAMPLED",t[t.RENDER_TARGET=2]="RENDER_TARGET",t[t.STORAGE=4]="STORAGE"})(vi||(vi={})),(function(t){t[t.NONE=0]="NONE",t[t.RED=1]="RED",t[t.GREEN=2]="GREEN",t[t.BLUE=4]="BLUE",t[t.ALPHA=8]="ALPHA",t[t.RGB=7]="RGB",t[t.ALL=15]="ALL"})(oo||(oo={})),(function(t){t[t.KEEP=7680]="KEEP",t[t.ZERO=0]="ZERO",t[t.REPLACE=7681]="REPLACE",t[t.INVERT=5386]="INVERT",t[t.INCREMENT_CLAMP=7682]="INCREMENT_CLAMP",t[t.DECREMENT_CLAMP=7683]="DECREMENT_CLAMP",t[t.INCREMENT_WRAP=34055]="INCREMENT_WRAP",t[t.DECREMENT_WRAP=34056]="DECREMENT_WRAP"})(Oi||(Oi={}));function qXt(t,e,r,i){const s=Xr.TEXTURE_2D,o=1,n=vi.SAMPLED;return{dimension:s,format:t,width:e,height:r,depthOrArrayLayers:o,mipLevelCount:i,usage:n}}var dn;(function(t){t[t.Float=0]="Float",t[t.UnfilterableFloat=1]="UnfilterableFloat",t[t.Uint=2]="Uint",t[t.Sint=3]="Sint",t[t.Depth=4]="Depth"})(dn||(dn={}));var WL;(function(t){t[t.LOWER_LEFT=0]="LOWER_LEFT",t[t.UPPER_LEFT=1]="UPPER_LEFT"})(WL||(WL={}));var jL;(function(t){t[t.NEGATIVE_ONE=0]="NEGATIVE_ONE",t[t.ZERO=1]="ZERO"})(jL||(jL={}));var gj;(function(t){t[t.OcclusionConservative=0]="OcclusionConservative"})(gj||(gj={}));var Tt;(function(t){t[t.U8=1]="U8",t[t.U16=2]="U16",t[t.U32=3]="U32",t[t.S8=4]="S8",t[t.S16=5]="S16",t[t.S32=6]="S32",t[t.F16=7]="F16",t[t.F32=8]="F32",t[t.BC1=65]="BC1",t[t.BC2=66]="BC2",t[t.BC3=67]="BC3",t[t.BC4_UNORM=68]="BC4_UNORM",t[t.BC4_SNORM=69]="BC4_SNORM",t[t.BC5_UNORM=70]="BC5_UNORM",t[t.BC5_SNORM=71]="BC5_SNORM",t[t.U16_PACKED_5551=97]="U16_PACKED_5551",t[t.U16_PACKED_565=98]="U16_PACKED_565",t[t.D24=129]="D24",t[t.D32F=130]="D32F",t[t.D24S8=131]="D24S8",t[t.D32FS8=132]="D32FS8"})(Tt||(Tt={}));var Se;(function(t){t[t.R=1]="R",t[t.RG=2]="RG",t[t.RGB=3]="RGB",t[t.RGBA=4]="RGBA",t[t.A=5]="A"})(Se||(Se={}));var oe;(function(t){t[t.None=0]="None",t[t.Normalized=1]="Normalized",t[t.sRGB=2]="sRGB",t[t.Depth=4]="Depth",t[t.Stencil=8]="Stencil",t[t.RenderTarget=16]="RenderTarget",t[t.Luminance=32]="Luminance"})(oe||(oe={}));function Ue(t,e,r){return t<<16|e<<8|r}(function(t){t[t.ALPHA=Ue(Tt.U8,Se.A,oe.None)]="ALPHA",t[t.U8_LUMINANCE=Ue(Tt.U8,Se.A,oe.Luminance)]="U8_LUMINANCE",t[t.F16_LUMINANCE=Ue(Tt.F16,Se.A,oe.Luminance)]="F16_LUMINANCE",t[t.F32_LUMINANCE=Ue(Tt.F32,Se.A,oe.Luminance)]="F32_LUMINANCE",t[t.F16_R=Ue(Tt.F16,Se.R,oe.None)]="F16_R",t[t.F16_RG=Ue(Tt.F16,Se.RG,oe.None)]="F16_RG",t[t.F16_RGB=Ue(Tt.F16,Se.RGB,oe.None)]="F16_RGB",t[t.F16_RGBA=Ue(Tt.F16,Se.RGBA,oe.None)]="F16_RGBA",t[t.F32_R=Ue(Tt.F32,Se.R,oe.None)]="F32_R",t[t.F32_RG=Ue(Tt.F32,Se.RG,oe.None)]="F32_RG",t[t.F32_RGB=Ue(Tt.F32,Se.RGB,oe.None)]="F32_RGB",t[t.F32_RGBA=Ue(Tt.F32,Se.RGBA,oe.None)]="F32_RGBA",t[t.U8_R=Ue(Tt.U8,Se.R,oe.None)]="U8_R",t[t.U8_R_NORM=Ue(Tt.U8,Se.R,oe.Normalized)]="U8_R_NORM",t[t.U8_RG=Ue(Tt.U8,Se.RG,oe.None)]="U8_RG",t[t.U8_RG_NORM=Ue(Tt.U8,Se.RG,oe.Normalized)]="U8_RG_NORM",t[t.U8_RGB=Ue(Tt.U8,Se.RGB,oe.None)]="U8_RGB",t[t.U8_RGB_NORM=Ue(Tt.U8,Se.RGB,oe.Normalized)]="U8_RGB_NORM",t[t.U8_RGB_SRGB=Ue(Tt.U8,Se.RGB,oe.sRGB|oe.Normalized)]="U8_RGB_SRGB",t[t.U8_RGBA=Ue(Tt.U8,Se.RGBA,oe.None)]="U8_RGBA",t[t.U8_RGBA_NORM=Ue(Tt.U8,Se.RGBA,oe.Normalized)]="U8_RGBA_NORM",t[t.U8_RGBA_SRGB=Ue(Tt.U8,Se.RGBA,oe.sRGB|oe.Normalized)]="U8_RGBA_SRGB",t[t.U16_R=Ue(Tt.U16,Se.R,oe.None)]="U16_R",t[t.U16_R_NORM=Ue(Tt.U16,Se.R,oe.Normalized)]="U16_R_NORM",t[t.U16_RG_NORM=Ue(Tt.U16,Se.RG,oe.Normalized)]="U16_RG_NORM",t[t.U16_RGBA_NORM=Ue(Tt.U16,Se.RGBA,oe.Normalized)]="U16_RGBA_NORM",t[t.U16_RGBA=Ue(Tt.U16,Se.RGBA,oe.None)]="U16_RGBA",t[t.U16_RGB=Ue(Tt.U16,Se.RGB,oe.None)]="U16_RGB",t[t.U16_RG=Ue(Tt.U16,Se.RG,oe.None)]="U16_RG",t[t.U32_R=Ue(Tt.U32,Se.R,oe.None)]="U32_R",t[t.U32_RG=Ue(Tt.U32,Se.RG,oe.None)]="U32_RG",t[t.U32_RGB=Ue(Tt.U32,Se.RGB,oe.None)]="U32_RGB",t[t.U32_RGBA=Ue(Tt.U32,Se.RGBA,oe.None)]="U32_RGBA",t[t.S8_R=Ue(Tt.S8,Se.R,oe.None)]="S8_R",t[t.S8_R_NORM=Ue(Tt.S8,Se.R,oe.Normalized)]="S8_R_NORM",t[t.S8_RG_NORM=Ue(Tt.S8,Se.RG,oe.Normalized)]="S8_RG_NORM",t[t.S8_RGB_NORM=Ue(Tt.S8,Se.RGB,oe.Normalized)]="S8_RGB_NORM",t[t.S8_RGBA_NORM=Ue(Tt.S8,Se.RGBA,oe.Normalized)]="S8_RGBA_NORM",t[t.S16_R=Ue(Tt.S16,Se.R,oe.None)]="S16_R",t[t.S16_RG=Ue(Tt.S16,Se.RG,oe.None)]="S16_RG",t[t.S16_RG_NORM=Ue(Tt.S16,Se.RG,oe.Normalized)]="S16_RG_NORM",t[t.S16_RGB_NORM=Ue(Tt.S16,Se.RGB,oe.Normalized)]="S16_RGB_NORM",t[t.S16_RGBA=Ue(Tt.S16,Se.RGBA,oe.None)]="S16_RGBA",t[t.S16_RGBA_NORM=Ue(Tt.S16,Se.RGBA,oe.Normalized)]="S16_RGBA_NORM",t[t.S32_R=Ue(Tt.S32,Se.R,oe.None)]="S32_R",t[t.S32_RG=Ue(Tt.S32,Se.RG,oe.None)]="S32_RG",t[t.S32_RGB=Ue(Tt.S32,Se.RGB,oe.None)]="S32_RGB",t[t.S32_RGBA=Ue(Tt.S32,Se.RGBA,oe.None)]="S32_RGBA",t[t.U16_RGBA_5551=Ue(Tt.U16_PACKED_5551,Se.RGBA,oe.Normalized)]="U16_RGBA_5551",t[t.U16_RGB_565=Ue(Tt.U16_PACKED_565,Se.RGB,oe.Normalized)]="U16_RGB_565",t[t.BC1=Ue(Tt.BC1,Se.RGBA,oe.Normalized)]="BC1",t[t.BC1_SRGB=Ue(Tt.BC1,Se.RGBA,oe.Normalized|oe.sRGB)]="BC1_SRGB",t[t.BC2=Ue(Tt.BC2,Se.RGBA,oe.Normalized)]="BC2",t[t.BC2_SRGB=Ue(Tt.BC2,Se.RGBA,oe.Normalized|oe.sRGB)]="BC2_SRGB",t[t.BC3=Ue(Tt.BC3,Se.RGBA,oe.Normalized)]="BC3",t[t.BC3_SRGB=Ue(Tt.BC3,Se.RGBA,oe.Normalized|oe.sRGB)]="BC3_SRGB",t[t.BC4_UNORM=Ue(Tt.BC4_UNORM,Se.R,oe.Normalized)]="BC4_UNORM",t[t.BC4_SNORM=Ue(Tt.BC4_SNORM,Se.R,oe.Normalized)]="BC4_SNORM",t[t.BC5_UNORM=Ue(Tt.BC5_UNORM,Se.RG,oe.Normalized)]="BC5_UNORM",t[t.BC5_SNORM=Ue(Tt.BC5_SNORM,Se.RG,oe.Normalized)]="BC5_SNORM",t[t.D24=Ue(Tt.D24,Se.R,oe.Depth)]="D24",t[t.D24_S8=Ue(Tt.D24S8,Se.RG,oe.Depth|oe.Stencil)]="D24_S8",t[t.D32F=Ue(Tt.D32F,Se.R,oe.Depth)]="D32F",t[t.D32F_S8=Ue(Tt.D32FS8,Se.RG,oe.Depth|oe.Stencil)]="D32F_S8",t[t.U8_RGB_RT=Ue(Tt.U8,Se.RGB,oe.RenderTarget|oe.Normalized)]="U8_RGB_RT",t[t.U8_RGBA_RT=Ue(Tt.U8,Se.RGBA,oe.RenderTarget|oe.Normalized)]="U8_RGBA_RT",t[t.U8_RGBA_RT_SRGB=Ue(Tt.U8,Se.RGBA,oe.RenderTarget|oe.Normalized|oe.sRGB)]="U8_RGBA_RT_SRGB"})(X||(X={}));function aq(t){return t>>>8&255}function cy(t){return t>>>16&255}function w2(t){return t&255}function wft(t){switch(t){case Tt.F32:case Tt.U32:case Tt.S32:return 4;case Tt.U16:case Tt.S16:case Tt.F16:return 2;case Tt.U8:case Tt.S8:return 1;default:throw new Error("whoops")}}function Eft(t){return wft(cy(t))}function ZXt(t){const e=wft(cy(t)),r=aq(t);return e*r}function Aft(t){const e=w2(t);if(e&oe.Depth)return dn.Depth;if(e&oe.Normalized)return dn.Float;const r=cy(t);if(r===Tt.F16||r===Tt.F32)return dn.Float;if(r===Tt.U8||r===Tt.U16||r===Tt.U32)return dn.Uint;if(r===Tt.S8||r===Tt.S16||r===Tt.S32)return dn.Sint;throw new Error("whoops")}function pe(t,e=""){if(!t)throw new Error(`Assert fail: ${e}`)}function oh(t){if(t!=null)return t;throw new Error("Missing object")}function xft(t,e){return t.r===e.r&&t.g===e.g&&t.b===e.b&&t.a===e.a}function Sft(t,e){t.r=e.r,t.g=e.g,t.b=e.b,t.a=e.a}function Tft(t){const{r:e,g:r,b:i,a:s}=t;return{r:e,g:r,b:i,a:s}}function lq(t,e,r,i=1){return{r:t,g:e,b:r,a:i}}let cq;Ra=lq(0,0,0,0),QU=lq(1,1,1,0),cq=lq(1,1,1,1);function mj(t){return!!(t&&(t&t-1)===0)}function lw(t,e){return t??e}function JXt(t){return t===void 0?null:t}function hq(t,e,r){t.length=e,t.fill(r)}function yj(t,e){const r=e-1;return t+r&~r}function QXt(t,e){const r=new Array(t);for(let i=0;i<t;i++)r[i]=e();return r}function tzt(t,e=1){return t.split(` 6903`).map((r,i)=>`${ezt(""+(e+i),4," ")} ${r}`).join(` 6904`)}function ezt(t,e,r="0"){for(;t.length<e;)t=`${r}${t}`;return t}function Rft(t,e){t.blendDstFactor=e.blendDstFactor,t.blendSrcFactor=e.blendSrcFactor,t.blendMode=e.blendMode}function vj(t,e){return e===void 0||(t===void 0&&(t={}),t.compare=e.compare,t.depthFailOp=e.depthFailOp,t.passOp=e.passOp,t.failOp=e.failOp,t.mask=e.mask),t}function Cft(t,e){return t===void 0&&(t={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),Rft(t.rgbBlendState,e.rgbBlendState),Rft(t.alphaBlendState,e.alphaBlendState),t.channelWriteMask=e.channelWriteMask,t}function Mft(t,e){t.length!==e.length&&(t.length=e.length);for(let r=0;r<e.length;r++)t[r]=Cft(t[r],e[r])}function rzt(t,e){e.attachmentsState!==void 0&&Mft(t.attachmentsState,e.attachmentsState),t.blendConstant&&e.blendConstant&&Sft(t.blendConstant,e.blendConstant),t.depthCompare=lw(e.depthCompare,t.depthCompare),t.depthWrite=lw(e.depthWrite,t.depthWrite),t.stencilWrite=lw(e.stencilWrite,t.stencilWrite),t.stencilFront&&e.stencilFront&&vj(t.stencilFront,e.stencilFront),t.stencilBack&&e.stencilBack&&vj(t.stencilBack,e.stencilBack),t.cullMode=lw(e.cullMode,t.cullMode),t.frontFace=lw(e.frontFace,t.frontFace),t.polygonOffset=lw(e.polygonOffset,t.polygonOffset),t.polygonOffsetFactor=lw(e.polygonOffsetFactor,t.polygonOffsetFactor),t.polygonOffsetUnits=lw(e.polygonOffsetUnits,t.polygonOffsetUnits)}function E2(t){const e=Object.assign({},t);return e.attachmentsState=[],Mft(e.attachmentsState,t.attachmentsState),e.blendConstant=e.blendConstant&&Tft(e.blendConstant),e.stencilFront=vj(void 0,t.stencilFront),e.stencilBack=vj(void 0,t.stencilBack),e}const Bft={blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ZERO},K0={attachmentsState:[{channelWriteMask:oo.ALL,rgbBlendState:Bft,alphaBlendState:Bft}],blendConstant:Tft(Ra),depthWrite:!0,depthCompare:li.LEQUAL,stencilWrite:!1,stencilFront:{compare:li.ALWAYS,passOp:Oi.KEEP,depthFailOp:Oi.KEEP,failOp:Oi.KEEP},stencilBack:{compare:li.ALWAYS,passOp:Oi.KEEP,depthFailOp:Oi.KEEP,failOp:Oi.KEEP},cullMode:jl.NONE,frontFace:GL.CCW,polygonOffset:!1,polygonOffsetFactor:0,polygonOffsetUnits:0};function _j(t=null,e=K0){const r=E2(e);return t!==null&&rzt(r,t),r}const Oft=_j({depthCompare:li.ALWAYS,depthWrite:!1},K0),Ift={texture:null,sampler:null,formatKind:dn.Float,dimension:Xr.TEXTURE_2D};function cw(t,e,r){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!r(t[i],e[i]))return!1;return!0}function A2(t,e){const r=Array(t.length);for(let i=0;i<t.length;i++)r[i]=e(t[i]);return r}function izt(t,e){return t.texture===e.texture&&t.binding===e.binding}function Dft(t,e){return t.buffer===e.buffer&&t.size===e.size&&t.binding===e.binding&&t.offset===e.offset}function szt(t,e){return t===null?e===null:e===null?!1:t.sampler===e.sampler&&t.texture===e.texture&&t.dimension===e.dimension&&t.formatKind===e.formatKind&&t.comparison===e.comparison}function ozt(t,e){return t.samplerBindings=t.samplerBindings||[],t.uniformBufferBindings=t.uniformBufferBindings||[],t.storageBufferBindings=t.storageBufferBindings||[],t.storageTextureBindings=t.storageTextureBindings||[],e.samplerBindings=e.samplerBindings||[],e.uniformBufferBindings=e.uniformBufferBindings||[],e.storageBufferBindings=e.storageBufferBindings||[],e.storageTextureBindings=e.storageTextureBindings||[],!(t.pipeline!==e.pipeline||t.samplerBindings.length!==e.samplerBindings.length||!cw(t.samplerBindings,e.samplerBindings,szt)||!cw(t.uniformBufferBindings,e.uniformBufferBindings,Dft)||!cw(t.storageBufferBindings,e.storageBufferBindings,Dft)||!cw(t.storageTextureBindings,e.storageTextureBindings,izt))}function Pft(t,e){return t.blendMode==e.blendMode&&t.blendSrcFactor===e.blendSrcFactor&&t.blendDstFactor===e.blendDstFactor}function nzt(t,e){return!(!Pft(t.rgbBlendState,e.rgbBlendState)||!Pft(t.alphaBlendState,e.alphaBlendState)||t.channelWriteMask!==e.channelWriteMask)}function bj(t,e){return t.compare==e.compare&&t.depthFailOp===e.depthFailOp&&t.failOp===e.failOp&&t.passOp===e.passOp&&t.mask===e.mask}function azt(t,e){return!cw(t.attachmentsState,e.attachmentsState,nzt)||t.blendConstant&&e.blendConstant&&!xft(t.blendConstant,e.blendConstant)||t.stencilFront&&e.stencilFront&&!bj(t.stencilFront,e.stencilFront)||t.stencilBack&&e.stencilBack&&!bj(t.stencilBack,e.stencilBack)?!1:t.depthCompare===e.depthCompare&&t.depthWrite===e.depthWrite&&t.stencilWrite===e.stencilWrite&&t.cullMode===e.cullMode&&t.frontFace===e.frontFace&&t.polygonOffset===e.polygonOffset&&t.polygonOffsetFactor===e.polygonOffsetFactor&&t.polygonOffsetUnits===e.polygonOffsetUnits}function Fft(t,e){return t.id===e.id}function lzt(t,e){return t===e}function czt(t,e){var r,i;return!(t.topology!==e.topology||t.inputLayout!==e.inputLayout||t.sampleC
6904ount!==e.sampleCount||!azt((r=t.megaStateDescriptor)!==null&&r!==void 0?r:K0,(i=e.megaStateDescriptor)!==null&&i!==void 0?i:K0)||!Fft(t.program,e.program)||!cw(t.colorAttachmentFormats,e.colorAttachmentFormats,lzt)||t.depthStencilAttachmentFormat!==e.depthStencilAttachmentFormat)}function hzt(t,e){return t.offset===e.offset&&t.shaderLocation===e.shaderLocation&&t.format===e.format&&t.divisor===e.divisor}function uzt(t,e){return me(t)?me(e):me(e)?!1:t.arrayStride===e.arrayStride&&t.stepMode===e.stepMode&&cw(t.attributes,e.attributes,hzt)}function dzt(t,e){return!(t.indexBufferFormat!==e.indexBufferFormat||!cw(t.vertexBufferDescriptors,e.vertexBufferDescriptors,uzt)||!Fft(t.program,e.program))}function fzt(t,e){return t.addressModeU===e.addressModeU&&t.addressModeV===e.addressModeV&&t.minFilter===e.minFilter&&t.magFilter===e.magFilter&&t.mipmapFilter===e.mipmapFilter&&t.lodMinClamp===e.lodMinClamp&&t.lodMaxClamp===e.lodMaxClamp&&t.maxAnisotropy===e.maxAnisotropy&&t.compareFunction===e.compareFunction}function pzt(t){const e=t.sampler,r=t.texture,i=t.dimension,s=t.formatKind,o=t.comparison;return{sampler:e,texture:r,dimension:i,formatKind:s,comparison:o}}function Nft(t){const e=t.buffer,r=t.size,i=t.binding,s=t.offset;return{binding:i,buffer:e,offset:s,size:r}}function gzt(t){const e=t.binding,r=t.texture;return{binding:e,texture:r}}function mzt(t){const e=t.samplerBindings&&A2(t.samplerBindings,pzt),r=t.uniformBufferBindings&&A2(t.uniformBufferBindings,Nft),i=t.storageBufferBindings&&A2(t.storageBufferBindings,Nft),s=t.storageTextureBindings&&A2(t.storageTextureBindings,gzt);return{samplerBindings:e,uniformBufferBindings:r,storageBufferBindings:i,storageTextureBindings:s,pipeline:t.pipeline}}function yzt(t){const e=t.inputLayout,r=t.program,i=t.topology,s=t.megaStateDescriptor&&E2(t.megaStateDescriptor),o=t.colorAttachmentFormats.slice(),n=t.depthStencilAttachmentFormat,a=t.sampleCount;return{inputLayout:e,megaStateDescriptor:s,program:r,topology:i,colorAttachmentFormats:o,depthStencilAttachmentFormat:n,sampleCount:a}}function vzt(t){const e=t.shaderLocation,r=t.format,i=t.offset,s=t.divisor;return{shaderLocation:e,format:r,offset:i,divisor:s}}function _zt(t){if(me(t))return t;{const e=t.arrayStride,r=t.stepMode,i=A2(t.attributes,vzt);return{arrayStride:e,stepMode:r,attributes:i}}}function bzt(t){const e=A2(t.vertexBufferDescriptors,_zt),r=t.indexBufferFormat,i=t.program;return{vertexBufferDescriptors:e,indexBufferFormat:r,program:i}}const wzt=/([^[]*)(\[[0-9]+\])?/;function Ezt(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};const e=t.match(wzt);
6904if(!e||e.length<2)throw new Error(`Failed to parse GLSL uniform name ${t}`);return{name:e[1],length:Number(e[2])||1,isArray:!!e[2]}}function Lh(){let t=null;return(e,r,i)=>{const s=t!==i;return s&&(e.uniform1i(r,i),t=i),s}}function fn(t,e,r,i){let s=null,o=null;return(n,a,l)=>{const c=e(l,r),h=c.length;let u=!1;if(s===null)s=new Float32Array(h),o=h,u=!0;else{pe(o===h,"Uniform length cannot change.");for(let d=0;d<h;++d)if(c[d]!==s[d]){u=!0;break}}return u&&(i(n,t,a,c),s.set(c)),u}}function nh(t,e,r,i){t[e](r,i)}function q0(t,e,r,i){t[e](r,!1,i)}const Azt={},xzt={},Szt={},kft=[0];function uq(t,e,r,i){e===1&&typeof t=="boolean"&&(t=t?1:0),Number.isFinite(t)&&(kft[0]=t,t=kft);const s=t.length;if(t instanceof r)return t;let o=i[s];o||(o=new r(s),i[s]=o);for(let n=0;n<s;n++)o[n]=t[n];return o}function Pd(t,e){return uq(t,e,Float32Array,Azt)}function hw(t,e){return uq(t,e,Int32Array,xzt)}function wj(t,e){return uq(t,e,Uint32Array,Szt)}const Tzt={[K.FLOAT]:fn.bind(null,"uniform1fv",Pd,1,nh),[K.FLOAT_VEC2]:fn.bind(null,"uniform2fv",Pd,2,nh),[K.FLOAT_VEC3]:fn.bind(null,"uniform3fv",Pd,3,nh),[K.FLOAT_VEC4]:fn.bind(null,"uniform4fv",Pd,4,nh),[K.INT]:fn.bind(null,"uniform1iv",hw,1,nh),[K.INT_VEC2]:fn.bind(null,"uniform2iv",hw,2,nh),[K.INT_VEC3]:fn.bind(null,"uniform3iv",hw,3,nh),[K.INT_VEC4]:fn.bind(null,"uniform4iv",hw,4,nh),[K.BOOL]:fn.bind(null,"uniform1iv",hw,1,nh),[K.BOOL_VEC2]:fn.bind(null,"uniform2iv",hw,2,nh),[K.BOOL_VEC3]:fn.bind(null,"uniform3iv",hw,3,nh),[K.BOOL_VEC4]:fn.bind(null,"uniform4iv",hw,4,nh),[K.FLOAT_MAT2]:fn.bind(null,"uniformMatrix2fv",Pd,4,q0),[K.FLOAT_MAT3]:fn.bind(null,"uniformMatrix3fv",Pd,9,q0),[K.FLOAT_MAT4]:fn.bind(null,"uniformMatrix4fv",Pd,16,q0),[K.UNSIGNED_INT]:fn.bind(null,"uniform1uiv",wj,1,nh),[K.UNSIGNED_INT_VEC2]:fn.bind(null,"uniform2uiv",wj,2,nh),[K.UNSIGNED_INT_VEC3]:fn.bind(null,"uniform3uiv",wj,3,nh),[K.UNSIGNED_INT_VEC4]:fn.bind(null,"uniform4uiv",wj,4,nh),[K.FLOAT_MAT2x3]:fn.bind(null,"uniformMatrix2x3fv",Pd,6,q0),[K.FLOAT_MAT2x4]:fn.bind(null,"uniformMatrix2x4fv",Pd,8,q0),[K.FLOAT_MAT3x2]:fn.bind(null,"uniformMatrix3x2fv",Pd,6,q0),[K.FLOAT_MAT3x4]:fn.bind(null,"uniformMatrix3x4fv",Pd,12,q0),[K.FLOAT_MAT4x2]:fn.bind(null,"uniformMatrix4x2fv",Pd,8,q0),[K.FLOAT_MAT4x3]:fn.bind(null,"uniformMatrix4x3fv",Pd,12,q0),[K.SAMPLER_2D]:Lh,[K.SAMPLER_CUBE]:Lh,[K.SAMPLER_3D]:Lh,[K.SAMPLER_2D_SHADOW]:Lh,[K.SAMPLER_2D_ARRAY]:Lh,[K.SAMPLER_2D_ARRAY_SHADOW]:Lh,[K.SAMPLER_CUBE_SHADOW]:Lh,[K.INT_SAMPLER_2D]:Lh,[K.INT_SAMPLER_3D]:Lh,[K.INT_SAMPLER_CUBE]:Lh,[K.INT_SAMPLER_2D_ARRAY]:Lh,[K.UNSIGNED_INT_SAMPLER_2D]:Lh,[K.UNSIGNED_INT_SAMPLER_3D]:Lh,[K.UNSIGNED_INT_SAMPLER_CUBE]:Lh,[K.UNSIGNED_INT_SAMPLER_2D_ARRAY]:Lh};function Lft(t,e,r){const i=Tzt[r.type];if(!i)throw new Error(`Unknown GLSL uniform type ${r.type}`);return i().bind(null,t,e)}const Rzt={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121};function Czt(t){return Object.prototype.toString.call(t)in Rzt}function XL(t,e){return`#define ${t} ${e}`}function Mzt(t){const e={};return t.replace(/^\s*#define\s*(\S*)\s*(\S*)\s*$/gm,(r,i,s)=>{const o=Number(s);return e[i]=isNaN(o)?s:o,""}),e}function Bzt(t,e){const r=[];return t.replace(/^\s*layout\(location\s*=\s*(\S*)\)\s*in\s+\S+\s*(.*);$/gm,(i,s,o)=>{const n=Number(s);return r.push({location:isNaN(n)?e[s]:n,name:o}),""}),r}function Uft(t){if(t===void 0)return null;const e=/binding\s*=\s*(\d+)/.exec(t);if(e!==null){const r=parseInt(e[1],10);if(!Number.isNaN(r))return r}return null}function Gft(t){return[t,""]}function Ej(t,e,r,i=null,s=!0){var o;const n=t.glslVersion==="#version 100",a=e==="frag"&&((o=r.match(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm))===null||o===void 0?void 0:o.length)>1,l=r.replace(`\r 6905`,` 6906`).split(` 6907`).map(g=>g.replace(/[/][/].*$/,"")).filter(g=>!(!g||/^\s+$/.test(g)));let c="";i!==null&&(c=Object.keys(i).map(g=>XL(g,i[g])).join(` 6908`));let h=l.find(g=>g.startsWith("precision"))||"precision mediump float;",u=s?l.filter(g=>!g.startsWith("precision")).join(` 6909`):l.join(` 6910`),d="";if(t.viewportOrigin===WL.UPPER_LEFT&&(d+=`${XL("VIEWPORT_ORIGIN_TL","1")} 6911`),t.clipSpaceNearZ===jL.ZERO&&(d+=`${XL("CLIPSPACE_NEAR_ZERO","1")}
6911 6912`),t.explicitBindingLocations){let g=0,p=0,m=0;u=u.replace(/^\s*(layout\((.*)\))?\s*uniform(.+{)$/gm,(v,b,y,_)=>`layout(${y?`${y}, `:""}set = ${g}, binding = ${p++}) uniform ${_}`),g++,p=0,pe(t.separateSamplerTextures),u=u.replace(/^\s*(layout\((.*)\))?\s*uniform\s+(?:(highp|mediump|lowp)\s+)?sampler(\w+)\s+(\w+)\s*;/gm,(v,b,y,_,w,E)=>{let A=Uft(y);A===null&&(A=p++);const[x,S]=Gft(w);return e==="frag"?` 6913layout(set = ${g}, binding = ${A*2+0}) uniform texture${x} T_${E}; 6914layout(set = ${g}, binding = ${A*2+1}) uniform sampler${S} S_${E};`.trim():""}),u=u.replace(e==="frag"?/^\s*\b(varying|in)\b/gm:/^\s*\b(varying|out)\b/gm,(v,b)=>`layout(location = ${m++}) ${b}`),d+=`${XL("gl_VertexID","gl_VertexIndex")} 6915`,d+=`${XL("gl_InstanceID","gl_InstanceIndex")} 6916`,h=h.replace(/^precision (.*) sampler(.*);$/gm,"")}else{let g=0;u=u.replace(/^\s*(layout\((.*)\))?\s*uniform\s+(?:(highp|mediump|lowp)\s+)?sampler(\w+)\s+(\w+)\s*;/gm,(p,m,v,b,y,_)=>{let w=Uft(v);return w===null&&(w=g++),`uniform ${b?`${b} `:""}sampler${y} ${_}; // BINDING=${w}`})}if(u=u.replace(/\bPU_SAMPLER_(\w+)\((.*?)\)/g,(g,p,m)=>`SAMPLER_${p}(P_${m})`),u=u.replace(/\bPF_SAMPLER_(\w+)\((.*?)\)/g,(g,p,m)=>`PP_SAMPLER_${p}(P_${m})`),u=u.replace(/\bPU_TEXTURE\((.*?)\)/g,(g,p)=>`TEXTURE(P_${p})`),t.separateSamplerTextures)u=u.replace(/\bPD_SAMPLER_(\w+)\((.*?)\)/g,(g,p,m)=>{const[v,b]=Gft(p);return`texture${v} T_P_${m}, sampler${b} S_P_${m}`}),u=u.replace(/\bPP_SAMPLER_(\w+)\((.*?)\)/g,(g,p,m)=>`T_${m}, S_${m}`),u=u.replace(/\bSAMPLER_(\w+)\((.*?)\)/g,(g,p,m)=>`sampler${p}(T_${m}, S_${m})`),u=u.replace(/\bTEXTURE\((.*?)\)/g,(g,p)=>`T_${p}`);else{const g=[];u=u.replace(/\bPD_SAMPLER_(\w+)\((.*?)\)/g,(p,m,v)=>`sampler${m} P_${v}`),u=u.replace(/\bPP_SAMPLER_(\w+)\((.*?)\)/g,(p,m,v)=>v),u=u.replace(/\bSAMPLER_(\w+)\((.*?)\)/g,(p,m,v)=>(g.push([v,m]),v)),n&&g.forEach(([p,m])=>{u=u.replace(new RegExp(`texture\\(${p}`,"g"),()=>`texture${m}(${p}`)}),u=u.replace(/\bTEXTURE\((.*?)\)/g,(p,m)=>m)}let f=`${n?"":t.glslVersion} 6917${n&&a?`#extension GL_EXT_draw_buffers : require 6918`:""} 6919${n&&e==="frag"?`#extension GL_OES_standard_derivatives : enable 6920`:""}${s?h:""} 6921${d||""}${c?c+` 6922`:""} 6923${u} 6924`.trim();if(t.explicitBindingLocations&&e==="frag"&&(f=f.replace(/^\b(out)\b/g,(g,p)=>`layout(location = 0) ${p}`)),n){if(e==="frag"&&(f=f.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,(g,p,m)=>`varying ${p} ${m}; 6925`)),e==="vert"&&(f=f.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(g,p,m)=>`varying ${p} ${m}; 6926`),f=f.replace(/^\s*layout\(location\s*=\s*\S*\)\s*in\s+(\S+)\s*(.*);$/gm,(g,p,m)=>`attribute ${p} ${m}; 6927`)),f=f.replace(/\s*uniform\s*.*\s*{((?:\s*.*\s*)*?)};/g,(g,p)=>p.trim().replace(/^.*$/gm,m=>{const v=m.trim();return v.startsWith("#")?v:m?`uniform ${v}`:""})),e==="frag")if(a){const g=[];f=f.replace(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm,(m,v)=>(g.push(v),`vec4 ${v}; 6928`));const p=f.lastIndexOf("}");f=f.substring(0,p)+` 6929 ${g.map((m,v)=>`gl_FragData[${v}] = ${m}; 6930 `).join(` 6931`)}`+f.substring(p)}else{let g=null;if(f=f.replace(/^\s*out\s+(\S+)\s+(\S+)\s*;$/gm,(p,m,v)=>(g={dataType:m,name:v},`${m} ${v}; 6932`)),g){const{dataType:p,name:m}=g,v=f.lastIndexOf("}"),b=p==="vec4"?` gl_FragColor = ${m}; 6933`:` gl_FragColor = ${p}(${m}); 6934`;f=f.substring(0,v)+b+f.substring(v)}}f=f.replace(/^\s*layout\((.*)\)/gm,"")}return f}class Lf extends Uo{constructor({id:e,device:r}){super(),this.id=e,this.device=r,this.device.resourceCreationTracker!==null&&this.device.resourceCreationTracker.trackResourceCreated(this)}destroy(){this.device.resourceCreationTracker!==null&&this.device.resourceCreationTracker.trackResourceDestroyed(this)}}class Ozt extends Lf{constructor({id:e,device:r,descriptor:i}){super({id:e,device:r}),this.type=$i.Bindings;const{uniformBufferBindings:s,samplerBindings:o}=i;this.uniformBufferBindings=s||[],this.samplerBindings=o||[],this.bindingLayouts=this.createBindingLayouts()}createBindingLayouts(){let e=0,r=0;const i=[],s=this.uniformBufferBindings.length,o=this.samplerBindings.length;return i.push({firstUniformBuffer:e,numUniformBuffers:s,firstSampler:r,numSamplers:o}),e+=s,r+=o,{numUniformBuffers:e,numSamplers:r,bindingLayoutTables:i}}}let zL;function Te(t){return zL!==void 0?zL:typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?(zL=!0,!0):(zL=!!(t&&t._version===2),zL)}function Wft(t){switch(cy(t)){case Tt.BC1:case Tt.BC2:case Tt.BC3:case Tt.BC4_UNORM:case Tt.BC4_SNORM:case Tt.BC5_UNORM:case Tt.BC5_SNORM:return!0;default:return!1}}function jft(t){if(w2(t)&oe.Normalized)return!1;const e=cy(t);return e===Tt.S8||e===Tt.S16||e===Tt.S32||e===Tt.U8||e===Tt.U16||e===Tt.U32}function Izt(t){switch(t){case rr.STATIC:return K.STATIC_DRAW;case rr.DYNAMIC:return K.DYNAMIC_DRAW}}function Xft(t){if(t&Ee.INDEX)return K.ELEMENT_ARRAY_BUFFER;if(t&Ee.VERTEX)return K.ARRAY_BUFFER;if(t&Ee.UNIFORM)return K.UNIFORM_BUFFER}function Dzt(t){switch(t){case Ia.TRIANGLES:return K.TRIANGLES;case Ia.POINTS:return K.POINTS;case Ia.TRIANGLE_STRIP:return K.TRIANGLE_STRIP;case Ia.LINES:return K.LINES;case Ia.LINE_STRIP:return K.LINE_STRIP;default:throw new Error("Unknown primitive topology mode")}}function Pzt(t){switch(t){case Tt.U8:return K.UNSIGNED_BYTE;case Tt.U16:return K.UNSIGNED_SHORT;case Tt.U32:return K.UNSIGNED_INT;case Tt.S8:return K.BYTE;case Tt.S16:return K.SHORT;case Tt.S32:return K.INT;case Tt.F16:return K.HALF_FLOAT;case Tt.F32:return K.FLOAT;default:throw new Error("whoops")}}function Fzt(t){switch(t){case Se.R:return 1;case Se.RG:return 2;case Se.RGB:return 3;case Se.RGBA:return 4;default:return 1}}function Nzt(t){const e=cy(t),r=aq(t),i=w2(t),s=Pzt(e),o=Fzt(r),n=!!(i&oe.Normalized);return{size:o,type:s,normalized:n}}function kzt(t){switch(t){case X.U8_R:return K.UNSIGNED_BYTE;case X.U16_R:return K.UNSIGNED_SHORT;case X.U32_R:return K.UNSIGNED_INT;default:throw new Error("whoops")}}function VL(t){switch(t){case ho.CLAMP_TO_EDGE:return K.CLAMP_TO_EDGE;case ho.REPEAT:return K.REPEAT;case ho.MIRRORED_REPEAT:return K.MIRRORED_REPEAT;default:throw new Error("whoops")}}function Aj(t,e){if(e===Ro.LINEAR&&t===hs.BILINEAR)return K.LINEAR_MIPMAP_LINEAR;if(e===Ro.LINEAR&&t===hs.POINT)return K.NEAREST_MIPMAP_LINEAR;if(e===Ro.NEAREST&&t===hs.BILINEAR)return K.LINEAR_MIPMAP_NEAREST;if(e===Ro.NEAREST&&t===hs.POINT)return K.NEAREST_MIPMAP_NEAREST;if(e===Ro.NO_MIP&&t===hs.BILINEAR)return K.LINEAR;if(e===Ro.NO_MIP&&t===hs.POINT)return K.NEAREST;throw new Error("Unknown texture filter mode")}function x2(t,e=0){const r=t;return r.gl_buffer_pages[e/r.pageByteSize|0]}function S2(t){return t.gl_texture}function dq(t){return t.gl_sampler}function YL(t,e){t.name=e,t.__SPECTOR_Metadata={name:e}}function zft(t,e){const r=[];for(;;){const i=e.exec(t);if(!i)break;r.push(i)}return r}function uw(t){return t.blendMode==Li.ADD&&t.blendSrcFactor==Re.ONE&&t.blendDstFactor===Re.ZERO}function Lzt(t){switch(t){case gj.OcclusionConservative:return K.ANY_SAMPLES_PASSED_CONSERVATIVE;default:throw new Error("whoops")}}function Uzt(t){if(t===Xr.TEXTURE_2D)return K.TEXTURE_2D;if(t===Xr.TEXTURE_2D_ARRAY)return K.TEXTURE_2D_ARRAY;if(t===Xr.TEXTURE_CUBE_MAP)return K.TEXTURE_CUBE_MAP;if(t===Xr.TEXTURE_3D)return K.TEXTURE_3D;throw new Error("whoops")}function fq(t,e,r,i){return!(t%r!==0||e%i!==0)}class Gzt extends Lf{constructor({id:e,device:r,descriptor:i}){super({id:e,device:r}),this.type=$i.Buffer;const{viewOrSize:s,usage:o,hint:n=rr.STATIC}=i,{uniformBufferMaxPageByteSize:a,gl:l}=r,c=o&Ee.UNIFORM;c||(Te(l)?l.bindVertexArray(null):r.OES_vertex_array_object.bindVertexArrayOES(null));const h=lc(s)?yj(s,4):yj(s.byteLength,4);this.gl_buffer_pages=[];let u;if(c){let d=h;for(;d>0;)this.gl_buffer_pages.push(this.createBufferPage(Math.min(d,a),o,n)),d-=a;u=a}else this.gl_buffer_pages.push(this.createBufferPage(h,o,n)),u=h;this.pageByteSize=u,this.byteSize=h,this.usage=o,this.gl_target=Xft(o),lc(s)||this.setSubData(0,new Uint8Array(s.buffer)),c||(Te(l)?l.bindVertexArray(this.device.currentBoundVAO):r.OES_vertex_array_object.bindVertexArrayOES(this.device.currentBoundVAO))}setSubData(e,r,i=0,s=r.byteLength-i){const o=this.device.gl,{pageByteSize:n}=this,a=e+s;let l=e,c=e%n;for(;l<a;){const h=Te(o)?o.COPY_WRITE_BUFFER:this.gl_target,u=x2(this,l);if(u.ubo)return;o.bindBuffer(h,u),Te(o)?o.bufferSubData(h,c,r,i,Math.min(a-l,n)):o.bufferSubData(h,c,r),l+=n,c=0,i+=n,this.device.debugGroupStatisticsBufferUpload()}}destroy(){super.destroy();for(let e=0;e<this.gl_buffer_pages.length;e++)this.gl_buffer_pages[e].ubo||this.device.gl.deleteBuffer(this.gl_buffer_pages[e]);this.gl_buffer_pages=[]}createBufferPage(e,r,i){const s=this.device.gl,o=r&Ee.UNIFORM;if(!Te(s)&&o)return{ubo:!0};{const n=this.device.ensureResourceExists(s.createBuffer()),a=Xft(r),l=Izt(i);return s.bindBuffer(a,n),s.bufferData(a,e,l),n}}}class Wzt extends Lf{constructor({id:e,device:r,descriptor:i}){var s;super({id:e,device:r}),this.type=$i.InputLayout;const{vertexBufferDescriptors:o,indexBufferFormat:n,program:a}=i;pe(n===X.U16_R||n===X.U32_R||n===null);const l=n!==null?kzt(n):null,c=n!==null?Eft(n):null,h=this.device.gl,u=this.device.ensureResourceExists(Te(h)?h.createVertexArray():r.OES_vertex_array_object.createVertexArrayOES());Te(h)?h.bindVertexArray(u):r.OES_vertex_array_object.bindVertexArrayOES(u),h.bindBuffer(h.ARRAY_BUFFER,x2(this.device.fallbackVertexBuffer));for(const d of i.vertexBufferDescriptors){const{stepMode:f,attributes:g}=d;for(const p of g){const{shaderLocation:m,format:v,divisor:b=1}=p,y=Te(h)?m:(s=a.attributes[m])===null||s===void 0?void 0:s.location,_=Nzt(v);if(p.vertexFormat=_,!me(y)){jft(v);const{size:w,type:E,normalized:A}=_;h.vertexAttribPointer(y,w,E,A,0,0),f===Pi.INSTANCE&&(Te(h)?h.vertexAttribDivisor(y,b):r.ANGLE_
6934instanced_arrays.vertexAttribDivisorANGLE(y,b)),h.enableVertexAttribArray(y)}}}Te(h)?h.bindVertexArray(null):r.OES_vertex_array_object.bindVertexArrayOES(null),this.vertexBufferDescriptors=o,this.vao=u,this.indexBufferFormat=n,this.indexBufferType=l,this.indexBufferCompByteSize=c,this.program=a}destroy(){if(!this.vao)return;super.destroy();const e=this.device.gl;this.device.currentBoundVAO===this.vao&&(Te(e)?e.bindVertexArray(null):this.device.OES_vertex_array_object.bindVertexArrayOES(null),this.device.currentBoundVAO=null),Te(e)?e.deleteVertexArray(this.vao):this.device.OES_vertex_array_object.deleteVertexArrayOES(this.vao),this.vao=null}}class pq extends Lf{constructor({id:e,device:r,descriptor:i,fake:s}){super({id:e,device:r}),this.type=$i.Texture,i=Object.assign({dimension:Xr.TEXTURE_2D,depthOrArrayLayers:1,mipLevelCount:1},i);const o=this.device.gl;let n,a;const l=this.clampmipLevelCount(i);if(this.immutable=(i.usage&vi.RENDER_TARGET)!==0,this.pixelStore=i.pixelStore,this.format=i.format,this.dimension=i.dimension,this.formatKind=Aft(i.format),this.width=i.width,this.height=i.height,this.depthOrArrayLayers=i.depthOrArrayLayers,this.mipmaps=l>=1,!s){a=this.device.ensureResourceExists(o.createTexture());const c=this.device.translateTextureType(i.format),h=this.device.translateTextureInternalFormat(i.format);if(this.device.setActiveTexture(o.TEXTURE0),this.device.currentTextures[0]=null,this.preprocessImage(),i.dimension===Xr.TEXTURE_2D){if(n=K.TEXTURE_2D,o.bindTexture(n,a),this.immutable)if(Te(o))o.texStorage2D(n,l,h,i.width,i.height);else{const u=(h===K.DEPTH_COMPONENT||this.isNPOT(),0);(this.format===X.D32F||this.format===X.D24_S8)&&!Te(o)&&!r.WEBGL_depth_texture||(o.texImage2D(n,u,h,i.width,i.height,0,h,c,null),this.mipmaps&&(this.mipmaps=!1,o.texParameteri(K.TEXTURE_2D,K.TEXTURE_MIN_FILTER,K.LINEAR),o.texParameteri(K.TEXTURE_2D,K.TEXTURE_WRAP_S,K.CLAMP_TO_EDGE),o.texParameteri(K.TEXTURE_2D,K.TEXTURE_WRAP_T,K.CLAMP_TO_EDGE)))}pe(i.depthOrArrayLayers===1)}else if(i.dimension===Xr.TEXTURE_2D_ARRAY)n=K.TEXTURE_2D_ARRAY,o.bindTexture(n,a),this.immutable&&Te(o)&&o.texStorage3D(n,l,h,i.width,i.height,i.depthOrArrayLayers);else if(i.dimension===Xr.TEXTURE_3D)n=K.TEXTURE_3D,o.bindTexture(n,a),this.immutable&&Te(o)&&o.texStorage3D(n,l,h,i.width,i.height,i.depthOrArrayLayers);else if(i.dimension===Xr.TEXTURE_CUBE_MAP)n=K.TEXTURE_CUBE_MAP,o.bindTexture(n,a),this.immutable&&Te(o)&&o.texStorage2D(n,l,h,i.width,i.height),pe(i.depthOrArrayLayers===6);else throw new Error("whoops")}this.gl_texture=a,this.gl_target=n,this.mipLevelCount=l}setImageData(e,r=0){const i=this.device.gl;Wft(this.format);const s=this.gl_target===K.TEXTURE_3D||this.gl_target===K.TEXTURE_2D_ARRAY,o=this.gl_target===K.TEXTURE_CUBE_MAP,n=Czt(e[0]);this.device.setActiveTexture(i.TEXTURE0),this.device.currentTextures[0]=null;const a=e[0];let l,c;n?(l=this.width,c=this.height):(l=a.width,c=a.height,this.width=l,this.height=c),i.bindTexture(this.gl_target,this.gl_texture);const h=this.device.translateTextureFormat(this.format),u=Te(i)?this.device.translateInternalTextureFormat(this.format):h,d=this.device.translateTextureType(this.format);this.preprocessImage();const f=Te(i)&&s&&!o&&!this.immutable&&n,g=f?1:this.depthOrArrayLayers;for(let p=0;p<g;p++){const m=f?e[0]:e[p];let v=this.gl_target;o&&(v=K.TEXTURE_CUBE_MAP_POSITIVE_X+p%6),this.immutable?i.texSubImage2D(v,r,0,0,l,c,h,d,m):Te(i)?s?i.texImage3D(v,r,u,l,c,this.depthOrArrayLayers,0,h,d,m):i.texImage2D(v,r,u,l,c,0,h,d,m):n?i.texImage2D(v,r,h,l,c,0,h,d,m):i.texImage2D(v,r,h,h,d,m)}this.mipmaps&&this.generateMipmap(s)}destroy(){super.destroy(),this.device.gl.deleteTexture(S2(this))}clampmipLevelCount(e){if(e.dimension===Xr.TEXTURE_2D_ARRAY&&e.depthOrArrayLayers>1&&cy(e.format)===Tt.BC1){let r=e.width,i=e.height;for(let s=0;s<e.mipLevelCount;s++){if(r<=2||i<=2)return s-1;r=Math.max(r/2|0,1),i=Math.max(i/2|0,1)}}return e.mipLevelCount}preprocessImage(){const e=this.device.gl;this.pixelStore&&(this.pixelStore.unpackFlipY&&e.pixelStorei(K.UNPACK_FLIP_Y_WEBGL,!0),this.pixelStore.packAlignment&&e.pixelStorei(K.PACK_ALIGNMENT,this.pixelStore.packAlignment),this.pixelStore.unpackAlignment&&e.pixelStorei(K.UNPACK_ALIGNMENT,this.pixelStore.unpackAlignment))}generateMipmap(e=!1){const r=this.device.gl;return!Te(r)&&this.isNPOT()?this:(this.gl_texture&&this.gl_target&&(r.bindTexture(this.gl_target,this.gl_texture),e?(r.texParameteri(this.gl_target,K.TEXTURE_BASE_LEVEL,0),r.texParameteri(this.gl_target,K.TEXTURE_MAX_LEVEL,Math.log2(this.width)),r.texParameteri(this.gl_target,K.TEXTURE_MIN_FILTER,K.LINEAR_MIPMAP_LINEAR),r.texParameteri(this.gl_target,K.TEXTURE_MAG_FILTER,K.LINEAR)):r.texParameteri(K.TEXTURE_2D,K.TEXTURE_MIN_FILTER,K.NEAREST_MIPMAP_LINEAR),r.generateMipmap(this.gl_target),r.bindTexture(this.gl_target,null)),this)}isNPOT(){const e=this.device.gl;return Te(e)?!1:!mj(this.width)||!mj(this.height)}}class jzt extends Lf{constructor({id:e,device:r,descriptor:i}){super({id:e,device:r}),this.type=$i.RenderTarget,this.gl_renderbuffer=null,this.texture=null;const s=this.device.gl,{format:o,width:n,height:a,sampleCount:l=1,texture:c}=i;let h=!1;
6934if((o===X.D32F||o===X.D24_S8)&&c&&!Te(s)&&!r.WEBGL_depth_texture&&(c.destroy(),this.texture=null,h=!0),!h&&c)this.texture=c;else{this.gl_renderbuffer=this.device.ensureResourceExists(s.createRenderbuffer()),s.bindRenderbuffer(s.RENDERBUFFER,this.gl_renderbuffer);const u=this.device.translateTextureInternalFormat(o,!0);Te(s)&&l>1?s.renderbufferStorageMultisample(K.RENDERBUFFER,l,u,n,a):s.renderbufferStorage(K.RENDERBUFFER,u,n,a)}this.format=o,this.width=n,this.height=a,this.sampleCount=l}destroy(){super.destroy(),this.gl_renderbuffer!==null&&this.device.gl.deleteRenderbuffer(this.gl_renderbuffer),this.texture&&this.texture.destroy()}}var Xu;(function(t){t[t.NeedsCompile=0]="NeedsCompile",t[t.Compiling=1]="Compiling",t[t.NeedsBind=2]="NeedsBind",t[t.ReadyToUse=3]="ReadyToUse"})(Xu||(Xu={}));class Xzt extends Lf{constructor({id:e,device:r,descriptor:i},s){super({id:e,device:r}),this.rawVertexGLSL=s,this.type=$i.Program,this.uniformSetters={},this.attributes=[];const o=this.device.gl;this.descriptor=i,this.gl_program=this.device.ensureResourceExists(o.createProgram()),this.gl_shader_vert=null,this.gl_shader_frag=null,this.compileState=Xu.NeedsCompile,this.tryCompileProgram()}destroy(){super.destroy(),this.device.gl.deleteProgram(this.gl_program),this.device.gl.deleteShader(this.gl_shader_vert),this.device.gl.deleteShader(this.gl_shader_frag)}tryCompileProgram(){pe(this.compileState===Xu.NeedsCompile);const{vertex:e,fragment:r}=this.descriptor,i=this.device.gl;e!=null&&e.glsl&&(r!=null&&r.glsl)&&(this.gl_shader_vert=this.compileShader(e.postprocess?e.postprocess(e.glsl):e.glsl,i.VERTEX_SHADER),this.gl_shader_frag=this.compileShader(r.postprocess?r.postprocess(r.glsl):r.glsl,i.FRAGMENT_SHADER),i.attachShader(this.gl_program,this.gl_shader_vert),i.attachShader(this.gl_program,this.gl_shader_frag),i.linkProgram(this.gl_program),this.compileState=Xu.Compiling,Te(i)||(this.readUniformLocationsFromLinkedProgram(),this.readAttributesFromLinkedProgram()))}readAttributesFromLinkedProgram(){var e;const r=this.device.gl,i=r.getProgramParameter(this.gl_program,r.ACTIVE_ATTRIBUTES),s=Mzt(this.descriptor.vertex.glsl),o=Bzt(this.rawVertexGLSL,s);for(let n=0;n<i;n++){const{name:a,type:l,size:c}=r.getActiveAttrib(this.gl_program,n),h=r.getAttribLocation(this.gl_program,a),u=(e=o.find(d=>d.name===a))===null||e===void 0?void 0:e.location;h>=0&&!me(u)&&(this.attributes[u]={name:a,location:h,type:l,size:c})}}readUniformLocationsFromLinkedProgram(){const e=this.device.gl,r=e.getProgramParameter(this.gl_program,e.ACTIVE_UNIFORMS);for(let i=0;i<r;i++){const s=e.getActiveUniform(this.gl_program,i),{name:o}=Ezt(s.name);let n=e.getUniformLocation(this.gl_program,o);if(this.uniformSetters[o]=Lft(e,n,s),s&&s.size>1)for(let a=0;a<s.size;a++)n=e.getUniformLocation(this.gl_program,`${o}[${a}]`),this.uniformSetters[`${o}[${a}]`]=Lft(e,n,s)}}compileShader(e,r){const i=this.device.gl,s=this.device.ensureResourceExists(i.createShader(r));return i.shaderSource(s,e),i.compileShader(s),s}setUniformsLegacy(e={}){const r=this.device.gl;if(!Te(r)){let i=!1;for(const s in e){i||(r.useProgram(this.gl_program),i=!0);const o=e[s],n=this.uniformSetters[s];if(n){let a=o;a instanceof pq&&(a=a.textureIndex),n(a)}}}return this}}class zzt extends Lf{constructor({id:e,device:r,descriptor:i}){super({id:e,device:r}),this.type=$i.QueryPool;const s=this.device.gl;if(Te(s)){const{elemCount:o,type:n}=i;this.gl_query=QXt(o,()=>this.device.ensureResourceExists(s.createQuery())),this.gl_query_type=Lzt(n)}}queryResultOcclusion(e){const r=this.device.gl;if(Te(r)){const i=this.gl_query[e];return r.getQueryParameter(i,r.QUERY_RESULT_AVAILABLE)?!!r.getQueryParameter(i,r.QUERY_RESULT):null}return null}destroy(){super.destroy();const e=this.device.gl;if(Te(e))for(let r=0;r<this.gl_query.length;r++)e.deleteQuery(this.gl_query[r])}}var gq=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};class Vzt extends Lf{constructor({id:e,device:r}){super({id:e,device:r}),this.type=$i.Readback,this.gl_pbo=null,this.gl_sync=null}clientWaitAsync(e,r=0,i=10){const s=this.device.gl;return new Promise((o,n)=>{function a(){const l=s.clientWaitSync(e,r,0);if(l==s.WAIT_FAILED){n();return}if(l==s.TIMEOUT_EXPIRED){setTimeout(a,Hst(i,0,s.MAX_CLIENT_WAIT_TIMEOUT_WEBGL));return}o()}a()})}getBufferSubDataAsync(e,r,i,s,o,n){return gq(this,void 0,void 0,function*(){const a=this.device.gl;if(Te(a))return this.gl_sync=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0),a.flush(),yield this.clientWaitAsync(this.gl_sync,0,10),a.bindBuffer(e,r),a.getBufferSubData(e,i,s,o,n),a.bindBuffer(e,null),s})}readTexture(e,r,i,s,o,n){return gq(this,arguments,void 0,function*(a,l,c,h,u,d,f=0,g=d.byteLength||0){const p=this.device.gl,m=a,v=this.device.translateTextureFormat(m.format),b=this.device.translateTextureType(m.format),y=ZXt(m.format);return Te(p)?(this.gl_pbo=this.device.ensureResourceExists(p.createBuffer()),p.bindBuffer(p.PIXEL_PACK_BUFFER,this.gl_pbo),p.bufferData(p.PIXEL_PACK_BUFFER,g,p.STREAM_READ),p.bindBuffer(p.PIXEL_PACK_BUFFER,null),p.bindFramebuffer(K.READ_FRAMEBUFFER,this.device.readbackFramebuffer),p.framebufferTexture2D(K.READ_FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_2D,m.gl_texture,0),p.bindBuffer(p.PIXEL_PACK_BUFFER,this.gl_pbo),p.readPixels(l,c,h,u,v,b,f*y),p.bindBuffer(p.PIXEL_PACK_BUFFER,null),this.getBufferSubDataAsync(p.PIXEL_PACK_BUFFER,this.gl_pbo,0,d,f,0)):this.readTextureSync(a,l,c,h,u,d,f,g)})}readTextureSync(e,r,i,s,o,n,a=0,l=n.byteLength||0){const c=this.device.gl,h=e,u=this.device.translateTextureType(h.format);return c.bindFramebuffer(K.FRAMEBUFFER,this.device.readbackFramebuffer),c.framebufferTexture2D(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_2D,h.gl_texture,0),c.pixelStorei(c.PACK_ALIGNMENT,4),c.readPixels(r,i,s,o,c.RGBA,u,n),n}readBuffer(e,r,i,s,o){return gq(this,void 0,void 0,function*(){const n=this.device.gl;return Te(n)?this.getBufferSubDataAsync(n.ARRAY_BUFFER,x2(e,r),r,i,s,o):Promise.reject()})}destroy(){super.destroy(),Te(this.device.gl)&&(this.gl_sync!==null&&this.device.gl.deleteSync(this.gl_sync),this.gl_pbo!==null&&this.device.gl.deleteBuffer(this.gl_pbo))}}class Yzt extends Lf{constructor({id:e,device:r,descriptor:i}){var s,o;super({id:e,device:r}),this.type=$i.RenderPipeline,this.drawMode=Dzt((s=i.topology)!==null&&s!==void 0?s:Ia.TRIANGLES),this.program=i.program,this.inputLayout=i.inputLayout,this.megaState=Object.assign(Object.assign({},E2(K0)),i.megaStateDescriptor),this.colorAttachmentFormats=i.colorAttachmentFormats.slice(),this.depthStencilAttachmentFormat=i.depthStencilAttachmentFormat,this.sampleCount=(o=i.sampleCount)!==null&&o!==void 0?o:1}}class $zt extends Lf{constructor({id:e,device:r,descriptor:i}){super({id:e,device:r}),this.type=$i.ComputePipeline,this.descriptor=i}}class Hzt{constructor(){this.liveObjects=new Set,this.creationStacks=new Map,this.deletionStacks=new Map}trackResourceCreated(e){this.creationStacks.set(e,new Error().stack),this.liveObjects.add(e)}trackResourceDestroyed(e){this.deletionStacks.has(e)&&console.warn("Object double freed:",e,` 6935 6936Creation stack: `,this.creationStacks.get(e),` 6937 6938Deletion stack: `,this.deletionStacks.get(e),` 6939 6940This stack: `,new Error().stack),this.deletionStacks.set(e,new Error().stack),this.liveObjects.delete(e)}checkForLeaks(){for(const e of this.liveObjects.values())console.warn("Object leaked:",e,"Creation stack:",this.creationStacks.get(e))}setResourceLeakCheck(e,r){r?this.liveObjects.add(e):this.liveObjects.delete(e)}}class Kzt extends Lf{constructor({id:e,device:r,descriptor:i}){var s,o;super({id:e,device:r}),this.type=$i.Sampler;const n=this.device.gl;if(Te(n)){const a=this.device.ensureResourceExists(n.createSampler());n.samplerParameteri(a,K.TEXTURE_WRAP_S,VL(i.addressModeU)),n.samplerParameteri(a,K.TEXTURE_WRAP_T,VL(i.addressModeV)),n.samplerParameteri(a,K.TEXTURE_WRAP_R,VL((s=i.addressModeW)!==null&&s!==void 0?s:i.addressModeU)),n.samplerParameteri(a,K.TEXTURE_MIN_FILTER,Aj(i.minFilter,i.mipmapFilter)),n.samplerParameteri(a,K.TEXTURE_MAG_FILTER,Aj(i.magFilter,Ro.NO_MIP)),i.lodMinClamp!==void 0&&n.samplerParameterf(a,K.TEXTURE_MIN_LOD,i.lodMinClamp),i.lodMaxClamp!==void 0&&n.samplerParameterf(a,K.TEXTURE_MAX_LOD,i.lodMaxClamp),i.compareFunction!==void 0&&(n.samplerParameteri(a,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.samplerParameteri(a,n.TEXTURE_COMPARE_FUNC,i.compareFunction));const l=(o=i.maxAnisotropy)!==null&&o!==void 0?o:1;l>1&&this.device.EXT_texture_filter_anisotropic!==null&&(pe(i.minFilter===hs.BILINEAR&&i.magFilter===hs.BILINEAR&&i.mipmapFilter===Ro.LINEAR),n.samplerParameterf(a,this.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,l)),this.gl_sampler=a}else this.descriptor=i}
6940setTextureParameters(e,r,i){var s;const o=this.device.gl,n=this.descriptor;this.isNPOT(r,i)?o.texParameteri(K.TEXTURE_2D,K.TEXTURE_MIN_FILTER,K.LINEAR):o.texParameteri(e,K.TEXTURE_MIN_FILTER,Aj(n.minFilter,n.mipmapFilter)),o.texParameteri(K.TEXTURE_2D,K.TEXTURE_WRAP_S,VL(n.addressModeU)),o.texParameteri(K.TEXTURE_2D,K.TEXTURE_WRAP_T,VL(n.addressModeV)),o.texParameteri(e,K.TEXTURE_MAG_FILTER,Aj(n.magFilter,Ro.NO_MIP));const a=(s=n.maxAnisotropy)!==null&&s!==void 0?s:1;a>1&&this.device.EXT_texture_filter_anisotropic!==null&&(pe(n.minFilter===hs.BILINEAR&&n.magFilter===hs.BILINEAR&&n.mipmapFilter===Ro.LINEAR),o.texParameteri(e,this.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,a))}destroy(){super.destroy(),Te(this.device.gl)&&this.device.gl.deleteSampler(dq(this))}isNPOT(e,r){return!mj(e)||!mj(r)}}class qzt{dispatchWorkgroups(e,r,i){}dispatchWorkgroupsIndirect(e,r){}setPipeline(e){}setBindings(e){}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}}class Zzt extends Lf{constructor(){super(...arguments),this.type=$i.RenderBundle,this.commands=[]}push(e){this.commands.push(e)}replay(){this.commands.forEach(e=>e())}}const Vft=65536,Jzt=/uniform(?:\s+)(\w+)(?:\s?){([^]*?)}/g;class Qzt{constructor(e,r={}){this.shaderDebug=!1,this.OES_vertex_array_object=null,this.ANGLE_instanced_arrays=null,this.OES_texture_float=null,this.OES_draw_buffers_indexed=null,this.WEBGL_draw_buffers=null,this.WEBGL_depth_texture=null,this.WEBGL_color_buffer_float=null,this.EXT_color_buffer_half_float=null,this.WEBGL_compressed_texture_s3tc=null,this.WEBGL_compressed_texture_s3tc_srgb=null,this.EXT_texture_compression_rgtc=null,this.EXT_texture_filter_anisotropic=null,this.KHR_parallel_shader_compile=null,this.EXT_texture_norm16=null,this.EXT_color_buffer_float=null,this.OES_texture_float_linear=null,this.OES_texture_half_float_linear=null,this.scTexture=null,this.scPlatformFramebuffer=null,this.currentActiveTexture=null,this.currentBoundVAO=null,this.currentProgram=null,this.resourceCreationTracker=null,this.resourceUniqueId=0,this.currentColorAttachments=[],this.currentColorAttachmentLevels=[],this.currentColorResolveTos=[],this.currentColorResolveToLevels=[],this.currentSampleCount=-1,this.currentIndexBufferByteOffset=null,this.currentMegaState=E2(K0),this.currentSamplers=[],this.currentTextures=[],this.currentUniformBuffers=[],this.currentUniformBufferByteOffsets=[],this.currentUniformBufferByteSizes=[],this.currentScissorEnabled=!1,this.currentStencilRef=null,this.currentRenderPassDescriptor=null,this.currentRenderPassDescriptorStack=[],this.debugGroupStack=[],this.resolveColorAttachmentsChanged=!1,this.resolveDepthStencilAttachmentsChanged=!1,this.destroyed=!1,this.fallbackTextures=[],this.explicitBindingLocations=!1,this.separateSamplerTextures=!1,this.viewportOrigin=WL.LOWER_LEFT,this.clipSpaceNearZ=jL.NEGATIVE_ONE,this.supportMRT=!1,this.inBlitRenderPass=!1,this.supportedSampleCounts=[],this.occlusionQueriesRecommended=!1,this.computeShadersSupported=!1,this.currentPassToScreen=!1,this.gl=e,this.contextAttributes=oh(e.getContextAttributes()),Te(e)?(this.EXT_texture_norm16=e.getExtension("EXT_texture_norm16"),this.EXT_color_buffer_float=e.getExtension("EXT_color_buffer_float")):(this.OES_vertex_array_object=e.getExtension("OES_vertex_array_object"),this.ANGLE_instanced_arrays=e.getExtension("ANGLE_instanced_arrays"),this.OES_texture_float=e.getExtension("OES_texture_float"),this.WEBGL_draw_buffers=e.getExtension("WEBGL_draw_buffers"),this.WEBGL_depth_texture=e.getExtension("WEBGL_depth_texture"),this.WEBGL_color_buffer_float=e.getExtension("WEBGL_color_buffer_float"),this.EXT_color_buffer_half_float=e.getExtension("EXT_color_buffer_half_float"),e.getExtension("EXT_frag_depth"),e.getExtension("OES_element_index_uint"),e.getExtension("OES_standard_derivatives")),this.WEBGL_compressed_texture_s3tc=e.getExtension("WEBGL_compressed_texture_s3tc"),this.WEBGL_compressed_texture_s3tc_srgb=e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),this.EXT_texture_compression_rgtc=e.getExtension("EXT_texture_compression_rgtc"),this.EXT_texture_filter_anisotropic=e.getExtension("EXT_texture_filter_anisotropic"),this.EXT_texture_norm16=e.getExtension("EXT_texture_norm16"),this.OES_texture_float_linear=e.getExtension("OES_texture_float_linear"),this.OES_texture_half_float_linear=e.getExtension("OES_texture_half_float_linear"),this.KHR_parallel_shader_compile=e.getExtension("KHR_parallel_shader_compile"),Te(e)?(this.platformString="WebGL2",this.glslVersion="#version 300 es"):(this.platformString="WebGL1",this.glslVersion="#version 100"),this.scTexture=new pq({id:this.getNextUniqueId(),device:this,descriptor:{width:0,height:0,depthOrArrayLayers:1,dimension:Xr.TEXTURE_2D,mipLevelCount:1,usage:vi.RENDER_TARGET,format:this.contextAttributes.alpha===!1?X.U8_RGB_RT:X.U8_RGBA_RT},fake:!0}),this.scTexture.formatKind=dn.Float,this.scTexture.gl_target=null,this.scTexture.gl_texture=null,this.resolveColorReadFramebuffer=this.ensureResourceExists(e.createFramebuffer()),this.resolveColorDrawFramebuffer=this.ensureResourceExists(e.createFramebuffer()),this.resolveDepthStencilReadFramebuffer=this.ensureResourceExists(e.createFramebuffer()),this.resolveDepthStencilDrawFramebuffer=this.ensureResourceExists(e.createFramebuffer()),this.renderPassDrawFramebuffer=this.ensureResourceExists(e.createFramebuffer()),this.readbackFramebuffer=this.ensureResourceExists(e.createFramebuffer()),this.fallbackTexture2D=this.createFallbackTexture(Xr.TEXTURE_2D,dn.Float),this.fallbackTexture2DDepth=this.createFallbackTexture(Xr.TEXTURE_2D,dn.Depth),this.fallbackVertexBuffer=this.createBuffer({viewOrSize:1,usage:Ee.VERTEX,hint:rr.STATIC}),Te(e)&&(this.fallbackTexture2DArray=this.createFallbackTexture(Xr.TEXTURE_2D_ARRAY,dn.Float),this.fallbackTexture3D=this.createFallbackTexture(Xr.TEXTURE_3D,dn.Float),this.fallbackTextureCube=this.createFallbackTexture(Xr.TEXTURE_CUBE_MAP,dn.Float)),this.currentMegaState.depthCompare=li.LESS,this.currentMegaState.depthWrite=!1,this.currentMegaState.attachmentsState[0].channelWriteMask=oo.ALL,e.enable(e.DEPTH_TEST),e.enable(e.STENCIL_TEST),this.checkLimits(),r.shaderDebug&&(this.shaderDebug=!0),r.trackResources&&(this.resourceCreationTracker=new Hzt)}destroy(){var e;if(!this.destroyed){this.destroyed=!0,this.blitBindings&&this.blitBindings.destroy(),this.blitInputLayout&&this.blitInputLayout.destroy(),this.blitRenderPipeline&&this.blitRenderPipeline.destroy(),this.blitVertexBuffer&&this.blitVertexBuffer.destroy(),this.blitProgram&&this.blitProgram.destroy(),this.fallbackVertexBuffer.destroy(),this.fallbackTextures.forEac
6940h(r=>r.destroy()),this.fallbackTextures.length=0,(e=this.scTexture)===null||e===void 0||e.destroy();for(const r of[this.resolveColorReadFramebuffer,this.resolveColorDrawFramebuffer,this.resolveDepthStencilReadFramebuffer,this.resolveDepthStencilDrawFramebuffer,this.renderPassDrawFramebuffer,this.readbackFramebuffer])this.gl.deleteFramebuffer(r)}}createFallbackTexture(e,r){const i=e===Xr.TEXTURE_CUBE_MAP?6:1,s=r===dn.Depth?X.D32F:X.U8_RGBA_NORM,o=this.createTexture({dimension:e,format:s,usage:vi.SAMPLED,width:1,height:1,depthOrArrayLayers:i,mipLevelCount:1});return r===dn.Float&&o.setImageData([new Uint8Array(4*i)]),this.fallbackTextures.push(o),S2(o)}getNextUniqueId(){return++this.resourceUniqueId}checkLimits(){const e=this.gl;if(this.maxVertexAttribs=e.getParameter(K.MAX_VERTEX_ATTRIBS),Te(e)){this.uniformBufferMaxPageByteSize=Math.min(e.getParameter(K.MAX_UNIFORM_BLOCK_SIZE),Vft),this.uniformBufferWordAlignment=e.getParameter(e.UNIFORM_BUFFER_OFFSET_ALIGNMENT)/4;const r=e.getInternalformatParameter(e.RENDERBUFFER,e.DEPTH32F_STENCIL8,e.SAMPLES);this.supportedSampleCounts=r?[...r]:[],this.occlusionQueriesRecommended=!0}else this.uniformBufferWordAlignment=64,this.uniformBufferMaxPageByteSize=Vft;this.uniformBufferMaxPageWordSize=this.uniformBufferMaxPageByteSize/4,this.supportedSampleCounts.includes(1)||this.supportedSampleCounts.push(1),this.supportedSampleCounts.sort((r,i)=>r-i)}configureSwapChain(e,r,i){const s=Math.max(1,e),o=Math.max(1,r),n=this.scTexture;n.width=s,n.height=o,this.scPlatformFramebuffer=JXt(i);const a=this.gl.canvas;a&&(a.width!==s||a.height!==o)&&(a.width=s,a.height=o)}getDevice(){return this}getCanvas(){return this.gl.canvas}getOnscreenTexture(){return this.scTexture}beginFrame(){}endFrame(){}translateTextureInternalFormat(e,r=!1){switch(e){case X.ALPHA:return K.ALPHA;case X.U8_LUMINANCE:case X.F16_LUMINANCE:case X.F32_LUMINANCE:return K.LUMINANCE;case X.F16_R:return K.R16F;case X.F16_RG:return K.RG16F;case X.F16_RGB:return K.RGB16F;case X.F16_RGBA:return K.RGBA16F;case X.F32_R:return K.R32F;case X.F32_RG:return K.RG32F;case X.F32_RGB:return K.RGB32F;case X.F32_RGBA:return Te(this.gl)?K.RGBA32F:r?this.WEBGL_color_buffer_float.RGBA32F_EXT:K.RGBA;case X.U8_R_NORM:return K.R8;case X.U8_RG_NORM:return K.RG8;case X.U8_RGB_NORM:case X.U8_RGB_RT:return K.RGB8;case X.U8_RGB_SRGB:return K.SRGB8;case X.U8_RGBA_NORM:case X.U8_RGBA_RT:return Te(this.gl)?K.RGBA8:r?K.RGBA4:K.RGBA;case X.U8_RGBA:return K.RGBA;case X.U8_RGBA_SRGB:case X.U8_RGBA_RT_SRGB:return K.SRGB8_ALPHA8;case X.U16_R:return K.R16UI;case X.U16_R_NORM:return this.EXT_texture_norm16.R16_EXT;case X.U16_RG_NORM:return this.EXT_texture_norm16.RG16_EXT;case X.U16_RGBA_NORM:return this.EXT_texture_norm16.RGBA16_EXT;case X.U16_RGBA_5551:return K.RGB5_A1;case X.U16_RGB_565:return K.RGB565;case X.U32_R:return K.R32UI;case X.S8_RGBA_NORM:return K.RGBA8_SNORM;case X.S8_RG_NORM:return K.RG8_SNORM;case X.BC1:return this.WEBGL_compressed_texture_s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT;case X.BC1_SRGB:return this.WEBGL_compressed_texture_s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;case X.BC2:return this.WEBGL_compressed_texture_s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT;case X.BC2_SRGB:return this.WEBGL_compressed_texture_s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;case X.BC3:return this.WEBGL_compressed_texture_s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT;case X.BC3_SRGB:return this.WEBGL_compressed_texture_s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;case X.BC4_UNORM:return this.EXT_texture_compression_rgtc.COMPRESSED_RED_RGTC1_EXT;case X.BC4_SNORM:return this.EXT_texture_compression_rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT;case X.BC5_UNORM:return this.EXT_texture_compression_rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT;case X.BC5_SNORM:return this.EXT_texture_compression_rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;case X.D32F_S8:return Te(this.gl)?K.DEPTH32F_STENCIL8:this.WEBGL_depth_texture?K.DEPTH_STENCIL:K.DEPTH_COMPONENT16;case X.D24_S8:return Te(this.gl)?K.DEPTH24_STENCIL8:this.WEBGL_depth_texture?K.DEPTH_STENCIL:K.DEPTH_COMPONENT16;case X.D32F:return Te(this.gl)?K.DEPTH_COMPONENT32F:this.WEBGL_depth_texture?K.DEPTH_COMPONENT:K.DEPTH_COMPONENT16;case X.D24:return Te(this.gl)?K.DEPTH_COMPONENT24:this.WEBGL_depth_texture?K.DEPTH_COMPONENT:K.DEPTH_COMPONENT16;default:throw new Error("whoops")}}translateTextureType(e){switch(cy(e)){case Tt.U8:return K.UNSIGNED_BYTE;case Tt.U16:return K.UNSIGNED_SHORT;case Tt.U32:return K.UNSIGNED_INT;case Tt.S8:return K.BYTE;case Tt.F16:return K.HALF_FLOAT;case Tt.F32:return K.FLOAT;case Tt.U16_PACKED_5551:return K.UNSIGNED_SHORT_5_5_5_1;case Tt.D32F:return Te(this.gl)?K.FLOAT:this.WEBGL_depth_texture?K.UNSIGNED_INT:K.UNSIGNED_BYTE;case Tt.D24:return Te(this.gl)?K.UNSIGNED_INT_24_8:this.WEBGL_depth_texture?K.UNSIGNED_SHORT:K.UNSIGNED_BYTE;case Tt.D24S8:return Te(this.gl)?K.UNSIGNED_INT_24_8:this.WEBGL_depth_texture?K.UNSIGNED_INT_24_8_WEBGL:K.UNSIGNED_BYTE;case Tt.D32FS8:return K.FLOAT_32_UNSIGNED_INT_24_8_REV;default:throw new Error("whoops")}}translateInternalTextureFormat(e){switch(e){case X.F32_R:return K.R32F;case X.F32_RG:return K.RG32F;case X.F32_RGB:return K.RGB32F;case X.F32_RGBA:return K.RGBA32F;case X.F16_R:return K.R16F;case X.F16_RG:return K.RG16F;case X.F16_RGB:return K.RGB16F;case X.F16_RGBA:return K.RGBA16F}return this.translateTextureFormat(e)}translateTextureFormat(e){if(Wft(e)||e===X.F32_LUMINANCE||e===X.U8_LUMINANCE)return this.translateTextureInternalFormat(e);const r=Te(this.gl)||!Te(this.gl)&&!!this.WEBGL_depth_texture;switch(e){case X.D24_S8:case X.D32F_S8:return r?K.DEPTH_STENCIL:K.RGBA;case X.D24:case X.D32F:return r?K.DEPTH_COMPONENT:K.RGBA}const i=jft(e);switch(aq(e)){case Se.A:return K.ALPHA;case Se.R:return i?K.RED_INTEGER:K.RED;case Se.RG:return i?K.RG_INTEGER:K.RG;case Se.RGB:return i?K.RGB_INTEGER:K.RGB;case Se.RGBA:return K.RGBA}}setActiveTexture(e){this.currentActiveTexture!==e&&(this.gl.activeTexture(e),this.currentActiveTexture=e)}bindVAO(e){this.currentBoundVAO!==e&&(Te(this.gl)?this.gl.bindVertexArray(e):this.OES_vertex_array_object.bindVertexArrayOES(e),this.currentBoundVAO=e)}programCompiled(e){pe(e.compileState!==Xu.NeedsCompile),e.compileState===Xu.Compiling&&(e.compileState=Xu.NeedsBind,this.shaderDebug&&this.checkProgramCompilationForErrors(e))}useProgram(e){this.currentProgram!==e&&(this.programCompiled(e),this.gl.useProgram(e.gl_program),this.currentProgram=e)}ensureResourceExists(e){if(e===null){const r=this.gl.getError();throw new Error(`Created resource is null; GL error encountered: ${r}`)}else return e}createBuffer(e){return new Gzt({id:this.getNextUniqueId(),device:this,descriptor:e})}createTexture(e){return new pq({id:this.getNextUniqueId(),device:this,descriptor:e})}createSampler(e){return new Kzt({id:this.getNextUniqueId(),device:this,descriptor:e})}createRenderTarget(e){return new jzt({id:this.getNextUniqueId(),device:this,descriptor:e})}createRenderTargetFromTexture(e){const{format:r,width:i,height:s,mipLevelCount:o}=e;return pe(o===1),this.createRenderTarget({format:r,width:i,height:s,sampleCount:1,texture:e})}createProgram(e){var r,i,s;const o=(r=e.vertex)===null||r===void 0?void 0:r.glsl;return!((i=e.vertex)===null||i===void 0)&&i.glsl&&(e.vertex.glsl=Ej(this.queryVendorInfo(),"vert",e.vertex.glsl)),!((s=e.fragment)===null||s===void 0)&&s.glsl&&(e.fragment.glsl=Ej(this.queryVendorInfo(),"frag",e.fragment.glsl)),this.createProgramSimple(e,o)}createProgramSimple(e,r){return new Xzt({id:this.getNextUniqueId(),device:this,descriptor:e},r)}createBindings(e){return new Ozt({id:this.getNextUniqueId(),device:this,descriptor:e})}createInputLayout(e){return new Wzt({id:this.getNextUniqueId(),device:this,descriptor:e})}createRenderPipeline(e){return new Yzt({id:this.getNextUniqueId(),device:this,descriptor:e})}createComputePass(){return new qzt}createComputePipeline(e){return new $zt({id:this.getNextUniqueId(),device:this,descriptor:e})}createReadback(){return new Vzt({id:this.getNextUniqueId(),device:this})}createQueryPool(e,r){return new zzt({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:r}})}formatRenderPassDescriptor(e){var r,i,s,o,n,a;const{colorAttachment:l}=e;e.depthClearValue=(r=e.depthClearValue)!==null&&r!==void 0?r:"load",e.stencilClearValue=(i=e.stencilClearValue)!==null&&i!==void 0?i:"load";for(let c=0;c<l.length;c++)e.colorAttachmentLevel||(e.colorAttachmentLevel=[]),e.colorAttachmentLevel[c]=(s=e.colorAttachmentLevel[c])!==null&&s!==void 0?s:0,e.colorResolveToLevel||(e.colorResolveToLevel=[]),e.colorResolveToLevel[c]=(o=e.colorResolveToLevel[c])!==null&&o!==void 0?o:0,e.colorClearColor||(e.colorClearColor=[]),e.colorClearColor[c]=(n=e.colorClearColor[c])!==null&&n!==void 0?n:"load",e.colorStore||(e.colorStore=[]),e.colorStore[c]=(a=e.colorStore[c])!==null&&a!==void 0?a:!1}createRenderBundle(){return new Zzt({id:this.getNextUniqueId(),device:this})}beginBundle(e){this.renderBundle=e}endBundle(){this.renderBundle=void 0}executeBundles(e){e.forEach(r=>{r.replay()})}createRenderPass(e){this.currentRenderPassDescriptor!==null&&this.currentRenderPassDescriptorStack.push(this.currentRenderPassDescriptor),this.currentRenderPassDescriptor=e,this.formatRenderPassDescriptor(e);const{colorAttachment:r,colorAttachmentLevel:i,colorClearColor:s,colorResolveTo:o,colorResolveToLevel:n,depthStencilAttachment:a,depthClearValue:l,stencilClearValue:c,depthStencilResolveTo:h}=e,u=this.computeSkipBlit(o,r);this.setRenderPassParametersBegin(r.length,u);for(let d=0;d<r.length;d++)this.setRenderPassParametersColor(d,r[d],i[d],o[d],n[d],u);this.setRenderPassParametersDepthStencil(a,h,u),this.validateCurrentAttachments();for(let d=0;d<r.length;d++){const f=s[d];f!=="load"&&this.setRenderPassParametersClearColor(d,f.r,f.g,f.b,f.a)}return this.setRenderPassParametersClearDepthStencil(l,c),this}submitPass(e){pe(this.currentRenderPassDescriptor!==null),this.endPass(),this.currentRenderPassDescriptorStack.length?this.currentRenderPassDescriptor=this.currentRenderPassDescriptorStack.pop():this.currentRenderPassDescriptor=null}submitComputeImmediate(e){throw new Error("submitComputeImmediate requires WebGPU")}saveRenderPassAttachmentState(){return{descriptor:this.currentRenderPassDescriptor,stack:this.currentRenderPassDescriptorStack.slice(),colorAttachments:this.currentColorAttachments.slice(),colorAttachmentLevels:this.currentColorAttachmentLevels.slice(),colorResolveTos:this.currentColorResolveTos.slice(),colorResolveToLevels:this.currentColorResolveToLevels.slice(),depthStencilAttachment:this.currentDepthStencilAttachment,depthStencilResolveTo:this.currentDepthStencilResolveTo,sampleCount:this.currentSampleCount,resolve
6940ColorAttachmentsChanged:this.resolveColorAttachmentsChanged,resolveDepthStencilAttachmentsChanged:this.resolveDepthStencilAttachmentsChanged,currentPassToScreen:this.currentPassToScreen}}restoreRenderPassAttachmentState(e){this.currentRenderPassDescriptor=e.descriptor,this.currentRenderPassDescriptorStack=e.stack.slice(),this.currentColorAttachments=e.colorAttachments.slice(),this.currentColorAttachmentLevels=e.colorAttachmentLevels.slice(),this.currentColorResolveTos=e.colorResolveTos.slice(),this.currentColorResolveToLevels=e.colorResolveToLevels.slice(),this.currentDepthStencilAttachment=e.depthStencilAttachment,this.currentDepthStencilResolveTo=e.depthStencilResolveTo,this.currentSampleCount=e.sampleCount,this.resolveColorAttachmentsChanged=e.resolveColorAttachmentsChanged,this.resolveDepthStencilAttachmentsChanged=e.resolveDepthStencilAttachmentsChanged,this.currentPassToScreen=e.currentPassToScreen;const r=this.gl;Te(r)?(r.bindFramebuffer(K.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(K.READ_FRAMEBUFFER,null)):r.bindFramebuffer(K.FRAMEBUFFER,null)}submitRenderPassImmediate(e,r){const i=this.saveRenderPassAttachmentState();this.currentRenderPassDescriptor=null,this.currentRenderPassDescriptorStack=[];const s=this.createRenderPass(e);r(s),this.submitPass(s),this.restoreRenderPassAttachmentState(i),this.resolveColorAttachmentsChanged=!0,this.resolveDepthStencilAttachmentsChanged=!0}copySubTexture2D(e,r,i,s,o,n){const a=this.gl,l=e,c=s;if(pe(c.mipLevelCount===1),pe(l.mipLevelCount===1),Te(a))l===this.scTexture?a.bindFramebuffer(a.DRAW_FRAMEBUFFER,this.scPlatformFramebuffer):(a.bindFramebuffer(a.DRAW_FRAMEBUFFER,this.resolveColorDrawFramebuffer),this.bindFramebufferAttachment(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0,l,0)),a.bindFramebuffer(a.READ_FRAMEBUFFER,this.resolveColorReadFramebuffer),this.bindFramebufferAttachment(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,c,0),a.blitFramebuffer(o,n,o+c.width,n+c.height,r,i,r+c.width,i+c.height,a.COLOR_BUFFER_BIT,a.LINEAR),a.bindFramebuffer(a.READ_FRAMEBUFFER,null),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,null);else if(l===this.scTexture){const h=this.createRenderTargetFromTexture(s);this.submitBlitRenderPass(h,l)}}queryLimits(){return this}queryTextureFormatSupported(e,r,i){switch(e){case X.BC1_SRGB:case X.BC2_SRGB:case X.BC3_SRGB:return this.WEBGL_compressed_texture_s3tc_srgb!==null?fq(r,i,4,4):!1;case X.BC1:case X.BC2:case X.BC3:return this.WEBGL_compressed_texture_s3tc!==null?fq(r,i,4,4):!1;case X.BC4_UNORM:case X.BC4_SNORM:case X.BC5_UNORM:case X.BC5_SNORM:return this.EXT_texture_compression_rgtc!==null?fq(r,i,4,4):!1;case X.U16_R_NORM:case X.U16_RG_NORM:case X.U16_RGBA_NORM:return this.EXT_texture_norm16!==null;case X.F32_R:case X.F32_RG:case X.F32_RGB:case X.F32_RGBA:return this.OES_texture_float_linear!==null;case X.F16_R:case X.F16_RG:case X.F16_RGB:case X.F16_RGBA:return this.OES_texture_half_float_linear!==null;default:return!0}}queryProgramReady(e){const r=this.gl;if(e.compileState===Xu.NeedsCompile)throw new Error("whoops");if(e.compileState===Xu.Compiling){let i;return this.KHR_parallel_shader_compile!==null?i=r.getProgramParameter(e.gl_program,this.KHR_parallel_shader_compile.COMPLETION_STATUS_KHR):i=!0,i&&this.programCompiled(e),i}return e.compileState===Xu.NeedsBind||e.compileState===Xu.ReadyToUse}queryPlatformAvailable(){return this.gl.isContextLost()}queryVendorInfo(){return this}queryRenderPass(e){return this.currentRenderPassDescriptor}queryRenderTarget(e){return e}setResourceName(e,r){if(e.name=r,e.type===$i.Buffer){const{gl_buffer_pages:i}=e;for(let s=0;s<i.length;s++)YL(i[s],`${r} Page ${s}`)}else if(e.type===$i.Texture)YL(S2(e),r);else if(e.type===$i.Sampler)YL(dq(e),r);else if(e.type===$i.RenderTarget){const{gl_renderbuffer:i}=e;i!==null&&YL(i,r)}else e.type===$i.InputLayout&&YL(e.vao,r)}setResourceLeakCheck(e,r){this.resourceCreationTracker!==null&&this.resourceCreationTracker.setResourceLeakCheck(e,r)}checkForLeaks(){this.resourceCreationTracker!==null&&this.resourceCreationTracker.checkForLeaks()}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}programPatched(e,r){pe(this.shaderDebug)}getBufferData(e,r,i=0){const s=this.gl;Te(s)&&(s.bindBuffer(s.COPY_READ_BUFFER,x2(e,i*4)),s.getBufferSubData(s.COPY_READ_BUFFER,i*4,r))}debugGroupStatisticsDrawCall(e=1){for(let r=this.debugGroupStack.length-1;r>=0;r--)this.debugGroupStack[r].drawCallCount+=e}debugGroupStatisticsBufferUpload(e=1){for(let r=this.debugGroupStack.length-1;r>=0;r--)this.debugGroupStack[r].bufferUploadCount+=e}debugGroupStatisticsTextureBind(e=1){for(let r=this.debugGroupStack.length-1;r>=0;r--)this.debugGroupStack[r].textureBindCount+=e}debugGroupStatisticsTriangles(e){for(let r=this.debugGroupStack.length-1;r>=0;
6940r--)this.debugGroupStack[r].triangleCount+=e}reportShaderError(e,r){const i=this.gl,s=i.getShaderParameter(e,i.COMPILE_STATUS);if(!s){console.error(tzt(r));const o=i.getExtension("WEBGL_debug_shaders");o&&console.error(o.getTranslatedShaderSource(e)),console.error(i.getShaderInfoLog(e))}return s}checkProgramCompilationForErrors(e){const r=this.gl,i=e.gl_program;if(!r.getProgramParameter(i,r.LINK_STATUS)){const s=e.descriptor;if(!this.reportShaderError(e.gl_shader_vert,s.vertex.glsl)||!this.reportShaderError(e.gl_shader_frag,s.fragment.glsl))return;console.error(r.getProgramInfoLog(e.gl_program))}}bindFramebufferAttachment(e,r,i,s){const o=this.gl;if(me(i))o.framebufferRenderbuffer(e,r,o.RENDERBUFFER,null);else if(i.type===$i.RenderTarget)i.gl_renderbuffer!==null?o.framebufferRenderbuffer(e,r,o.RENDERBUFFER,i.gl_renderbuffer):i.texture!==null&&o.framebufferTexture2D(e,r,K.TEXTURE_2D,S2(i.texture),s);else if(i.type===$i.Texture){const n=S2(i);i.dimension===Xr.TEXTURE_2D?o.framebufferTexture2D(e,r,K.TEXTURE_2D,n,s):Te(o)&&(i.dimension,Xr.TEXTURE_2D_ARRAY)}}bindFramebufferDepthStencilAttachment(e,r){const i=this.gl,s=me(r)?oe.Depth|oe.Stencil:w2(r.format),o=!!(s&oe.Depth),n=!!(s&oe.Stencil);o&&n?Te(this.gl)||!Te(this.gl)&&this.WEBGL_depth_texture?this.bindFramebufferAttachment(e,i.DEPTH_STENCIL_ATTACHMENT,r,0):this.bindFramebufferAttachment(e,i.DEPTH_ATTACHMENT,r,0):o?(this.bindFramebufferAttachment(e,i.DEPTH_ATTACHMENT,r,0),this.bindFramebufferAttachment(e,i.STENCIL_ATTACHMENT,null,0)):n&&(this.bindFramebufferAttachment(e,i.STENCIL_ATTACHMENT,r,0),this.bindFramebufferAttachment(e,i.DEPTH_ATTACHMENT,null,0))}validateCurrentAttachments(){let e=-1,r=-1,i=-1;for(let s=0;s<this.currentColorAttachments.length;s++){const o=this.currentColorAttachments[s];o!==null&&(e===-1?(e=o.sampleCount,r=o.width,i=o.height):(pe(e===o.sampleCount),pe(r===o.width),pe(i===o.height)))}this.currentDepthStencilAttachment&&(e===-1?e=this.currentDepthStencilAttachment.sampleCount:(pe(e===this.currentDepthStencilAttachment.sampleCount),pe(r===this.currentDepthStencilAttachment.width),pe(i===this.currentDepthStencilAttachment.height))),this.currentSampleCount=e}setRenderPassParametersBegin(e,r=!1){const i=this.gl;if(this.currentPassToScreen=r,r)Te(i)?(i.bindFramebuffer(K.DRAW_FRAMEBUFFER,null),i.drawBuffers([K.BACK])):i.bindFramebuffer(K.FRAMEBUFFER,null);else{if(Te(i)?i.bindFramebuffer(K.DRAW_FRAMEBUFFER,this.renderPassDrawFramebuffer):this.inBlitRenderPass||i.bindFramebuffer(K.FRAMEBUFFER,this.renderPassDrawFramebuffer),Te(i)){const s=[];for(let o=0;o<4;o++)s.push(o<e?K.COLOR_ATTACHMENT0+o:K.NONE);i.drawBuffers(s)}else if(!this.inBlitRenderPass&&this.WEBGL_draw_buffers){const s=[];for(let o=0;o<4;o++)s.push(o<e?K.COLOR_ATTACHMENT0_WEBGL+o:K.NONE);this.WEBGL_draw_buffers.drawBuffersWEBGL(s)}if(!this.inBlitRenderPass)for(let s=e;s<this.currentColorAttachments.length;s++){const o=Te(i)?K.DRAW_FRAMEBUFFER:K.FRAMEBUFFER,n=Te(i)?K.COLOR_ATTACHMENT0:K.COLOR_ATTACHMENT0_WEBGL;i.framebufferRenderbuffer(o,n+s,K.RENDERBUFFER,null),i.framebufferTexture2D(o,n+s,K.TEXTURE_2D,null,0)}}this.currentColorAttachments.length=e}setRenderPassParametersColor(e,r,i,s,o,n=!1){const a=this.gl,l=Te(a);!n&&(l||e===0||this.WEBGL_draw_buffers)&&this.bindFramebufferAttachment(l?K.DRAW_FRAMEBUFFER:K.FRAMEBUFFER,(l?K.COLOR_ATTACHMENT0:K.COLOR_ATTACHMENT0_WEBGL)+e,r,i),(this.currentColorAttachments[e]!==r||this.currentColorAttachmentLevels[e]!==i)&&(this.currentColorAttachments[e]=r,this.currentColorAttachmentLevels[e]=i,this.resolveColorAttachmentsChanged=!0),(this.currentColorResolveTos[e]!==s||this.currentColorResolveToLevels[e]!==o)&&(this.currentColorResolveTos[e]=s,this.currentColorResolveToLevels[e]=o,s!==null&&(this.resolveColorAttachmentsChanged=!0))}setRenderPassParametersDepthStencil(e,r,i=!1){const s=this.gl;!i&&!this.inBlitRenderPass&&this.bindFramebufferDepthStencilAttachment(Te(s)?K.DRAW_FRAMEBUFFER:K.FRAMEBUFFER,e),this.currentDepthStencilAttachment!==e&&(this.currentDepthStencilAttachment=e,this.resolveDepthStencilAttachmentsChanged=!0),this.currentDepthStencilResolveTo!==r&&(this.currentDepthStencilResolveTo=r,r&&(this.resolveDepthStencilAttachmentsChanged=!0))}setRenderPassParametersClearColor(e,r,i,s,o){const n=this.gl;if(this.OES_draw_buffers_indexed!==null){const a=this.currentMegaState.attachmentsState[e];a&&a.channelWriteMask!==oo.ALL&&(this.OES_draw_buffers_indexed.colorMaskiOES(e,!0,!0,!0,!0),a.channelWriteMask=oo.ALL)}else{const a=this.currentMegaState.attachmentsState[0];
6940a&&a.channelWriteMask!==oo.ALL&&(n.colorMask(!0,!0,!0,!0),a.channelWriteMask=oo.ALL)}this.setScissorRectEnabled(!1),Te(n)?this.currentPassToScreen?(n.clearColor(r,i,s,o),n.clear(n.COLOR_BUFFER_BIT)):n.clearBufferfv(n.COLOR,e,[r,i,s,o]):(n.clearColor(r,i,s,o),n.clear(n.COLOR_BUFFER_BIT))}setRenderPassParametersClearDepthStencil(e="load",r="load"){const i=this.gl;e!=="load"&&(pe(!!this.currentDepthStencilAttachment),this.currentMegaState.depthWrite||(i.depthMask(!0),this.currentMegaState.depthWrite=!0),Te(i)?this.currentPassToScreen?(i.clearDepth(e),i.clear(i.DEPTH_BUFFER_BIT)):i.clearBufferfv(i.DEPTH,0,[e]):(i.clearDepth(e),i.clear(i.DEPTH_BUFFER_BIT))),r!=="load"&&(pe(!!this.currentDepthStencilAttachment),this.currentMegaState.stencilWrite||(i.enable(i.STENCIL_TEST),i.stencilMask(255),this.currentMegaState.stencilWrite=!0),Te(i)?this.currentPassToScreen?(i.clearStencil(r),i.clear(i.STENCIL_BUFFER_BIT)):i.clearBufferiv(i.STENCIL,0,[r]):(i.clearStencil(r),i.clear(i.STENCIL_BUFFER_BIT)))}setBindings(e){var r;if(this.renderBundle){this.renderBundle.push(()=>this.setBindings(e));return}const i=this.gl,{uniformBufferBindings:s,samplerBindings:o,bindingLayouts:n}=e;pe(0<n.bindingLayoutTables.length);const a=n.bindingLayoutTables[0];pe(s.length>=a.numUniformBuffers),pe(o.length>=a.numSamplers);for(let l=0;l<s.length;l++){const c=s[l];if(c.size===0)continue;const h=a.firstUniformBuffer+l,u=c.buffer,d=c.offset||0,f=c.size||u.byteSize;if(u!==this.currentUniformBuffers[h]||d!==this.currentUniformBufferByteOffsets[h]||f!==this.currentUniformBufferByteSizes[h]){const g=d%u.pageByteSize,p=u.gl_buffer_pages[d/u.pageByteSize|0];pe(g+f<=u.pageByteSize),Te(i)&&i.bindBufferRange(i.UNIFORM_BUFFER,h,p,g,f),this.currentUniformBuffers[h]=u,this.currentUniformBufferByteOffsets[h]=d,this.currentUniformBufferByteSizes[h]=f}}for(let l=0;l<a.numSamplers;l++){const c=o[l],h=a.firstSampler+l,u=c!==null&&c.sampler!==null?dq(c.sampler):null,d=c!==null&&c.texture!==null?S2(c.texture):null;if(this.currentSamplers[h]!==u&&(Te(i)&&i.bindSampler(h,u),this.currentSamplers[h]=u),this.currentTextures[h]!==d){if(this.setActiveTexture(i.TEXTURE0+h),d!==null){const{gl_target:f,width:g,height:p}=oh(c).texture;c.texture.textureIndex=h,i.bindTexture(f,d),Te(i)||(r=c.sampler)===null||r===void 0||r.setTextureParameters(f,g,p),this.debugGroupStatisticsTextureBind()}else{const f=Object.assign(Object.assign({},c),Ift),{dimension:g,formatKind:p}=f,m=Uzt(g);i.bindTexture(m,this.getFallbackTexture(Object.assign({gl_target:m,formatKind:p},f)))}this.currentTextures[h]=d}}}setViewport(e,r,i,s){this.gl.viewport(e,r,i,s)}setScissorRect(e,r,i,s){const o=this.gl;this.setScissorRectEnabled(!0),o.scissor(e,r,i,s)}applyAttachmentStateIndexed(e,r,i){const s=this.gl,o=this.OES_draw_buffers_indexed;r.channelWriteMask!==i.channelWriteMask&&(o.colorMaskiOES(e,!!(i.channelWriteMask&oo.RED),!!(i.channelWriteMask&oo.GREEN),!!(i.channelWriteMask&oo.BLUE),!!(i.channelWriteMask&oo.ALPHA)),r.channelWriteMask=i.channelWriteMask);const n=r.rgbBlendState.blendMode!==i.rgbBlendState.blendMode||r.alphaBlendState.blendMode!==i.alphaBlendState.blendMode,a=r.rgbBlendState.blendSrcFactor!==i.rgbBlendState.blendSrcFactor||r.alphaBlendState.blendSrcFactor!==i.alphaBlendState.blendSrcFactor||r.rgbBlendState.blendDstFactor!==i.rgbBlendState.blendDstFactor||r.alphaBlendState.blendDstFactor!==i.alphaBlendState.blendDstFactor;(a||n)&&(uw(r.rgbBlendState)&&uw(r.alphaBlendState)?o.enableiOES(e,s.BLEND):uw(i.rgbBlendState)&&uw(i.alphaBlendState)&&o.disableiOES(e,s.BLEND)),n&&(o.blendEquationSeparateiOES(e,i.rgbBlendState.blendMode,i.alphaBlendState.blendMode),r.rgbBlendState.blendMode=i.rgbBlendState.blendMode,r.alphaBlendState.blendMode=i.alphaBlendState.blendMode),a&&(o.blendFuncSeparateiOES(e,i.rgbBlendState.blendSrcFactor,i.rgbBlendState.blendDstFactor,i.alphaBlendState.blendSrcFactor,i.alphaBlendState.blendDstFactor),r.rgbBlendState.blendSrcFactor=i.rgbBlendState.blendSrcFactor,r.alphaBlendState.blendSrcFactor=i.alphaBlendState.blendSrcFactor,r.rgbBlendState.blendDstFactor=i.rgbBlendState.blendDstFactor,r.alphaBlendState.blendDstFactor=i.alphaBlendState.blendDstFactor)}applyAttachmentState(e,r){const i=this.gl;e.channelWriteMask!==r.channelWriteMask&&(i.colorMask(!!(r.channelWriteMask&oo.RED),!!(r.channelWriteMask&oo.GREEN),!!(r.channelWriteMask&oo.BLUE),!!(r.channelWriteMask&oo.ALPHA)),e.channelWriteMask=r.channelWriteMask);const s=e.rgbBlendState.blendMode!==r.rgbBlendState.blendMode||e.alphaBlendState.blendMode!==r.alphaBlendState.blendMode,o=e.rgbBlendState.blendSrcFactor!==r.rgbBlendState.blendSrcFactor||e.alphaBlendState.blendSrcFactor!==r.alphaBlendState.blendSrcFactor||e.rgbBlendState.blendDstFactor!==r.rgbBlendState.blendDstFactor||e.alphaBlendState.blendDstFactor!==r.alphaBlendState.blendDstFactor;(o||s)&&(uw(e.rgbBlendState)&&uw(e.alphaBlendState)?i.enable(i.BLEND):uw(r.rgbBlendState)&&uw(r.alphaBlendState)&&i.disable(i.BLEND)),s&&(i.blendEquationSeparate(r.rgbBlendState.blendMode,r.alphaBlendState.blendMode),e.rgbBlendState.blendMode=r.rgbBlendState.blendMode,e.alphaBlendState.blendMode=r.alphaBlendState.blendMode),o&&(i.blendFuncSeparate(r.rgbBlendState.blendSrcFactor,r.rgbBlendState.blendDstFactor,r.alphaBlendState.blendSrcFactor,r.alphaBlendState.blendDstFactor),e.rgbBlendState.blendSrcFactor=r.rgbBlendState.blendSrcFactor,e.alphaBlendState.blendSrcFactor=r.alphaBlendState.blendSrcFactor,e.rgbBlendState.blendDstFactor=r.rgbBlendState.blendDstFactor,e.alphaBlendState.blendDstFactor=r.alphaBlendState.blendDstFactor)}setMegaState(e){const r=this.gl,i=this.currentMegaState;if(this.OES_draw_buffers_indexed!==null)for(let o=0;o<e.attachmentsState.length;o++)this.applyAttachmentStateIndexed(o,i.attachmentsState[0],e.attachmentsState[0]);else pe(e.attachmentsState.length===1),this.applyAttachmentState(i.attachmentsState[0],e.attachmentsState[0]);
6940xft(i.blendConstant,e.blendConstant)||(r.blendColor(e.blendConstant.r,e.blendConstant.g,e.blendConstant.b,e.blendConstant.a),Sft(i.blendConstant,e.blendConstant)),i.depthCompare!==e.depthCompare&&(r.depthFunc(e.depthCompare),i.depthCompare=e.depthCompare),!!i.depthWrite!=!!e.depthWrite&&(r.depthMask(e.depthWrite),i.depthWrite=e.depthWrite),!!i.stencilWrite!=!!e.stencilWrite&&(r.stencilMask(e.stencilWrite?255:0),i.stencilWrite=e.stencilWrite);let s=!1;if(!bj(i.stencilFront,e.stencilFront)){s=!0;const{passOp:o,failOp:n,depthFailOp:a,compare:l}=e.stencilFront;(i.stencilFront.passOp!==o||i.stencilFront.failOp!==n||i.stencilFront.depthFailOp!==a)&&(r.stencilOpSeparate(r.FRONT,n,a,o),i.stencilFront.passOp=o,i.stencilFront.failOp=n,i.stencilFront.depthFailOp=a),i.stencilFront.compare!==l&&(this.setStencilReference(0),i.stencilFront.compare=l)}if(!bj(i.stencilBack,e.stencilBack)){s=!0;const{passOp:o,failOp:n,depthFailOp:a,compare:l}=e.stencilBack;(i.stencilBack.passOp!==o||i.stencilBack.failOp!==n||i.stencilBack.depthFailOp!==a)&&(r.stencilOpSeparate(r.BACK,n,a,o),i.stencilBack.passOp=o,i.stencilBack.failOp=n,i.stencilBack.depthFailOp=a),i.stencilBack.compare!==l&&(this.setStencilReference(0),i.stencilBack.compare=l)}(i.stencilFront.mask!==e.stencilFront.mask||i.stencilBack.mask!==e.stencilBack.mask)&&(s=!0,i.stencilFront.mask=e.stencilFront.mask,i.stencilBack.mask=e.stencilBack.mask),s&&this.applyStencil(),i.cullMode!==e.cullMode&&(i.cullMode===jl.NONE?r.enable(r.CULL_FACE):e.cullMode===jl.NONE&&r.disable(r.CULL_FACE),e.cullMode===jl.BACK?r.cullFace(r.BACK):e.cullMode===jl.FRONT?r.cullFace(r.FRONT):e.cullMode===jl.FRONT_AND_BACK&&r.cullFace(r.FRONT_AND_BACK),i.cullMode=e.cullMode),i.frontFace!==e.frontFace&&(r.frontFace(e.frontFace),i.frontFace=e.frontFace),i.polygonOffset!==e.polygonOffset&&(e.polygonOffset?r.enable(r.POLYGON_OFFSET_FILL):r.disable(r.POLYGON_OFFSET_FILL),i.polygonOffset=e.polygonOffset),(i.polygonOffsetFactor!==e.polygonOffsetFactor||i.polygonOffsetUnits!==e.polygonOffsetUnits)&&(r.polygonOffset(e.polygonOffsetFactor,e.polygonOffsetUnits),i.polygonOffsetFactor=e.polygonOffsetFactor,i.polygonOffsetUnits=e.polygonOffsetUnits)}validatePipelineFormats(e){if(!this.inBlitRenderPass){for(let r=0;r<this.currentColorAttachments.length;r++)this.currentColorAttachments[r];this.currentDepthStencilAttachment&&pe(this.currentDepthStencilAttachment.format===e.depthStencilAttachmentFormat),this.currentSampleCount!==-1&&pe(this.currentSampleCount===e.sampleCount)}}setPipeline(e){if(this.renderBundle){this.renderBundle.push(()=>this.setPipeline(e));return}this.currentPipeline=e,this.validatePipelineFormats(this.currentPipeline),this.setMegaState(this.currentPipeline.megaState);const r=this.currentPipeline.program;if(this.useProgram(r),r.compileState===Xu.NeedsBind){const i=this.gl,s=r.gl_program,o=r.descriptor,n=zft(o.vertex.glsl,Jzt);if(Te(i))for(let l=0;l<n.length;l++){const[,c]=n[l],h=i.getUniformBlockIndex(s,c);h!==-1&&h!==4294967295&&i.uniformBlockBinding(s,h,l)}const a=zft(o.fragment.glsl,/^uniform .*sampler\S+ (\w+);\s* \/\/ BINDING=(\d+)$/gm);for(let l=0;l<a.length;l++){const[,c,h]=a[l],u=i.getUniformLocation(s,c);i.uniform1i(u,parseInt(h))}r.compileState=Xu.ReadyToUse}}setVertexInput(e,r,i){var s;if(this.renderBundle){this.renderBundle.push(()=>this.setVertexInput(e,r,i));return}if(e!==null){pe(this.currentPipeline.inputLayout===e);const o=e;this.bindVAO(o.vao);const n=this.gl;for(let a=0;a<o.vertexBufferDescriptors.length;a++){const l=o.vertexBufferDescriptors[a],{arrayStride:c,attributes:h}=l;for(const u of h){const{shaderLocation:d,offset:f}=u,g=Te(n)?d:(s=o.program.attributes[d])===null||s===void 0?void 0:s.location;if(!me(g)){const p=r[a];if(p===null)continue;const m=u.vertexFormat;n.bindBuffer(n.ARRAY_BUFFER,x2(p.buffer));const v=(p.offset||0)+f;n.vertexAttribPointer(g,m.size,m.type,m.normalized,c,v)}}}if(pe(i!==null==(o.indexBufferFormat!==null)),i!==null){const a=i.buffer;pe(a.usage===Ee.INDEX),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,x2(a)),this.currentIndexBufferByteOffset=i.offset||0}else this.currentIndexBufferByteOffset=null}else pe(this.currentPipeline.inputLayout===null),pe(i===null),this.bindVAO(null),this.currentIndexBufferByteOffset=0}setStencilReference(e){this.currentStencilRef!==e&&(this.currentStencilRef=e,this.applyStencil())}draw(e,r,i,s){if(this.renderBundle){this.renderBundle.push(()=>this.draw(e,r,i,s));return}const o=this.gl,n=this.currentPipeline;if(r){const a=[n.drawMode,i||0,e,r];Te(o)?o.drawArraysInstanced(...a):this.ANGLE_instanced_arrays.drawArraysInstancedANGLE(...a)}else o.drawArrays(n.drawMode,i,e);this.debugGroupStatisticsDrawCall(),this.debugGroupStatisticsTriangles(e/3*Math.max(r,1))}drawIndexed(e,r,i,s,o){if(this.renderBundle){this.renderBundle.push(()=>this.drawIndexed(e,r,i,s,o));return}const n=this.gl,a=this.currentPipeline,l=oh(a.inputLayout),c=oh(this.currentIndexBufferByteOffset)+i*l.indexBufferCompByteSize;if(r){const h=[a.drawMode,e,l.indexBufferType,c,r];Te(n)?n.drawElementsInstanced(...h):this.ANGLE_instanced_arrays.drawElementsInstancedANGLE(...h)}else n.drawElements(a.drawMode,e,l.indexBufferType,c);this.debugGroupStatisticsDrawCall(),this.debugGroupStatisticsTriangles(e/3*Math.max(r,1))}drawIndirect(e,r){}drawIndexedIndirect(e,r){}beginOcclusionQuery(e){const r=this.gl;if(Te(r)){const i=this.currentRenderPassDescriptor.occlusionQueryPool;r.beginQuery(i.gl_query_type,i.gl_query[e])}}endOcclusionQuery(){const e=this.gl;if(Te(e)){const r=this.currentRenderPassDescriptor.occlusionQueryPool;e.endQuery(r.gl_query_type)}}pipelineQueryReady(e){const r=e;return this.queryProgramReady(r.program)}pipelineForceReady(e){}computeSkipBlit(e,r){return e.length===1&&e[0]===this.scTexture?r.filter(i=>i!==null).length<=1:!1}shouldUseShaderColorBlit(e,r){return r===null?!1:!!(!Te(this.gl)||r===this.scTexture&&this.contextAttributes.antialias||e.sampleC
6940ount>1)}endPass(){const e=this.gl,r=Te(e),i=this.computeSkipBlit(this.currentColorResolveTos,this.currentColorAttachments);let s=!1;for(let n=0;n<this.currentColorAttachments.length;n++){const a=this.currentColorAttachments[n];if(a!==null){const l=this.currentColorResolveTos[n];let c=!1;if(l!==null){pe(a.width===l.width&&a.height===l.height),this.setScissorRectEnabled(!1);const h=this.shouldUseShaderColorBlit(a,l);!i&&!h&&(r&&e.bindFramebuffer(e.READ_FRAMEBUFFER,this.resolveColorReadFramebuffer),this.resolveColorAttachmentsChanged&&r&&this.bindFramebufferAttachment(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,a,this.currentColorAttachmentLevels[n])),c=!0,!i&&!h&&(l===this.scTexture?e.bindFramebuffer(r?K.DRAW_FRAMEBUFFER:K.FRAMEBUFFER,this.scPlatformFramebuffer):(e.bindFramebuffer(r?K.DRAW_FRAMEBUFFER:K.FRAMEBUFFER,this.resolveColorDrawFramebuffer),this.resolveColorAttachmentsChanged&&e.framebufferTexture2D(r?K.DRAW_FRAMEBUFFER:K.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,l.gl_texture,this.currentColorResolveToLevels[n]))),i||(h?this.submitBlitRenderPass(a,l):r?(e.blitFramebuffer(0,0,a.width,a.height,0,0,l.width,l.height,e.COLOR_BUFFER_BIT,e.LINEAR),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null)):this.submitBlitRenderPass(a,l)),s=!0}this.currentRenderPassDescriptor.colorStore[n]||!i&&!c&&(e.bindFramebuffer(r?K.READ_FRAMEBUFFER:K.FRAMEBUFFER,this.resolveColorReadFramebuffer),this.resolveColorAttachmentsChanged&&this.bindFramebufferAttachment(r?K.READ_FRAMEBUFFER:K.FRAMEBUFFER,e.COLOR_ATTACHMENT0,a,this.currentColorAttachmentLevels[n])),i||e.bindFramebuffer(r?K.READ_FRAMEBUFFER:K.FRAMEBUFFER,null)}}this.resolveColorAttachmentsChanged=!1;const o=this.currentDepthStencilAttachment;if(o){const n=this.currentDepthStencilResolveTo;let a=!1;n&&(pe(o.width===n.width&&o.height===n.height),this.setScissorRectEnabled(!1),i||(e.bindFramebuffer(r?K.READ_FRAMEBUFFER:K.FRAMEBUFFER,this.resolveDepthStencilReadFramebuffer),e.bindFramebuffer(r?K.DRAW_FRAMEBUFFER:K.FRAMEBUFFER,this.resolveDepthStencilDrawFramebuffer),this.resolveDepthStencilAttachmentsChanged&&(this.bindFramebufferDepthStencilAttachment(r?K.READ_FRAMEBUFFER:K.FRAMEBUFFER,o),this.bindFramebufferDepthStencilAttachment(r?K.DRAW_FRAMEBUFFER:K.FRAMEBUFFER,n))),a=!0,i||(r&&e.blitFramebuffer(0,0,o.width,o.height,0,0,n.width,n.height,e.DEPTH_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(r?K.DRAW_FRAMEBUFFER:K.FRAMEBUFFER,null)),s=!0),!i&&!this.currentRenderPassDescriptor.depthStencilStore&&(a||(e.bindFramebuffer(r?K.READ_FRAMEBUFFER:K.FRAMEBUFFER,this.resolveDepthStencilReadFramebuffer),this.resolveDepthStencilAttachmentsChanged&&this.bindFramebufferDepthStencilAttachment(r?K.READ_FRAMEBUFFER:K.FRAMEBUFFER,o),a=!0),r&&e.invalidateFramebuffer(e.READ_FRAMEBUFFER,[e.DEPTH_STENCIL_ATTACHMENT])),!i&&a&&e.bindFramebuffer(r?K.READ_FRAMEBUFFER:K.FRAMEBUFFER,null),this.resolveDepthStencilAttachmentsChanged=!1}!i&&!s&&e.bindFramebuffer(r?K.DRAW_FRAMEBUFFER:K.FRAMEBUFFER,null)}setScissorRectEnabled(e){if(this.currentScissorEnabled===e)return;const r=this.gl;e?r.enable(r.SCISSOR_TEST):r.disable(r.SCISSOR_TEST),this.currentScissorEnabled=e}applyStencil(){me(this.currentStencilRef)||(this.gl.stencilFuncSeparate(K.FRONT,this.currentMegaState.stencilFront.compare,this.currentStencilRef,this.currentMegaState.stencilFront.mask||255),this.gl.stencilFuncSeparate(K.BACK,this.currentMegaState.stencilBack.compare,this.currentStencilRef,this.currentMegaState.stencilBack.mask||255))}getFallbackTexture(e){const r=e.gl_target,i=e.formatKind;if(r===K.TEXTURE_2D)return i===dn.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(r===K.TEXTURE_2D_ARRAY)return this.fallbackTexture2DArray;if(r===K.TEXTURE_3D)return this.fallbackTexture3D;if(r===K.TEXTURE_CUBE_MAP)return this.fallbackTextureCube;throw new Error("whoops")}submitBlitRenderPass(e,r){const i=this.gl;this.blitRenderPipeline||(this.blitProgram=this.createProgram({vertex:{glsl:`layout(location = 0) in vec2 a_Position; 6941out vec2 v_TexCoord; 6942void main() { 6943 v_TexCoord = 0.5 * (a_Position + 1.0); 6944 gl_Position = vec4(a_Position, 0., 1.); 6945 6946 #ifdef VIEWPORT_ORIGIN_TL 6947 v_TexCoord.y = 1.0 - v_TexCoord.y; 6948 #endif 6949}`},fragment:{glsl:`uniform sampler2D u_Texture; 6950in vec2 v_TexCoord; 6951out vec4 outputColor; 6952void main() { 6953 outputColor = texture(SAMPLER_2D(u_Texture), v_TexCoord); 6954}`}}),this.blitVertexBuffer=this.createBuffer({usage:Ee.VERTEX|Ee.COPY_DST,viewOrSize:new Float32Array([-4,-4,4,-4,0,4])}),this.blitInputLayout=this.createInputLayout({vertexBufferDescriptors:[{arrayStri
6954de:8,stepMode:Pi.VERTEX,attributes:[{format:X.F32_RG,offset:0,shaderLocation:0}]}],indexBufferFormat:null,program:this.blitProgram}),this.blitRenderPipeline=this.createRenderPipeline({topology:Ia.TRIANGLES,sampleCount:1,program:this.blitProgram,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:null,inputLayout:this.blitInputLayout,megaStateDescriptor:E2(K0)})),pe(e.texture!==null),this.blitBindings&&this.blitBindings.destroy(),this.blitBindings=this.createBindings({samplerBindings:[{sampler:null,texture:e.texture}],uniformBufferBindings:[]}),this.blitProgram.setUniformsLegacy({u_Texture:e.texture});const s=this.currentRenderPassDescriptor;this.currentRenderPassDescriptor=null,this.inBlitRenderPass=!0,r===this.scTexture?i.bindFramebuffer(K.FRAMEBUFFER,this.scPlatformFramebuffer):(i.bindFramebuffer(K.FRAMEBUFFER,this.resolveColorDrawFramebuffer),i.framebufferTexture2D(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_2D,r.gl_texture,0)),this.setScissorRectEnabled(!1),this.setViewport(0,0,r.width,r.height),this.setPipeline(this.blitRenderPipeline),this.setBindings(this.blitBindings),this.setVertexInput(this.blitInputLayout,[{buffer:this.blitVertexBuffer}],null),i.disable(i.BLEND),this.draw(3,0),i.enable(i.BLEND),i.bindFramebuffer(K.FRAMEBUFFER,null),this.inBlitRenderPass=!1,this.currentRenderPassDescriptor=s}}var tVt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};class eVt{constructor(e){this.pluginOptions=e}createSwapChain(e){return tVt(this,void 0,void 0,function*(){const{targets:r,xrCompatible:i,antialias:s=!1,preserveDrawingBuffer:o=!1,premultipliedAlpha:n=!0,shaderDebug:a,trackResources:l}=this.pluginOptions,c={antialias:s,preserveDrawingBuffer:o,stencil:!0,premultipliedAlpha:n,xrCompatible:i};this.handleContextEvents(e);let h;if(r.includes("webgl2")&&(h=e.getContext("webgl2",c)||e.getContext("experimental-webgl2",c)),!h&&r.includes("webgl1")&&(h=e.getContext("webgl",c)||e.getContext("experimental-webgl",c)),!h)throw new Error("WebGL context creation failed (canvas may be invalid or the browser WebGL context limit was reached).");return new Qzt(h,{shaderDebug:a,trackResources:l})})}handleContextEvents(e){const{onContextLost:r,onContextRestored:i,onContextCreationError:s}=this.pluginOptions;s&&e.addEventListener("webglcontextcreationerror",s,!1),r&&e.addEventListener("webglcontextlost",r,!1),i&&e.addEventListener("webglcontextrestored",i,!1)}}let pn;const Yft=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&Yft.decode();let $L=null;function xj(){return($L===null||$L.byteLength===0)&&($L=new Uint8Array(pn.memory.buffer)),$L}function Sj(t,e){return t=t>>>0,Yft.decode(xj().subarray(t,t+e))}const Z0=new Array(128).fill(void 0);Z0.push(void 0,null,!0,!1);let HL=Z0.length;function rVt(t){HL===Z0.length&&Z0.push(Z0.length+1);const e=HL;return HL=Z0[e],Z0[e]=t,e}function Tj(t){return Z0[t]}function iVt(t){t<132||(Z0[t]=HL,HL=t)}function sVt(t){const e=Tj(t);return iVt(t),e}let T2=0;const Rj=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},oVt=typeof Rj.encodeInto=="function"?function(t,e){return Rj.encodeInto(t,e)}:function(t,e){const r=Rj.encode(t);return e.set(r),{read:t.length,written:r.length}};function Cj(t,e,r){if(r===void 0){const a=Rj.encode(t),l=e(a.length,1)>>>0;return xj().subarray(l,l+a.length).set(a),T2=a.length,l}let i=t.length,s=e(i,1)>>>0;const o=xj();let n=0;for(;n<i;n++){const a=t.charCodeAt(n);if(a>127)break;o[s+n]=a}if(n!==i){n!==0&&(t=t.slice(n)),s=r(s,i,i=n+t.length*3,1)>>>0;const a=xj().subarray(s+n,s+i),l=oVt(t,a);n+=l.written}return T2=n,s}let KL=null;function Mj(){return(KL===null||KL.byteLength===0)&&(KL=new Int32Array(pn.memory.buffer)),KL}function nVt(t,e,r){let i,s;try{const a=pn.__wbindgen_add_to_stack_pointer(-16),l=Cj(t,pn.__wbindgen_malloc,pn.__wbindgen_realloc),c=T2,h=Cj(e,pn.__wbindgen_malloc,pn.__wbindgen_realloc),u=T2;pn.glsl_compile(a,l,c,h,u,r);var o=Mj()[a/4+0],n=Mj()[a/4+1];return i=o,s=n,Sj(o,n)}finally{pn.__wbindgen_add_to_stack_pointer(16),pn.__wbindgen_free(i,s,1)}}class qL{static __wrap(e){e=e>>>0;const r=Object.create(qL.prototype);return r.__wbg_ptr=e,r}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();pn.__wbg_wgslcomposer_free(e)}constructor(){const e=pn.wgslcomposer_new();return qL.__wrap(e)}load_composable(e){const r=Cj(e,pn.__wbindgen_malloc,pn.__wbindgen_realloc),i=T2;
6954pn.wgslcomposer_load_composable(this.__wbg_ptr,r,i)}wgsl_compile(e){let r,i;try{const n=pn.__wbindgen_add_to_stack_pointer(-16),a=Cj(e,pn.__wbindgen_malloc,pn.__wbindgen_realloc),l=T2;pn.wgslcomposer_wgsl_compile(n,this.__wbg_ptr,a,l);var s=Mj()[n/4+0],o=Mj()[n/4+1];return r=s,i=o,Sj(s,o)}finally{pn.__wbindgen_add_to_stack_pointer(16),pn.__wbindgen_free(r,i,1)}}}async function aVt(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(i){if(t.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",i);else throw i}const r=await t.arrayBuffer();return await WebAssembly.instantiate(r,e)}else{const r=await WebAssembly.instantiate(t,e);return r instanceof WebAssembly.Instance?{instance:r,module:t}:r}}function lVt(){const t={};return t.wbg={},t.wbg.__wbindgen_string_new=function(e,r){const i=Sj(e,r);return rVt(i)},t.wbg.__wbindgen_object_drop_ref=function(e){sVt(e)},t.wbg.__wbg_log_1d3ae0273d8f4f8a=function(e){console.log(Tj(e))},t.wbg.__wbg_log_576ca876af0d4a77=function(e,r){console.log(Tj(e),Tj(r))},t.wbg.__wbindgen_throw=function(e,r){throw new Error(Sj(e,r))},t}function cVt(t,e){return pn=t.exports,$ft.__wbindgen_wasm_module=e,KL=null,$L=null,pn}async function $ft(t){if(pn!==void 0)return pn;const e=lVt();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));const{instance:r,module:i}=await aVt(await t,e);return cVt(r,i)}var el;(function(t){t[t.COPY_SRC=1]="COPY_SRC",t[t.COPY_DST=2]="COPY_DST",t[t.TEXTURE_BINDING=4]="TEXTURE_BINDING",t[t.STORAGE_BINDING=8]="STORAGE_BINDING",t[t.STORAGE=8]="STORAGE",t[t.RENDER_ATTACHMENT=16]="RENDER_ATTACHMENT"})(el||(el={}));var mq;(function(t){t[t.READ=1]="READ",t[t.WRITE=2]="WRITE"})(mq||(mq={}));function hVt(t){let e=0;return t&vi.SAMPLED&&(e|=el.TEXTURE_BINDING|el.COPY_DST|el.COPY_SRC),t&vi.STORAGE&&(e|=el.TEXTURE_BINDING|el.STORAGE_BINDING|el.COPY_SRC|el.COPY_DST),t&vi.RENDER_TARGET&&(e|=el.RENDER_ATTACHMENT|el.TEXTURE_BINDING|el.COPY_SRC|el.COPY_DST),e}function yq(t){if(t===X.U8_R_NORM)return"r8unorm";if(t===X.S8_R_NORM)return"r8snorm";if(t===X.U8_RG_NORM)return"rg8unorm";if(t===X.S8_RG_NORM)return"rg8snorm";if(t===X.U32_R)return"r32uint";if(t===X.S32_R)return"r32sint";if(t===X.F32_R)return"r32float";if(t===X.U16_RG)return"rg16uint";if(t===X.S16_RG)return"rg16sint";if(t===X.F16_RG)return"rg16float";if(t===X.U8_RGBA_RT)return"bgra8unorm";if(t===X.U8_RGBA_RT_SRGB)return"bgra8unorm-srgb";if(t===X.U8_RGBA_NORM)return"rgba8unorm";if(t===X.U8_RGBA_SRGB)return"rgba8unorm-srgb";if(t===X.S8_RGBA_NORM)return"rgba8snorm";if(t===X.U32_RG)return"rg32uint";if(t===X.S32_RG)return"rg32sint";if(t===X.F32_RG)return"rg32float";if(t===X.U16_RGBA)return"rgba16uint";if(t===X.S16_RGBA)return"rgba16sint";if(t===X.F16_RGBA)return"rgba16float";if(t===X.F32_RGBA)return"rgba32float";if(t===X.U32_RGBA)return"rgba32uint";if(t===X.S32_RGBA)return"rgba32sint";if(t===X.D24)return"depth24plus";if(t===X.D24_S8)return"depth24plus-stencil8";if(t===X.D32F)return"depth32float";if(t===X.D32F_S8)return"depth32float-stencil8";if(t===X.BC1)return"bc1-rgba-unorm";if(t===X.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(t===X.BC2)return"bc2-rgba-unorm";if(t===X.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(t===X.BC3)return"bc3-rgba-unorm";if(t===X.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(t===X.BC4_SNORM)return"bc4-r-snorm";if(t===X.BC4_UNORM)return"bc4-r-unorm";if(t===X.BC5_SNORM)return"bc5-rg-snorm";if(t===X.BC5_UNORM)return"bc5-rg-unorm";throw"whoops"}function uVt(t){if(t===Xr.TEXTURE_2D||t===Xr.TEXTURE_CUBE_MAP||t===Xr.TEXTURE_2D_ARRAY)return"2d";if(t===Xr.TEXTURE_3D)return"3d";throw new Error("whoops")}function dVt(t){if(t===Xr.TEXTURE_2D)return"2d";if(t===Xr.TEXTURE_CUBE_MAP)return"cube";if(t===Xr.TEXTURE_2D_ARRAY)return"2d-array";if(t===Xr.TEXTURE_3D)return"3d";throw new Error("whoops")}
6954function fVt(t){let e=0;return t&Ee.INDEX&&(e|=GPUBufferUsage.INDEX),t&Ee.VERTEX&&(e|=GPUBufferUsage.VERTEX),t&Ee.UNIFORM&&(e|=GPUBufferUsage.UNIFORM),t&Ee.STORAGE&&(e|=GPUBufferUsage.STORAGE),t&Ee.COPY_SRC&&(e|=GPUBufferUsage.COPY_SRC),t&Ee.INDIRECT&&(e|=GPUBufferUsage.INDIRECT),e|=GPUBufferUsage.COPY_DST,e}function vq(t){if(t===ho.CLAMP_TO_EDGE)return"clamp-to-edge";if(t===ho.REPEAT)return"repeat";if(t===ho.MIRRORED_REPEAT)return"mirror-repeat";throw new Error("whoops")}function Hft(t){if(t===hs.BILINEAR)return"linear";if(t===hs.POINT)return"nearest";throw new Error("whoops")}function pVt(t){if(t===Ro.LINEAR)return"linear";if(t===Ro.NEAREST||t===Ro.NO_MIP)return"nearest";throw new Error("whoops")}function R2(t){return t.gpuBuffer}function gVt(t){return t.gpuSampler}function mVt(t){return t.querySet}function yVt(t){if(t===gj.OcclusionConservative)return"occlusion";throw new Error("whoops")}function vVt(t){switch(t){case Ia.TRIANGLES:return"triangle-list";case Ia.POINTS:return"point-list";case Ia.TRIANGLE_STRIP:return"triangle-strip";case Ia.LINES:return"line-list";case Ia.LINE_STRIP:return"line-strip";default:throw new Error("Unknown primitive topology mode")}}function _Vt(t){if(t===jl.NONE)return"none";if(t===jl.FRONT)return"front";if(t===jl.BACK)return"back";throw new Error("whoops")}function bVt(t){if(t===GL.CCW)return"ccw";if(t===GL.CW)return"cw";throw new Error("whoops")}function wVt(t,e){return{topology:vVt(t),cullMode:_Vt(e.cullMode),frontFace:bVt(e.frontFace)}}function Kft(t){if(t===Re.ZERO)return"zero";if(t===Re.ONE)return"one";if(t===Re.SRC)return"src";if(t===Re.ONE_MINUS_SRC)return"one-minus-src";if(t===Re.DST)return"dst";if(t===Re.ONE_MINUS_DST)return"one-minus-dst";if(t===Re.SRC_ALPHA)return"src-alpha";if(t===Re.ONE_MINUS_SRC_ALPHA)return"one-minus-src-alpha";if(t===Re.DST_ALPHA)return"dst-alpha";if(t===Re.ONE_MINUS_DST_ALPHA)return"one-minus-dst-alpha";if(t===Re.CONST)return"constant";if(t===Re.ONE_MINUS_CONSTANT)return"one-minus-constant";if(t===Re.SRC_ALPHA_SATURATE)return"src-alpha-saturated";throw new Error("whoops")}function EVt(t){if(t===Li.ADD)return"add";if(t===Li.SUBSTRACT)return"subtract";if(t===Li.REVERSE_SUBSTRACT)return"reverse-subtract";if(t===Li.MIN)return"min";if(t===Li.MAX)return"max";throw new Error("whoops")}function qft(t){return{operation:EVt(t.blendMode),srcFactor:Kft(t.blendSrcFactor),dstFactor:Kft(t.blendDstFactor)}}function Zft(t){return t.blendMode===Li.ADD&&t.blendSrcFactor===Re.ONE&&t.blendDstFactor===Re.ZERO}function AVt(t){if(!(Zft(t.rgbBlendState)&&Zft(t.alphaBlendState)))return{color:qft(t.rgbBlendState),alpha:qft(t.alphaBlendState)}}function xVt(t,e){return{format:yq(e),blend:AVt(t),writeMask:t.channelWriteMask}}function SVt(t,e){return e.attachmentsState.map((r,i)=>xVt(r,t[i]))}function Bj(t){if(t===li.NEVER)return"never";if(t===li.LESS)return"less";if(t===li.EQUAL)return"equal";if(t===li.LEQUAL)return"less-equal";if(t===li.GREATER)return"greater";if(t===li.NOTEQUAL)return"not-equal";if(t===li.GEQUAL)return"greater-equal";if(t===li.ALWAYS)return"always";throw new Error("whoops")}function C2(t){if(t===Oi.KEEP)return"keep";if(t===Oi.REPLACE)return"replace";if(t===Oi.ZERO)return"zero";if(t===Oi.DECREMENT_CLAMP)return"decrement-clamp";if(t===Oi.DECREMENT_WRAP)return"decrement-wrap";if(t===Oi.INCREMENT_CLAMP)return"increment-clamp";if(t===Oi.INCREMENT_WRAP)return"increment-wrap";if(t===Oi.INVERT)return"invert";throw new Error("whoops")}function TVt(t,e){if(!me(t))return{format:yq(t),depthWriteEnabled:!!e.depthWrite,depthCompare:Bj(e.depthCompare),depthBias:e.polygonOffset?e.polygonOffsetUnits:0,depthBiasSlopeScale:e.polygonOffset?e.polygonOffsetFactor:0,stencilFront:{compare:Bj(e.stencilFront.compare),passOp:C2(e.stencilFront.passOp),failOp:C2(e.stencilFront.failOp),depthFailOp:C2(e.stencilFront.depthFailOp)},stencilBack:{compare:Bj(e.stencilBack.compare),passOp:C2(e.stencilBack.passOp),failOp:C2(e.stencilBack.failOp),depthFailOp:C2(e.stencilBack.depthFailOp)},stencilReadMask:4294967295,stencilWriteMask:4294967295}}function RVt(t){if(t!==null){if(t===X.U16_R)return"uint16";if(t===X.U32_R)return"uint32";throw new Error("whoops")}}function CVt(t){if(t===Pi.VERTEX)return"vertex";if(t===Pi.INSTANCE)return"instance";throw new Error("whoops")}function MVt(t){if(t===X.U8_R||t===X.U8_RG)return"uint8x2";if(t===X.U8_RGB||t===X.U8_RGBA)return"uint8x4";if(t===X.U8_RG_NORM)return"unorm8x2";if(t===X.U8_RGBA_NORM)return"unorm8x4";if(t===X.S8_RGB_NORM||t===X.S8_RGBA_NORM)return"snorm8x4";if(t===X.U16_RG_NORM)return"unorm16x2";if(t===X.U16_RGBA_NORM)return"unorm16x4";if(t===X.S16_RG_NORM)return"snorm16x2";if(t===X.S16_RGBA_NORM)return"snorm16x4";if(t===X.S16_RG)return"uint16x2";if(t===X.F16_RG)return"float16x2";if(t===X.F16_RGBA)return"float16x4";if(t===X.F32_R)return"float32";if(t===X.F32_RG)return"float32x2";if(t===X.F32_RGB)return"float32x3";if(t===X.F32_RGBA)return"float32x4";throw"whoops"}function BVt(t){switch(cy(t)){case Tt.BC1:case Tt.BC2:case Tt.BC3:case Tt.BC4_SNORM:case Tt.BC4_UNORM:case Tt.BC5_SNORM:case Tt.BC5_UNORM:return!0;default:return!1}}function OVt(t){switch(cy(t)){case Tt.BC1:case Tt.BC2:case Tt.BC3:case Tt.BC4_SNORM:case Tt.BC4_UNORM:case Tt.BC5_SNORM:case Tt.BC5_UNORM:return 4;default:return 1}}function Jft(t,e,r=!1,i){switch(t){case X.S8_R:case X.S8_R_NORM:case X.S8_RG_NORM:case X.S8_RGB_NORM:case X.S8_RGBA_NORM:{const o=e instanceof ArrayBuffer?new Int8Array(e):new Int8Array(e);return i&&o.set(new Int8Array(i)),o}case X.U8_R:case X.U8_R_NORM:case X.U8_RG:case X.U8_RG_NORM:case X.U8_RGB:case X.U8_RGB_NORM:case X.U8_RGB_SRGB:case X.U8_RGBA:case X.U8_RGBA_NORM:case X.U8_RGBA_SRGB:{const o=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e);return i&&o.set(new Uint8Array(i)),o}case X.S16_R:case X.S16_RG:case X.S16_RG_NORM:case X.S16_RGB_NORM:case X.S16_RGBA:case X.S16_RGBA_NORM:{const o=e instanceof ArrayBuffer?new Int16Array(e):new Int16Array(r?e/2:e);return i&&o.set(new Int16Array(i)),o}case X.U16_R:case X.U16_RGB:case X.U16_RGBA_5551:case X.U16_RGBA_NORM:case X.U16_RG_NORM:case X.U16_R_NORM:{const o=e instanceof ArrayBuffer?new Uint16Array(e):new Uint16Array(r?e/2:e);return i&&o.set(new Uint16Array(i)),o}case X.S32_R:{const o=e instanceof ArrayBuffer?new Int32Array(e):new Int32Array(r?e/4:e);return i&&o.set(new Int32Array(i)),o}case X.U32_R:case X.U32_RG:{const o=e instanceof ArrayBuffer?new Uint32Array(e):new Uint32Array(r?e/4:e);return i&&o.set(new Uint32Array(i)),o}case X.F32_R:case X.F32_RG:case X.F32_RGB:case X.F32_RGBA:{const o=e instanceof ArrayBuffer?new Float32Array(e):new Float32Array(r?e/4:e);return i&&o.set(new Float32Array(i)),o}}const s=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e);return i&&s.set(new Uint8Array(i)),s}function IVt(t){const e=(t&32768)>>15,r=(t&31744)>>10,i=t&1023;return r===0?(e?-1:1)*Math.pow(2,-14)*(i/Math.pow(2,10)):r==31?i?NaN:(e?-1:1)*(1/0):(e?-1:1)*Math.pow(2,r-15
6954)*(1+i/Math.pow(2,10))}function Qft(t){switch(t){case"r8unorm":case"r8snorm":case"r8uint":case"r8sint":return{width:1,height:1,length:1};case"r16uint":case"r16sint":case"r16float":case"rg8unorm":case"rg8snorm":case"rg8uint":case"rg8sint":return{width:1,height:1,length:2};case"r32uint":case"r32sint":case"r32float":case"rg16uint":case"rg16sint":case"rg16float":case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8snorm":case"rgba8uint":case"rgba8sint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgb9e5ufloat":case"rgb10a2unorm":case"rg11b10ufloat":return{width:1,height:1,length:4};case"rg32uint":case"rg32sint":case"rg32float":case"rgba16uint":case"rgba16sint":case"rgba16float":return{width:1,height:1,length:8};case"rgba32uint":case"rgba32sint":case"rgba32float":return{width:1,height:1,length:16};case"stencil8":throw new Error("No fixed size for Stencil8 format!");case"depth16unorm":return{width:1,height:1,length:2};case"depth24plus":throw new Error("No fixed size for Depth24Plus format!");case"depth24plus-stencil8":throw new Error("No fixed size for Depth24PlusStencil8 format!");case"depth32float":return{width:1,height:1,length:4};case"depth32float-stencil8":return{width:1,height:1,length:5};case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc6h-rgb-ufloat":case"bc6h-rgb-float":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc5-rg-unorm":case"bc5-rg-snorm":return{width:4,height:4,length:16};case"bc4-r-unorm":case"bc4-r-snorm":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":return{width:4,height:4,length:8};default:return{width:1,height:1,length:4}}}class Mg extends Uo{constructor({id:e,device:r}){super(),this.id=e,this.device=r}destroy(){}}class DVt extends Mg{constructor({id:e,device:r,descriptor:i}){var s,o;super({id:e,device:r}),this.type=$i.Bindings;const{pipeline:n}=i;pe(!!n);const{uniformBufferBindings:a,storageBufferBindings:l,samplerBindings:c,storageTextureBindings:h}=i;this.numUniformBuffers=(a==null?void 0:a.length)||0;const u=[[],[],[],[]];let d=0;if(a&&a.length)for(let g=0;g<a.length;g++){const{binding:p,size:m,offset:v,buffer:b}=i.uniformBufferBindings[g],y={buffer:R2(b),offset:v??0,size:m};u[0].push({binding:p??d++,resource:y})}if(c&&c.length){d=0;for(let g=0;g<c.length;g++){const p=Object.assign(Object.assign({},c[g]),Ift),m=i.samplerBindings[g],v=m.texture!==null?m.texture:this.device.getFallbackTexture(p);p.dimension=v.dimension,p.formatKind=Aft(v.format);const b=v.gpuTextureView;if(u[1].push({binding:(s=m.textureBinding)!==null&&s!==void 0?s:d++,resource:b}),m.samplerBinding!==-1){const y=m.sampler!==null?m.sampler:this.device.getFallbackSampler(p),_=gVt(y);u[1].push({binding:(o=m.samplerBinding)!==null&&o!==void 0?o:d++,resource:_})}}}if(l&&l.length){d=0;for(let g=0;g<l.length;g++){const{binding:p,size:m,offset:v,buffer:b}=i.storageBufferBindings[g],y={buffer:R2(b),offset:v??0,size:m};u[2].push({binding:p??d++,resource:y})}}if(h&&h.length){d=0;for(let g=0;g<h.length;g++){const{binding:p,texture:m}=i.storageTextureBindings[g],v=m.gpuTextureView;u[3].push({binding:p??d++,resource:v})}}const f=u.findLastIndex(g=>!!g.length);this.gpuBindGroup=u.map((g,p)=>p<=f&&this.device.device.createBindGroup({layout:n.getBindGroupLayout(p),entries:g}))}}class PVt extends Mg{constructor({id:e,device:r,descriptor:i}){super({id:e,device:r}),this.type=$i.Buffer;const{usage:s,viewOrSize:o}=i,n=!!(s&Ee.MAP_READ);this.usage=fVt(s),n&&(this.usage=Ee.MAP_READ|Ee.COPY_DST);const a=!lc(o);if(this.view=lc(o)?null:o,this.size=lc(o)?yj(o,4):yj(o.byteLength,4),lc(o))this.gpuBuffer=this.device.device.createBuffer({usage:this.usage,size:this.size,mappedAtCreation:n?a:!1});else{this.gpuBuffer=this.device.device.createBuffer({usage:this.usage,size:this.size,mappedAtCreation:!0});const l=o&&o.constructor||Float32Array;new l(this.gpuBuffer.getMappedRange()).set(o),this.gpuBuffer.unmap()}}setSubData(e,r,i=0,s=0){const o=this.gpuBuffer;s=s||r.byteLength,s=Math.min(s,this.size-e);let n=r.byteOffset+i,a=n+s;const l=s+3&-4;if(l!==s){const u=new Uint8Array(r.buffer.slice(n,a));r=new Uint8Array(l),r.set(u),i=0,n=0,a=l,s=l}const c=1024*1024*15;let h=0;for(;a-(n+h)>c;)this.device.device.queue.writeBuffer(o,e+h,r.buffer,n+h,c),h+=c;this.device.device.queue.writeBuffer(o,e+h,r.buffer,n+h,s-h)}destroy(){super.destroy(),this.gpuBuffer.destroy()}}class _q{constructor(){this.gpuComputePassEncoder=null}dispatchWorkgroups(e,r,i){this.gpuComputePassEncoder.dispatchWorkgroups(e,r,i)}dispatchWorkgroupsIndirect(e,r){this.gpuComputePassEncoder.dispatchWorkgroupsIndirect(e.gpuBuffer,r)}finish(){this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.frameCommandEncoder=null}beginComputePass(e){pe(this.gpuComputePassEncoder===null),this.frameCommandEncoder=e,this.gpuComputePassEncoder=this.frameCommandEncoder.beginComputePass(this.gpuComputePassDescriptor)}setPipeline(e){const r=oh(e.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(r)}setBindings(e){const r=e;r.gpuBindGroup.forEach((i,s)=>{i&&this.gpuComputePassEncoder.setBindGroup(s,r.gpuBindGroup[s])})}
6954pushDebugGroup(e){this.gpuComputePassEncoder.pushDebugGroup(e)}popDebugGroup(){this.gpuComputePassEncoder.popDebugGroup()}insertDebugMarker(e){this.gpuComputePassEncoder.insertDebugMarker(e)}}class FVt extends Mg{constructor({id:e,device:r,descriptor:i}){super({id:e,device:r}),this.type=$i.ComputePipeline,this.gpuComputePipeline=null,this.descriptor=i;const s=i.program.computeStage;if(s===null)return;const o={layout:"auto",compute:Object.assign({},s)};this.gpuComputePipeline=this.device.device.createComputePipeline(o),this.name!==void 0&&(this.gpuComputePipeline.label=this.name)}getBindGroupLayout(e){return this.gpuComputePipeline.getBindGroupLayout(e)}}class NVt extends Mg{constructor({id:e,device:r,descriptor:i}){super({id:e,device:r}),this.type=$i.InputLayout;const s=[];for(const o of i.vertexBufferDescriptors){const{arrayStride:n,stepMode:a,attributes:l}=o;s.push({arrayStride:n,stepMode:CVt(a),attributes:[]});for(const c of l){const{shaderLocation:h,format:u,offset:d}=c;s[s.length-1].attributes.push({shaderLocation:h,format:MVt(u),offset:d})}}this.indexFormat=RVt(i.indexBufferFormat),this.buffers=s}}class tpt extends Mg{constructor({id:e,device:r,descriptor:i}){super({id:e,device:r}),this.type=$i.Program,this.vertexStage=null,this.fragmentStage=null,this.computeStage=null,this.descriptor=i,i.vertex&&(this.vertexStage=this.createShaderStage(i.vertex,"vertex")),i.fragment&&(this.fragmentStage=this.createShaderStage(i.fragment,"fragment")),i.compute&&(this.computeStage=this.createShaderStage(i.compute,"compute"))}setUniformsLegacy(e={}){}createShaderStage({glsl:e,wgsl:r,entryPoint:i,postprocess:s},o){let n=r;if(!n)try{n=this.device.glsl_compile(e,o,!1)}catch(a){throw console.error(a,e),new Error("whoops")}for(const a of["u_TextureFramebufferDepth"])n.includes(a)&&(n=n.replace(`var T_${a}: texture_2d<f32>;`,`var T_${a}: texture_depth_2d;`),n=n.replace(new RegExp(`textureSample\\(T_${a}(.*)\\);$`,"gm"),(l,c)=>`vec4<f32>(textureSample(T_${a}${c}), 0.0, 0.0, 0.0);`));return s&&(n=s(n)),{module:this.device.device.createShaderModule({code:n}),entryPoint:i||"main"}}}class kVt extends Mg{constructor({id:e,device:r,descriptor:i}){super({id:e,device:r}),this.type=$i.QueryPool;const{elemCount:s,type:o}=i;this.querySet=this.device.device.createQuerySet({type:yVt(o),count:s}),this.resolveBuffer=this.device.device.createBuffer({size:s*8,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.cpuBuffer=this.device.device.createBuffer({size:s*8,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),this.results=null}queryResultOcclusion(e){return this.results===null?null:this.results[e]!==BigInt(0)}destroy(){super.destroy(),this.querySet.destroy(),this.resolveBuffer.destroy(),this.cpuBuffer.destroy()}}var LVt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};class UVt extends Mg{constructor({id:e,device:r}){super({id:e,device:r}),this.type=$i.Readback}readTexture(e,r,i,s,o,n){return LVt(this,arguments,void 0,function*(a,l,c,h,u,d,f=0,g=0){const p=a,m=0,v=Qft(p.gpuTextureformat),b=Math.ceil(h/v.width)*v.length,y=Math.ceil(b/256)*256,_=y*u,w=this.device.createBuffer({usage:Ee.STORAGE|Ee.MAP_READ|Ee.COPY_DST,hint:rr.STATIC,viewOrSize:_}),E=this.device.device.createCommandEncoder();return E.copyTextureToBuffer({texture:p.gpuTexture,mipLevel:0,origin:{x:l,y:c,z:Math.max(m,0)}},{buffer:w.gpuBuffer,offset:0,bytesPerRow:y},{width:h,height:u,depthOrArrayLayers:1}),this.device.device.queue.submit([E.finish()]),this.readBuffer(w,0,d.byteLength===_?d:null,f,_,p.format,!0,!1,b,y,u)})}readTextureSync(e,r,i,s,o,n,a=0,l=0){throw new Error("ERROR_MSG_METHOD_NOT_IMPLEMENTED")}readBuffer(e,r=0,i=null,s=0,o=0,n=X.U8_RGB,a=!1,l=!1,c=0,h=0,u=0){const d=e,f=o||d.size,g=i||d.view,p=g&&g.constructor&&g.constructor.BYTES_PER_ELEMENT||Eft(n);let m=d;if(!(d.usage&Ee.MAP_READ&&d.usage&Ee.COPY_DST)){const v=this.device.device.createCommandEncoder();m=this.device.createBuffer({usage:Ee.STORAGE|Ee.MAP_READ|Ee.COPY_DST,hint:rr.STATIC,viewOrSize:f}),v.copyBufferToBuffer(d.gpuBuffer,r,m.gpuBuffer,0,f),this.device.device.queue.submit([v.finish()])}return new Promise((v,b)=>{m.gpuBuffer.mapAsync(mq.READ,r,f).then(()=>{const y=m.gpuBuffer.getMappedRange(r,f);let _=g;if(a)_===null?_=Jft(n,f,!0,y):_=Jft(n,_.buffer,void 0,y);else if(_===null)switch(p){case 1:_=new Uint8Array(f),_.set(new Uint8Array(y));break;case 2:_=this.getHalfFloatAsFloatRGBAArrayBuffer(f/2,y);break;case 4:_=new Float32Array(f/4),_.set(new Float32Array(y));break}else switch(p){case 1:_=new Uint8Array(_.buffer),_.set(new Uint8Array(y));break;case 2:_=this.getHalfFloatAsFloatRGBAArrayBuffer(f/2,y,g);break;case 4:const w=g&&g.constructor||Float32Array;_=new w(_.buffer),_.set(new w(y));break}if(c!==h){p===1&&!a&&(c*=2,h*=2);const w=new Uint8Array(_.buffer);let E=c,A=0;for(let x=1;x<u;++x){A=x*h;for(let S=0;S<c;++S)w[E++]=w[A++]}
6954p!==0&&!a?_=new Float32Array(w.buffer,0,E/4):_=new Uint8Array(w.buffer,0,E)}m.gpuBuffer.unmap(),v(_)},y=>b(y))})}getHalfFloatAsFloatRGBAArrayBuffer(e,r,i){i||(i=new Float32Array(e));const s=new Uint16Array(r);for(;e--;)i[e]=IVt(s[e]);return i}}class bq{constructor(e){this.device=e,this.gpuRenderPassEncoder=null,this.gfxColorAttachment=[],this.gfxColorAttachmentLevel=[],this.gfxColorResolveTo=[],this.gfxColorResolveToLevel=[],this.gfxDepthStencilAttachment=null,this.gfxDepthStencilResolveTo=null,this.gpuColorAttachments=[],this.gpuDepthStencilAttachment={view:null,depthLoadOp:"load",depthStoreOp:"store",stencilLoadOp:"load",stencilStoreOp:"store"},this.gpuRenderPassDescriptor={colorAttachments:this.gpuColorAttachments,depthStencilAttachment:this.gpuDepthStencilAttachment}}getEncoder(){var e;return((e=this.renderBundle)===null||e===void 0?void 0:e.renderBundleEncoder)||this.gpuRenderPassEncoder}getTextureView(e,r){return pe(r<e.mipLevelCount),e.mipLevelCount===1?e.gpuTextureView:e.gpuTexture.createView({baseMipLevel:r,mipLevelCount:1})}setRenderPassDescriptor(e){var r,i,s,o,n,a;this.descriptor=e,this.gpuRenderPassDescriptor.colorAttachments=this.gpuColorAttachments;const l=e.colorAttachment.length;this.gfxColorAttachment.length=l,this.gfxColorResolveTo.length=l;for(let u=0;u<e.colorAttachment.length;u++){let d=e.colorAttachment[u],f=e.colorResolveTo[u];if(d===null&&f!==null&&(d=f,f=null),this.gfxColorAttachment[u]=d,this.gfxColorResolveTo[u]=f,this.gfxColorAttachmentLevel[u]=((r=e.colorAttachmentLevel)===null||r===void 0?void 0:r[u])||0,this.gfxColorResolveToLevel[u]=((i=e.colorResolveToLevel)===null||i===void 0?void 0:i[u])||0,d!==null){this.gpuColorAttachments[u]===void 0&&(this.gpuColorAttachments[u]={});const g=this.gpuColorAttachments[u];g.view=this.getTextureView(d,((s=this.gfxColorAttachmentLevel)===null||s===void 0?void 0:s[u])||0);const p=(n=(o=e.colorClearColor)===null||o===void 0?void 0:o[u])!==null&&n!==void 0?n:"load";p==="load"?g.loadOp="load":(g.loadOp="clear",g.clearValue=p),g.storeOp=!((a=e.colorStore)===null||a===void 0)&&a[u]?"store":"discard",g.resolveTarget=void 0,f!==null&&(d.sampleCount>1?g.resolveTarget=this.getTextureView(f,this.gfxColorResolveToLevel[u]):g.storeOp="store")}else{this.gpuColorAttachments.length=u,this.gfxColorAttachment.length=u,this.gfxColorResolveTo.length=u;break}}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,e.depthStencilAttachment){const u=e.depthStencilAttachment,d=this.gpuDepthStencilAttachment;d.view=u.gpuTextureView,w2(u.format)&oe.Depth?(e.depthClearValue==="load"?d.depthLoadOp="load":(d.depthLoadOp="clear",d.depthClearValue=e.depthClearValue),e.depthStencilStore||this.gfxDepthStencilResolveTo!==null?d.depthStoreOp="store":d.depthStoreOp="discard"):(d.depthLoadOp=void 0,d.depthStoreOp=void 0),w2(u.format)&oe.Stencil?(e.stencilClearValue==="load"?d.stencilLoadOp="load":(d.stencilLoadOp="clear",d.stencilClearValue=e.stencilClearValue),e.depthStencilStore||this.gfxDepthStencilResolveTo!==null?d.stencilStoreOp="store":d.stencilStoreOp="discard"):(d.stencilLoadOp=void 0,d.stencilStoreOp=void 0),this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=me(e.occlusionQueryPool)?void 0:mVt(e.occlusionQueryPool);const c=this.gfxColorAttachment.length>0?this.gfxColorAttachment[0]:null,h=this.gfxColorAttachmentLevel.length>0&&this.gfxColorAttachmentLevel[0]||0;if(c!=null)this._viewportFlipHeight=Math.max(1,c.height>>>h);else if(e.depthStencilAttachment){const u=e.depthStencilAttachment;this._viewportFlipHeight=Math.max(1,u.height>>>0)}else this._viewportFlipHeight=this.device.swapChainHeight}beginRenderPass(e,r){pe(this.gpuRenderPassEncoder===null),this.setRenderPassDescriptor(r),this.frameCommandEncoder=e,this.gpuRenderPassEncoder=this.frameCommandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)}flipY(e,r){var i;return((i=this._viewportFlipHeight)!==null&&i!==void 0?i:this.device.swapChainHeight)-e-r}setViewport(e,r,i,s,o=0,n=1){this.gpuRenderPassEncoder.setViewport(e,this.flipY(r,s),i,s,o,n)}
6954setScissorRect(e,r,i,s){this.gpuRenderPassEncoder.setScissorRect(e,this.flipY(r,s),i,s)}setPipeline(e){const r=oh(e.gpuRenderPipeline);this.getEncoder().setPipeline(r)}setVertexInput(e,r,i){if(e===null)return;const s=this.getEncoder(),o=e;i!==null&&s.setIndexBuffer(R2(i.buffer),oh(o.indexFormat),i.offset);for(let n=0;n<r.length;n++){const a=r[n];a!==null&&s.setVertexBuffer(n,R2(a.buffer),a.offset)}}setBindings(e){const r=e,i=this.getEncoder();r.gpuBindGroup.forEach((s,o)=>{s&&i.setBindGroup(o,r.gpuBindGroup[o])})}setStencilReference(e){this.gpuRenderPassEncoder.setStencilReference(e)}draw(e,r,i,s){this.getEncoder().draw(e,r,i,s)}drawIndexed(e,r,i,s,o){this.getEncoder().drawIndexed(e,r,i,s,o)}drawIndirect(e,r){this.getEncoder().drawIndirect(R2(e),r)}drawIndexedIndirect(e,r){this.getEncoder().drawIndexedIndirect(R2(e),r)}beginOcclusionQuery(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)}endOcclusionQuery(){this.gpuRenderPassEncoder.endOcclusionQuery()}pushDebugGroup(e){this.gpuRenderPassEncoder.pushDebugGroup(e)}popDebugGroup(){this.gpuRenderPassEncoder.popDebugGroup()}insertDebugMarker(e){this.gpuRenderPassEncoder.insertDebugMarker(e)}beginBundle(e){this.renderBundle=e}endBundle(){this.renderBundle.finish()}executeBundles(e){this.gpuRenderPassEncoder.executeBundles(e.map(r=>r.renderBundle))}finish(){var e;(e=this.gpuRenderPassEncoder)===null||e===void 0||e.end(),this.gpuRenderPassEncoder=null;for(let r=0;r<this.gfxColorAttachment.length;r++){const i=this.gfxColorAttachment[r],s=this.gfxColorResolveTo[r];i!==null&&s!==null&&i.sampleCount===1&&this.copyAttachment(s,this.gfxColorAttachmentLevel[r],i,this.gfxColorResolveToLevel[r])}this.gfxDepthStencilAttachment&&this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,0,this.gfxDepthStencilAttachment,0)),this.frameCommandEncoder=null}copyAttachment(e,r,i,s){pe(i.sampleCount===1);const o={texture:i.gpuTexture,mipLevel:s},n={texture:e.gpuTexture,mipLevel:r};pe(i.width>>>s===e.width>>>r),pe(i.height>>>s===e.height>>>r),pe(!!(i.usage&el.COPY_SRC)),pe(!!(e.usage&el.COPY_DST)),this.frameCommandEncoder.copyTextureToTexture(o,n,[e.width,e.height,1])}}class GVt extends Mg{constructor({id:e,device:r,descriptor:i}){super({id:e,device:r}),this.type=$i.RenderPipeline,this.isCreatingAsync=!1,this.gpuRenderPipeline=null,this.descriptor=i,this.device.createRenderPipelineInternal(this,!1)}getBindGroupLayout(e){return this.gpuRenderPipeline.getBindGroupLayout(e)}}class WVt extends Mg{constructor({id:e,device:r,descriptor:i}){var s,o;super({id:e,device:r}),this.type=$i.Sampler;const n=i.lodMinClamp,a=i.mipmapFilter===Ro.NO_MIP?i.lodMinClamp:i.lodMaxClamp,l=(s=i.maxAnisotropy)!==null&&s!==void 0?s:1;l>1&&pe(i.minFilter===hs.BILINEAR&&i.magFilter===hs.BILINEAR&&i.mipmapFilter===Ro.LINEAR),this.gpuSampler=this.device.device.createSampler({addressModeU:vq(i.addressModeU),addressModeV:vq(i.addressModeV),addressModeW:vq((o=i.addressModeW)!==null&&o!==void 0?o:i.addressModeU),lodMinClamp:n,lodMaxClamp:a,minFilter:Hft(i.minFilter),magFilter:Hft(i.magFilter),mipmapFilter:pVt(i.mipmapFilter),compare:i.compareFunction!==void 0?Bj(i.compareFunction):void 0,maxAnisotropy:l})}}class Oj extends Mg{constructor({id:e,device:r,descriptor:i,skipCreate:s,sampleCount:o}){super({id:e,device:r}),this.type=$i.Texture,this.flipY=!1;const{format:n,dimension:a,width:l,height:c,depthOrArrayLayers:h,mipLevelCount:u,usage:d,pixelStore:f}=i;this.flipY=!!(f!=null&&f.unpackFlipY),this.device.createTextureShared({format:n,dimension:a??Xr.TEXTURE_2D,width:l,height:c,depthOrArrayLayers:h??1,mipLevelCount:u??1,usage:d,sampleCount:o??1},this,s)}textureFromImageBitmapOrCanvas(e,r,i){const s=r[0].width,o=r[0].height,n={size:{width:s,height:o,depthOrArrayLayers:i},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:this.mipLevelCount},a=e.createTexture(n);for(let l=0;l<r.length;l++)e.queue.copyExternalImageToTexture({source:r[l],flipY:this.flipY},{texture:a,origin:[0,0,l]},[s,o]);return this.mipLevelCount>1&&this.device.getMipmapGenerator().generateMipmap(a),[a,s,o]}isImageBitmapOrCanvases(e){const r=e[0];return r instanceof ImageBitmap||r instanceof HTMLCanvasElement||r instanceof OffscreenCanvas}isVideo(e){return e[0]instanceof HTMLVideoElement}setImageData(e,r=0){const{device:i}=this.device;let s,o,n;if(this.isImageBitmapOrCanvases(e))[s,o,n]=this.textureFromImageBitmapOrCanvas(i,e,this.depthOrArrayLayers);else if(this.isVideo(e))s=i.importExternalTexture({source:e[0]}),o=this.width,n=this.height;else{const a=Qft(this.gpuTextureformat),l=Math.ceil(this.width/a.width)*a.length,c=e[0];this.dimension===Xr.TEXTURE_3D?i.queue.writeTexture({texture:this.gpuTexture},c,{bytesPerRow:l,rowsPerImage:this.height},{width:this.width,height:this.height,depthOrArrayLayers:this.depthOrArrayLayers}):e.forEach(h=>{i.queue.writeTexture({texture:this.gpuTexture},h,{bytesPerRow:l},{width:this.width,height:this.height})}),o=this.width,n=this.height}this.width=o,this.height=n,s&&(this.gpuTexture=s),this.gpuTextureView=this.gpuTexture.createView({dimension:dVt(this.dimension)})}destroy(){super.destroy(),this.gpuTexture.destroy()}}class jVt extends Mg{constructor({id:e,device:r}){super({id:e,device:r}),this.type=$i.RenderBundle,this.renderBundleEncoder=this.device.device.createRenderBundleEncoder({colorFormats:[this.device.swapChainFormat]})}finish(){this.renderBundle=this.renderBundleEncoder.finish()}}class XVt{constructor(e){this._device=e,this._mipmapShader=this._device.createShaderModule({label:"MipmapGenerator",code:` 6955 struct VSOutput { 6956 @builtin(position) position: vec4f, 6957 @location(0) texcoord: vec2f, 6958 }; 6959 6960 @vertex fn vs( 6961 @builtin(vertex_index) vertexIndex : u32 6962 ) -> VSOutput { 6963 let pos = array( 6964 // 1st triangle 6965 vec2f( 0.0, 0.0), // center 6966 vec2f( 1.0, 0.0), // right, center 6967 vec2f( 0.0, 1.0), // center, top 6968 6969 // 2nd triangle 6970 vec2f( 0.0, 1.0), // center, top 6971 vec2f( 1.0, 0.0), // right, center 6972 vec2f( 1.0, 1.0), // right, top 6973 ); 6974 6975 var vsOutput: VSOutput; 6976 let xy = pos[vertexIndex]; 6977 vsOutput.position = vec4f(xy * 2.0 - 1.0, 0.0, 1.0); 6978 vsOutput.texcoord = vec2f(xy.x, 1.0 - xy.y); 6979 return vsOutput; 6980 } 6981 6982 @group(0) @binding(0) var ourSampler: sampler; 6983 @group(0) @binding(1) var ourTexture: texture_2d<f32>; 6984 6985 @fragment fn fs(fsInput: VSOutput) -> @location(0) vec4f { 6986 return textureSample(ourTexture, ourSampler, fsInput.texcoord); 6987 } 6988 `}),this._mipmapSampler=this._device.createSampler({minFilter:"linear"}),this._pipelines=new Map}_requestPipeline(e){let r=this._pipelines.get(e);return r||(r=this._device.createRenderPipeline({layout:"auto",vertex:{module:this._mipmapShader,entryPoint:"vs"},fragment:{module:this._mipmapShader,entryPoint:"fs",targets:[{format:e}]}}),this._pipelines.set(e,r)),r}generateMipmap(e){const r=this._device.createCommandEncoder({label:"mipmap generator command encoder"}),i=this._requestPipeline(e.format);let s=e.width,o=e.height,n=0;for(;(s>1||o>1)&&n<e.mipLevelCount-1;){s=Math.max(1,s/2),o=Math.max(1,o/2);const a=this._device.createBindGroup({layout:i.getBindGroupLayout(0),entries:[{binding:0,resource:this._mipmapSampler},{binding:1,resource:e.createView({baseMipLevel:n,mipLevelCount:1})}]});++n;const l=r.beginRenderPass({colorAttachments:[{view:e.createView({baseMipLevel:n,mipLevelCount:1}),loadOp:"clear",storeOp:"store"}]});l.setPipeline(i),l.setBindGroup(0,a),l.draw(6),l.end()}
6988this._device.queue.submit([r.finish()])}}var zVt=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};class VVt{constructor(e,r,i,s,o,n){this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=el.RENDER_ATTACHMENT|el.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.frameCommandEncoderPool=[],this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=WL.UPPER_LEFT,this.clipSpaceNearZ=jL.ZERO,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.device=r,this.canvas=i,this.canvasContext=s,this.glsl_compile=o,this.WGSLComposer=n,this.mipmapGenerator=new XVt(r),this.fallbackTexture2D=this.createFallbackTexture(Xr.TEXTURE_2D,dn.Float),this.setResourceName(this.fallbackTexture2D,"Fallback Texture2D"),this.fallbackTexture2DDepth=this.createFallbackTexture(Xr.TEXTURE_2D,dn.Depth),this.setResourceName(this.fallbackTexture2DDepth,"Fallback Depth Texture2D"),this.fallbackTexture2DArray=this.createFallbackTexture(Xr.TEXTURE_2D_ARRAY,dn.Float),this.setResourceName(this.fallbackTexture2DArray,"Fallback Texture2DArray"),this.fallbackTexture3D=this.createFallbackTexture(Xr.TEXTURE_3D,dn.Float),this.setResourceName(this.fallbackTexture3D,"Fallback Texture3D"),this.fallbackTextureCube=this.createFallbackTexture(Xr.TEXTURE_CUBE_MAP,dn.Float),this.setResourceName(this.fallbackTextureCube,"Fallback TextureCube"),this.fallbackSamplerFiltering=this.createSampler({addressModeU:ho.REPEAT,addressModeV:ho.REPEAT,minFilter:hs.POINT,magFilter:hs.POINT,mipmapFilter:Ro.NEAREST}),this.setResourceName(this.fallbackSamplerFiltering,"Fallback Sampler Filtering"),this.fallbackSamplerComparison=this.createSampler({addressModeU:ho.REPEAT,addressModeV:ho.REPEAT,minFilter:hs.POINT,magFilter:hs.POINT,mipmapFilter:Ro.NEAREST,compareFunction:li.ALWAYS}),this.setResourceName(this.fallbackSamplerComparison,"Fallback Sampler Comparison Filtering"),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=a=>{console.error(a.error)},this.swapChainFormat=navigator.gpu.getPreferredCanvasFormat(),this.canvasContext.configure({device:this.device,format:this.swapChainFormat,usage:this.swapChainTextureUsage,alphaMode:"premultiplied"})}destroy(){}configureSwapChain(e,r){this.swapChainWidth===e&&this.swapChainHeight===r||(this.swapChainWidth=e,this.swapChainHeight=r)}getOnscreenTexture(){const e=this.canvasContext.getCurrentTexture(),r=e.createView(),i=new Oj({id:0,device:this,descriptor:{format:X.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depthOrArrayLayers:0,dimension:Xr.TEXTURE_2D,mipLevelCount:1,usage:this.swapChainTextureUsage},skipCreate:!0});return i.depthOrArrayLayers=1,i.sampleCount=1,i.gpuTexture=e,i.gpuTextureView=r,i.name="Onscreen",this.setResourceName(i,"Onscreen Texture"),i}getDevice(){return this}getMipmapGenerator(){return this.mipmapGenerator}getCanvas(){return this.canvas}beginFrame(){pe(this.frameCommandEncoderPool.length===0)}endFrame(){pe(this.frameCommandEncoderPool.every(e=>e!==null)),this.device.queue.submit(this.frameCommandEncoderPool.map(e=>e.finish())),this.frameCommandEncoderPool=[]}getNextUniqueId(){return++this._resourceUniqueId}createBuffer(e){return new PVt({id:this.getNextUniqueId(),device:this,descriptor:e})}createTexture(e){return new Oj({id:this.getNextUniqueId(),device:this,descriptor:e})}createSampler(e){return new WVt({id:this.getNextUniqueId(),device:this,descriptor:e})}createRenderTarget(e){const r=new Oj({id:this.getNextUniqueId(),device:this,descriptor:Object.assign(Object.assign({},e),{dimension:Xr.TEXTURE_2D,mipLevelCount:1,depthOrArrayLayers:1,usage:vi.RENDER_TARGET}
6988),sampleCount:e.sampleCount});return r.depthOrArrayLayers=1,r.type=$i.RenderTarget,r}createRenderTargetFromTexture(e){const{format:r,width:i,height:s,depthOrArrayLayers:o,sampleCount:n,mipLevelCount:a,gpuTexture:l,gpuTextureView:c,usage:h}=e;pe(!!(h&el.RENDER_ATTACHMENT));const u=new Oj({id:this.getNextUniqueId(),device:this,descriptor:{format:r,width:i,height:s,depthOrArrayLayers:o,dimension:Xr.TEXTURE_2D,mipLevelCount:a,usage:h},skipCreate:!0});return u.depthOrArrayLayers=o,u.sampleCount=n,u.gpuTexture=l,u.gpuTextureView=c,u}createProgram(e){var r,i;return!((r=e.vertex)===null||r===void 0)&&r.glsl&&(e.vertex.glsl=Ej(this.queryVendorInfo(),"vert",e.vertex.glsl)),!((i=e.fragment)===null||i===void 0)&&i.glsl&&(e.fragment.glsl=Ej(this.queryVendorInfo(),"frag",e.fragment.glsl)),new tpt({id:this.getNextUniqueId(),device:this,descriptor:e})}createProgramSimple(e){return new tpt({id:this.getNextUniqueId(),device:this,descriptor:e})}createTextureShared(e,r,i){const s={width:e.width,height:e.height,depthOrArrayLayers:e.depthOrArrayLayers},o=e.mipLevelCount,n=yq(e.format),a=uVt(e.dimension),l=hVt(e.usage);if(r.gpuTextureformat=n,r.dimension=e.dimension,r.format=e.format,r.width=e.width,r.height=e.height,r.depthOrArrayLayers=e.depthOrArrayLayers,r.mipLevelCount=o,r.usage=l,r.sampleCount=e.sampleCount,!i){const c=this.device.createTexture({size:s,mipLevelCount:o,format:n,dimension:a,sampleCount:e.sampleCount,usage:l}),h=c.createView();r.gpuTexture=c,r.gpuTextureView=h}}getFallbackSampler(e){return e.formatKind===dn.Depth&&e.comparison?this.fallbackSamplerComparison:this.fallbackSamplerFiltering}getFallbackTexture(e){const r=e.dimension,i=e.formatKind;if(r===Xr.TEXTURE_2D)return i===dn.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(r===Xr.TEXTURE_2D_ARRAY)return this.fallbackTexture2DArray;if(r===Xr.TEXTURE_3D)return this.fallbackTexture3D;if(r===Xr.TEXTURE_CUBE_MAP)return this.fallbackTextureCube;throw new Error("whoops")}createFallbackTexture(e,r){const i=e===Xr.TEXTURE_CUBE_MAP?6:1,s=r===dn.Float?X.U8_RGBA_NORM:X.D24;return this.createTexture({dimension:e,format:s,usage:vi.SAMPLED,width:1,height:1,depthOrArrayLayers:i,mipLevelCount:1})}createBindings(e){return new DVt({id:this.getNextUniqueId(),device:this,descriptor:e})}createInputLayout(e){return new NVt({id:this.getNextUniqueId(),device:this,descriptor:e})}createComputePipeline(e){return new FVt({id:this.getNextUniqueId(),device:this,descriptor:e})}createRenderPipeline(e){return new GVt({id:this.getNextUniqueId(),device:this,descriptor:Object.assign({},e)})}createQueryPool(e,r){return new kVt({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:r}})}createRenderPipelineInternal(e,r=!1){var i;if(e.gpuRenderPipeline!==null)return;const s=e.descriptor,o=s.program,n=o.vertexStage,a=o.fragmentStage;if(n===null||a===null)return;const l=s.megaStateDescriptor||{},{stencilBack:c,stencilFront:h}=l,u=zVt(l,["stencilBack","stencilFront"]),d=E2(K0);s.megaStateDescriptor=Object.assign(Object.assign(Object.assign({},d),{stencilBack:Object.assign(Object.assign({},d.stencilBack),c),stencilFront:Object.assign(Object.assign({},d.stencilFront),h)}),u);const f=s.megaStateDescriptor.attachmentsState[0];s.colorAttachmentFormats.forEach((_,w)=>{s.megaStateDescriptor.attachmentsState[w]||(s.megaStateDescriptor.attachmentsState[w]=Cft(void 0,f))});const g=wVt((i=s.topology)!==null&&i!==void 0?i:Ia.TRIANGLES,s.megaStateDescriptor),p=SVt(s.colorAttachmentFormats,s.megaStateDescriptor),m=TVt(s.depthStencilAttachmentFormat,s.megaStateDescriptor);let v;s.inputLayout!==null&&(v=s.inputLayout.buffers);const b=s.sampleCount,y={layout:"auto",vertex:Object.assign(Object.assign({},n),{buffers:v}),primitive:g,depthStencil:m,multisample:{count:b},fragment:Object.assign(Object.assign({},a),{targets:p})};e.gpuRenderPipeline=this.device.createRenderPipeline(y)}createReadback(){return new UVt({id:this.getNextUniqueId(),device:this})}createRenderBundle(){return new jVt({id:this.getNextUniqueId(),device:this})}createRenderPass(e){let r=this.renderPassPool.pop();r===void 0&&(r=new bq(this));let i=this.frameCommandEncoderPool.pop();return i===void 0&&(i=this.device.createCommandEncoder()),r.beginRenderPass(i,e),r}createComputePass(){let e=this.computePassPool.pop();e===void 0&&(e=new _q);let r=this.frameCommandEncoderPool.pop();return r===void 0&&(r=this.device.createCommandEncoder()),e.beginComputePass(r),e}submitPass(e){const r=e;r instanceof bq?(this.frameCommandEncoderPool.push(r.frameCommandEncoder),r.finish(),this.renderPassPool.push(r)):r instanceof _q&&(this.frameCommandEncoderPool.push(r.frameCommandEncoder),r.finish(),this.computePassPool.push(r))}submitComputeImmediate(e){let r=this.computePassPool.pop();r===void 0&&(r=new _q);const i=this.device.createCommandEncoder();r.beginComputePass(i),e(r),r.finish(),this.computePassPool.push(r),this.device.queue.submit([i.finish()])}submitRenderPassImmediate(e,r){let i=this.renderPassPool.pop();i===void 0&&(i=new bq(this));const s=this.device.createCommandEncoder();i.beginRenderPass(s,e),r(i),i.finish(),this.renderPassPool.push(i),this.device.queue.submit([s.finish()])}copySubTexture2D(e,r,i,s,o,n,a){const l=this.device.createCommandEncoder(),c=e,h=s,u={texture:h.gpuTexture,origin:[o,n,0],mipLevel:0,aspect:"all"},d={texture:c.gpuTexture,origin:[r,i,0],mipLevel:0,aspect:"all"};pe(!!(h.usage&el.COPY_SRC)),pe(!!(c.usage&el.COPY_DST)),l.copyTextureToTexture(u,d,[h.width,h.height,a||1]),this.device.queue.submit([l.finish()])}queryLimits(){return{uniformBufferMaxPageWordSize:this.device.limits.maxUniformBufferBindingSize>>>2,uniformBufferWordAlignment:this.device.limits.minUniformBufferOffsetAlignment>>>2,supportedSampleCounts:[1],occlusionQueriesRecommended:!0,computeShadersSupported:!0}
6988}queryTextureFormatSupported(e,r,i){if(BVt(e)){if(!this.featureTextureCompressionBC)return!1;const s=OVt(e);return r%s!==0||i%s!==0?!1:this.featureTextureCompressionBC}switch(e){case X.U16_RGBA_NORM:return!1;case X.F32_RGBA:return!1}return!0}queryPlatformAvailable(){return!0}queryVendorInfo(){return this}queryRenderPass(e){return e.descriptor}queryRenderTarget(e){return e}setResourceName(e,r){if(e.name=r,e.type===$i.Buffer){const i=e;i.gpuBuffer.label=r}else if(e.type===$i.Texture){const i=e;i.gpuTexture.label=r,i.gpuTextureView.label=r}else if(e.type===$i.RenderTarget){const i=e;i.gpuTexture.label=r,i.gpuTextureView.label=r}else if(e.type===$i.Sampler){const i=e;i.gpuSampler.label=r}else if(e.type===$i.RenderPipeline){const i=e;i.gpuRenderPipeline!==null&&(i.gpuRenderPipeline.label=r)}}setResourceLeakCheck(e,r){}checkForLeaks(){}programPatched(e){}pipelineQueryReady(e){return e.gpuRenderPipeline!==null}pipelineForceReady(e){const r=e;this.createRenderPipelineInternal(r,!1)}}var YVt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};let ZL=null;class $Vt{constructor(e){this.pluginOptions=e}createSwapChain(e){return YVt(this,void 0,void 0,function*(){if(globalThis.navigator.gpu===void 0)return null;let r=null;try{const{xrCompatible:a}=this.pluginOptions;r=yield globalThis.navigator.gpu.requestAdapter({xrCompatible:a})}catch(a){console.log(a)}if(r===null)return null;const i=["depth32float-stencil8","texture-compression-bc","float32-filterable"].filter(a=>r.features.has(a));let s,o;if(ZL!==null)o=ZL.adapter,s=ZL.device;else{const a=yield r.requestDevice({requiredFeatures:i});if(a===null)return null;o=r,s=a,ZL={adapter:o,device:s};{const{onContextLost:l}=this.pluginOptions;s.lost.then(()=>{ZL=null,l&&l()})}}const n=e.getContext("webgpu");if(!n)return null;try{yield $ft(this.pluginOptions.shaderCompilerPath)}catch{}return new VVt(o,s,e,n,nVt,qL&&new qL)})}}function Os(t,e=0){return t+=e,t+=t<<10,t+=t>>>6,t>>>0}function ept(t){return t+=t<<3,t^=t>>>11,t+=t<<15,t>>>0}function wq(){return 0}class HVt{constructor(){this.keys=[],this.values=[]}}class JL{constructor(e,r){this.keyEqualFunc=e,this.keyHashFunc=r,this.buckets=new Map}findBucketIndex(e,r){for(let i=0;i<e.keys.length;i++)if(this.keyEqualFunc(r,e.keys[i]))return i;return-1}findBucket(e){const r=this.keyHashFunc(e);return this.buckets.get(r)}get(e){const r=this.findBucket(e);if(r===void 0)return null;const i=this.findBucketIndex(r,e);return i<0?null:r.values[i]}add(e,r){const i=this.keyHashFunc(e);this.buckets.get(i)===void 0&&this.buckets.set(i,new HVt);const s=this.buckets.get(i);s.keys.push(e),s.values.push(r)}delete(e){const r=this.findBucket(e);if(r===void 0)return;const i=this.findBucketIndex(r,e);i!==-1&&(r.keys.splice(i,1),r.values.splice(i,1))}clear(){this.buckets.clear()}size(){let e=0;for(const r of this.buckets.values())e+=r.values.length;return e}*values(){for(const e of this.buckets.values())for(let r=e.values.length-1;r>=0;r--)yield e.values[r]}}function rpt(t,e){return t=Os(t,e.blendMode),t=Os(t,e.blendSrcFactor),t=Os(t,e.blendDstFactor),t}function KVt(t,e){return t=rpt(t,e.rgbBlendState),t=rpt(t,e.alphaBlendState),t=Os(t,e.channelWriteMask),t}function qVt(t,e){return t=Os(t,e.r<<24|e.g<<16|e.b<<8|e.a),t}function ZVt(t,e){var r,i,s,o,n,a,l,c;for(let h=0;h<e.attachmentsState.length;h++)t=KVt(t,e.attachmentsState[h]);return t=qVt(t,e.blendConstant||Ra),t=Os(t,e.depthCompare),t=Os(t,e.depthWrite?1:0),t=Os(t,(r=e.stencilFront)===null||r===void 0?void 0:r.compare),t=Os(t,(i=e.stencilFront)===null||i===void 0?void 0:i.passOp),t=Os(t,(s=e.stencilFront)===null||s===void 0?void 0:s.failOp),t=Os(t,(o=e.stencilFront)===null||o===void 0?void 0:o.depthFailOp),t=Os(t,(n=e.stencilBack)===null||n===void 0?void 0:n.compare),t=Os(t,(a=e.stencilBack)===null||a===void 0?void 0:a.passOp),t=Os(t,(l=e.stencilBack)===null||l===void 0?void 0:l.failOp),t=Os(t,(c=e.stencilBack)===null||c===void 0?void 0:c.depthFailOp),t=Os(t,e.stencilWrite?1:0),t=Os(t,e.cullMode),t=Os(t,e.frontFace?1:0),t=Os(t,e.polygonOffset?1:0),t}function JVt(t){var e;let r=0;r=Os(r,t.program.id),t.inputLayout!==null&&(r=Os(r,t.inputLayout.id)),r=ZVt(r,(e=t.megaStateDescriptor)!==null&&e!==void 0?e:K0);for(let i=0;i<t.colorAttachmentFormats.length;i++)r=Os(r,t.colorAttachmentFormats[i]||0);return r=Os(r,t.depthStencilAttachmentFormat||0),ept(r)}function QVt(t){let e=0;if(t.pipeline&&(e=Os(e,t.pipeline.id)),t.samplerBindings)for(let r=0;r<t.samplerBindings.length;r++){const i=t.samplerBindings[r];i!==null&&i.texture!==null&&(e=Os(e,i.texture.id))}if(t.uniformBufferBindings)for(let r=0;r<t.uniformBufferBindings.length;r++){const i=t.uniformBufferBindings[r];i!==null&&i.buffer!==null&&(e=Os(e,i.buffer.id),e=Os(e,i.binding),e=Os(e,i.offset),e=Os(e,i.size))}if(t.storageBufferBindings)for(let r=0;r<t.storageBufferBindings.length;r++){const i=t.storageBufferBindings[r];i!==null&&i.buffer!==null&&(e=Os(e,i.buffer.id),e=Os(e,i.binding),e=Os(e,i.offset),e=Os(e,i.size))}if(t.storageTextureBindings)for(let r=0;r<t.storageTextureBindings.length;r++){const i=t.storageTextureBindings[r];i!==null&&i.texture!==null&&(e=Os(e,i.texture.id),e=Os(e,i.binding))}return ept(e)}function tYt(t,e){var r,i,s,o;return((r=t.vertex)===null||r===void 0?void 0:r.glsl)===((i=e.vertex)===null||i===void 0?void 0:i.glsl)&&((s=t.fragment)===null||s===void 0?void 0:s.glsl)===((o=e.fragment)===null||o===void 0?void 0:o.glsl)}function eYt(t){var e,r;return{vertex:{glsl:(e=t.vertex)===null||e===void 0?void 0:e.glsl},fragment:{glsl:(r=t.fragment)===null||r===void 0?void 0:r.glsl}}}class rYt{constructor(e){this.device=e,this.bindingsCache=new JL(ozt,QVt),this.renderPipelinesCache=new JL(czt,JVt),this.inputLayoutsCache=new JL(dzt,wq),this.programCache=new JL(tYt,wq),this.samplerCache=new JL(fzt,wq)}createBindings(e){let r=this.bindingsCache.get(e);if(r===null){const i=mzt(e);r=this.device.createBindings(i),this.bindingsCache.add(i,r)}return r}createRenderPipeline(e){let r=this.renderPipelinesCache.get(e);if(r===null){const i=yzt(e);i.colorAttachmentFormats=i.colorAttachmentFormats.filter(s=>s),r=this.device.createRenderPipeline(i),this.renderPipelinesCache.add(i,r)}return r}createInputLayout(e){e.vertexBufferDescriptors=e.vertexBufferDescriptors.filter(i=>!!i);let r=this.inputLayoutsCache.get(e);if(r===null){const i=bzt(e);r=this.device.createInputLayout(i),this.inputLayoutsCache.add(i,r)}return r}createProgram(e){let r=this.programCache.get(e);if(r===null){const i=eYt(e);r=this.device.createProgram(e),this.programCache.add(i,r)}return r}createSampler(e){let r=this.samplerCache.get(e);return r===null&&(r=this.device.createSampler(e),this.samplerCache.add(e,r)),r}destroy(){for(const e of this.bindingsCache.values())e.destroy();for(const e of this.renderPipelinesCache.values())e.destroy();for(const e of this.inputLayoutsCache.values())e.destroy();for(const e of this.programCache.values())e.destroy();for(const e of this.samplerCache.values())e.destroy();this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()}}const Eq={default:-1};function iYt(t="default"){return Eq[t]===void 0&&(Eq[t]=-1),++Eq[t]}function QL(t){return t.split("").reduce(function(e,r){return e=(e<<5)-e+r.charCodeAt(0),e&e},0)}const sYt={normal:"normal",darken:"darken",multiply:"multiply",linearBurn:null,colorBurn:"color-burn",light:"lighten",screen:"screen",linearDodge:null,colorDodge:"color-dodge",overlay:"overlay",softLight:"soft-light",hardLight:"hard-light",difference:"difference",exclusion:"exclusion",hue:"hue",saturation:"saturation",color:"color",luminosity:"luminosity"};function oYt(t){if(!t)return null;const e=sYt[t];return!e||e==="normal"?null:e}function Ij(t,e){const r=t.getNodeByEntity(e);return r==null?void 0:r.blendMode}function Aq(t){return t!=null&&t!=="normal"}var xq;(function(t){t[t.POSITION=0]="POSITION"})(xq||(xq={}));const Sq=` 6989layout(location = ${xq.POSITION}) in vec2 a_Position; 6990 6991out vec2 v_Uv; 6992 6993void main() { 6994 v_Uv = 0.5 * (a_Position + 1.0); 6995 gl_Position = vec4(a_Position, 0.0, 1.0); 6996 6997 #ifdef VIEWPORT_ORIGIN_TL 6998 v_Uv.y = 1.0 - v_Uv.y; 6999 #endif 7000} 7001`,ipt=` 7002layout(std140) uniform FillLayerComposeUniforms { 7003 vec4 u_BlendParams; 7004}; 7005`,nYt=` 7006${ipt} 7007uniform sampler2D u_Src; 7008in vec2 v_Uv; 7009out vec4 outputColor; 7010 7011void main() { 7012 vec4 s = texture(SAMPLER_2D(u_Src), v_Uv); 7013 float op = u_BlendParams.y; 7014 outputColor = vec4(s.rgb * op, s.a * op); 7015} 7016`,spt=` 7017${ipt} 7018uniform sampler2D u_Backdrop; 7019uniform sampler2D u_Src; 7020in vec2 v_Uv; 7021out vec4 outputColor; 7022 7023const float EPS = 1e-5; 7024 7025vec3 rgb2hsl(vec3 c) { 7026 float maxc = max(max(c.r, c.g), c.b); 7027 float minc = min(min(c.r, c.g), c.b); 7028 float l = (maxc + minc) * 0.5; 7029 float s = 0.0; 7030 float h = 0.0; 7031 float d = maxc - minc; 7032 if (d > EPS) { 7033 s = l > 0.5 ? d / (2.0 - maxc - minc) : d / (maxc + minc); 7034 if (maxc == c.r) h = (c.g - c.b) / d + (c.g < c.b ? 6.0 : 0.0); 7035 else if (maxc == c.g) h = (c.b - c.r) / d + 2.0; 7036 else h = (c.r - c.g) / d + 4.0; 7037 h /= 6.0; 7038 } 7039 return vec3(h, s, l); 7040} 7041 7042float hue2rgb(float p, float q, float t) { 7043 if (t < 0.0) t += 1.0; 7044 if (t > 1.0) t -= 1.0; 7045 if (t < 1.0 / 6.0) return p + (q - p) * 6.0 * t; 7046 if (t < 0.5) return q; 7047 if (t < 2.0 / 3.0) return p + (q - p) * (2.0 / 3.0 - t) * 6.0; 7048 return p; 7049} 7050 7051vec3 hsl2rgb(vec3 hsl) { 7052 float h = hsl.x; 7053 float s = hsl.y; 7054 float l = hsl.z; 7055 if (s < EPS) return vec3(l); 7056 float q = l < 0.5 ? l * (1.0 + s) : l + s - l * s; 7057 float p = 2.0 * l - q; 7058 return vec3( 7059 hue2rgb(p, q, h + 1.0 / 3.0), 7060 hue2rgb(p, q, h), 7061 hue2rgb(p, q, h - 1.0 / 3.0) 7062 ); 7063} 7064
7065vec3 clip_color(vec3 c) { 7066 float l = dot(c, vec3(1.0)); 7067 float n = min(min(c.r, c.g), c.b); 7068 float x = max(max(c.r, c.g), c.b); 7069 if (n < 0.0) c = l + ((c - l) * l) / max(l - n, EPS); 7070 if (x > 1.0) c = l + ((c - l) * (1.0 - l)) / max(x - l, EPS); 7071 return clamp(c, 0.0, 1.0); 7072} 7073 7074vec3 set_lum(vec3 c, float l2) { 7075 float d = l2 - dot(c, vec3(0.3, 0.59, 0.11)); 7076 return clip_color(c + d); 7077} 7078 7079vec3 set_sat(vec3 c, float s2) { 7080 float maxc = max(max(c.r, c.g), c.b); 7081 float minc = min(min(c.r, c.g), c.b); 7082 float sat = maxc - minc; 7083 if (sat < EPS) return vec3(0.0); 7084 return (c - minc) * s2 / sat; 7085} 7086 7087vec3 blend_mode_rgb(vec3 Cb, vec3 Cs, int mode) { 7088 if (mode == 0) return Cs; 7089 if (mode == 1) return min(Cb, Cs); 7090 if (mode == 2) return Cb * Cs; 7091 if (mode == 3) return Cb + Cs - 1.0; 7092 if (mode == 4) return vec3(1.0) - min(vec3(1.0), (vec3(1.0) - Cb) / max(Cs, vec3(EPS))); 7093 if (mode == 5) return max(Cb, Cs); 7094 if (mode == 6) return vec3(1.0) - (vec3(1.0) - Cb) * (vec3(1.0) - Cs); 7095 if (mode == 7) return min(vec3(1.0), Cb + Cs); 7096 if (mode == 8) return min(vec3(1.0), Cb / max(vec3(1.0) - Cs, vec3(EPS))); 7097 if (mode == 9) { 7098 vec3 r; 7099 r.r = Cb.r < 0.5 ? (2.0 * Cb.r * Cs.r) : (1.0 - 2.0 * (1.0 - Cb.r) * (1.0 - Cs.r)); 7100 r.g = Cb.g < 0.5 ? (2.0 * Cb.g * Cs.g) : (1.0 - 2.0 * (1.0 - Cb.g) * (1.0 - Cs.g)); 7101 r.b = Cb.b < 0.5 ? (2.0 * Cb.b * Cs.b) : (1.0 - 2.0 * (1.0 - Cb.b) * (1.0 - Cs.b)); 7102 return r; 7103 } 7104 if (mode == 10) { 7105 vec3 one = vec3(1.0); 7106 return (one - Cs) * Cb * Cb + Cs * (one - (one - Cb) * (one - Cb)); 7107 } 7108 if (mode == 11) { 7109 vec3 r; 7110 r.r = Cs.r < 0.5 ? (2.0 * Cb.r * Cs.r) : (1.0 - 2.0 * (1.0 - Cb.r) * (1.0 - Cs.r)); 7111 r.g = Cs.g < 0.5 ? (2.0 * Cb.g * Cs.g) : (1.0 - 2.0 * (1.0 - Cb.g) * (1.0 - Cs.g)); 7112 r.b = Cs.b < 0.5 ? (2.0 * Cb.b * Cs.b) : (1.0 - 2.0 * (1.0 - Cb.b) * (1.0 - Cs.b)); 7113 return r; 7114 } 7115 if (mode == 12) return abs(Cb - Cs); 7116 if (mode == 13) return Cb + Cs - 2.0 * Cb * Cs; 7117 vec3 sh = rgb2hsl(Cs); 7118 vec3 bh = rgb2hsl(Cb); 7119 if (mode == 14) return hsl2rgb(vec3(sh.x, bh.y, bh.z)); 7120 if (mode == 15) return set_lum(set_sat(Cs, bh.y), dot(Cb, vec3(0.3, 0.59, 0.11))); 7121 if (mode == 16) return hsl2rgb(vec3(sh.x, sh.y, bh.z)); 7122 if (mode == 17) return set_lum(Cs, dot(Cb, vec3(0.3, 0.59, 0.11))); 7123 return Cs; 7124} 7125 7126void main() { 7127 vec4 bp = texture(SAMPLER_2D(u_Backdrop), v_Uv); 7128 vec4 sp = texture(SAMPLER_2D(u_Src), v_Uv); 7129 float op = u_BlendParams.y; 7130 sp = vec4(sp.rgb * op, sp.a * op); 7131 float ab = bp.a; 7132 float as = sp.a; 7133 vec3 Cb = ab > EPS ? bp.rgb / ab : vec3(0.0); 7134 vec3 Cs = as > EPS ? sp.rgb / as : vec3(0.0); 7135 int mode = int(u_BlendParams.x + 0.5); 7136 vec3 Bmix = blend_mode_rgb(Cb, Cs, mode); 7137 vec3 outP = as * Bmix + bp.rgb * (1.0 - as); 7138 float ao = as + ab * (1.0 - as); 7139 outputColor = vec4(outP, ao); 7140} 7141`;function opt(t){switch(t??"normal"){case"normal":return 0;case"darken":return 1;case"multiply":return 2;case"linearBurn":return 3;case"colorBurn":return 4;case"light":return 5;case"screen":return 6;case"linearDodge":return 7;case"colorDodge":return 8;case"overlay":return 9;case"softLight":return 10;case"hardLight":return 11;case"difference":return 12;case"exclusion":return 13;case"hue":return 14;case"saturation":return 15;case"color":return 16;case"luminosity":return 17;default:return 0}}function npt(t,e,r){t.submitRenderPassImmediate(e,r)}function apt(t,e,r,i,s,o,n){var a;const l=r.length;if(i.length!==l||l<2)throw new Error("composeFillLayerTexturesOnGpu: invalid layers/textures");const c=t.queryVendorInfo().platformString==="WebGPU"?`diagnostic(off,derivative_uniformity); 7142`:"",h=e.createProgram({vertex:{glsl:Sq},fragment:{glsl:nYt,postprocess:B=>c+B}}),u=e.createProgram({vertex:{glsl:Sq},fragment:{glsl:spt,postprocess:B=>c+B}}),d=t.createBuffer({viewOrSize:new Float32Array([1,3,-3,-1,1,-1]),usage:Ee.VERTEX,hint:rr.STATIC}),f=e.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:Pi.VERTEX,attributes:[{shaderLocation:0,offset:0,format:X.F32_RG}]}],indexBufferFormat:null,program:h}),g=e.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:Pi.VERTEX,attributes:[{shaderLocation:0,offset:0,format:X.F32_RG}]}],indexBufferFormat:null,program:u}
7142),p=e.createRenderPipeline({inputLayout:f,program:h,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:null,megaStateDescriptor:Oft}),m=e.createRenderPipeline({inputLayout:g,program:u,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:null,megaStateDescriptor:Oft}),v=t.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*4,usage:Ee.UNIFORM,hint:rr.DYNAMIC}),b=t.createTexture({format:X.U8_RGBA_RT,width:s,height:o,usage:vi.RENDER_TARGET|vi.SAMPLED}),y=t.createTexture({format:X.U8_RGBA_RT,width:s,height:o,usage:vi.RENDER_TARGET|vi.SAMPLED}),_=t.createRenderTargetFromTexture(b),w=t.createRenderTargetFromTexture(y),E=n(),A=(B,O)=>{const C=new Float32Array(4);C[0]=B,C[1]=O,v.setSubData(0,new Uint8Array(C.buffer))};A(0,Cg(r[0].opacity));const x=e.createBindings({pipeline:p,uniformBufferBindings:[{buffer:v}],samplerBindings:[{texture:i[0],sampler:E}]});npt(t,{colorAttachment:[_],colorClearColor:[Ra],colorResolveTo:[null],colorStore:[!0]},B=>{B.setViewport(0,0,s,o),B.setPipeline(p),B.setBindings(x),B.setVertexInput(f,[{buffer:d}],null),B.draw(3)}),x.destroy();let S=b,T=!0;for(let B=1;B<l;B++){const O=r[B];A(opt(O.blendMode),Cg(O.opacity));const C=T?w:_,F=e.createBindings({pipeline:m,uniformBufferBindings:[{buffer:v}],samplerBindings:[{texture:S,sampler:E},{texture:i[B],sampler:E}]});npt(t,{colorAttachment:[C],colorClearColor:[Ra],colorResolveTo:[null],colorStore:[!0]},U=>{U.setViewport(0,0,s,o),U.setPipeline(m),U.setBindings(F),U.setVertexInput(g,[{buffer:d}],null),U.draw(3)}),F.destroy(),S=T?y:b,T=!T}v.destroy(),d.destroy();const R=S===b?y:b;return(a=R.destroy)===null||a===void 0||a.call(R),S}var J0=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Uh=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},M2,t3,e3,r3,i3,Kx,s3;const aYt=_j({attachmentsState:[{channelWriteMask:oo.ALL,rgbBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ZERO},alphaBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ZERO}}],blendConstant:Ra,cullMode:jl.NONE,depthCompare:li.ALWAYS,depthWrite:!1});class lYt{constructor(e,r){this.device=e,this.renderCache=r,M2.set(this,void 0),t3.set(this,void 0),e3.set(this,void 0),r3.set(this,void 0),i3.set(this,void 0),Kx.set(this,null),s3.set(this,"");const i=e.queryVendorInfo().platformString==="WebGPU"?`diagnostic(off,derivative_uniformity); 7143`:"",s=r.createProgram({vertex:{glsl:Sq},fragment:{glsl:spt,postprocess:o=>i+o}});J0(this,t3,e.createBuffer({viewOrSize:new Float32Array([1,3,-3,-1,1,-1]),usage:Ee.VERTEX,hint:rr.STATIC}),"f"),J0(this,i3,r.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:Pi.VERTEX,attributes:[{shaderLocation:0,offset:0,format:X.F32_RG}]}],indexBufferFormat:null,program:s}),"f"),J0(this,r3,r.createRenderPipeline({inputLayout:Uh(this,i3,"f"),program:s,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:X.D24_S8,megaStateDescriptor:aYt}),"f"),J0(this,M2,e.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*4,usage:Ee.UNIFORM,hint:rr.DYNAMIC}),"f"),J0(this,e3,r.createSampler({addressModeU:ho.CLAMP_TO_EDGE,addressModeV:ho.CLAMP_TO_EDGE,minFilter:hs.POINT,magFilter:hs.BILINEAR,mipmapFilter:Ro.LINEAR,lodMinClamp:0,lodMaxClamp:0}),"f")}composite(e,r,i,s,o,n){var a;const l=new Float32Array(4);l[0]=opt(s),l[1]=1,Uh(this,M2,"f").setSubData(0,new Uint8Array(l.buffer));const c=`${r.id}:${i.id}:${l[0]}`;Uh(this,s3,"f")!==c&&((a=Uh(this,Kx,"f"))===null||a===void 0||a.destroy(),J0(this,Kx,this.renderCache.createBindings({pipeline:Uh(this,r3,"f"),uniformBufferBindings:[{buffer:Uh(this,M2,"f")}],samplerBindings:[{texture:r,sampler:Uh(this,e3,"f")},{texture:i,sampler:Uh(this,e3,"f")}]}
7143),"f"),J0(this,s3,c,"f")),e.setViewport(0,0,o,n),e.setPipeline(Uh(this,r3,"f")),e.setBindings(Uh(this,Kx,"f")),e.setVertexInput(Uh(this,i3,"f"),[{buffer:Uh(this,t3,"f")}],null),e.draw(3)}destroy(){var e;(e=Uh(this,Kx,"f"))===null||e===void 0||e.destroy(),J0(this,Kx,null,"f"),J0(this,s3,"","f"),Uh(this,M2,"f").destroy(),Uh(this,t3,"f").destroy()}}M2=new WeakMap,t3=new WeakMap,e3=new WeakMap,r3=new WeakMap,i3=new WeakMap,Kx=new WeakMap,s3=new WeakMap;const lpt=new WeakMap;function cYt(t,e){let r=lpt.get(t);return r||(r=new lYt(t,e),lpt.set(t,r)),r}function hYt(t,e,r,i,s,o,n,a){cYt(e,r).composite(t,i,s,o,n,a)}function o3(t){if(!t)return 0;const{alignment:e="center",width:r=0}=t;return e==="center"?r/2:e==="inner"?0:e==="outer"?r:0}function uYt(t){return!!t.color&&t.thickness>0}function dYt(t,e){const{type:r}=t;return r==="rect"||r==="rough-rect"||r==="html"||r==="embed"?$t.getGeometryBounds(t):r==="ellipse"||r==="rough-ellipse"?ae.getGeometryBounds(t):r==="polyline"||r==="rough-polyline"?_t.getGeometryBounds(t):r==="line"||r==="rough-line"?Mt.getGeometryBounds(t):r==="path"?xt.getGeometryBounds(t):r==="text"?Yt.getGeometryBounds(t,e):r==="g"?new Qe(0,0,0,0):new Qe(1/0,1/0,-1/0,-1/0)}const Bg=AG.generator();function cpt(t){const e=[];return t.ops.forEach(({op:r,data:i})=>{r==="move"?e.push(["M",i[0],i[1]]):r==="lineTo"?e.push(["L",i[0],i[1]]):r==="bcurveTo"&&e.push(["C",i[0],i[1],i[2],i[3],i[4],i[5]])}),e}RV=function(t){return Object.fromEntries(Object.entries(t).filter(([e,r])=>r!==void 0))};class n3{constructor(){this.arcLengthDivisions=200,this.needsUpdate=!0}getPointAt(e,r){const i=this.getUtoTmapping(e);return this.getPoint(i,r)}getPoints(e=5){const r=[];for(let i=0;i<=e;i++)r.push(this.getPoint(i/e));return r}getSpacedPoints(e=5){const r=[];for(let i=0;i<=e;i++)r.push(this.getPointAt(i/e));return r}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const r=[];let i,s=this.getPoint(0),o=0;r.push(0);for(let n=1;n<=e;n++)i=this.getPoint(n/e),o+=Hy(i,s),r.push(o),s=i;return this.cacheArcLengths=r,r}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,r){const i=this.getLengths();let s=0;const o=i.length;let n;r?n=r:n=e*i[o-1];let a=0,l=o-1,c;for(;a<=l;)if(s=Math.floor(a+(l-a)/2),c=i[s]-n,c<0)a=s+1;else if(c>0)l=s-1;else{l=s;break}if(s=l,i[s]===n)return s/(o-1);const h=i[s],u=i[s+1]-h,d=(n-h)/u;return(s+d)/(o-1)}getTangent(e,r){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),n=this.getPoint(s),a=r||it();return ru(a,n,o),aE(a,a),a}getTangentAt(e,r){const i=this.getUtoTmapping(e);return this.getTangent(i,r)}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Tq extends n3{constructor(e=it(),r=it()){super(),this.v1=e,this.v2=r,this.v1=e,this.v2=r}getPoint(e,r=it()){const i=r;return e===1?di(i,this.v2):(ru(i,di(i,this.v2),this.v1),lG(i,this.v1,i,e)),i}getPointAt(e,r){return this.getPoint(e,r)}}class hpt extends n3{constructor(e=0,r=0,i=1,s=1,o=0,n=Math.PI*2,a=!1,l=0){super(),this.aX=e,this.aY=r,this.xRadius=i,this.yRadius=s,this.aStartAngle=o,this.aEndAngle=n,this.aClockwise=a,this.aRotation=l}getPoint(e,r=it()){const i=r,s=Math.PI*2;let o=this.aEndAngle-this.aStartAngle;const n=Math.abs(o)<Number.EPSILON;for(;o<0;)o+=s;for(;o>s;)o-=s;o<Number.EPSILON&&(n?o=0:o=s),this.aClockwise===!0&&!n&&(o===s?o=-s:o=o-s);const a=this.aStartAngle+e*o;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*h-f*u+this.aX,c=d*u+f*h+this.aY}return Jn(i,l,c)}}class fYt extends n3{constructor(){super(...arguments),this.curves=[],this.autoClose=!1,this.cacheLengths=null}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),r=this.curves[this.curves.length-1].getPoint(1);return sd(e,r)||this.curves.push(new Tq(r,e)),this}getPoint(e,r){const i=e*this.getLength(),s=this.getCurveLengths();let o=0;for(;o<s.length;){if(s[o]>=i){const n=s[o]-i,a=this.curves[o],l=a.getLength(),c=l===0?0:1-n/l;return a.getPointAt(c,r)}o++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let r=0;for(let i=0,s=this.curves.length;i<s;i++)r+=this.curves[i].getLength(),e.push(r);return this.cacheLengths=e,e}getPoints(e=12){const r=[];let i;for(let s=0,o=this.curves;s<o.length;s++){const n=o[s],a=n instanceof hpt?e*2:n instanceof Tq?1:n.isSplineCurve?e*n.points.length:e,l=n.getPoints(a);for(let c=0;c<l.length;c++){const h=l[c];i&&sd(i,h)||(r.push(h),i=h)}}return this.autoClose&&r.length>1&&!sd(r[r.length-1],r[0])&&r.push(r[0]),r}}function pYt(t,e){const r=1-t;return r*r*e}function gYt(t,e){return 2*(1-t)*t*e}function mYt(t,e){return t*t*e}function upt(t,e,r,i){return pYt(t,e)+gYt(t,r)+mYt(t,i)}function yYt(t,e){const r=1-t;return r*r*r*e}function vYt(t,e){const r=1-t;return 3*r*r*t*e}function _Yt(t,e){return 3*(1-t)*t*t*e}function bYt(t,e){return t*t*t*e}function dpt(t,e,r,i,s){return yYt(t,e)+vYt(t,r)+_Yt(t,i)+bYt(t,s)}class wYt extends n3{constructor(e=it(),r=it(),i=it()){super(),this.v0=e,this.v1=r,this.v2=i,this.v0=e,this.v1=r,this.v2=i}
7143getPoint(e,r=it()){const i=r,{v0:s,v1:o,v2:n}=this;return Jn(i,upt(e,s[0],o[0],n[0]),upt(e,s[1],o[1],n[1])),i}getPointAt(e,r){return this.getPoint(e,r)}}class Rq extends n3{constructor(e=it(),r=it(),i=it(),s=it()){super(),this.v0=e,this.v1=r,this.v2=i,this.v3=s,this.v0=e,this.v1=r,this.v2=i,this.v3=s}getPoint(e,r=it()){const i=r,{v0:s,v1:o,v2:n,v3:a}=this;return Jn(i,dpt(e,s[0],o[0],n[0],a[0]),dpt(e,s[1],o[1],n[1],a[1])),i}getPointAt(e,r){return this.getPoint(e,r)}}let EYt=class extends fYt{constructor(t){super(),this.currentPoint=it(),t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0][0],t[0][1]);for(let e=1,r=t.length;e<r;e++)this.lineTo(t[e][0],t[e][1]);return this}moveTo(t,e){return Jn(this.currentPoint,t,e),this}lineTo(t,e){const r=new Tq(Ta(this.currentPoint),Be(t,e));return this.curves.push(r),Jn(this.currentPoint,t,e),this}quadraticCurveTo(t,e,r,i){const s=new wYt(Ta(this.currentPoint),Be(t,e),Be(r,i));return this.curves.push(s),Jn(this.currentPoint,r,i),this}bezierCurveTo(t,e,r,i,s,o){const n=new Rq(Ta(this.currentPoint),Be(t,e),Be(r,i),Be(s,o));return this.curves.push(n),Jn(this.currentPoint,s,o),this}arc(t,e,r,i,s,o){const[n,a]=this.currentPoint;return this.absarc(t+n,e+a,r,i,s,o),this}absarc(t,e,r,i,s,o){return this.absellipse(t,e,r,r,i,s,o),this}absellipse(t,e,r,i,s,o,n,a){const l=new hpt(t,e,r,i,s,o,n,a);if(this.curves.length>0){const h=l.getPoint(0);sd(h,this.currentPoint)||this.lineTo(h[0],h[1])}this.curves.push(l);const c=l.getPoint(1);return di(this.currentPoint,c),this}};class AYt{constructor(){this.subPaths=[],this.currentPath=null}moveTo(e,r){return this.currentPath=new EYt,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,r),this}lineTo(e,r){return this.currentPath.lineTo(e,r),this}quadraticCurveTo(e,r,i,s){return this.currentPath.quadraticCurveTo(e,r,i,s),this}bezierCurveTo(e,r,i,s,o,n){return this.currentPath.bezierCurveTo(e,r,i,s,o,n),this}}function a3(t){const e=new AYt,r=it(),i=it(),s=it();let o=!0,n=!1;return(Na(t)?ep(t):cpt(t)).forEach(a=>{const l=a[0],c=a.slice(1);o===!0&&(n=!0,o=!1);let h;switch(l){case"M":h=c;for(let u=0,d=h.length;u<d;u+=2)r[0]=h[u+0],r[1]=h[u+1],i[0]=r[0],i[1]=r[1],u===0?e.moveTo(r[0],r[1]):e.lineTo(r[0],r[1]),u===0&&di(s,r);break;case"H":h=c;for(let u=0,d=h.length;u<d;u++)r[0]=h[u],i[0]=r[0],i[1]=r[1],e.lineTo(r[0],r[1]),u===0&&n===!0&&di(s,r);break;case"V":h=c;for(let u=0,d=h.length;u<d;u++)r[1]=h[u],i[0]=r[0],i[1]=r[1],e.lineTo(r[0],r[1]),u===0&&n===!0&&di(s,r);break;case"L":h=c;for(let u=0,d=h.length;u<d;u+=2)r[0]=h[u+0],r[1]=h[u+1],i[0]=r[0],i[1]=r[1],e.lineTo(r[0],r[1]),u===0&&n===!0&&di(s,r);break;case"C":h=c;for(let u=0,d=h.length;u<d;u+=6)e.bezierCurveTo(h[u+0],h[u+1],h[u+2],h[u+3],h[u+4],h[u+5]),i[0]=h[u+2],i[1]=h[u+3],r[0]=h[u+4],r[1]=h[u+5],u===0&&n===!0&&di(s,r);break;case"S":h=c;for(let u=0,d=h.length;u<d;u+=4)e.bezierCurveTo(Dj(r[0],i[0]),Dj(r[1],i[1]),h[u+0],h[u+1],h[u+2],h[u+3]),i[0]=h[u+0],i[1]=h[u+1],r[0]=h[u+2],r[1]=h[u+3],u===0&&n===!0&&di(s,r);break;case"Q":h=c;for(let u=0,d=h.length;u<d;u+=4)e.quadraticCurveTo(h[u+0],h[u+1],h[u+2],h[u+3]),i[0]=h[u+0],i[1]=h[u+1],r[0]=h[u+2],r[1]=h[u+3],u===0&&n===!0&&di(s,r);break;case"T":h=c;for(let u=0,d=h.length;u<d;u+=2){const f=Dj(r[0],i[0]),g=Dj(r[1],i[1]);e.quadraticCurveTo(f,g,h[u+0],h[u+1]),i[0]=f,i[1]=g,r[0]=h[u+0],r[1]=h[u+1],u===0&&n===!0&&di(s,r)}break;case"A":h=c;for(let u=0,d=h.length;u<d;u+=7){if(h[u+5]==r[0]&&h[u+6]==r[1])continue;const f=Ta(r);r[0]=h[u+5],r[1]=h[u+6],i[0]=r[0],i[1]=r[1],xYt(e,h[u],h[u+1],h[u+2],h[u+3],h[u+4],f,r),u===0&&n===!0&&di(s,r)}break;case"Z":e.currentPath.autoClose=!0,e.currentPath.curves.length>0&&(di(r,s),di(e.currentPath.currentPoint,r),o=!0);break;default:console.warn(a)}n=!1}),e}function Dj(t,e){return t-(e-t)}function xYt(t,e,r,i,s,o,n,a){if(e==0||r==0){t.lineTo(a[0],a[1]);return}i=i*Math.PI/180,e=Math.abs(e),r=Math.abs(r);const l=(n[0]-a[0])/2,c=(n[1]-a[1])/2,h=Math.cos(i)*l+Math.sin(i)*c,u=-Math.sin(i)*l+Math.cos(i)*c;let d=e*e,f=r*r;const g=h*h,p=u*u,m=g/d+p/f;if(m>1){const T=Math.sqrt(m);e=T*e,r=T*r,d=e*e,f=r*r}const v=d*p+f*g,b=(d*f-v)/v;let y=Math.sqrt(Math.max(0,b));s===o&&(y=-y);const _=y*e*u/r,w=-y*r*h/e,E=Math.cos(i)*_-Math.sin(i)*w+(n[0]+a[0])/2,A=Math.sin(i)*_+Math.cos(i)*w+(n[1]+a[1])/2,x=fpt(1,0,(h-_)/e,(u-w)/r),S=fpt((h-_)/e,(u-w)/r,(-h-_)/e,(-u-w)/r)%(Math.PI*2);t.currentPath.absellipse(E,A,e,r,x,x+S,o===0,i)}function fpt(t,e,r,i){const s=t*r+e*i,o=Math.sqrt(t*t+e*e)*Math.sqrt(r*r+i*i);let n=Math.acos(Math.max(-1,Math.min(1,s/o)));return t*i-e*r<0&&(n=-n),n}function SYt(t){const e=t.length;let r=0;for(let i=e-1,s=0;s<e;i=s++)r+=t[i][0]*t[s][1]-t[s][0]*t[i][1];return r*.5}function Cq(t){return SYt(t)>0}function TYt(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,s,o,n;return n={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(n[Symbol.iterator]=function(){return this}),n;function a(c){return function(h){return l([c,h])}}function l(c){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,s&&(o=c[0]&2?s.return:c[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,c[1])).done)return o;switch(s=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,s=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){r.label=c[1];break}if(c[0]===6&&r.label<o[1]){r.label=o[1],o=c;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(c);break}o[2]&&r.ops.pop(),r.trys.pop();continue}c=e.call(t,r)}catch(h){c=[6,h],s=0}finally{i=o=0}
7143if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}var dw=(function(){function t(e,r){this.next=null,this.key=e,this.data=r,this.left=null,this.right=null}return t})();function RYt(t,e){return t>e?1:t<e?-1:0}function fw(t,e,r){for(var i=new dw(null,null),s=i,o=i;;){var n=r(t,e.key);if(n<0){if(e.left===null)break;if(r(t,e.left.key)<0){var a=e.left;if(e.left=a.right,a.right=e,e=a,e.left===null)break}o.left=e,o=e,e=e.left}else if(n>0){if(e.right===null)break;if(r(t,e.right.key)>0){var a=e.right;if(e.right=a.left,a.left=e,e=a,e.right===null)break}s.right=e,s=e,e=e.right}else break}return s.right=e.left,o.left=e.right,e.left=i.right,e.right=i.left,e}function Mq(t,e,r,i){var s=new dw(t,e);if(r===null)return s.left=s.right=null,s;r=fw(t,r,i);var o=i(t,r.key);return o<0?(s.left=r.left,s.right=r,r.left=null):o>=0&&(s.right=r.right,s.left=r,r.right=null),s}function ppt(t,e,r){var i=null,s=null;if(e){e=fw(t,e,r);var o=r(e.key,t);o===0?(i=e.left,s=e.right):o<0?(s=e.right,e.right=null,i=e):(i=e.left,e.left=null,s=e)}return{left:i,right:s}}function CYt(t,e,r){return e===null?t:(t===null||(e=fw(t.key,e,r),e.left=t),e)}function Bq(t,e,r,i,s){if(t){i(""+e+(r?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ")+s(t)+` 7144`);var o=e+(r?" ":"\u2502 ");t.left&&Bq(t.left,o,!1,i,s),t.right&&Bq(t.right,o,!0,i,s)}}var Oq=(function(){function t(e){e===void 0&&(e=RYt),this._root=null,this._size=0,this._comparator=e}return t.prototype.insert=function(e,r){return this._size++,this._root=Mq(e,r,this._root,this._comparator)},t.prototype.add=function(e,r){var i=new dw(e,r);this._root===null&&(i.left=i.right=null,this._size++,this._root=i);var s=this._comparator,o=fw(e,this._root,s),n=s(e,o.key);return n===0?this._root=o:(n<0?(i.left=o.left,i.right=o,o.left=null):n>0&&(i.right=o.right,i.left=o,o.right=null),this._size++,this._root=i),this._root},t.prototype.remove=function(e){this._root=this._remove(e,this._root,this._comparator)},t.prototype._remove=function(e,r,i){var s;if(r===null)return null;r=fw(e,r,i);var o=i(e,r.key);return o===0?(r.left===null?s=r.right:(s=fw(e,r.left,i),s.right=r.right),this._size--,s):r},t.prototype.pop=function(){var e=this._root;if(e){for(;e.left;)e=e.left;return this._root=fw(e.key,this._root,this._comparator),this._root=this._remove(e.key,this._root,this._comparator),{key:e.key,data:e.data}}return null},t.prototype.findStatic=function(e){for(var r=this._root,i=this._comparator;r;){var s=i(e,r.key);if(s===0)return r;s<0?r=r.left:r=r.right}return null},t.prototype.find=function(e){return this._root&&(this._root=fw(e,this._root,this._comparator),this._comparator(e,this._root.key)!==0)?null:this._root},t.prototype.contains=function(e){for(var r=this._root,i=this._comparator;r;){var s=i(e,r.key);if(s===0)return!0;s<0?r=r.left:r=r.right}return!1},t.prototype.forEach=function(e,r){for(var i=this._root,s=[],o=!1;!o;)i!==null?(s.push(i),i=i.left):s.length!==0?(i=s.pop(),e.call(r,i),i=i.right):o=!0;return this},t.prototype.range=function(e,r,i,s){for(var o=[],n=this._comparator,a=this._root,l;o.length!==0||a;)if(a)o.push(a),a=a.left;else{if(a=o.pop(),l=n(a.key,r),l>0)break;if(n(a.key,e)>=0&&i.call(s,a))return this;a=a.right}return this},t.prototype.keys=function(){var e=[];return this.forEach(function(r){var i=r.key;return e.push(i)}),e},t.prototype.values=function(){var e=[];return this.forEach(function(r){var i=r.data;return e.push(i)}),e},t.prototype.min=function(){return this._root?this.minNode(this._root).key:null},t.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},t.prototype.minNode=function(e){if(e===void 0&&(e=this._root),e)for(;e.left;)e=e.left;return e},t.prototype.maxNode=function(e){if(e===void 0&&(e=this._root),e)for(;e.right;)e=e.right;return e},t.prototype.at=function(e){for(var r=this._root,i=!1,s=0,o=[];!i;)if(r)o.push(r),r=r.left;else if(o.length>0){if(r=o.pop(),s===e)return r;s++,r=r.right}else i=!0;return null},t.prototype.next=function(e){var r=this._root,i=null;if(e.right){for(i=e.right;i.left;)i=i.left;return i}for(var s=this._comparator;r;){var o=s(e.key,r.key);if(o===0)break;o<0?(i=r,r=r.left):r=r.right}return i},t.prototype.prev=function(e){var r=this._root,i=null;if(e.left!==null){for(i=e.left;i.right;)i=i.right;return i}for(var s=this._comparator;r;){var o=s(e.key,r.key);if(o===0)break;o<0?r=r.left:(i=r,r=r.right)}return i},t.prototype.clear=function(){return this._root=null,this._size=0,this},t.prototype.toList=function(){return BYt(this._root)},t.prototype.load=function(e,r,i){r===void 0&&(r=[]),i===void 0&&(i=!1);var s=e.length,o=this._comparator;if(i&&Pq(e,r,0,s-1,o),this._root===null)this._root=Iq(e,r,0,s),this._size=s;else{var n=OYt(this.toList(),MYt(e,r),o);s=this._size+s,this._root=Dq({head:n},0,s)}return this},t.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(t.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){e===void 0&&(e=function(i){return String(i.key)});var r=[];return Bq(this._root,"",!0,function(i){return r.push(i)},e),r.join("")},t.prototype.update=function(e,r,i){var s=this._comparator,o=ppt(e,this._root,s),n=o.left,a=o.right;s(e,r)<0?a=Mq(r,i,a,s):n=Mq(r,i,n,s),this._root=CYt(n,a,s)},t.prototype.split=function(e){return ppt(e,this._root,this._comparator)},t.prototype[Symbol.iterator]=function(){var e,r,i;return TYt(this,function(s){switch(s.label){case 0:e=this._root,r=[],i=!1,s.label=1;case 1:return i?[3,6]:e===null?[3,2]:(r.push(e),e=e.left,[3,5]);case 2:return r.length===0?[3,4]:(e=r.pop(),[4,e]);case 3:return s.sent(),e=e.right,[3,5];case 4:i=!0,s.label=5;case 5:return[3,1];case 6:return[2]}})},t})();function Iq(t,e,r,i){var s=i-r;if(s>0){var o=r+Math.floor(s/2),n=t[o],a=e[o],l=new dw(n,a);return l.left=Iq(t,e,r,o),l.right=Iq(t,e,o+1,i),l}return null}function MYt(t,e){for(var r=new dw(null,null),i=r,s=0;s<t.length;s++)i=i.next=new dw(t[s],e[s]);return i.next=null,r.next}function BYt(t){for(var e=t,r=[],i=!1,s=new dw(null,null),o=s;!i;)e?(r.push(e),e=e.left):r.length>0?(e=o=o.next=r.pop(),e=e.right):i=!0;return o.next=null,s.next}function Dq(t,e,r){var i=r-e;if(i>0){var s=e+Math.floor(i/2),o=Dq(t,e,s),n=t.head;return n.left=o,t.head=t.head.next,n.right=Dq(t,s+1,r),n}return null}function OYt(t,e,r){for(var i=new dw(null,null),s=i,o=t,n=e;o!==null&&n!==null;)r(o.key,n.key)<0?(s.next=o,o=o.next):(s.next=n,n=n.next),s=s.next;return o!==null?s.next=o:n!==null&&(s.next=n),i.next}function Pq(t,e,r,i,s){if(!(r>=i)){for(var o=t[r+i>>1],n=r-1,a=i+1;;){do n++;while(s(t[n],o)<0);do a--;while(s(t[a],o)>0);if(n>=a)break;var l=t[n];t[n]=t[a],t[a]=l,l=e[n],e[n]=e[a],e[a]=l}Pq(t,e,r,a,s),Pq(t,e,a+1,i,s)}}const Q0=11102230246251563e-32,ah=134217729,IYt=(3+8*Q0)*Q0;function Fq(t,e,r,i,s){let o,n,a,l,c=e[0],h=i[0],u=0,d=0;h>c==h>-c?(o=c,c=e[++u]):(o=h,h=i[++d]);let f=0;if(u<t&&d<r)for(h>c==h>-c?(n=c+o,a=o-(n-c),c=e[++u]):(n=h+o,a=o-(n-h),h=i[++d]),o=n,a!==0&&(s[f++]=a);u<t&&d<r;)h>c==h>-c?(n=o+c,l=n-o,a=o-(n-l)+(c-l),c=e[++u]):(n=o+h,l=n-o,a=o-(n-l)+(h-l),h=i[++d]),o=n,a!==0&&(s[f++]=a);for(;u<t;)n=o+c,l=n-o,a=o-(n-l)+(c-l),c=e[++u],o=n,a!==0&&(s[f++]=a);for(;d<r;)n=o+h,l=n-o,a=o-(n-l)+(h-l),h=i[++d],o=n,a!==0&&(s[f++]=a);return(o!==0||f===0)&&(s[f++]=o),f}function DYt(t,e){let r=e[0];for(let i=1;i<t;i++)r+=e[i];return r}function l3(t){return new Float64Array(t)}const PYt=(3+16*Q0)*Q0,FYt=(2+12*Q0)*Q0,NYt=(9+64*Q0)*Q0*Q0,B2=l3(4),gpt=l3(8),mpt=l3(12),ypt=l3(16),Gh=l3(4);function kYt(t,e,r,i,s,o,n){let a,l,c,h,u,d,f,g,p,m,v,b,y,_,w,E,A,x;const S=t-s,T=r-s,R=e-o,B=i-o;_=S*B,d=ah*S,f=d-(d-S),g=S-f,d=ah*B,p=d-(d-B),m=B-p,w=g*m-(_-f*p-g*p-f*m),E=R*T,d=ah*R,f=d-(d-R),g=R-f,d=ah*T,p=d-(d-T),m=T-p,A=g*m-(E-f*p-g*p-f*m),v=w-A,u=w-v,B2[0]=w-(v+u)+(u-A),b=_+v,u=b-_,y=_-(b-u)+(v-u),v=y-E,u=y-v,B2[1]=y-(v+u)+(u-E),x=b+v,u=x-b,B2[2]=b-(x-u)+(v-u),B2[3]=x;let O=DYt(4,B2),C=FYt*n;if(O>=C||-O>
7144=C||(u=t-S,a=t-(S+u)+(u-s),u=r-T,c=r-(T+u)+(u-s),u=e-R,l=e-(R+u)+(u-o),u=i-B,h=i-(B+u)+(u-o),a===0&&l===0&&c===0&&h===0)||(C=NYt*n+IYt*Math.abs(O),O+=S*h+B*a-(R*c+T*l),O>=C||-O>=C))return O;_=a*B,d=ah*a,f=d-(d-a),g=a-f,d=ah*B,p=d-(d-B),m=B-p,w=g*m-(_-f*p-g*p-f*m),E=l*T,d=ah*l,f=d-(d-l),g=l-f,d=ah*T,p=d-(d-T),m=T-p,A=g*m-(E-f*p-g*p-f*m),v=w-A,u=w-v,Gh[0]=w-(v+u)+(u-A),b=_+v,u=b-_,y=_-(b-u)+(v-u),v=y-E,u=y-v,Gh[1]=y-(v+u)+(u-E),x=b+v,u=x-b,Gh[2]=b-(x-u)+(v-u),Gh[3]=x;const F=Fq(4,B2,4,Gh,gpt);_=S*h,d=ah*S,f=d-(d-S),g=S-f,d=ah*h,p=d-(d-h),m=h-p,w=g*m-(_-f*p-g*p-f*m),E=R*c,d=ah*R,f=d-(d-R),g=R-f,d=ah*c,p=d-(d-c),m=c-p,A=g*m-(E-f*p-g*p-f*m),v=w-A,u=w-v,Gh[0]=w-(v+u)+(u-A),b=_+v,u=b-_,y=_-(b-u)+(v-u),v=y-E,u=y-v,Gh[1]=y-(v+u)+(u-E),x=b+v,u=x-b,Gh[2]=b-(x-u)+(v-u),Gh[3]=x;const U=Fq(F,gpt,4,Gh,mpt);_=a*h,d=ah*a,f=d-(d-a),g=a-f,d=ah*h,p=d-(d-h),m=h-p,w=g*m-(_-f*p-g*p-f*m),E=l*c,d=ah*l,f=d-(d-l),g=l-f,d=ah*c,p=d-(d-c),m=c-p,A=g*m-(E-f*p-g*p-f*m),v=w-A,u=w-v,Gh[0]=w-(v+u)+(u-A),b=_+v,u=b-_,y=_-(b-u)+(v-u),v=y-E,u=y-v,Gh[1]=y-(v+u)+(u-E),x=b+v,u=x-b,Gh[2]=b-(x-u)+(v-u),Gh[3]=x;const H=Fq(U,mpt,4,Gh,ypt);return ypt[H-1]}function LYt(t,e,r,i,s,o){const n=(e-o)*(r-s),a=(t-s)*(i-o),l=n-a,c=Math.abs(n+a);return Math.abs(l)>=PYt*c?l:-kYt(t,e,r,i,s,o,c)}var vpt={};const c3=(t,e)=>t.ll.x<=e.x&&e.x<=t.ur.x&&t.ll.y<=e.y&&e.y<=t.ur.y,Nq=(t,e)=>{if(e.ur.x<t.ll.x||t.ur.x<e.ll.x||e.ur.y<t.ll.y||t.ur.y<e.ll.y)return null;const r=t.ll.x<e.ll.x?e.ll.x:t.ll.x,i=t.ur.x<e.ur.x?t.ur.x:e.ur.x,s=t.ll.y<e.ll.y?e.ll.y:t.ll.y,o=t.ur.y<e.ur.y?t.ur.y:e.ur.y;return{ll:{x:r,y:s},ur:{x:i,y:o}}};let pw=Number.EPSILON;pw===void 0&&(pw=Math.pow(2,-52));const UYt=pw*pw,_pt=(t,e)=>{if(-pw<t&&t<pw&&-pw<e&&e<pw)return 0;const r=t-e;return r*r<UYt*t*e?0:t<e?-1:1};class GYt{constructor(){this.reset()}reset(){this.xRounder=new bpt,this.yRounder=new bpt}round(e,r){return{x:this.xRounder.round(e),y:this.yRounder.round(r)}}}class bpt{constructor(){this.tree=new Oq,this.round(0)}round(e){const r=this.tree.add(e),i=this.tree.prev(r);if(i!==null&&_pt(r.key,i.key)===0)return this.tree.remove(e),i.key;const s=this.tree.next(r);return s!==null&&_pt(r.key,s.key)===0?(this.tree.remove(e),s.key):e}}const h3=new GYt,Pj=(t,e)=>t.x*e.y-t.y*e.x,wpt=(t,e)=>t.x*e.x+t.y*e.y,Ept=(t,e,r)=>{const i=LYt(t.x,t.y,e.x,e.y,r.x,r.y);return i>0?-1:i<0?1:0},Fj=t=>Math.sqrt(wpt(t,t)),WYt=(t,e,r)=>{const i={x:e.x-t.x,y:e.y-t.y},s={x:r.x-t.x,y:r.y-t.y};return Pj(s,i)/Fj(s)/Fj(i)},jYt=(t,e,r)=>{const i={x:e.x-t.x,y:e.y-t.y},s={x:r.x-t.x,y:r.y-t.y};return wpt(s,i)/Fj(s)/Fj(i)},Apt=(t,e,r)=>e.y===0?null:{x:t.x+e.x/e.y*(r-t.y),y:r},xpt=(t,e,r)=>e.x===0?null:{x:r,y:t.y+e.y/e.x*(r-t.x)},XYt=(t,e,r,i)=>{if(e.x===0)return xpt(r,i,t.x);if(i.x===0)return xpt(t,e,r.x);if(e.y===0)return Apt(r,i,t.y);if(i.y===0)return Apt(t,e,r.y);const s=Pj(e,i);if(s==0)return null;const o={x:r.x-t.x,y:r.y-t.y},n=Pj(o,e)/s,a=Pj(o,i)/s,l=t.x+a*e.x,c=r.x+n*i.x,h=t.y+a*e.y,u=r.y+n*i.y,d=(l+c)/2,f=(h+u)/2;return{x:d,y:f}};class Uf{static compare(e,r){const i=Uf.comparePoints(e.point,r.point);return i!==0?i:(e.point!==r.point&&e.link(r),e.isLeft!==r.isLeft?e.isLeft?1:-1:gw.compare(e.segment,r.segment))}static comparePoints(e,r){return e.x<r.x?-1:e.x>r.x?1:e.y<r.y?-1:e.y>r.y?1:0}constructor(e,r){e.events===void 0?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=r}link(e){if(e.point===this.point)throw new Error("Tried to link already linked events");const r=e.point.events;for(let i=0,s=r.length;i<s;i++){const o=r[i];this.point.events.push(o),o.point=this.point}this.checkForConsuming()}checkForConsuming(){const e=this.point.events.length;for(let r=0;r<e;r++){const i=this.point.events[r];if(i.segment.consumedBy===void 0)for(let s=r+1;s<e;s++){const o=this.point.events[s];o.consumedBy===void 0&&i.otherSE.point.events===o.otherSE.point.events&&i.segment.consume(o.segment)}}}getAvailableLinkedEvents(){const e=[];for(let r=0,i=this.point.events.length;r<i;r++){const s=this.point.events[r];s!==this&&!s.segment.ringOut&&s.segment.isInResult()&&e.push(s)}return e}getLeftmostComparator(e){const r=new Map,i=s=>{const o=s.otherSE;
7144r.set(s,{sine:WYt(this.point,e.point,o.point),cosine:jYt(this.point,e.point,o.point)})};return(s,o)=>{r.has(s)||i(s),r.has(o)||i(o);const{sine:n,cosine:a}=r.get(s),{sine:l,cosine:c}=r.get(o);return n>=0&&l>=0?a<c?1:a>c?-1:0:n<0&&l<0?a<c?-1:a>c?1:0:l<n?-1:l>n?1:0}}}let zYt=0;class gw{static compare(e,r){const i=e.leftSE.point.x,s=r.leftSE.point.x,o=e.rightSE.point.x,n=r.rightSE.point.x;if(n<i)return 1;if(o<s)return-1;const a=e.leftSE.point.y,l=r.leftSE.point.y,c=e.rightSE.point.y,h=r.rightSE.point.y;if(i<s){if(l<a&&l<c)return 1;if(l>a&&l>c)return-1;const u=e.comparePoint(r.leftSE.point);if(u<0)return 1;if(u>0)return-1;const d=r.comparePoint(e.rightSE.point);return d!==0?d:-1}if(i>s){if(a<l&&a<h)return-1;if(a>l&&a>h)return 1;const u=r.comparePoint(e.leftSE.point);if(u!==0)return u;const d=e.comparePoint(r.rightSE.point);return d<0?1:d>0?-1:1}if(a<l)return-1;if(a>l)return 1;if(o<n){const u=r.comparePoint(e.rightSE.point);if(u!==0)return u}if(o>n){const u=e.comparePoint(r.rightSE.point);if(u<0)return 1;if(u>0)return-1}if(o!==n){const u=c-a,d=o-i,f=h-l,g=n-s;if(u>d&&f<g)return 1;if(u<d&&f>g)return-1}return o>n?1:o<n||c<h?-1:c>h?1:e.id<r.id?-1:e.id>r.id?1:0}constructor(e,r,i,s){this.id=++zYt,this.leftSE=e,e.segment=this,e.otherSE=r,this.rightSE=r,r.segment=this,r.otherSE=e,this.rings=i,this.windings=s}static fromRing(e,r,i){let s,o,n;const a=Uf.comparePoints(e,r);if(a<0)s=e,o=r,n=1;else if(a>0)s=r,o=e,n=-1;else throw new Error(`Tried to create degenerate segment at [${e.x}, ${e.y}]`);const l=new Uf(s,!0),c=new Uf(o,!1);return new gw(l,c,[i],[n])}replaceRightSE(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const e=this.leftSE.point.y,r=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:e<r?e:r},ur:{x:this.rightSE.point.x,y:e>r?e:r}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(e){return e.x===this.leftSE.point.x&&e.y===this.leftSE.point.y||e.x===this.rightSE.point.x&&e.y===this.rightSE.point.y}comparePoint(e){if(this.isAnEndpoint(e))return 0;const r=this.leftSE.point,i=this.rightSE.point,s=this.vector();if(r.x===i.x)return e.x===r.x?0:e.x<r.x?1:-1;const o=(e.y-r.y)/s.y,n=r.x+o*s.x;if(e.x===n)return 0;const a=(e.x-r.x)/s.x,l=r.y+a*s.y;return e.y===l?0:e.y<l?-1:1}getIntersection(e){const r=this.bbox(),i=e.bbox(),s=Nq(r,i);if(s===null)return null;const o=this.leftSE.point,n=this.rightSE.point,a=e.leftSE.point,l=e.rightSE.point,c=c3(r,a)&&this.comparePoint(a)===0,h=c3(i,o)&&e.comparePoint(o)===0,u=c3(r,l)&&this.comparePoint(l)===0,d=c3(i,n)&&e.comparePoint(n)===0;if(h&&c)return d&&!u?n:!d&&u?l:null;if(h)return u&&o.x===l.x&&o.y===l.y?null:o;if(c)return d&&n.x===a.x&&n.y===a.y?null:a;if(d&&u)return null;if(d)return n;if(u)return l;const f=XYt(o,this.vector(),a,e.vector());return f===null||!c3(s,f)?null:h3.round(f.x,f.y)}split(e){const r=[],i=e.events!==void 0,s=new Uf(e,!0),o=new Uf(e,!1),n=this.rightSE;this.replaceRightSE(o),r.push(o),r.push(s);const a=new gw(s,n,this.rings.slice(),this.windings.slice());return Uf.comparePoints(a.leftSE.point,a.rightSE.point)>0&&a.swapEvents(),Uf.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),i&&(s.checkForConsuming(),o.checkForConsuming()),r}swapEvents(){const e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let r=0,i=this.windings.length;r<i;r++)this.windings[r]*=-1}consume(e){let r=this,i=e;for(;r.consumedBy;)r=r.consumedBy;for(;i.consumedBy;)i=i.consumedBy;const s=gw.compare(r,i);if(s!==0){if(s>0){const o=r;r=i,i=o}if(r.prev===i){const o=r;r=i,i=o}for(let o=0,n=i.rings.length;o<n;o++){const a=i.rings[o],l=i.windings[o],c=r.rings.indexOf(a);c===-1?(r.rings.push(a),r.windings.push(l)):r.windings[c]+=l}i.rings=null,i.windings=null,i.consumedBy=r,i.leftSE.consumedBy=r.leftSE,i.rightSE.consumedBy=r.rightSE}}prevInResult(){return this._prevInResult!==void 0?this._prevInResult:(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null,this._prevInResult)}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{const e=this.prev.consumedBy||this.prev;this._beforeState=e.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;const e=this.beforeState();this._afterState={rings:e.rings.slice(0),windings:e.windings.slice(0),multiPolys:[]};const r=this._afterState.rings,i=this._afterState.windings,s=this._afterState.multiPolys;for(let a=0,l=this.rings.length;a<l;
7144a++){const c=this.rings[a],h=this.windings[a],u=r.indexOf(c);u===-1?(r.push(c),i.push(h)):i[u]+=h}const o=[],n=[];for(let a=0,l=r.length;a<l;a++){if(i[a]===0)continue;const c=r[a],h=c.poly;if(n.indexOf(h)===-1)if(c.isExterior)o.push(h);else{n.indexOf(h)===-1&&n.push(h);const u=o.indexOf(c.poly);u!==-1&&o.splice(u,1)}}for(let a=0,l=o.length;a<l;a++){const c=o[a].multiPoly;s.indexOf(c)===-1&&s.push(c)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;const e=this.beforeState().multiPolys,r=this.afterState().multiPolys;switch(Og.type){case"union":{const i=e.length===0,s=r.length===0;this._isInResult=i!==s;break}case"intersection":{let i,s;e.length<r.length?(i=e.length,s=r.length):(i=r.length,s=e.length),this._isInResult=s===Og.numMultiPolys&&i<s;break}case"xor":{const i=Math.abs(e.length-r.length);this._isInResult=i%2===1;break}case"difference":{const i=s=>s.length===1&&s[0].isSubject;this._isInResult=i(e)!==i(r);break}default:throw new Error(`Unrecognized operation type found ${Og.type}`)}return this._isInResult}}class Spt{constructor(e,r,i){if(!Array.isArray(e)||e.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=r,this.isExterior=i,this.segments=[],typeof e[0][0]!="number"||typeof e[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const s=h3.round(e[0][0],e[0][1]);this.bbox={ll:{x:s.x,y:s.y},ur:{x:s.x,y:s.y}};let o=s;for(let n=1,a=e.length;n<a;n++){if(typeof e[n][0]!="number"||typeof e[n][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let l=h3.round(e[n][0],e[n][1]);l.x===o.x&&l.y===o.y||(this.segments.push(gw.fromRing(o,l,this)),l.x<this.bbox.ll.x&&(this.bbox.ll.x=l.x),l.y<this.bbox.ll.y&&(this.bbox.ll.y=l.y),l.x>this.bbox.ur.x&&(this.bbox.ur.x=l.x),l.y>this.bbox.ur.y&&(this.bbox.ur.y=l.y),o=l)}(s.x!==o.x||s.y!==o.y)&&this.segments.push(gw.fromRing(o,s,this))}getSweepEvents(){const e=[];for(let r=0,i=this.segments.length;r<i;r++){const s=this.segments[r];e.push(s.leftSE),e.push(s.rightSE)}return e}}class VYt{constructor(e,r){if(!Array.isArray(e))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new Spt(e[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let i=1,s=e.length;i<s;i++){const o=new Spt(e[i],this,!1);o.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=o.bbox.ll.x),o.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=o.bbox.ll.y),o.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.interiorRings.push(o)}this.multiPoly=r}getSweepEvents(){const e=this.exteriorRing.getSweepEvents();for(let r=0,i=this.interiorRings.length;r<i;r++){const s=this.interiorRings[r].getSweepEvents();for(let o=0,n=s.length;o<n;o++)e.push(s[o])}return e}}class Tpt{constructor(e,r){if(!Array.isArray(e))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{typeof e[0][0][0]=="number"&&(e=[e])}catch{}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(let i=0,s=e.length;i<s;i++){const o=new VYt(e[i],this);o.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=o.bbox.ll.x),o.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=o.bbox.ll.y),o.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.polys.push(o)}this.isSubject=r}getSweepEvents(){const e=[];for(let r=0,i=this.polys.length;r<i;r++){const s=this.polys[r].getSweepEvents();for(let o=0,n=s.length;o<n;o++)e.push(s[o])}return e}}class Nj{static factory(e){const r=[];for(let i=0,s=e.length;i<s;i++){const o=e[i];if(!o.isInResult()||o.ringOut)continue;let n=null,a=o.leftSE,l=o.rightSE;const c=[a],h=a.point,u=[];for(;n=a,a=l,c.push(a),a.point!==h;)for(;;){const d=a.getAvailableLinkedEvents();if(d.length===0){const p=c[0].point,m=c[c.length-1].point;throw new Error(`Unable to complete output ring starting at [${p.x}, ${p.y}]. Last matching segment found ends at [${m.x}, ${m.y}].`)}if(d.length===1){l=d[0].otherSE;break}let f=null;for(let p=0,m=u.length;p<m;p++)if(u[p].point===a.point){f=p;break}if(f!==null){const p=u.splice(f)[0],m=c.splice(p.index);m.unshift(m[0].otherSE),r.push(new Nj(m.reverse()));continue}u.push({index:c.length,point:a.point});const g=a.getLeftmostComparator(n);l=d.sort(g)[0].otherSE;break}r.push(new Nj(c))}return r}constructor(e){this.events=e;for(let r=0,i=e.length;r<i;r++)e[r].segment.ringOut=this;this.poly=null}getGeom(){let e=this.events[0].point;const r=[e];for(let c=1,h=this.events.length-1;c<h;c++){const u=this.events[c].point,d=this.events[c+1].point;
7144Ept(u,e,d)!==0&&(r.push(u),e=u)}if(r.length===1)return null;const i=r[0],s=r[1];Ept(i,e,s)===0&&r.shift(),r.push(r[0]);const o=this.isExteriorRing()?1:-1,n=this.isExteriorRing()?0:r.length-1,a=this.isExteriorRing()?r.length:-1,l=[];for(let c=n;c!=a;c+=o)l.push([r[c].x,r[c].y]);return l}isExteriorRing(){if(this._isExteriorRing===void 0){const e=this.enclosingRing();this._isExteriorRing=e?!e.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let e=this.events[0];for(let s=1,o=this.events.length;s<o;s++){const n=this.events[s];Uf.compare(e,n)>0&&(e=n)}let r=e.segment.prevInResult(),i=r?r.prevInResult():null;for(;;){if(!r)return null;if(!i)return r.ringOut;if(i.ringOut!==r.ringOut)return i.ringOut.enclosingRing()!==r.ringOut?r.ringOut:r.ringOut.enclosingRing();r=i.prevInResult(),i=r?r.prevInResult():null}}}class Rpt{constructor(e){this.exteriorRing=e,e.poly=this,this.interiorRings=[]}addInterior(e){this.interiorRings.push(e),e.poly=this}getGeom(){const e=[this.exteriorRing.getGeom()];if(e[0]===null)return null;for(let r=0,i=this.interiorRings.length;r<i;r++){const s=this.interiorRings[r].getGeom();s!==null&&e.push(s)}return e}}class YYt{constructor(e){this.rings=e,this.polys=this._composePolys(e)}getGeom(){const e=[];for(let r=0,i=this.polys.length;r<i;r++){const s=this.polys[r].getGeom();s!==null&&e.push(s)}return e}_composePolys(e){const r=[];for(let i=0,s=e.length;i<s;i++){const o=e[i];if(!o.poly)if(o.isExteriorRing())r.push(new Rpt(o));else{const n=o.enclosingRing();n.poly||r.push(new Rpt(n)),n.poly.addInterior(o)}}return r}}class $Yt{constructor(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:gw.compare;this.queue=e,this.tree=new Oq(r),this.segments=[]}process(e){const r=e.segment,i=[];if(e.consumedBy)return e.isLeft?this.queue.remove(e.otherSE):this.tree.remove(r),i;const s=e.isLeft?this.tree.add(r):this.tree.find(r);if(!s)throw new Error(`Unable to find segment #${r.id} [${r.leftSE.point.x}, ${r.leftSE.point.y}] -> [${r.rightSE.point.x}, ${r.rightSE.point.y}] in SweepLine tree.`);let o=s,n=s,a,l;for(;a===void 0;)o=this.tree.prev(o),o===null?a=null:o.key.consumedBy===void 0&&(a=o.key);for(;l===void 0;)n=this.tree.next(n),n===null?l=null:n.key.consumedBy===void 0&&(l=n.key);if(e.isLeft){let c=null;if(a){const u=a.getIntersection(r);if(u!==null&&(r.isAnEndpoint(u)||(c=u),!a.isAnEndpoint(u))){const d=this._splitSafely(a,u);for(let f=0,g=d.length;f<g;f++)i.push(d[f])}}let h=null;if(l){const u=l.getIntersection(r);if(u!==null&&(r.isAnEndpoint(u)||(h=u),!l.isAnEndpoint(u))){const d=this._splitSafely(l,u);for(let f=0,g=d.length;f<g;f++)i.push(d[f])}}if(c!==null||h!==null){let u=null;c===null?u=h:h===null?u=c:u=Uf.comparePoints(c,h)<=0?c:h,this.queue.remove(r.rightSE),i.push(r.rightSE);const d=r.split(u);for(let f=0,g=d.length;f<g;f++)i.push(d[f])}i.length>0?(this.tree.remove(r),i.push(e)):(this.segments.push(r),r.prev=a)}else{if(a&&l){const c=a.getIntersection(l);if(c!==null){if(!a.isAnEndpoint(c)){const h=this._splitSafely(a,c);for(let u=0,d=h.length;u<d;u++)i.push(h[u])}if(!l.isAnEndpoint(c)){const h=this._splitSafely(l,c);for(let u=0,d=h.length;u<d;u++)i.push(h[u])}}}this.tree.remove(r)}return i}_splitSafely(e,r){this.tree.remove(e);const i=e.rightSE;this.queue.remove(i);const s=e.split(r);return s.push(i),e.consumedBy===void 0&&this.tree.add(e),s}}const Cpt=typeof process<"u"&&vpt.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,HYt=typeof process<"u"&&vpt.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6;class KYt{run(e,r,i){Og.type=e,h3.reset();const s=[new Tpt(r,!0)];for(let h=0,u=i.length;h<u;h++)s.push(new Tpt(i[h],!1));if(Og.numMultiPolys=s.length,Og.type==="difference"){const h=s[0];let u=1;for(;u<s.length;)Nq(s[u].bbox,h.bbox)!==null?u++:s.splice(u,1)}if(Og.type==="intersection")for(let h=0,u=s.length;h<u;h++){const d=s[h];for(let f=h+1,g=s.length;f<g;f++)if(Nq(d.bbox,s[f].bbox)===null)return[]}const o=new Oq(Uf.compare);for(let h=0,u=s.length;h<u;h++){const d=s[h].getSweepEvents();for(let f=0,g=d.length;f<g;f++)if(o.insert(d[f]),o.size>Cpt)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).")}const n=new $Yt(o);let a=o.size,l=o.pop();for(;l;){const h=l.key;if(o.size===a){const d=h.segment;
7144throw new Error(`Unable to pop() ${h.isLeft?"left":"right"} SweepEvent [${h.point.x}, ${h.point.y}] from segment #${d.id} [${d.leftSE.point.x}, ${d.leftSE.point.y}] -> [${d.rightSE.point.x}, ${d.rightSE.point.y}] from queue.`)}if(o.size>Cpt)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");if(n.segments.length>HYt)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");const u=n.process(h);for(let d=0,f=u.length;d<f;d++){const g=u[d];g.consumedBy===void 0&&o.insert(g)}a=o.size,l=o.pop()}h3.reset();const c=Nj.factory(n.segments);return new YYt(c).getGeom()}}const Og=new KYt;var qYt={union:function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return Og.run("union",t,r)},intersection:function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return Og.run("intersection",t,r)},xor:function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return Og.run("xor",t,r)},difference:function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return Og.run("difference",t,r)}};function ZYt(t,e){e[e.length]=t[0],e[e.length]=t[1]}function JYt(t){t!==Eo.primitiveType.GL_TRIANGLES&&console.log("expected TRIANGLES but got type: "+t)}function QYt(t){console.log("error callback"),console.log("error number: "+t)}function t$t(t,e,r){return[t[0],t[1],t[2]]}function e$t(t){}function kq(t,e){const r=new Eo.GluTesselator;r.gluTessProperty(Eo.gluEnum.GLU_TESS_WINDING_RULE,e==="evenodd"?Eo.windingRule.GLU_TESS_WINDING_ODD:Eo.windingRule.GLU_TESS_WINDING_NONZERO),r.gluTessCallback(Eo.gluEnum.GLU_TESS_VERTEX_DATA,ZYt),r.gluTessCallback(Eo.gluEnum.GLU_TESS_BEGIN,JYt),r.gluTessCallback(Eo.gluEnum.GLU_TESS_ERROR,QYt),r.gluTessCallback(Eo.gluEnum.GLU_TESS_COMBINE,t$t),r.gluTessCallback(Eo.gluEnum.GLU_TESS_EDGE_FLAG,e$t),r.gluTessNormal(0,0,1);const i=[];r.gluTessBeginPolygon(i);for(let s=0;s<t.length;s++){r.gluTessBeginContour();const o=t[s];for(let n=0;n<o.length;n++){const a=[o[n][0],o[n][1],0];r.gluTessVertex(a,a)}r.gluTessEndContour()}return r.gluTessEndPolygon(),i}const kj=(t,e)=>(t+e)/2;EV=function(t,e=!0){const r=t.length;if(r<4)return"";let i=t[0],s=t[1];const o=t[2];let n=`M${Zt(i[0])},${Zt(i[1])} Q${Zt(s[0])},${Zt(s[1])} ${Zt(kj(s[0],o[0]))},${Zt(kj(s[1],o[1]))} T`;for(let a=2,l=r-1;a<l;a++)i=t[a],s=t[a+1],n+=`${Zt(kj(i[0],s[0]))},${Zt(kj(i[1],s[1]))} `;return e&&(n+="Z"),n};function Mpt(t){const e=qYt.union([t]),r=[];return e.forEach(i=>i.forEach(s=>{r.push(EV(s,!1)||`M${Zt(s[0][0])},${Zt(s[0][1])} ${s.map(o=>`L${Zt(o[0])},${Zt(o[1])}`).join("")}`)})),r.join(" ")}function r$t(t){return/[\u{1F300}-\u{1F9FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]|[\u{1F100}-\u{1F1FF}]|[\u{1F200}-\u{1F2FF}]|[\u{1F600}-\u{1F64F}]|[\u{1F680}-\u{1F6FF}]|[\u{1F900}-\u{1F9FF}]|[\u{2B00}-\u{2BFF}]|[\u{2900}-\u{297F}]|[\u{2B00}-\u{2BFF}]|[\u{1F000}-\u{1F02F}]|[\u{1F0A0}-\u{1F0FF}]|[\u{1F100}-\u{1F64F}]|[\u{1F680}-\u{1F6FF}]|[\u{1F910}-\u{1F96B}]|[\u{1F980}-\u{1F9E0}]/u.test(t)}const Bpt={test(t){return typeof t=="string"&&t.startsWith("info face=")},parse(t){var e,r,i;const s=t.match(/^[a-z][a-zA-Z]*\s+.+$/gm),o={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const g in s){const p=s[g].match(/^[a-z][a-zA-Z]*/gm)[0],m=s[g].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),v={};for(const b in m){const y=m[b].split("="),_=y[0],w=y[1].replace(/"/gm,""),E=parseFloat(w),A=isNaN(E)?w:E;v[_]=A}o[p].push(v)}const n={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[a]=o.info,[l]=o.common,[c]=(e=o.distanceField)!==null&&e!==void 0?e:[];c&&(n.distanceField={range:parseInt(c.distanceRange,10),type:c.fieldType}),n.fontSize=parseInt(a.size,10),n.fontFamily=a.face,n.lineHeight=parseInt(l.lineHeight,10);const h=o.page;for(let g=0;g<h.length;g++)n.pages.push({id:parseInt(h[g].id,10)||0,file:h[g].file});const u={};n.baseLineOffset=n.lineHeight-parseInt(l.base,10);const d=o.char;for(let g=0;g<d.length;g++){const p=d[g],m=parseInt(p.id,10);let v=(i=(r=p.letter)!==null&&r!==void 0?r:p.char)!==null&&i!==void 0?i:String.fromCharCode(m);v==="space"&&(v=" "),u[m]=v,n.chars[v]={id:m,page:parseInt(p.page,10)||0,x:parseInt(p.x,10),y:parseInt(p.y,10),width:parseInt(p.width,10),height:parseInt(p.height,10),xOffset:parseInt(p.xoffset,10),yOffset:parseInt(p.yoffset,10),xAdvance:parseInt(p.xadvance,10),kerning:{}}}const f=o.kerning||[];for(let g=0;g<f.length;g++){const p=parseInt(f[g].first,10),m=parseInt(f[g].second,10),v=parseInt(f[g].amount,10);n.chars[u[m]].kerning[u[p]]=v}return n}};class i$t extends Uo{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}destroy(e=!1){var r;
7144this.emit("destroy",this),this.removeAllListeners();for(const i in this.chars)(r=this.chars[i].texture)===null||r===void 0||r.destroy();this.chars=null,e&&(this.pages.forEach(i=>i.texture.destroy()),this.pages=null)}}class s$t extends i$t{constructor(e){var r;super(),this.options=e;const{data:i}=this.options;Object.keys(i.chars).forEach(s=>{var o;const n=i.chars[s],a={x:n.x,y:n.y,w:n.width,h:n.height};this.chars[s]={id:s.codePointAt(0),xOffset:n.xOffset,yOffset:n.yOffset,xAdvance:n.xAdvance,kerning:(o=n.kerning)!==null&&o!==void 0?o:{},rect:a}}),this.baseRenderedFontSize=i.fontSize,this.baseMeasurementFontSize=i.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:i.fontSize},this.baseLineOffset=i.baseLineOffset,this.lineHeight=i.lineHeight,this.fontFamily=i.fontFamily,this.distanceField=(r=i.distanceField)!==null&&r!==void 0?r:{type:"none",range:0}}createTexture(e){const{images:r,data:i}=this.options,s=r.map(o=>{const n=e.createTexture({format:X.U8_RGBA_NORM,width:o.width,height:o.height,usage:vi.SAMPLED});return n.setImageData([o]),{texture:n,width:o.width,height:o.height}});Object.keys(i.pages).forEach(o=>{const n=i.pages[parseInt(o,10)],{texture:a,width:l,height:c}=s[n.id];this.pages.push({texture:a,width:l,height:c})}),Object.keys(i.chars).forEach(o=>{const n=i.chars[o],{texture:a}=s[n.page];this.chars[o].texture=a})}destroy(){super.destroy();for(let e=0;e<this.pages.length;e++){const{texture:r}=this.pages[e];r.destroy()}this.pages=null}}const o$t={createCanvas:(t,e)=>new OffscreenCanvas(t??0,e??0),createTexImageSource:t=>t,createImage:t=>nj(t),getWindow:()=>self,getDocument:()=>null,getXMLSerializer:()=>null,getDOMParser:()=>null,splitGraphemes:t=>typeof(Intl==null?void 0:Intl.Segmenter)=="function"?[...new Intl.Segmenter().segment(t)].map(e=>e.segment):[...t],requestAnimationFrame:t=>requestAnimationFrame(t),cancelAnimationFrame:t=>cancelAnimationFrame(t)},Opt={test(t){const e=t;return!!(typeof e!="string"&&"getElementsByTagName"in e&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null)},parse(t){var e,r;const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},s=t.getElementsByTagName("info")[0],o=t.getElementsByTagName("common")[0],n=t.getElementsByTagName("distanceField")[0];n&&(i.distanceField={type:n.getAttribute("fieldType"),range:parseInt(n.getAttribute("distanceRange"),10)});const a=t.getElementsByTagName("page"),l=t.getElementsByTagName("char"),c=t.getElementsByTagName("kerning");i.fontSize=parseInt(s.getAttribute("size"),10),i.fontFamily=s.getAttribute("face"),i.lineHeight=parseInt(o.getAttribute("lineHeight"),10);for(let u=0;u<a.length;u++)i.pages.push({id:parseInt(a[u].getAttribute("id"),10)||0,file:a[u].getAttribute("file")});const h={};i.baseLineOffset=i.lineHeight-parseInt(o.getAttribute("base"),10);for(let u=0;u<l.length;u++){const d=l[u],f=parseInt(d.getAttribute("id"),10);let g=(r=(e=d.getAttribute("letter"))!==null&&e!==void 0?e:d.getAttribute("char"))!==null&&r!==void 0?r:String.fromCharCode(f);g==="space"&&(g=" "),h[f]=g,i.chars[g]={id:f,page:parseInt(d.getAttribute("page"),10)||0,x:parseInt(d.getAttribute("x"),10),y:parseInt(d.getAttribute("y"),10),width:parseInt(d.getAttribute("width"),10),height:parseInt(d.getAttribute("height"),10),xOffset:parseInt(d.getAttribute("xoffset"),10),yOffset:parseInt(d.getAttribute("yoffset"),10),xAdvance:parseInt(d.getAttribute("xadvance"),10),kerning:{}}}for(let u=0;u<c.length;u++){const d=parseInt(c[u].getAttribute("first"),10),f=parseInt(c[u].getAttribute("second"),10),g=parseInt(c[u].getAttribute("amount"),10);i.chars[h[f]].kerning[h[d]]=g}return i}},n$t={test(t){var e;return typeof t=="string"&&t.includes("<font>")?Opt.test((e=Pr.get().getDOMParser())===null||e===void 0?void 0:e.parseFromString(t,"text/xml")):!1},parse(t){var e;return Opt.parse((e=Pr.get().getDOMParser())===null||e===void 0?void 0:e.parseFromString(t,"text/xml"))}},Ipt={test(t){try{return JSON.parse(t),!0}catch{return!1}},parse(t){var e,r,i,s;const o={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},n=JSON.parse(t),a=n.info,l=n.common,c=n.distanceField;c&&(o.distanceField={type:c.fieldType,range:c.distanceRange});const h=n.pages,u=n.chars,d=n.kernings;o.fontSize=a.size,o.fontFamily=a.face,o.lineHeight=l.lineHeight;for(let g=0;g<h.length;g++)o.pages.push({id:((e=h[g])===null||e===void 0?void 0:e.id)||0,file:((r=h[g])===null||r===void 0?void 0:r.file)||h[g]});const f={};o.baseLineOffset=o.lineHeight-l.base;for(let g=0;g<u.length;g++){const p=u[g],m=p.id;let v=(s=(i=p.letter)!==null&&i!==void 0?i:p.char)!==null&&s!==void 0?s:String.fromCharCode(m);v==="space"&&(v=" "),f[m]=v,o.chars[v]={id:m,page:p.page||0,x:p.x,y:p.y,width:p.width,height:p.height,xOffset:p.xoffset,yOffset:p.yoffset,xAdvance:p.xadvance,kerning:{}}}for(let g=0;g<d.length;g++){const p=d[g],m=p.first,v=p.second,b=p.amount,y=f[v],_=f[m],w=y!=null?o.chars[y]:void 0;w!=null&&_!=null&&(w.kerning[_]=b)}return o}};var Dpt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};const a$t=["xml","fnt"],l$t={test(t){return a$t.includes(t.split(".").pop().toLowerCase())},parse(t){return Dpt(this,void 0,void 0,function*(){const e=Ipt.test(t)?Ipt.parse(t):Bpt.test(t)?Bpt.parse(t):n$t.parse(t),{pages:r}=e,i=[],s=e.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let n=0;n<r.length;++n){const a=r[n].file;i.push({src:a,data:s})}const o=yield Promise.all(i.map(n=>Dpt(this,[n],void 0,function*({src:a}){return yield Pr.get().createImage(a)})));return new s$t({data:e,images:o})})}};function c$t(t,{width:e,height:r},i,s){if(!s)s=new Uint8Array(e*r*i);else if(s.length!==e*r*i)throw new RangeError("mismatched image size");return t.width=e,t.height=r,t.data=s,t}function h$t(t,e,r,i,s,o){if(s.width===0||s.height===0)return e;if(s.width>t.width||s.height>t.height||r.x>t.width-s.width||r.y>t.height-s.height)throw new RangeError("out of range source coordinates for image copy");if(s.width>e.width||s.height>e.height||i.x>e.width-s.width||i.y>e.height-s.height)throw new RangeError("out of range destination coordinates for image copy");const n=t.data,a=e.data;for(let l=0;l<s.height;l++){const c=((r.y+l)*t.width+r.x)*o,h=((i.y+l)*e.width+i.x)*o;for(let u=0;u<s.width*o;u++)a[h+u]=n[c+u]}return e}class Lq{constructor(e,r){c$t(this,e,4,r)}static copy(e,r,i,s,o){h$t(e,r,i,s,o,4)}}const Fd=4,Ppt=24*Fd,Fpt=3*Fd,u$t=8*Fd,Npt=1,Lj=Npt*Fd;class d$t{constructor(e){const r={},i=[];for(const a in e){const l=e[a],c=r[a]={};for(const h in l){const u=l[h];if(!u||u.bitmap.width===0||u.bitmap.height===0)continue;const d={x:0,y:0,w:u.bitmap.width+2*Lj,h:u.bitmap.height+2*Lj};i.push(d),c[h]={rect:d,metrics:u.metrics}}}const{w:s,h:o}=PV(i),n=new Lq({width:s||1,height:o||1});for(const a in e){const l=e[a];for(const c in l){const h=l[c];if(!h||h.bitmap.width===0||h.bitmap.height===0)continue;const u=r[a][c].rect;Lq.copy(h.bitmap,n,{x:0,y:0},{x:u.x+Lj,y:u.y+Lj},h.bitmap)}}this.image=n,this.positions=r}}const f$t=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","BN","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],kpt
vendor: 13,531 bytes, line 7144
7144=[[697,698,"ON"],[706,719,"ON"],[722,735,"ON"],[741,749,"ON"],[751,767,"ON"],[768,879,"NSM"],[884,885,"ON"],[894,894,"ON"],[900,901,"ON"],[903,903,"ON"],[1014,1014,"ON"],[1155,1161,"NSM"],[1418,1418,"ON"],[1421,1422,"ON"],[1423,1423,"ET"],[1424,1424,"R"],[1425,1469,"NSM"],[1470,1470,"R"],[1471,1471,"NSM"],[1472,1472,"R"],[1473,1474,"NSM"],[1475,1475,"R"],[1476,1477,"NSM"],[1478,1478,"R"],[1479,1479,"NSM"],[1480,1535,"R"],[1536,1541,"AN"],[1542,1543,"ON"],[1544,1544,"AL"],[1545,1546,"ET"],[1547,1547,"AL"],[1548,1548,"CS"],[1549,1549,"AL"],[1550,1551,"ON"],[1552,1562,"NSM"],[1563,1610,"AL"],[1611,1631,"NSM"],[1632,1641,"AN"],[1642,1642,"ET"],[1643,1644,"AN"],[1645,1647,"AL"],[1648,1648,"NSM"],[1649,1749,"AL"],[1750,1756,"NSM"],[1757,1757,"AN"],[1758,1758,"ON"],[1759,1764,"NSM"],[1765,1766,"AL"],[1767,1768,"NSM"],[1769,1769,"ON"],[1770,1773,"NSM"],[1774,1775,"AL"],[1776,1785,"EN"],[1786,1808,"AL"],[1809,1809,"NSM"],[1810,1839,"AL"],[1840,1866,"NSM"],[1867,1957,"AL"],[1958,1968,"NSM"],[1969,1983,"AL"],[1984,2026,"R"],[2027,2035,"NSM"],[2036,2037,"R"],[2038,2041,"ON"],[2042,2044,"R"],[2045,2045,"NSM"],[2046,2069,"R"],[2070,2073,"NSM"],[2074,2074,"R"],[2075,2083,"NSM"],[2084,2084,"R"],[2085,2087,"NSM"],[2088,2088,"R"],[2089,2093,"NSM"],[2094,2136,"R"],[2137,2139,"NSM"],[2140,2143,"R"],[2144,2191,"AL"],[2192,2193,"AN"],[2194,2198,"AL"],[2199,2207,"NSM"],[2208,2249,"AL"],[2250,2273,"NSM"],[2274,2274,"AN"],[2275,2306,"NSM"],[2362,2362,"NSM"],[2364,2364,"NSM"],[2369,2376,"NSM"],[2381,2381,"NSM"],[2385,2391,"NSM"],[2402,2403,"NSM"],[2433,2433,"NSM"],[2492,2492,"NSM"],[2497,2500,"NSM"],[2509,2509,"NSM"],[2530,2531,"NSM"],[2546,2547,"ET"],[2555,2555,"ET"],[2558,2558,"NSM"],[2561,2562,"NSM"],[2620,2620,"NSM"],[2625,2626,"NSM"],[2631,2632,"NSM"],[2635,2637,"NSM"],[2641,2641,"NSM"],[2672,2673,"NSM"],[2677,2677,"NSM"],[2689,2690,"NSM"],[2748,2748,"NSM"],[2753,2757,"NSM"],[2759,2760,"NSM"],[2765,2765,"NSM"],[2786,2787,"NSM"],[2801,2801,"ET"],[2810,2815,"NSM"],[2817,2817,"NSM"],[2876,2876,"NSM"],[2879,2879,"NSM"],[2881,2884,"NSM"],[2893,2893,"NSM"],[2901,2902,"NSM"],[2914,2915,"NSM"],[2946,2946,"NSM"],[3008,3008,"NSM"],[3021,3021,"NSM"],[3059,3064,"ON"],[3065,3065,"ET"],[3066,3066,"ON"],[3072,3072,"NSM"],[3076,3076,"NSM"],[3132,3132,"NSM"],[3134,3136,"NSM"],[3142,3144,"NSM"],[3146,3149,"NSM"],[3157,3158,"NSM"],[3170,3171,"NSM"],[3192,3198,"ON"],[3201,3201,"NSM"],[3260,3260,"NSM"],[3276,3277,"NSM"],[3298,3299,"NSM"],[3328,3329,"NSM"],[3387,3388,"NSM"],[3393,3396,"NSM"],[3405,3405,"NSM"],[3426,3427,"NSM"],[3457,3457,"NSM"],[3530,3530,"NSM"],[3538,3540,"NSM"],[3542,3542,"NSM"],[3633,3633,"NSM"],[3636,3642,"NSM"],[3647,3647,"ET"],[3655,3662,"NSM"],[3761,3761,"NSM"],[3764,3772,"NSM"],[3784,3790,"NSM"],[3864,3865,"NSM"],[3893,3893,"NSM"],[3895,3895,"NSM"],[3897,3897,"NSM"],[3898,3901,"ON"],[3953,3966,"NSM"],[3968,3972,"NSM"],[3974,3975,"NSM"],[3981,3991,"NSM"],[3993,4028,"NSM"],[4038,4038,"NSM"],[4141,4144,"NSM"],[4146,4151,"NSM"],[4153,4154,"NSM"],[4157,4158,"NSM"],[4184,4185,"NSM"],[4190,4192,"NSM"],[4209,4212,"NSM"],[4226,4226,"NSM"],[4229,4230,"NSM"],[4237,4237,"NSM"],[4253,4253,"NSM"],[4957,4959,"NSM"],[5008,5017,"ON"],[5120,5120,"ON"],[5760,5760,"WS"],[5787,5788,"ON"],[5906,5908,"NSM"],[5938,5939,"NSM"],[5970,5971,"NSM"],[6002,6003,"NSM"],[6068,6069,"NSM"],[6071,6077,"NSM"],[6086,6086,"NSM"],[6089,6099,"NSM"],[6107,6107,"ET"],[6109,6109,"NSM"],[6128,6137,"ON"],[6144,6154,"ON"],[6155,6157,"NSM"],[6158,6158,"BN"],[6159,6159,"NSM"],[6277,6278,"NSM"],[6313,6313,"NSM"],[6432,6434,"NSM"],[6439,6440,"NSM"],[6450,6450,"NSM"],[6457,6459,"NSM"],[6464,6464,"ON"],[6468,6469,"ON"],[6622,6655,"ON"],[6679,6680,"NSM"],[6683,6683,"NSM"],[6742,6742,"NSM"],[6744,6750,"NSM"],[6752,6752,"NSM"],[6754,6754,"NSM"],[6757,6764,"NSM"],[6771,6780,"NSM"],[6783,6783,"NSM"],[6832,6877,"NSM"],[6880,6891,"NSM"],[6912,6915,"NSM"],[6964,6964,"NSM"],[6966,6970,"NSM"],[6972,6972,"NSM"],[6978,6978,"NSM"],[7019,7027,"NSM"],[7040,7041,"NSM"],[7074,7077,"NSM"],[7080,7081,"NSM"],[7083,7085,"NSM"],[7142,7142,"NSM"],[7144,7145,"NSM"],[7149,7149,"NSM"],[7151,7153,"NSM"],[7212,7219,"NSM"],[7222,7223,"NSM"],[7376,7378,"NSM"],[7380,7392,"NSM"],[7394,7400,"NSM"],[7405,7405,"NSM"],[7412,7412,"NSM"],[7416,7417,"NSM"],[7616,7679,"NSM"],[8125,8125,"ON"],[8127,8129,"ON"],[8141,8143,"ON"],[8157,8159,"ON"],[8173,8175,"ON"],[8189,8190,"ON"],[8192,8202,"WS"],[8203,8205,"BN"],[8207,8207,"R"],[8208,8231,"ON"],[8232,8232,"WS"],[8233,8233,"B"],[8234,8238,"BN"],[8239,8239,"CS"],[8240,8244,"ET"],[8245,8259,"ON"],[8260,8260,"CS"],[8261,8286,"ON"],[8287,8287,"WS"],[8288,8303,"BN"],[8304,8304,"EN"],[8308,8313,"EN"],[8314,8315,"ES"],[8316,8318,"ON"],[8320,8329,"EN"],[8330,8331,"ES"],[8332,8334,"ON"],[8352,8399,"ET"],[8400,8432,"NSM"],[8448,8449,"ON"],[8451,8454,"ON"],[8456,8457,"ON"],[8468,8468,"ON"],[8470,8472,"ON"],[8478,8483,"ON"],[8485,8485,"ON"],[8487,8487,"ON"],[8489,8489,"ON"],[8494,8494,"ET"],[8506,8507,"ON"],[8512,8516,"ON"],[8522,8525,"ON"],[8528,8543,"ON"],[8585,8587,"ON"],[8592,8721,"ON"],[8722,8722,"ES"],[8723,8723,"ET"],[8724,9013,"ON"],[9083,9108,"ON"],[9110,9257,"ON"],[9280,9290,"ON"],[9312,9351,"ON"],[9352,9371,"EN"],[9450,9899,"ON"],[9901,10239,"ON"],[10496,11123,"ON"],[11126,11263,"ON"],[11493,11498,"ON"],[11503,11505,"NSM"],[11513,11519,"ON"],[11647,11647,"NSM"],[11744,11775,"NSM"],[11776,11869,"ON"],[11904,11929,"ON"],[11931,12019,"ON"],[12032,12245,"ON"],[12272,12287,"ON"],[12288,12288,"WS"],[12289,12292,"ON"],[12296,12320,"ON"],[12330,12333,"NSM"],[12336,12336,"ON"],[12342,12343,"ON"],[12349,12351,"ON"],[12441,12442,"NSM"],[12443,12444,"ON"],[12448,12448,"ON"],[12539,12539,"ON"],[12736,12773,"ON"],[12783,12783,"ON"],[12829,12830,"ON"],[12880,12895,"ON"],[12924,12926,"ON"],[12977,12991,"ON"],[13004,13007,"ON"],[13175,13178,"ON"],[13278,13279,"ON"],[13311,13311,"ON"],[19904,19967,"ON"],[42128,42182,"ON"],[42509,42511,"ON"],[42607,42610,"NSM"],[42611,42611,"ON"],[42612,42621,"NSM"],[42622,42623,"ON"],[42654,42655,"NSM"],[42736,42737,"NSM"],[42752,42785,"ON"],[42888,42888,"ON"],[43010,43010,"NSM"],[43014,43014,"NSM"],[43019,43019,"NSM"],[43045,43046,"NSM"],[43048,43051,"ON"],[43052,43052,"NSM"],[43064,43065,"ET"],[43124,43127,"ON"],[43204,43205,"NSM"],[43232,43249,"NSM"],[43263,43263,"NSM"],[43302,43309,"NSM"],[43335,43345,"NSM"],[43392,43394,"NSM"],[43443,43443,"NSM"],[43446,43449,"NSM"],[43452,43453,"NSM"],[43493,43493,"NSM"],[43561,43566,"NSM"],[43569,43570,"NSM"],[43573,43574,"NSM"],[43587,43587,"NSM"],[43596,43596,"NSM"],[43644,43644,"NSM"],[43696,43696,"NSM"],[43698,43700,"NSM"],[43703,43704,"NSM"],[43710,43711,"NSM"],[43713,43713,"NSM"],[43756,43757,"NSM"],[43766,43766,"NSM"],[43882,43883,"ON"],[44005,44005,"NSM"],[44008,44008,"NSM"],[44013,44013,"NSM"],[64285,64285,"R"],[64286,64286,"NSM"],[64287,64296,"R"],[64297,64297,"ES"],[64298,64335,"R"],[64336,64450,"AL"],[64451,64466,"ON"],[64467,64829,"AL"],[64830,64847,"ON"],[64848,64911,"AL"],[64912,64913,"ON"],[64914,64967,"AL"],[64968,64975,"ON"],[64976,65007,"BN"],[65008,65020,"AL"],[65021,65023,"ON"],[65024,65039,"NSM"],[65040,65049,"ON"],[65056,65071,"NSM"],[65072,65103,"ON"],[65104,65104,"CS"],[65105,65105,"ON"],[65106,65106,"CS"],[65108,65108,"ON"],[65109,65109,"CS"],[65110,65118,"ON"],[65119,65119,"ET"],[65120,65121,"ON"],[65122,65123,"ES"],[65124,65126,"ON"],[65128,65128,"ON"],[65129,65130,"ET"],[65131,65131,"ON"],[65136,65278,"AL"],[65279,65279,"BN"],[65281,65282,"ON"],[65283,65285,"ET"],[65286,65290,"ON"],[65291,65291,"ES"],[65292,65292,"CS"],[65293,65293,"ES"],[65294,65295,"CS"],[65296,65305,"EN"],[65306,65306,"CS"],[65307,65312,"ON"],[65339,65344,"ON"],[65371,65381,"ON"],[65504,65505,"ET"],[65506,65508,"ON"],[65509,65510,"ET"],[65512,65518,"ON"],[65520,65528,"BN"],[65529,65533,"ON"],[65534,65535,"BN"],[65793,65793,"ON"],[65856,65932,"ON"],[65936,65948,"ON"],[65952,65952,"ON"],[66045,66045,"NSM"],[66272,66272,"NSM"],[66273,66299,"EN"],[66422,66426,"NSM"],[67584,67870,"R"],[67871,67871,"ON"],[67872,68096,"R"],[68097,68099,"NSM"],[68100,68100,"R"],[68101,68102,"NSM"],[68103,68107,"R"],[68108,68111,"NSM"],[68112,68151,"R"],[68152,68154,"NSM"],[68155,68158,"R"],[68159,68159,"NSM"],[68160,68324,"R"],[68325,68326,"NSM"],[68327,68408,"R"],[68409,68415,"ON"],[68416,68863,"R"],[68864,68899,"AL"],[68900,68903,"NSM"],[68904,68911,"AL"],[68912,68921,"AN"],[68922,68927,"AL"],[68928,68937,"AN"],[68938,68968,"R"],[68969,68973,"NSM"],[68974,68974,"ON"],[68975,69215,"R"],[69216,69246,"AN"],[69247,69290,"R"],[69291,69292,"NSM"],[69293,69311,"R"],[69312,69327,"AL"],[69328,69336,"ON"],[69337,69369,"AL"],[69370,69375,"NSM"],[69376,69423,"R"],[69424,69445,"AL"],[69446,69456,"NSM"],[69457,69487,"AL"],[69488,69505,"R"],[69506,69509,"NSM"],[69510,69631,"R"],[69633,69633,"NSM"],[69688,69702,"NSM"],[69714,69733,"ON"],[69744,69744,"NSM"],[69747,69748,"NSM"],[69759,69761,"NSM"],[69811,69814,"NSM"],[69817,69818,"NSM"],[69826,69826,"NSM"],[69888,69890,"NSM"],[69927,69931,"NSM"],[69933,69940,"NSM"],[70003,70003,"NSM"],[70016,70017,"NSM"],[70070,70078,"NSM"],[70089,70092,"NSM"],[70095,70095,"NSM"],[70191,70193,"NSM"],[70196,70196,"NSM"],[70198,70199,"NSM"],[70206,70206,"NSM"],[70209,70209,"NSM"],[70367,70367,"NSM"],[70371,70378,"NSM"],[70400,70401,"NSM"],[70459,70460,"NSM"],[70464,70464,"NSM"],[70502,70508,"NSM"],[70512,70516,"NSM"],[70587,70592,"NSM"],[70606,70606,"NSM"],[70608,70608,"NSM"],[70610,70610,"NSM"],[70625,70626,"NSM"],[70712,70719,"NSM"],[70722,70724,"NSM"],[70726,70726,"NSM"],[70750,70750,"NSM"],[70835,70840,"NSM"],[70842,70842,"NSM"],[70847,70848,"NSM"],[70850,70851,"NSM"],[71090,71093,"NSM"],[71100,71101,"NSM"],[71103,71104,"NSM"],[71132,71133,"NSM"],[71219,71226,"NSM"],[71229,71229,"NSM"],[71231,71232,"NSM"],[71264,71276,"ON"],[71339,71339,"NSM"],[71341,71341,"NSM"],[71344,71349,"NSM"],[71351,71351,"NSM"],[71453,71453,"NSM"],[71455,71455,"NSM"],[71458,71461,"NSM"],[71463,71467,"NSM"],[71727,71735,"NSM"],[71737,71738,"NSM"],[71995,71996,"NSM"],[71998,71998,"NSM"],[72003,72003,"NSM"],[72148,72151,"NSM"],[72154,72155,"NSM"],[72160,72160,"NSM"],[72193,72198,"NSM"],[72201,72202,"NSM"],[72243,72248,"NSM"],[72251,72254,"NSM"],[72263,72263,"NSM"],[72273,72278,"NSM"],[72281,72283,"NSM"],[72330,72342,"NSM"],[72344,72345,"NSM"],[72544,72544,"NSM"],[72546,72548,"NSM"],[72550,72550,"NSM"],[72752,72758,"NSM"],[72760,72765,"NSM"],[72850,72871,"NSM"],[72874,72880,"NSM"],[72882,72883,"NSM"],[72885,72886,"NSM"],[73009,73014,"NSM"],[73018,73018,"NSM"],[73020,73021,"NSM"],[73023,73029,"NSM"],[73031,73031,"NSM"],[73104,73105,"NSM"],[73109,73109,"NSM"],[73111,73111,"NSM"],[73459,73460,"NSM"],[73472,73473,"NSM"],[73526,73530,"NSM"],[73536,73536,"NSM"],[73538,73538,"NSM"],[73562,73562,"NSM"],[73685,73692,"ON"],[73693,73696,"ET"],[73697,73713,"ON"],[78912,78912,"NSM"],[78919,78933,"NSM"],[90398,90409,"NSM"],[90413,90415,"NSM"],[92912,92916,"NSM"],[92976,92982,"NSM"],[94031,94031,"NSM"],[94095,94098,"NSM"],[94178,94178,"ON"],[94180,94180,"NSM"],[113821,113822,"NSM"],[113824,113827,"BN"],[117760,117973,"ON"],[118e3,118009,"EN"],[118010,118012,"ON"],[118016,118451,"ON"],[118458,118480,"ON"],[118496,118512,"ON"],[118528,118573,"NSM"],[118576,118598,"NSM"],[119143,119145,"NSM"],[119155,119162,"BN"],[119163,119170,"NSM"],[119173,119179,"NSM"],[119210,119213,"NSM"],[119273,119274,"ON"],[119296,119361,"ON"],[119362,119364,"NSM"],[119365,119365,"ON"],[119552,119638,"ON"],[120513,120513,"ON"],[120539,120539,"ON"],[120571,120571,"ON"],[120597,120597,"ON"],[120629,120629,"ON"],[120655,120655,"ON"],[120687,120687,"ON"],[120713,120713,"ON"],[120745,120745,"ON"],[120771,120771,"ON"],[120782,120831,"EN"],[121344,121398,"NSM"],[121403,121452,"NSM"],[121461,121461,"NSM"],[121476,121476,"NSM"],[121499,121503,"NSM"],[121505,121519,"NSM"],[122880,122886,"NSM"],[122888,122904,"NSM"],[122907,122913,"NSM"],[122915,122916,"NSM"],[122918,122922,"NSM"],[123023,123023,"NSM"],[123184,123190,"NSM"],[123566,123566,"NSM"],[123628,123631,"NSM"],[123647,123647,"ET"],[124140,124143,"NSM"],[124398,124399,"NSM"],[124643,124643,"NSM"],[124646,124646,"NSM"],[124654,124655,"NSM"],[124661,124661,"NSM"],[124928,125135,"R"],[125136,125142,"NSM"],[125143,125251,"R"],[125252,125258,"NSM"],[125259,126063,"R"],[126064,126143,"AL"],[126144,126207,"R"],[126208,126287,"AL"],[126288,126463,"R"],[126464,126703,"AL"],[126704,126705,"ON"],[126706,126719,"AL"],[126720,126975,"R"],[126976,127019,"ON"],[127024,127123,"ON"],[127136,127150,"ON"],[127153,127167,"ON"],[127169,127183,"ON"],[127185,127221,"ON"],[127232,127242,"EN"],[127243,127247,"ON"],[127279,127279,"ON"],[127338,127343,"ON"],[127405,127405,"ON"],[127584,127589,"ON"],[127744,128728,"ON"],[128732,128748,"ON"],[128752,128764,"ON"],[128768,128985,"ON"],[128992,129003,"ON"],[129008,129008,"ON"],[129024,129035,"ON"],[129040,129095,"ON"],[129104,129113,"ON"],[129120,129159,"ON"],[129168,129197,"ON"],[129200,129211,"ON"],[129216,129217,"ON"],[129232,129240,"ON"],[129280,129623,"ON"],[129632,129645,"ON"],[129648,129660,"ON"],[129664,129674,"ON"],[129678,129734,"ON"],[129736,129736,"ON"],[129741,129756,"ON"],[129759,129770,"ON"],[129775,129784,"ON"],[129792,129938,"ON"],[129940,130031,"ON"],[130032,130041,"EN"],[130042,130042,"ON"],[131070,131071,"BN"],[196606,196607,"BN"],[262142,262143,"BN"],[327678,327679,"BN"],[393214,393215,"BN"],[458750,458751,"BN"],[524286,524287,"BN"],[589822,589823,"BN"],[655358,655359,"BN"],[720894,720895,"BN"],[786430,786431,"BN"],[851966,851967,"BN"],[917502,917759,"BN"],[917760,917999,"NSM"],[918e3,921599,"BN"],[983038,983039,"BN"],[1048574,1048575,"BN"],[1114110,1114111,"BN"]];function
7144p$t(t){if(t<=255)return f$t[t];let e=0,r=kpt.length-1;for(;e<=r;){const i=e+r>>1,s=kpt[i];if(t<s[0]){r=i-1;continue}if(t>s[1]){e=i+1;continue}return s[2]}return"L"}function g$t(t){const e=t.length;if(e===0)return null;const r=new Array(e);let i=!1;for(let c=0;c<e;){const h=t.charCodeAt(c);let u=h,d=1;if(h>=55296&&h<=56319&&c+1<e){const g=t.charCodeAt(c+1);g>=56320&&g<=57343&&(u=(h-55296<<10)+(g-56320)+65536,d=2)}const f=p$t(u);(f==="R"||f==="AL"||f==="AN")&&(i=!0);for(let g=0;g<d;g++)r[c+g]=f;c+=d}if(!i)return null;let s=0;for(let c=0;c<e;c++){const h=r[c];if(h==="L"){s=0;break}if(h==="R"||h==="AL"){s=1;break}}const o=new Int8Array(e);for(let c=0;c<e;c++)o[c]=s;const n=s&1?"R":"L",a=n;let l=a;for(let c=0;c<e;c++)r[c]==="NSM"?r[c]=l:l=r[c];l=a;for(let c=0;c<e;c++){const h=r[c];h==="EN"?r[c]=l==="AL"?"AN":"EN":(h==="R"||h==="L"||h==="AL")&&(l=h)}for(let c=0;c<e;c++)r[c]==="AL"&&(r[c]="R");for(let c=1;c<e-1;c++)r[c]==="ES"&&r[c-1]==="EN"&&r[c+1]==="EN"&&(r[c]="EN"),r[c]==="CS"&&(r[c-1]==="EN"||r[c-1]==="AN")&&r[c+1]===r[c-1]&&(r[c]=r[c-1]);for(let c=0;c<e;c++){if(r[c]!=="EN")continue;let h;for(h=c-1;h>=0&&r[h]==="ET";h--)r[h]="EN";for(h=c+1;h<e&&r[h]==="ET";h++)r[h]="EN"}for(let c=0;c<e;c++){const h=r[c];(h==="WS"||h==="ES"||h==="ET"||h==="CS")&&(r[c]="ON")}l=a;for(let c=0;c<e;c++){const h=r[c];h==="EN"?r[c]=l==="L"?"L":"EN":(h==="R"||h==="L")&&(l=h)}for(let c=0;c<e;c++){if(r[c]!=="ON")continue;let h=c+1;for(;h<e&&r[h]==="ON";)h++;const u=c>0?r[c-1]:a,d=h<e?r[h]:a,f=u!=="L"?"R":"L";if(f===(d!=="L"?"R":"L"))for(let g=c;g<h;g++)r[g]=f;c=h-1}for(let c=0;c<e;c++)r[c]==="ON"&&(r[c]=n);for(let c=0;c<e;c++){const h=r[c];(o[c]&1)===0?h==="R"?o[c]++:(h==="AN"||h==="EN")&&(o[c]+=2):(h==="L"||h==="AN"||h==="EN")&&o[c]++}return o}function m$t(t,e){const r=g$t(t);if(r===null)return null;const i=new Int8Array(e.length);for(let s=0;s<e.length;s++)i[s]=r[e[s]];return i}const y$t=/[ \t\n\r\f]+/g,v$t=/[\t\n\r\f]| {2,}|^ | $/;function _$t(t){const e=t??"normal";return e==="pre-wrap"?{mode:e,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:e,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function b$t(t){if(!v$t.test(t))return t;let e=t.replace(y$t," ");return e.charCodeAt(0)===32&&(e=e.slice(1)),e.length>0&&e.charCodeAt(e.length-1)===32&&(e=e.slice(0,-1)),e}function w$t(t){return/[\r\f]/.test(t)?t.replace(/\r\n/g,` 7145`).replace(/[\r\f]/g,` 7146`):t.replace(/\r\n/g,` 7147`)}let Uq=null,E$t;function A$t(){return Uq===null&&(Uq=new Intl.Segmenter(E$t,{granularity:"word"})),Uq}const x$t=new RegExp("\\p{Script=Arabic}","u"),Uj=new RegExp("\\p{M}","u"),Lpt=new RegExp("\\p{Nd}","u");function Upt(t){return x$t.test(t)}function Gpt(t){return t>=19968&&t<=40959||t>=13312&&t<=19903||t>=131072&&t<=173791||t>=173824&&t<=177983||t>=177984&&t<=178207||t>=178208&&t<=183983||t>=183984&&t<=191471||t>=191472&&t<=192093||t>=194560&&t<=195103||t>=196608&&t<=201551||t>=201552&&t<=205743||t>=205744&&t<=210041||t>=63744&&t<=64255||t>=12288&&t<=12351||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=44032&&t<=55215||t>=65280&&t<=65519}function tv(t){for(let e=0;e<t.length;e++){const r=t.charCodeAt(e);if(!(r<12288)){if(r>=55296&&r<=56319&&e+1<t.length){const i=t.charCodeAt(e+1);if(i>=56320&&i<=57343){const s=(r-55296<<10)+(i-56320)+65536;if(Gpt(s))return!0;e++;continue}}if(Gpt(r))return!0}}return!1}function S$t(t){const e=Wj(t);return e!==null&&(Wq.has(e)||qx.has(e))}const T$t=new Set(["\xA0","\u202F","\u2060","\uFEFF"]);function R$t(t){return tv(t)}function C$t(t){const e=Wj(t);return e!==null&&T$t.has(e)}function Gq(t){return!S$t(t)&&!C$t(t)}const Wq=new Set(["\uFF0C","\uFF0E","\uFF01","\uFF1A","\uFF1B","\uFF1F","\u3001","\u3002","\u30FB","\uFF09","\u3015","\u3009","\u300B","\u300D","\u300F","\u3011","\u3017","\u3019","\u301B","\u30FC","\u3005","\u303B","\u309D","\u309E","\u30FD","\u30FE"]),Gj=new Set(['"',"(","[","{","\u201C","\u2018","\xAB","\u2039","\uFF08","\u3014","\u3008","\u300A","\u300C","\u300E","\u3010","\u3016","\u3018","\u301A"]),jq=new Set(["'","\u2019"]),qx=new Set([".",",","!","?",":",";","\u060C","\u061B","\u061F","\u0964","\u0965","\u104A","\u104B","\u104C","\u104D","\u104F",")","]","}","%",'"',"\u201D","\u2019","\xBB","\u203A","\u2026"]),M$t=new Set([":",".","\u060C","\u061B"]),B$t=new Set(["\u104F"]),O$t=new Set(["\u201D","\u2019","\xBB","\u203A","\u300D","\u300F","\u3011","\u300B","\u3009","\u3015","\uFF09"]);function I$t(t){if(Xq(t))return!0;let e=!1;for(const r of t){if(qx.has(r)){e=!0;continue}if(!(e&&Uj.test(r)))return!1}return e}function D$t(t){for(const e of t)if(!Wq.has(e)&&!qx.has(e))return!1;return t.length>0}function P$t(t){if(Xq(t))return!0;for(const e of t)if(!Gj.has(e)&&!jq.has(e)&&!Uj.test(e))return!1;return t.length>0}function Xq(t){let e=!1;for(const r of t)if(!(r==="\\"||Uj.test(r))){if(Gj.has(r)||qx.has(r)||jq.has(r)){e=!0;continue}return!1}return e}function Wpt(t,e){const r=e-1;if(r<=0)return Math.max(r,0);const i=t.charCodeAt(r);if(i<56320||i>57343)return r;const s=r-1;if(s<0)return r;const o=t.charCodeAt(s);return o>=55296&&o<=56319?s:r}function Wj(t){if(t.length===0)return null;const e=Wpt(t,t.length);return t.slice(e)}function F$t(t){const e=Array.from(t);let r=e.length;for(;r>0;){const i=e[r-1];if(Uj.test(i)){r--;continue}if(Gj.has(i)||jq.has(i)){r--;continue}break}return r<=0||r===e.length?null:{head:e.slice(0,r).join(""),tail:e.slice(r).join("")}}function N$t(t,e,r){return r==="text"&&!e&&t.length===1&&t!=="-"&&t!=="\u2014"?t:null}function jpt(t,e,r,i){const s=e[i],o=t[i];if(s==null)return o;const n=r[i];if(o.length===n)return o;const a=s.repeat(n);return t[i]=a,a}function Xpt(t,e){return t&&e!==null&&M$t.has(e)}function k$t(t){const e=Wj(t);return e!==null&&B$t.has(e)}function L$t(t){if(t.length<2||t[0]!==" ")return null;const e=t.slice(1);return new RegExp("^\\p{M}+$","u").test(e)?{space:" ",marks:e}:null}function zq(t){let e=t.length;for(;e>0;){const r=Wpt(t,e),i=t.slice(r,e);if(O$t.has(i))return!0;
7147if(!qx.has(i))return!1;e=r}return!1}function U$t(t,e){if(e.preserveOrdinarySpaces||e.preserveHardBreaks){if(t===" ")return"preserved-space";if(t===" ")return"tab";if(e.preserveHardBreaks&&t===` 7148`)return"hard-break"}return t===" "?"space":t==="\xA0"||t==="\u202F"||t==="\u2060"||t==="\uFEFF"?"glue":t==="\u200B"?"zero-width-break":t==="\xAD"?"soft-hyphen":"text"}const G$t=/[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;function Gf(t){return t.length===1?t[0]:t.join("")}function W$t(t,e){const r=[];for(let i=t.length-1;i>=0;i--)r.push(t[i]);return r.push(e),Gf(r)}function j$t(t,e,r,i){if(!G$t.test(t))return[{text:t,isWordLike:e,kind:"text",start:r}];const s=[];let o=null,n=[],a=r,l=!1,c=0;for(const h of t){const u=U$t(h,i),d=u==="text"&&e;if(o!==null&&u===o&&d===l){n.push(h),c+=h.length;continue}o!==null&&s.push({text:Gf(n),isWordLike:l,kind:o,start:a}),o=u,n=[h],a=r+c,l=d,c+=h.length}return o!==null&&s.push({text:Gf(n),isWordLike:l,kind:o,start:a}),s}function Vq(t){return t==="space"||t==="preserved-space"||t==="zero-width-break"||t==="hard-break"}const X$t=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function z$t(t,e){const r=t.texts[e];return r.startsWith("www.")?!0:X$t.test(r)&&e+1<t.len&&t.kinds[e+1]==="text"&&t.texts[e+1]==="//"}function V$t(t){return t.includes("?")&&(t.includes("://")||t.startsWith("www."))}function Y$t(t){const e=t.texts.slice(),r=t.isWordLike.slice(),i=t.kinds.slice(),s=t.starts.slice();for(let n=0;n<t.len;n++){if(i[n]!=="text"||!z$t(t,n))continue;const a=[e[n]];let l=n+1;for(;l<t.len&&!Vq(i[l]);){a.push(e[l]),r[n]=!0;const c=e[l].includes("?");if(i[l]="text",e[l]="",l++,c)break}e[n]=Gf(a)}let o=0;for(let n=0;n<e.length;n++){const a=e[n];a.length!==0&&(o!==n&&(e[o]=a,r[o]=r[n],i[o]=i[n],s[o]=s[n]),o++)}return e.length=o,r.length=o,i.length=o,s.length=o,{len:o,texts:e,isWordLike:r,kinds:i,starts:s}}function $$t(t){const e=[],r=[],i=[],s=[];for(let o=0;o<t.len;o++){const n=t.texts[o];if(e.push(n),r.push(t.isWordLike[o]),i.push(t.kinds[o]),s.push(t.starts[o]),!V$t(n))continue;const a=o+1;if(a>=t.len||Vq(t.kinds[a]))continue;const l=[],c=t.starts[a];let h=a;for(;h<t.len&&!Vq(t.kinds[h]);)l.push(t.texts[h]),h++;l.length>0&&(e.push(Gf(l)),r.push(!0),i.push("text"),s.push(c),o=h-1)}return{len:e.length,texts:e,isWordLike:r,kinds:i,starts:s}}const H$t=new Set([":","-","/","\xD7",",",".","+","\u2013","\u2014"]),zpt=/^[A-Za-z0-9_]+[,:;]*$/,Vpt=/[,:;]+$/;function Ypt(t){for(const e of t)if(Lpt.test(e))return!0;return!1}function jj(t){if(t.length===0)return!1;for(const e of t)if(!(Lpt.test(e)||H$t.has(e)))return!1;return!0}function K$t(t){const e=[],r=[],i=[],s=[];for(let o=0;o<t.len;o++){const n=t.texts[o],a=t.kinds[o];if(a==="text"&&jj(n)&&Ypt(n)){const l=[n];let c=o+1;for(;c<t.len&&t.kinds[c]==="text"&&jj(t.texts[c]);)l.push(t.texts[c]),c++;e.push(Gf(l)),r.push(!0),i.push("text"),s.push(t.starts[o]),o=c-1;continue}e.push(n),r.push(t.isWordLike[o]),i.push(a),s.push(t.starts[o])}return{len:e.length,texts:e,isWordLike:r,kinds:i,starts:s}}function q$t(t){const e=[],r=[],i=[],s=[];for(let o=0;o<t.len;o++){const n=t.texts[o],a=t.kinds[o],l=t.isWordLike[o];if(a==="text"&&l&&zpt.test(n)){const c=[n];let h=Vpt.test(n),u=o+1;for(;h&&u<t.len&&t.kinds[u]==="text"&&t.isWordLike[u]&&zpt.test(t.texts[u]);){const d=t.texts[u];c.push(d),h=Vpt.test(d),u++}e.push(Gf(c)),r.push(!0),i.push("text"),s.push(t.starts[o]),o=u-1;continue}e.push(n),r.push(l),i.push(a),s.push(t.starts[o])}return{len:e.length,texts:e,isWordLike:r,kinds:i,starts:s}}function Z$t(t){const e=[],r=[],i=[],s=[];for(let o=0;o<t.len;o++){const n=t.texts[o];if(t.kinds[o]==="text"&&n.includes("-")){const a=n.split("-");let l=a.length>1;for(let c=0;c<a.length;c++){const h=a[c];if(!l)break;(h.length===0||!Ypt(h)||!jj(h))&&(l=!1)}if(l){let c=0;for(let h=0;h<a.length;h++){const u=a[h],d=h<a.length-1?`${u}-`:u;e.push(d),r.push(!0),i.push("text"),s.push(t.starts[o]+c),c+=d.length}continue}}e.push(n),r.push(t.isWordLike[o]),i.push(t.kinds[o]),s.push(t.starts[o])}return{len:e.length,texts:e,isWordLike:r,kinds:i,starts:s}}function J$t(t){const e=[],r=[],i=[],s=[];let o=0;for(;o<t.len;){const n=[t.texts[o]];let a=t.isWordLike[o],l=t.kinds[o],c=t.starts[o];if(l==="glue"){const h=[n[0]],u=c;for(o++;o<t.len&&t.kinds[o]==="glue";)h.push(t.texts[o]),o++;const d=Gf(h);if(o<t.len&&t.kinds[o]==="text")n[0]=d,n.push(t.texts[o]),a=t.isWordLike[o],l="text",c=u,o++;else{e.push(d),r.push(!1),i.push("glue"),s.push(u);continue}}else o++;if(l==="text")for(;o<t.len&&t.kinds[o]==="glue";){const h=[];for(;o<t.len&&t.kinds[o]==="glue";)h.push(t.texts[o]),o++;const u=Gf(h);if(o<t.len&&t.kinds[o]==="text"){n.push(u,t.texts[o]),a=a||t.isWordLike[o],o++;continue}n.push(u)}e.push(Gf(n)),r.push(a),i.push(l),s.push(c)}return{len:e.length,texts:e,isWordLike:r,kinds:i,starts:s}}function Q$t(t){const e=t.texts.slice(),r=t.isWordLike.slice(),i=t.kinds.slice(),s=t.starts.slice();for(let o=0;o<e.length-1;o++){if(i[o]!=="text"||i[o+1]!=="text"||!tv(e[o])||!tv(e[o+1]))continue;const n=F$t(e[o]);n!==null&&(e[o]=n.head,e[o+1]=n.tail+e[o+1],s[o+1]=s[o]+n.head.length)}return{len:e.length,texts:e,isWordLike:r,kinds:i,starts:s}}function $pt(t,e,r){const i=A$t();let s=0;const o=[],n=[],a=[],l=[],c=[],h=[],u=[],d=[],f=[],g=[],p=[],m=[];for(const E of i.segment(t))for(const A of j$t(E.segment,E.isWordLike??!1,E.index,r)){let x=function(){h[U]!==null&&(n[U]=[jpt(o,h,u,U)],h[U]=null),n[U].push(A.text),a[U]=a[U]||A.isWordLike,d[U]=d[U]||R,f[U]=f[U]||B,g[U]=C,p[U]=F,m[U]=Xpt(f[U],O)};const S=A.kind==="text",T=N$t(A.text,A.isWordLike,A.kind),R=tv(A.text),B=Upt(A.text),O=Wj(A.text),C=zq(A.text),F=k$t(A.text),U=s-1;e.carryCJKAfterClosingQuote&&S&&s>
71480&&l[U]==="text"&&R&&d[U]&&g[U]||S&&s>0&&l[U]==="text"&&D$t(A.text)&&d[U]||S&&s>0&&l[U]==="text"&&p[U]?x():S&&s>0&&l[U]==="text"&&A.isWordLike&&B&&m[U]?(x(),a[U]=!0):T!==null&&s>0&&l[U]==="text"&&h[U]===T?u[U]=(u[U]??1)+1:S&&!A.isWordLike&&s>0&&l[U]==="text"&&(I$t(A.text)||A.text==="-"&&a[U])?x():(o[s]=A.text,n[s]=[A.text],a[s]=A.isWordLike,l[s]=A.kind,c[s]=A.start,h[s]=T,u[s]=T===null?0:1,d[s]=R,f[s]=B,g[s]=C,p[s]=F,m[s]=Xpt(B,O),s++)}for(let E=0;E<s;E++){if(h[E]!==null){o[E]=jpt(o,h,u,E);continue}o[E]=Gf(n[E])}for(let E=1;E<s;E++)l[E]==="text"&&!a[E]&&Xq(o[E])&&l[E-1]==="text"&&(o[E-1]+=o[E],a[E-1]=a[E-1]||a[E],o[E]="");const v=Array.from({length:s},()=>null);let b=-1;for(let E=s-1;E>=0;E--){const A=o[E];if(A.length!==0){if(l[E]==="text"&&!a[E]&&P$t(A)&&b>=0&&l[b]==="text"){const x=v[b]??[];x.push(A),v[b]=x,c[b]=c[E],o[E]="";continue}b=E}}for(let E=0;E<s;E++){const A=v[E];A!=null&&(o[E]=W$t(A,o[E]))}let y=0;for(let E=0;E<s;E++){const A=o[E];A.length!==0&&(y!==E&&(o[y]=A,a[y]=a[E],l[y]=l[E],c[y]=c[E]),y++)}o.length=y,a.length=y,l.length=y,c.length=y;const _=J$t({len:y,texts:o,isWordLike:a,kinds:l,starts:c}),w=Q$t(q$t(Z$t(K$t($$t(Y$t(_))))));for(let E=0;E<w.len-1;E++){const A=L$t(w.texts[E]);A!==null&&(w.kinds[E]!=="space"&&w.kinds[E]!=="preserved-space"||w.kinds[E+1]!=="text"||!Upt(w.texts[E+1])||(w.texts[E]=A.space,w.isWordLike[E]=!1,w.kinds[E]=w.kinds[E]==="preserved-space"?"preserved-space":"space",w.texts[E+1]=A.marks+w.texts[E+1],w.starts[E+1]=w.starts[E]+A.space.length))}return w}function tHt(t,e){if(t.len===0)return[];if(!e.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:t.len,consumedEndSegmentIndex:t.len}];const r=[];let i=0;for(let s=0;s<t.len;s++)t.kinds[s]==="hard-break"&&(r.push({startSegmentIndex:i,endSegmentIndex:s,consumedEndSegmentIndex:s+1}),i=s+1);return i<t.len&&r.push({startSegmentIndex:i,endSegmentIndex:t.len,consumedEndSegmentIndex:t.len}),r}function eHt(t){if(t.len<=1)return t;const e=[],r=[],i=[],s=[];let o=null,n=!1,a=0,l=!1,c=!1;function h(){o!==null&&(e.push(Gf(o)),r.push(n),i.push("text"),s.push(a),o=null)}for(let u=0;u<t.len;u++){const d=t.texts[u],f=t.kinds[u],g=t.isWordLike[u],p=t.starts[u];if(f==="text"){const m=R$t(d),v=Gq(d);if(o!==null&&l&&c){o.push(d),n=n||g,l=l||m,c=v;continue}h(),o=[d],n=g,a=p,l=m,c=v;continue}h(),e.push(d),r.push(g),i.push(f),s.push(p)}return h(),{len:e.length,texts:e,isWordLike:r,kinds:i,starts:s}}function rHt(t,e,r="normal",i="normal"){const s=_$t(r),o=s.mode==="pre-wrap"?w$t(t):b$t(t);if(o.length===0)return{normalized:o,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};const n=i==="keep-all"?eHt($pt(o,e,s)):$pt(o,e,s);return{normalized:o,chunks:tHt(n,s),...n}}let O2=null;const Hpt=new Map;let I2=null;const iHt=96,sHt=new RegExp("\\p{Emoji_Presentation}","u"),oHt=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;let Yq=null;const Kpt=new Map;function $q(){if(O2!==null)return O2;if(typeof OffscreenCanvas<"u")return O2=new OffscreenCanvas(1,1).getContext("2d"),O2;if(typeof document<"u")return O2=document.createElement("canvas").getContext("2d"),O2;throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function nHt(t){let e=Hpt.get(t);return e||(e=new Map,Hpt.set(t,e)),e}function mw(t,e){let r=e.get(t);return r===void 0&&(r={width:$q().measureText(t).width,containsCJK:tv(t)},e.set(t,r)),r}function Xj(){if(I2!==null)return I2;if(typeof navigator>"u")return I2={lineFitEpsilon:.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},I2;const t=navigator.userAgent,e=navigator.vendor==="Apple Computer, Inc."&&t.includes("Safari/")&&!t.includes("Chrome/")&&!t.includes("Chromium/")&&!t.includes("CriOS/")&&!t.includes("FxiOS/")&&!t.includes("EdgiOS/"),r=t.includes("Chrome/")||t.includes("Chromium/")||t.includes("CriOS/")||t.includes("Edg/");return I2={lineFitEpsilon:e?1/64:.005,carryCJKAfterClosingQuote:r,preferPrefixWidthsForBreakableRuns:e,preferEarlySoftHyphenBreak:e},I2}function aHt(t){const e=t.match(/(\d+(?:\.\d+)?)\s*px/);return e?parseFloat(e[1]):16}function qpt(){return Yq===null&&(Yq=new Intl.Segmenter(void 0,{granularity:"grapheme"})),Yq}function lHt(t){return sHt.test(t)||t.includes("\uFE0F")}function cHt(t){return oHt.test(t)}function hHt(t,e){let r=Kpt.get(t);if(r!==void 0)return r;const i=$q();i.font=t;const s=i.measureText("\u{1F600}").width;if(r=0,s>e+.5&&typeof document<"u"&&document.body!==null){const o=document.createElement("span");o.style.font=t,o.style.display="inline-block",o.style.visibility="hidden",o.style.position="absolute",o.textContent="\u{1F600}",document.body.appendChild(o);const n=o.getBoundingClientRect().width;document.body.removeChild(o),s-n>.5&&(r=s-n)}return Kpt.set(t,r),r}function uHt(t){let e=0;const r=qpt();for(const i of r.segment(t))lHt(i.segment)&&e++;return e}function dHt(t,e){return e.emojiCount===void 0&&(e.emojiCount=uHt(t)),e.emojiCount}function Zx(t,e,r){return r===0?e.width:e.width-dHt(t,e)*r}function fHt(t,e,r,i,s){if(e.breakableFitAdvances!==void 0)return e.breakableFitAdvances;const o=qpt(),n=[];for(const h of o.segment(t))n.push(h.segment);if(n.length<=1)return e.breakableFitAdvances=null,e.breakableFitAdvances;if(s==="sum-graphemes"){const h=[];for(const u of n){const d=mw(u,r);h.push(Zx(u,d,i))}return e.breakableFitAdvances=h,e.breakableFitAdvances}if(s==="pair-context"||n.length>iHt){const h=[];let u=null,d=0;for(const f of n){const g=mw(f,r),p=Zx(f,g,i);if(u===null)h.push(p);else{const m=u+f,v=mw(m,r);h.push(Zx(m,v,i)-d)}u=f,d=p}return e.breakableFitAdvances=h,e.breakableFitAdvances}const a=[];let l="",c=0;for(const h of n){l+=h;const u=mw(l,r),d=Zx(l,u,i);a.push(d-c),c=d}return e.breakableFitAdvances=a,e.breakableFitAdvances}function pHt(t,e){const r=$q();r.font=t;const i=nHt(t),s=aHt(t),o=e?hHt(t,s):0;return{cache:i,fontSize:s,emojiCorrection:o}}function gHt(t,e){for(;e<t.widths.length;){const r=t.kinds[e];if(r!=="space"&&r!=="zero-width-break"&&r!=="soft-hyphen")break;e++}return e}function mHt(t,e){if(e<=0)return 0;const r=t%e;return Math.abs(r)<=1e-6?e:e-r}function yHt(t,e,r,i,s){let o=0,n=e;for(;o<t.length;){const a=n+t[o];if((o+1<t.length?a+s:a)>r+i)break;n=a,o++}return{fitCount:o,fittedWidth:n}}function vHt(t,e,r){const{widths:i,kinds:s,breakableFitAdvances:o}=t;if(i.length===0)return 0;const n=Xj().lineFitEpsilon,a=e+n;let l=0,c=0,h=!1,u=0,d=0,f=0,g=0,p=-1,m=0;function v(){p=-1,m=0}function b(x=f,S=g,T=c){l++,r==null||r({startSegmentIndex:u,startGraphemeIndex:d,endSegmentIndex:x,endGraphemeIndex:S,width:T}),c=0,h=!1,v()}function y(x,S){h=!0,u=x,d=0,f=x+1,g=0,c=S}function _(x,S,T){h=!0,u=x,d=S,f=x,g=S+1,c=T}function w(x,S){if(!h){y(x,S);return}c+=S,f=x+1,g=0}function E(x,S){const T=o[x];for(let R=S;R<T.length;R++){const B=T[R];h?c+B>a?(b(),_(x,R,B)):(c+=B,f=x,g=R+1):_(x,R,B)}h&&f===x&&g===T.length&&(f=x+1,g=0)}let A=0;for(;A<i.length&&!(!h&&(A=gHt(t,A),A>=i.length));){const x=i[A],S=s[A],T=S==="space"||S==="preserved-space"||S==="tab"||S==="zero-width-break"||S==="soft-hyphen";if(!h){x>e&&o[A]!==null?E(A,0):y(A,x),T&&(p=A+1,m=c-x),A++;continue}if(c+x>a){if(T){w(A,x),b(A+1,0,c-x),A++;continue}if(p>=0){if(f>p||f===p&&g>0){b();continue}b(p,0,m);continue}if(x>e&&o[A]!==null){b(),E(A,0),A++;continue}b();continue}w(A,x),T&&(p=A+1,m=c-x),A++}return h&&b(),l}function _Ht(t,e,r){if(t.simpleLineWalkFastPath)return vHt(t,e,r);const{widths:i,lineEndFitAdvances:s,lineEndPaintAdvances:o,kinds:n,breakableFitAdvances:a,discretionaryHyphenWidth:l,tabStopAdvance:c,chunks:h}=t;if(i.length===0||h.length===0)return 0;const u=Xj(),d=u.lineFitEpsilon,f=e+d;let g=0,p=0,m=!1,v=0,b=0,y=0,_=0,w=-1,E=0,A=0,x=null;function S(){w=-1,E=0,A=0,x=null}function T(N=y,G=_,Y=p){g++,r==null||r({startSegmentIndex:v,startGraphemeIndex:b,endSegmentIndex:N,endGraphemeIndex:G,width:Y}),p=0,m=!1,S()}function R(N,G){m=!0,v=N,b=0,y=N+1,_=0,p=G}function B(N,G,Y){m=!0,v=N,b=G,y=N,_=G+1,p=Y}function O(N,G){if(!m){R(N,G);return}p+=G,y=N+1,_=0}function C(N,G,Y,q){if(!G)return;const L=N==="tab"?0:s[Y],J=N==="tab"?q:o[Y];w=Y+1,E=p-q+L,A=p-q+J,x=N}function F(N,G){const Y=a[N];for(let q=G;q<Y.length;q++){const L=Y[q];m?p+L>f?(T(),B(N,q,L)):(p+=L,y=N,_=q+1):B(N,q,L)}m&&y===N&&_===Y.length&&(y=N+1,_=0)}function U(N){if(x!=="soft-hyphen")return!1;const G=a[N];if(G==null)return!1;const{fitCount:Y,fittedWidth:q}=yHt(G,p,e,d,l);
7148return Y===0?!1:(p=q,y=N,_=Y,S(),Y===G.length?(y=N+1,_=0,!0):(T(N,Y,q+l),F(N,Y),!0))}function H(N){g++,r==null||r({startSegmentIndex:N.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:N.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),S()}for(let N=0;N<h.length;N++){const G=h[N];if(G.startSegmentIndex===G.endSegmentIndex){H(G);continue}m=!1,p=0,v=G.startSegmentIndex,b=0,y=G.startSegmentIndex,_=0,S();let Y=G.startSegmentIndex;for(;Y<G.endSegmentIndex;){const q=n[Y],L=q==="space"||q==="preserved-space"||q==="tab"||q==="zero-width-break"||q==="soft-hyphen",J=q==="tab"?mHt(p,c):i[Y];if(q==="soft-hyphen"){m&&(y=Y+1,_=0,w=Y+1,E=p+l,A=p+l,x=q),Y++;continue}if(!m){J>e&&a[Y]!==null?F(Y,0):R(Y,J),C(q,L,Y,J),Y++;continue}if(p+J>f){const tt=p+(q==="tab"?0:s[Y]),bt=p+(q==="tab"?J:o[Y]);if(x==="soft-hyphen"&&u.preferEarlySoftHyphenBreak&&E<=f){T(w,0,A);continue}if(x==="soft-hyphen"&&U(Y)){Y++;continue}if(L&&tt<=f){O(Y,J),T(Y+1,0,bt),Y++;continue}if(w>=0&&E<=f){if(y>w||y===w&&_>0){T();continue}const ct=w;T(ct,0,A),Y=ct;continue}if(J>e&&a[Y]!==null){T(),F(Y,0),Y++;continue}T();continue}O(Y,J),C(q,L,Y,J),Y++}if(m){const q=w===G.consumedEndSegmentIndex?A:p;T(G.consumedEndSegmentIndex,0,q)}}return g}let Hq=null,Zpt=new WeakMap;function Jpt(){return Hq===null&&(Hq=new Intl.Segmenter(void 0,{granularity:"grapheme"})),Hq}function bHt(t){return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]}}function wHt(t,e){const r=[];let i=[],s=0,o=!1,n=!1,a=!1;function l(){i.length!==0&&(r.push({text:i.length===1?i[0]:i.join(""),start:s}),i=[],o=!1,n=!1,a=!1)}function c(u,d,f){i=[u],s=d,o=f,n=zq(u),a=Gj.has(u)}function h(u,d){i.push(u),o=o||d;const f=zq(u);u.length===1&&qx.has(u)?n=n||f:n=f,a=!1}for(const u of Jpt().segment(t)){const d=u.segment,f=tv(d);if(i.length===0){c(d,u.index,f);continue}if(a||Wq.has(d)||qx.has(d)||e.carryCJKAfterClosingQuote&&f&&n){h(d,f);continue}if(!o&&!f){h(d,f);continue}l(),c(d,u.index,f)}return l(),r}function EHt(t){if(t.length<=1)return t;const e=[];let r=[t[0].text],i=t[0].start,s=tv(t[0].text),o=Gq(t[0].text);function n(){e.push({text:r.length===1?r[0]:r.join(""),start:i})}for(let a=1;a<t.length;a++){const l=t[a],c=tv(l.text),h=Gq(l.text);if(s&&o){r.push(l.text),s=s||c,o=h;continue}n(),r=[l.text],i=l.start,s=c,o=h}return n(),e}function AHt(t,e,r,i){const s=Xj(),{cache:o,emojiCorrection:n}=pHt(e,cHt(t.normalized)),a=Zx("-",mw("-",o),n),l=Zx(" ",mw(" ",o),n)*8;if(t.len===0)return bHt();const c=[],h=[],u=[],d=[];let f=t.chunks.length<=1;const g=[],p=[],m=r?[]:null,v=Array.from({length:t.len});function b(E,A,x,S,T,R,B){T!=="text"&&T!=="space"&&T!=="zero-width-break"&&(f=!1),c.push(A),h.push(x),u.push(S),d.push(T),g==null||g.push(R),p.push(B),m!==null&&m.push(E)}function y(E,A,x,S,T){const R=mw(E,o),B=Zx(E,R,n),O=A==="space"||A==="preserved-space"||A==="zero-width-break"?0:B,C=A==="space"||A==="zero-width-break"?0:B;if(T&&S&&E.length>1){let F="sum-graphemes";jj(E)?F="pair-context":s.preferPrefixWidthsForBreakableRuns&&(F="segment-prefixes");const U=fHt(E,R,o,n,F);b(E,B,O,C,A,x,U);return}b(E,B,O,C,A,x,null)}for(let E=0;E<t.len;E++){v[E]=c.length;const A=t.texts[E],x=t.isWordLike[E],S=t.kinds[E],T=t.starts[E];if(S==="soft-hyphen"){b(A,0,a,a,S,T,null);continue}if(S==="hard-break"){b(A,0,0,0,S,T,null);continue}if(S==="tab"){b(A,0,0,0,S,T,null);continue}const R=mw(A,o);if(S==="text"&&R.containsCJK){const B=wHt(A,s),O=i==="keep-all"?EHt(B):B;for(let C=0;C<O.length;C++){const F=O[C];y(F.text,"text",T+F.start,x,i==="keep-all"||!tv(F.text))}continue}y(A,S,T,x,!0)}const _=xHt(t.chunks,v,c.length),w=g===null?null:m$t(t.normalized,g);return m!==null?{widths:c,lineEndFitAdvances:h,lineEndPaintAdvances:u,kinds:d,simpleLineWalkFastPath:f,segLevels:w,breakableFitAdvances:p,discretionaryHyphenWidth:a,tabStopAdvance:l,chunks:_,segments:m}:{widths:c,lineEndFitAdvances:h,lineEndPaintAdvances:u,kinds:d,simpleLineWalkFastPath:f,segLevels:w,breakableFitAdvances:p,discretionaryHyphenWidth:a,tabStopAdvance:l,chunks:_}}function xHt(t,e,r){const i=[];for(let s=0;s<t.length;s++){const o=t[s],n=o.startSegmentIndex<e.length?e[o.startSegmentIndex]:r,a=o.endSegmentIndex<e.length?e[o.endSegmentIndex]:r,l=o.consumedEndSegmentIndex<e.length?e[o.consumedEndSegmentIndex]:r;i.push({startSegmentIndex:n,endSegmentIndex:a,consumedEndSegmentIndex:l})}return i}function SHt(t,e,r,i){const s=(i==null?void 0:i.wordBreak)??"normal",o=rHt(t,Xj(),i==null?void 0:i.whiteSpace,s);return AHt(o,e,r,s)}function Qpt(t,e,r){return SHt(t,e,!0,r)}function tgt(t,e,r){let i=r.get(t);if(i!==void 0)return i;i=[];const s=Jpt();for(const o of s.segment(e[t]))i.push(o.segment);return r.set(t,i),i}function THt(t){let e=Zpt.get(t);return e!==void 0||(e=new Map,Zpt.set(t,e)),e}function RHt(t,e,r,i){return i>0&&t[i-1]==="soft-hyphen"&&!(e===i&&r>0)}function CHt(t,e,r,i,s,o,n){let a="";const l=RHt(e,i,s,o);for(let c=i;c<o;c++)e[c]==="soft-hyphen"||e[c]==="hard-break"||(c===i&&s>0?a+=tgt(c,t,r).slice(s).join(""):a+=t[c]);return n>0?(l&&(a+="-"),a+=tgt(o,t,r).slice(i===o?s:0,n).join("")):l&&(a+="-"),a}
7148function MHt(t,e,r,i,s,o,n){return{text:CHt(t.segments,t.kinds,e,i,s,o,n),width:r,start:{segmentIndex:i,graphemeIndex:s},end:{segmentIndex:o,graphemeIndex:n}}}function BHt(t,e,r){return MHt(t,e,r.width,r.startSegmentIndex,r.startGraphemeIndex,r.endSegmentIndex,r.endGraphemeIndex)}function egt(t,e,r){const i=[];if(t.widths.length===0)return{lineCount:0,height:0,lines:i};const s=THt(t),o=_Ht(t,e,n=>{i.push(BHt(t,s,n))});return{lineCount:o,height:o*r,lines:i}}let rgt,Kq,igt,zj,sgt,ogt,ngt,agt,qq,lgt,cgt,hgt,ugt,dgt,fgt,pgt,ggt,mgt,ygt,vgt;rgt=/[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/,Kq=16777216,igt=CV(),zj={},sgt="|\xC9q\xC5",ogt="M",ngt=[10,13],agt=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],qq=/[a-zA-Z0-9\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff!"#$%&'()*+,-./:;]/,lgt=/[!%),.:;?\]}¢°·'""â â¡âºââ¶ãããããããï¹ï¹ï¼ï¼ï¼
ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼½ï½ï½]/,cgt=/[$(£¥·'"ããããããããï¹ï¹ï¼ï¼ï¼ï¼»ï½ï¿¡ï¿¥]/,hgt=/[!),.:;?\]}¢·ââ'"â¢"ãããããããã︰︱︲︳ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¹ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¸¶ï¸¸ï¸ºï¸¼ï¸¾ï¹ï¹ï¹ï¼½ï½ï½ï½¤]/,ugt=/[([{£¥'"âµãããããã︴ï¹ï¹ï¼ï½ï¸µï¸·ï¸¹ï¸»ï¸½ï¸¿ï¹ï¹ï¹]/,dgt=/[)\]ï½ããããããããã'"ï½ Â»ã½ã¾ã¼ã¡ã£ã¥ã§ã©ãã£ã¥ã§ã®ãµã¶ããã
ããã£ãã
ããããã°ã±ã²ã³ã´ãµã¶ã·ã¸ã¹ãºã»ã¼ã½ã¾ã¿ã
ã»âã âã?!â¼âââã»ã:;,ã.]/,fgt=/[([ï½ããããããããã'"ï½Â«â...â¥ã³ã´ãµ]/,pgt=/[!%),.:;?\]}¢°'"â â¡âããããããï¼ï¼
ï¼ï¼ï¼ï¼ï¼ï¼ï¼½ï½]/,ggt=/[$([{£¥'"ã
ãããããï¼ï¼ï¼»ï½ï½ ¥₩#]/,mgt=new RegExp(`${lgt.source}|${hgt.source}|${dgt.source}|${pgt.source}`),ygt=new RegExp(`${cgt.source}|${ugt.source}|${fgt.source}|${ggt.source}`),vgt=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],UV={thin:100,extraLight:200,ultraLight:200,light:300,normal:400,regular:400,medium:500,semiBold:600,demiBold:600,bold:700,extraBold:800,ultraBold:800,black:900,heavy:900,extraBlack:950,ultraBlack:950};function D2(t){var e,r;const i=typeof t.fontSize=="number"?`${t.fontSize}px`:t.fontSize;let s=t.fontFamily;Array.isArray(t.fontFamily)||(s=t.fontFamily.split(","));for(let o=s.length-1;o>=0;o--){let n=s[o].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!vgt.includes(n)&&(n=`"${n}"`),s[o]=n}return`${(e=t.fontStyle)!==null&&e!==void 0?e:"normal"} ${(r=t.fontVariant)!==null&&r!==void 0?r:"normal"} ${t.fontWeight?UV[t.fontWeight]||t.fontWeight:"normal"} ${i} ${s.join(",")}`}function u3(t,e){let r=0;const{fontBoundingBoxAscent:i=0,fontBoundingBoxDescent:s=0}=e;return t==="alphabetic"?r-=i:t==="middle"?r-=(i+s)/2:t==="hanging"?r=0:t==="ideographic"||t==="bottom"?r-=i+s:t==="top"&&(r=0),r}let Ig,ev;const Zq={};let Jq=OHt,Qq=NHt;Itt=function(t){Jq=t},Ott=function(t){Qq=t};class _gt extends We{constructor(){super(),this.texts=this.query(e=>e.addedOrChanged.with(Yt).trackWrites),this.query(e=>e.current.with(Ji).write)}execute(){this.texts.addedOrChanged.forEach(e=>{const r=e.read(Yt),i=om(r);nt(e,Ji),Object.assign(e.write(Ji),i)})}}function OHt(t){Ig||(Ig=Pr.get().createCanvas(1,1),ev=Ig.getContext("2d"));const e=D2(t);if(Zq[e])return Zq[e];ev.font=e;const{actualBoundingBoxAscent:r,actualBoundingBoxDescent:i,actualBoundingBoxLeft:s,actualBoundingBoxRight:o,alphabeticBaseline:n,fontBoundingBoxAscent:a,fontBoundingBoxDescent:l,hangingBaseline:c,ideographicBaseline:h,width:u,emHeightAscent:d,emHeightDescent:f}=ev.measureText(sgt+ogt),g={actualBoundingBoxAscent:r,actualBoundingBoxDescent:i,actualBoundingBoxLeft:s,actualBoundingBoxRight:o,alphabeticBaseline:n,fontBoundingBoxAscent:a,fontBoundingBoxDescent:l,hangingBaseline:c,ideographicBaseline:h,emHeightAscent:d,emHeightDescent:f,width:u,fontSize:r+i};return Zq[e]=g,g}function IHt(t){return rgt.test(t)}function DHt(t){if(!zj[t]){const e=[new Array],r=(a,l)=>{const c=l<0?0:l;for(;a.length>c+1;){const h=a.pop();a[a.length-1].push(...h.reverse())}},i=(a,l,c)=>{c+1>a.length?a.push(...Array.from({length:c+1-a.length},()=>new Array)):r(a,c),a[c].push({text:l,direction:c%2===0?"ltr":"rtl"})},s=igt.getEmbeddingLevels(t).levels.entries(),o=s.next();if(!o.done){let[a,l]=o.value;for(const[c,h]of s)h!==l&&(i(e,t.slice(a,c),l),a=c,l=h);i(e,t.slice(a),l),r(e,0)}let n="";for(const a of e[0]){const{text:l,direction:c}=a;c==="ltr"?n+=l:n+=MV.convertArabic(l).split("").reverse().join("")}zj[t]=n}return zj[t]}om=function(t){var e,r,i;Ig||(Ig=Pr.get().createCanvas(1,1),ev=Ig.getContext("2d"));const s=(e=t.content)!==null&&e!==void 0?e:"",{wordWrap:o,letterSpacing:n=0,textAlign:a="start",textBaseline:l="alphabetic",leading:c=0,bitmapFont:h,bitmapFontKerning:u,fontSize:d}=t,f=0;let g=(r=t.lineHeight)!==null&&r!==void 0?r:0;const p=D2(t);let m,v=1;
7148if(h){const T=FHt(h,t.fontSize);g=T.lineHeight,m=T.fontMetrics,v=T.scale}else m=Jq(t),ev.font=p;g*=v,m.fontSize===0&&(m.fontSize=d);const b=Math.max(1,g||m.fontSize+f||Number(d)||16);let y;if(IHt(s)){const T=DHt(s);y=(o?Egt(T,t,v):T).split(/(?:\r\n|\r|\n)/)}else if(h){const T=Qpt(s,p,{whiteSpace:"pre-wrap"}),{lines:R}=egt(T,Kq,b),B=R.map(O=>O.text).join(` 7149`);y=(o?Egt(B,t,v):B).split(/(?:\r\n|\r|\n)/)}else{const T=Qpt(s,p,{whiteSpace:"pre-wrap"}),R=o&&((i=t.wordWrapWidth)!==null&&i!==void 0?i:0)>0?t.wordWrapWidth+n:Kq,{lines:B}=egt(T,R,b);let O=B.map(C=>C.text);o&&Number.isFinite(t.maxLines)&&t.maxLines>0&&O.length>t.maxLines&&(O=O.slice(0,t.maxLines),PHt(O,t.maxLines-1,t,v)),y=O}const _=y.join(""),w=new Array(y.length);let E=0;for(let T=0;T<y.length;T++){const R=kHt(y[T],n,h,u,v,t);w[T]=R,E=Math.max(E,R)}const A=E+f;g=g||m.fontSize+f;const x=Math.max(g,m.fontSize+f)+(y.length-1)*(g+c);g+=c;let S=0;return l==="middle"?S=-x/2:l==="bottom"||l==="alphabetic"||l==="ideographic"?S=-x:(l==="top"||l==="hanging")&&(S=0),{bidiChars:_,font:p,width:A,height:x,lines:y,lineWidths:w,lineHeight:g,maxLineWidth:E,fontMetrics:m,lineMetrics:w.map((T,R)=>{let B=0;return a==="center"?B-=T/2:(a==="right"||a==="end")&&(B-=T),new Ua(B-f/2,S+R*g,T+f,g)})}};function bgt(t){var e;const r=(e=t.textOverflow)!==null&&e!==void 0?e:"ellipsis";return r==="ellipsis"?"...":r&&r!=="clip"?r:""}function wgt(t,e,r,i,s,o){var n;if(i<=0||i>s)return;const a=(n=t[e])!==null&&n!==void 0?n:"";let l=0,c=a.length;for(let h=0;h<a.length;h++){const u=o(a[h]);if(l+u+i>s){c=h;break}l+=u}t[e]=a.slice(0,c)+r}function PHt(t,e,r,i){const s=bgt(r);if(!s)return;const{letterSpacing:o=0,wordWrapWidth:n=0}=r,a=n+o,l=Ig.getContext("2d",{willReadFrequently:!0}),c={},h=d=>Agt(d,o,c,l,void 0,i,r),u=Array.from(s).reduce((d,f)=>d+h(f),0);wgt(t,e,s,u,a,h)}function Egt(t,e,r){const i=Ig.getContext("2d",{willReadFrequently:!0}),{letterSpacing:s=0,maxLines:o,bitmapFont:n}=e,a=e.wordWrapWidth+s,l=bgt(e);let c=[],h=0,u=0;const d={},f=v=>Agt(v,s,d,i,n,r,e),g=Array.from(l).reduce((v,b)=>v+f(b),0);function p(v){wgt(c,v,l,g,a,f)}const m=Array.from(t);for(let v=0;v<m.length;v++){const b=m[v],y=t[v-1],_=t[v+1],w=f(b);if(LHt(b)){if(h++,h>=o){v<m.length-1&&p(h-1);break}u=0,c[h]="";continue}if(u>0&&u+w>a){if(h+1>=o){p(h);break}if(h++,u=0,c[h]="",tZ(b))continue;jHt(b)||(c=UHt(c),u=XHt(c[h]||"",d)),_&&GHt(b,_)&&(c=WHt(c),u+=f(y||""))}u+=w,c[h]=(c[h]||"")+b}return c.join(` 7150`)}function FHt(t,e){const{fontMetrics:r,lineHeight:i}=t,s=e/t.baseMeasurementFontSize;return{scale:s,lineHeight:i*s,fontMetrics:{actualBoundingBoxAscent:r.ascent*s,actualBoundingBoxDescent:r.descent*s,fontSize:e}}}function NHt(t,e){var r;return Ig||(Ig=Pr.get().createCanvas(1,1),ev=Ig.getContext("2d")),ev.font=D2(e),ev.letterSpacing=`${(r=e.letterSpacing)!==null&&r!==void 0?r:0}px`,ev.measureText(t).width}function kHt(t,e,r,i,s,o){const n=Pr.get().splitGraphemes(t);let a,l,c;return r?(a=n.reduce((h,u)=>{var d,f;const g=(d=r.chars[u])===null||d===void 0?void 0:d.xAdvance,p=i&&c&&((f=r.chars[u])===null||f===void 0?void 0:f.kerning[c])||0;return c=u,h+((g+p)*s||0)},0),l=a):(a=Qq(t,o),l=a),Math.max(a,l)}function tZ(t){return agt.includes(t.charCodeAt(0))}function LHt(t){return ngt.includes(t.charCodeAt(0))}function UHt(t){const e=[...t],r=e[e.length-2],i=zHt(r);if(i===-1||!r)return e;const s=r.slice(i,i+1),o=tZ(s),n=i+1,a=i+(o?0:1);return e[e.length-1]+=r.slice(n,r.length),e[e.length-2]=r.slice(0,a),e}function GHt(t,e){return tZ(e)?!1:!!(t&&(ygt.exec(e)||mgt.exec(t)))}function WHt(t){const e=[...t],r=e[e.length-2];if(!r)return t;const i=r[r.length-1];return e[e.length-2]=r.slice(0,-1),e[e.length-1]=i+e[e.length-1],e}function jHt(t){return!(t&&qq.test(t))}function XHt(t,e){return t.split("").reduce((r,i)=>{if(!e[i])throw Error("cannot count the word without cache");return r+e[i]},0)}function zHt(t){for(let e=t.length-1;e>=0;e--)if(!qq.test(t[e]))return e;return-1}function Agt(t,e,r,i,s,o,n){var a;let l=r[t];if(typeof l!="number"){const c=t.length*e;l=(s?((a=s.chars[t])===null||a===void 0?void 0:a.xAdvance)||0:Qq(t,n))*o+c,r[t]=l}return l}const VHt=(t,e,r,i,s)=>{const o=r+s*2,n=i+s*2,a=o*n,{outer:l,inner:c}=t;l.fill(zu,0,a),c.fill(0,0,a);const h=(u,d)=>{var f;return((f=e[4*(d*r+u)+3])!==null&&f!==void 0?f:0)/255};for(let u=0;u<i;u++)for(let d=0;d<r;d++){const f=h(d,u),g=(u+s)*o+d+s;if(f>=254/255)e[4*(u*r+d)+3]=255,l[g]=0,c[g]=zu;else if(f>0){const p=.5-f;l[g]=p>0?p*p:0,c[g]=p<0?p*p:0}}},YHt=(t,e,r,i=4,s=3,o=.25)=>{const n=e+i*2,a=r+i*2,l=n*a,c=Math.max(n,a),h=new Uint8Array(l),u=Rgt(c);VHt(u,t,e,r,i);const{outer:d,inner:f,f:g,z:p,v:m}=u;Mgt(d,0,0,n,a,n,g,p,m),Mgt(f,i,i,e,r,n,g,p,m);for(let v=0;v<l;v++){const b=Math.sqrt(d[v])-Math.sqrt(f[v]);h[v]=Math.max(0,Math.min(255,Math.round(255-255*(b/s+o))))}return Tgt(h,n,a)},$Ht=(t,e,r,i,s)=>{const o=r+s*2,n=i+s*2,a=o*n,{outer:l,inner:c}=t;l.fill(zu,0,a),c.fill(0,0,a);const h=(u,d)=>{var f;
7150return(f=e[d*r+u])!==null&&f!==void 0?f:0};for(let u=0;u<i;u++)for(let d=0;d<r;d++){const f=h(d,u);if(!f)continue;const g=(u+s)*o+d+s;f>=254?(e[u*r+d]=255,l[g]=0,c[g]=zu):(l[g]=0,c[g]=0)}},HHt=(t,e,r,i,s,o,n)=>{const a=r+s*2,l=(c,h)=>{var u;return((u=e[h*r+c])!==null&&u!==void 0?u:0)/255};for(let c=0;c<i;c++)for(let h=0;h<r;h++){const u=l(h,c);if(!Vu(u)){const d=h+s+(c+s)*a,f=.5-u;t[d]=Math.max(0,Math.min(255,Math.round(255-255*(f/o+n))))}}},KHt=(t,e,r,i,s,o,n)=>{const a=r+s*2,l=i+s*2,c=a*l,{outer:h,inner:u,xo:d,yo:f,xi:g,yi:p}=t;d.fill(0,0,c),f.fill(0,0,c),g.fill(0,0,c),p.fill(0,0,c);const m=(y,_)=>{var w;return y>=0&&y<r&&_>=0&&_<i?((w=e[_*r+y])!==null&&w!==void 0?w:0)/255:0};for(let y=0;y<i;y++)for(let _=0;_<r;_++){const w=m(_,y),E=(y+s)*a+_+s;if(Vu(w)){if(e9t(w)){const A=m(_-1,y),x=m(_+1,y),S=m(_,y-1),T=m(_,y+1);Vj(A)&&(d[E-1]=.4999,h[E-1]=0,u[E-1]=0),Vj(x)&&(d[E+1]=-.4999,h[E+1]=0,u[E+1]=0),Vj(S)&&(f[E-a]=.4999,h[E-a]=0,u[E-a]=0),Vj(T)&&(f[E+a]=-.4999,h[E+a]=0,u[E+a]=0)}}else{const A=w-.5,x=m(_-1,y),S=m(_+1,y),T=m(_,y-1),R=m(_,y+1),B=m(_-1,y-1),O=m(_+1,y-1),C=m(_-1,y+1),F=m(_+1,y+1),U=(B+x*2+C)/4,H=(O+S*2+F)/4,N=(B+T*2+O)/4,G=(C+R*2+F)/4,Y=Math.min(x,S,T,R,B,O,C,F),q=Math.max(x,S,T,R,B,O,C,F);if(Y>0){u[E]=zu;continue}if(q<1){h[E]=zu;continue}let L=H-U,J=G-N;const tt=1/Math.sqrt(hy(L)+hy(J));L*=tt,J*=tt,d[E]=-A*L,f[E]=-A*J}}let v=d,b=f;if(o){const y=(_,w,E,A,x,S,T,R,B)=>(S*_+T*w)*(E*A)>0&&(R*_+B*w)*(E*x)>0&&(S*R+T*B)*(A*x)>0;for(let _=0;_<i;_++)for(let w=0;w<r;w++){const E=(_+s)*a+w+s,A=d[E],x=f[E];if(!A&&!x)continue;const S=m(w,_),T=m(w-1,_),R=m(w+1,_),B=m(w,_-1),O=m(w,_+1),C=d[E-1],F=d[E+1],U=d[E-a],H=d[E+a],N=f[E-1],G=f[E+1],Y=f[E-a],q=f[E+a];let L=A,J=x,tt=1;const bt=S-.5,ct=T-.5,Xt=R-.5,It=B-.5,zt=O-.5;!Vu(T)&&!Vu(R)&&y(A,x,bt,ct,Xt,C,N,F,G)&&(L+=(C+F)/2,J+=(N+G)/2,tt++),!Vu(B)&&!Vu(O)&&y(A,x,bt,It,zt,U,Y,H,q)&&(L+=(U+H)/2,J+=(Y+q)/2,tt++),!Vu(T)&&!Vu(B)&&y(A,x,bt,ct,It,C,N,U,Y)&&(L+=(C+U-1)/2,J+=(N+Y-1)/2,tt++),!Vu(R)&&!Vu(B)&&y(A,x,bt,Xt,It,F,G,U,Y)&&(L+=(F+U+1)/2,J+=(G+Y-1)/2,tt++),!Vu(T)&&!Vu(O)&&y(A,x,bt,ct,zt,C,N,H,q)&&(L+=(C+H-1)/2,J+=(N+q+1)/2,tt++),!Vu(R)&&!Vu(O)&&y(A,x,bt,Xt,zt,F,G,H,q)&&(L+=(F+H+1)/2,J+=(G+q+1)/2,tt++);const Ht=Math.sqrt(A*A+x*x),Lt=(L*A+J*x)/Ht;L=A*Lt/tt/Ht,J=x*Lt/tt/Ht,g[E]=L,p[E]=J}v=g,b=p}for(let y=0;y<i;y++)for(let _=0;_<r;_++){const w=(y+s)*a+_+s,E=v[w],A=b[w];if(!E&&!A)continue;const x=Math.sqrt(hy(E)+hy(A)),S=Math.abs(E/x)-.5>0?Math.sign(E):0,T=Math.abs(A/x)-.5>0?Math.sign(A):0,R=m(_,y),B=m(_+S,y+T),O=Math.sign(B-R);let C=x+.4999*O,F=x-.4999*O;F/=x,C/=x,d[w]=E*C,f[w]=A*C,g[w]=E*F,p[w]=A*F}},qHt=(t,e,r,i,s)=>{const o=r+s*2,{xo:n,yo:a,xi:l,yi:c}=t,h=(d,f,g,p,m,v,b,y,_,w)=>{const E=(p+s)*o+g+s,A=m+d[E],x=v+f[E],S=Math.sqrt(hy(A)+hy(x));return S<_?(d[w]=A,f[w]=x,S):_},u=(d,f)=>{for(let g=0;g<i;g++)for(let p=0;p<r;p++){const m=(g+s)*o+p+s,v=d[m],b=f[m];if(!v&&!b)continue;let y=Math.sqrt(v*v+b*b);const _=(y-.5)/y,w=p+v*_,E=g+b*_,A=Math.round(w),x=Math.round(E);y=h(d,f,A+1,x,A-p+1,x-g,w,E,y,m),y=h(d,f,A-1,x,A-p-1,x-g,w,E,y,m),y=h(d,f,A,x+1,A-p,x-g+1,w,E,y,m),y=h(d,f,A,x-1,A-p,x-g-1,w,E,y,m)}};u(n,a),u(l,c)},ZHt=(t,e,r,i,s,o,n)=>{const a=s+n*2,l=o+n*2;{let c=0,h=(n+n*a)*4;for(let u=0;u<o;u++){for(let d=0;d<s;d++)e[c+3]&&(t[h]=e[c],t[h+1]=e[c+1],t[h+2]=e[c+2],t[h+3]=e[c+3]),c+=4,h+=4;h+=n*8}}{let c=0,h=0;for(let u=0;u<l;u++)for(let d=0;d<a;d++){if(t[c+3]===0){const f=r[h],g=i[h],p=Math.round(d+f),m=Math.round(u+g),v=(p+m*a)*4;t[c]=t[v],t[c+1]=t[v+1],t[c+2]=t[v+2],t[c+3]=1}c+=4,h++}}},JHt=(t,e,r,i,s)=>{const o=r+s*2;let n=0,a=(s+s*o)*4;for(let l=0;l<i;l++){for(let c=0;c<r;c++)t[a+3]=e[n],n++,a+=4;a+=s*8}},xgt=(t,e,r,i,s,o,n,a,l,c,h)=>{h[0]=0,l[0]=e[i],c[0]=r[i],a[0]=-zu,a[1]=zu,n[0]=t[i]?zu:r[i]*r[i];let u=0;for(let d=1,f=0;d<o;d++){const g=i+d*s,p=e[g],m=r[g],v=n[d]=t[g]?zu:m*m;c[d]=m;const b=d+p,y=b*b;l[d]=b;do{const _=h[u],w=l[_],E=w*w;f=(v-n[_]+y-E)/(b-w)/2}while(f<=a[u]&&--u>-1);u++,h[u]=d,a[u]=f,a[u+1]=zu}for(let d=0,f=0;d<o;d++){for(;a[f+1]<d;)f++;const g=h[f],p=l[g],m=c[g],v=p-d,b=i+d*s;e[b]=v,r[b]=m,g!==d&&(t[b]=0)}},Sgt=(t,e,r,i,s,o,n,a,l,c,h=0)=>{if(h!==1)for(let u=0;u<i;++u)xgt(t,r,e,u,i,s,o,n,a,l,c);if(h!==2)for(let u=0;u<s;++u)xgt(t,e,r,u*i,1,i,o,n,a,l,c)},QHt=(t,e,r,i,s=4,o=3,n=.25,a=!1,l=!1)=>
7150{const c=r+s*2,h=i+s*2,u=c*h,d=Math.max(c,h),f=Rgt(d),{outer:g,inner:p,xo:m,yo:v,xi:b,yi:y,f:_,z:w,b:E,t:A,v:x}=f;$Ht(f,t,r,i,s),KHt(f,t,r,i,s,a),Sgt(g,m,v,c,h,_,w,E,A,x),Sgt(p,b,y,c,h,_,w,E,A,x),l&&qHt(f,t,r,i,s);const S=new Uint8Array(u);for(let T=0;T<u;++T){const R=Math.max(0,Math.sqrt(hy(m[T])+hy(v[T]))-.5),B=Math.max(0,Math.sqrt(hy(b[T])+hy(y[T]))-.5),O=R>=B?R:-B;S[T]=Math.max(0,Math.min(255,Math.round(255-255*(O/o+n))))}if(a||HHt(S,t,r,i,s,o,n),e){const T=new Uint8Array(u*4);return ZHt(T,e,m,v,r,i,s),JHt(T,S,c,h,0),{data:T,width:c,height:h}}else return Tgt(S,c,h)},Tgt=(t,e,r,i=0)=>{const s=e+i*2,o=r+i*2,n=new Uint8Array(s*o*4);for(let a=0;a<t.length;a++)n[a*4]=t[a],n[a*4+1]=t[a],n[a*4+2]=t[a],n[a*4+3]=t[a];return{data:n,width:s,height:o}},zu=1e10,Rgt=t=>{const e=t*t,r=new Float32Array(e),i=new Float32Array(e),s=new Float32Array(e),o=new Float32Array(e),n=new Float32Array(e),a=new Float32Array(e),l=new Float32Array(t),c=new Float32Array(t+1),h=new Float32Array(t),u=new Float32Array(t),d=new Uint16Array(t);return{outer:r,inner:i,xo:s,yo:o,xi:n,yi:a,f:l,z:c,b:h,t:u,v:d,size:t}};class t9t{constructor({fontSize:e=24,buffer:r=3,radius:i=8,cutoff:s=.25,fontFamily:o="sans-serif",fontWeight:n="normal",fontStyle:a="normal",fill:l="black"}={}){this.buffer=r,this.cutoff=s,this.radius=i;const c=this.size=e+r*4,h=Pr.get().createCanvas(c,c),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=D2({fontStyle:a,fontWeight:n,fontSize:e,fontFamily:o}),u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle=l}draw(e,r=!1,i=!1){const{width:s,actualBoundingBoxAscent:o,actualBoundingBoxDescent:n,actualBoundingBoxLeft:a,actualBoundingBoxRight:l}=this.ctx.measureText(e),c=Math.ceil(o),h=0,u=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(l-a))),d=Math.min(this.size-this.buffer,c+Math.ceil(n));if(u===0||d===0){const _=u+2*this.buffer,w=d+2*this.buffer,E=Math.max(_*w,0);return{data:new Uint8ClampedArray(E*4),width:_,height:w,glyphWidth:u,glyphHeight:d,glyphTop:c,glyphLeft:h,glyphAdvance:s}}const f=this.buffer,{ctx:g,buffer:p}=this;g.clearRect(p,p,u,d),g.fillText(e,p,p+c);const m=g.getImageData(p,p,u,d);let v,b,y;if(r){const _=new Uint8ClampedArray(m.data.length/4);for(let w=0;w<m.data.length;w+=4)_[w/4]=m.data[w+3];({data:v,width:b,height:y}=QHt(_,i?m.data:null,u,d,f,this.radius,this.cutoff))}else({data:v,width:b,height:y}=YHt(m.data,u,d,f,this.radius,this.cutoff));return{data:v,width:b,height:y,glyphWidth:u,glyphHeight:d,glyphTop:c,glyphLeft:h,glyphAdvance:s}}}const Cgt=(t,e,r,i,s,o,n)=>{n[0]=0,o[0]=-zu,o[1]=zu,s[0]=t[e];for(let a=1,l=0,c=0;a<i;a++){s[a]=t[e+a*r];const h=a*a;do{const u=n[l];c=(s[a]-s[u]+h-u*u)/(a-u)/2}while(c<=o[l]&&--l>-1);l++,n[l]=a,o[l]=c,o[l+1]=zu}for(let a=0,l=0;a<i;a++){for(;o[l+1]<a;)l++;const c=n[l],h=a-c,u=s[c];t[e+a*r]=u+h*h}},Mgt=(t,e,r,i,s,o,n,a,l,c)=>{for(let h=r;h<r+s;h++)Cgt(t,h*o+e,1,i,n,a,l);for(let h=e;h<e+i;h++)Cgt(t,r*o+h,o,s,n,a,l)},Vj=t=>!t,e9t=t=>t===1,Vu=t=>!(t&&1-t),hy=t=>t*t;function r9t(){const t=[];for(let e=32;e<128;e++)t.push(String.fromCharCode(e));return t}class i9t{constructor(){this.sdfGeneratorCache={},this.glyphMap={}}destroy(){this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy()}getMap(){return this.glyphMap}getAtlas(){return this.glyphAtlas}getAtlasTexture(){return this.glyphAtlasTexture}layout(e,r,i,s,o,n,a,l,c,h){const u=[];let d=c??0,f=h??0;const g=s==="right"||s==="end"?1:s==="left"||s==="start"?0:.5;return e.forEach(p=>{const m=u.length;let v;Pr.get().splitGraphemes(p).forEach(y=>{let _,w=0;if(n){const E=n.chars[y];_=E.xAdvance,w=l&&v&&E.kerning[v]||0}else{const E=this.glyphMap[r];_=(E&&E[y]).metrics.advance}u.push({glyph:y,x:d,y:f,scale:a,fontStack:r}),d+=(_+w)*a+o,v=y});const b=d-o;for(let y=m;y<u.length;y++)u[y].x-=g*b;d=0,f+=i}),u}generateAtlas(e="",r,i,s="",o,n,a,l){let c=[];this.glyphMap[e]||(c=r9t());const h=Object.keys(this.glyphMap[e]||{});if(Array.from(new Set(Pr.get().splitGraphemes(o))).forEach(u=>{h.indexOf(u)===-1&&c.push(u)}),c.length){const u=c.map(p=>this.generateSDF(e,r,i,s,p,a,l)).reduce((p,m)=>(p[m.id]=m,p),{});this.glyphMap[e]=Object.assign(Object.assign({},this.glyphMap[e]),u),this.glyphAtlas=new d$t(this.glyphMap);const{width:d,height:f,data:g}=this.glyphAtlas.image;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=n.createTexture(Object.assign({},qXt(X.U8_RGBA_NORM,d,f,1))),this.glyphAtlasTexture.setImageData([g])}}generateSDF(e="",r,i,s,o,n,a){let l=this.sdfGeneratorCache[e+a];l||(l=this.sdfGeneratorCache[e+a]=new t9t({fontSize:Ppt,fontFamily:r,fontWeight:i,fontStyle:s,buffer:Fpt,radius:u$t,fill:a}));const{data:c,width:h,height:u,glyphWidth:d,glyphHeight:f,glyphLeft:g,glyphTop:p,glyphAdvance:m}=l.draw(o,n,!!a);return{id:o,bitmap:new Lq({width:h,height:u}
7150,c),metrics:{width:d/Fd,height:f/Fd,left:g/Fd,top:p/Fd,advance:m/Fd}}}}function s9t(t,e,r){const i=[];for(let s=0;s<t.length;s++){const o=t[s],n=e[o.fontStack],a=n&&n[o.glyph];if(!a)continue;const{rect:l,metrics:c}=a;if(!l)continue;const{x:h,y:u,scale:d}=o,f=r?0:Fpt/Fd+Npt,g=1,p=l.w*d/(g*(r?1:Fd)),m=l.h*d/(g*(r?1:Fd)),v=(c.left-f)*o.scale+h,b=(-c.top-f)*o.scale+u,y=v+p,_=b+m,w={x:v,y:b},E={x:y,y:b},A={x:v,y:_},x={x:y,y:_};i.push({tl:w,tr:E,bl:A,br:x,tex:l})}return i}function Bgt(t){return t.__id!==void 0}var o9t=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};SV=function(t){return o9t(this,void 0,void 0,function*(){var e;if(typeof t=="string"){const r=yield Pr.get().createImage(t),i=Pr.get().getDocument().createElement("canvas");return i.width=r.width,i.height=r.height,i.getContext("2d").drawImage(r,0,0),(e=r.close)===null||e===void 0||e.call(r),i}else{const r=Pr.get().getDocument().createElement("canvas");return r.width=t.width,r.height=t.height,r.getContext("2d").drawImage(t,0,0),Promise.resolve(r)}})};function n9t(t){return{a:parseFloat(t.a),b:parseFloat(t.b),c:parseFloat(t.c),d:parseFloat(t.d),e:parseFloat(t.e),f:parseFloat(t.f)}}function d3(t){return typeof t>"u"}function Jx(t,e=0){return{a:1,c:0,e:t,b:0,d:1,f:e}}function Yj(...t){t=Array.isArray(t[0])?t[0]:t;const e=(r,i)=>({a:r.a*i.a+r.c*i.b,c:r.a*i.c+r.c*i.d,e:r.a*i.e+r.c*i.f+r.e,b:r.b*i.a+r.d*i.b,d:r.b*i.c+r.d*i.d,f:r.b*i.e+r.d*i.f+r.f});switch(t.length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return e(t[0],t[1]);default:{const[r,i,...s]=t,o=e(r,i);return Yj(o,...s)}}}function $j(...t){return Yj(...t)}const{cos:a9t,sin:l9t,PI:c9t}=Math;function h9t(t,e,r){const i=a9t(t),s=l9t(t),o={a:i,c:-s,e:0,b:s,d:i,f:0};return d3(e)||d3(r)?o:Yj([Jx(e,r),o,Jx(-e,-r)])}function eZ(t,e=void 0,r=void 0){return h9t(t*c9t/180,e,r)}function P2(t,e=void 0,r=void 0,i=void 0){d3(e)&&(e=t);const s={a:t,c:0,e:0,b:0,d:e,f:0};return d3(r)||d3(i)?s:Yj([Jx(r,i),s,Jx(-r,-i)])}function u9t(t,e){return{a:1,c:t,e:0,b:e,d:1,f:0}}const{tan:Ogt}=Math;function d9t(t,e){return{a:1,c:Ogt(t),e:0,b:Ogt(e),d:1,f:0}}function Igt(t,e){return d9t(t*Math.PI/180,e*Math.PI/180)}function f9t(t){return Array.isArray(t)?t.map(e):e(t);function e(r){switch(r.type){case"matrix":if("a"in r&&"b"in r&&"c"in r&&"d"in r&&"e"in r&&"f"in r)return n9t(r);throw new Error("MISSING_MANDATORY_PARAM");case"translate":if(!("tx"in r))throw new Error("MISSING_MANDATORY_PARAM");return"ty"in r?Jx(r.tx,r.ty):Jx(r.tx);case"scale":if(!("sx"in r))throw new Error("MISSING_MANDATORY_PARAM");return"sy"in r?P2(r.sx,r.sy):P2(r.sx);case"rotate":if(!("angle"in r))throw new Error("MISSING_MANDATORY_PARAM");return"cx"in r&&"cy"in r?eZ(r.angle,r.cx,r.cy):eZ(r.angle);case"skewX":if(!("angle"in r))throw new Error("MISSING_MANDATORY_PARAM");return Igt(r.angle,0);case"skewY":if(!("angle"in r))throw new Error("MISSING_MANDATORY_PARAM");return Igt(0,r.angle);case"shear":if(!("shx"in r&&"shy"in r))throw new Error("MISSING_MANDATORY_PARAM");return u9t(r.shx,r.shy);default:throw new Error("UNSUPPORTED_DESCRIPTOR")}}}function p9t(t,e){function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r}function F2(t,e,r,i){var s=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(s,F2.prototype),s.expected=e,s.found=r,s.location=i,s.name="SyntaxError",s}p9t(F2,Error);function rZ(t,e,r){return r=r||" ",t.length>e?t:(e-=t.length,r+=r.repeat(e),t+r.slice(0,e))}F2.prototype.format=function(t){var e="Error: "+this.message;if(this.location){var r=null,i;for(i=0;i<t.length;i++)if(t[i].source===this.location.source){r=t[i].text.split(/\r\n|\n|\r/g);break}var s=this.location.start,o=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(s):s,n=this.location.source+":"+o.line+":"+o.column;if(r){var a=this.location.end,l=rZ("",o.line.toString().length," "),c=r[s.line-1],h=s.line===a.line?a.column:c.length+1,u=h-s.column||1;e+=` 7151 --> `+n+` 7152`+l+` | 7153`+o.line+" | "+c+` 7154`+l+" | "+rZ("",s.column-1," ")+rZ("",u,"^")}else e+=` 7155 at `+n}return e},F2.buildMessage=function(t,e){var r={literal:function(c){return'"'+s(c.text)+'"'},class:function(c){var h=c.parts.map(function(u){return Array.isArray(u)?o(u[0])+"-"+o(u[1]):o(u)});return"["+(c.inverted?"^":"")+h.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(c){return c.description}};
7155function i(c){return c.charCodeAt(0).toString(16).toUpperCase()}function s(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+i(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+i(h)})}function o(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+i(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+i(h)})}function n(c){return r[c.type](c)}function a(c){var h=c.map(n),u,d;if(h.sort(),h.length>0){for(u=1,d=1;u<h.length;u++)h[u-1]!==h[u]&&(h[d]=h[u],d++);h.length=d}switch(h.length){case 1:return h[0];case 2:return h[0]+" or "+h[1];default:return h.slice(0,-1).join(", ")+", or "+h[h.length-1]}}function l(c){return c?'"'+s(c)+'"':"end of input"}return"Expected "+a(t)+" but "+l(e)+" found."};function g9t(t,e){e=e!==void 0?e:{};var r={},i=e.grammarSource,s={transformList:Es},o=Es,n="matrix",a="(",l=")",c="translate",h="scale",u="rotate",d="skewX",f="skewY",g=",",p=".",m=/^[eE]/,v=/^[+\-]/,b=/^[0-9]/,y=/^[ \t\r\n]/,_=st("matrix",!1),w=st("(",!1),E=st(")",!1),A=st("translate",!1),x=st("scale",!1),S=st("rotate",!1),T=st("skewX",!1),R=st("skewY",!1),B=st(",",!1),O=mi("fractionalConstant"),C=st(".",!1),F=ve(["e","E"],!1,!1),U=ve(["+","-"],!1,!1),H=ve([["0","9"]],!1,!1),N=ve([" "," ","\r",` 7156`],!1,!1),G=function(V){return V},Y=function(V,pt){return V.concat(pt)},q=function(V,pt,Ot,ee,qr,Oe){return[{type:"matrix",a:V,b:pt,c:Ot,d:ee,e:qr,f:Oe}]},L=function(V,pt){var Ot={type:"translate",tx:V};return pt&&(Ot.ty=pt),[Ot]},J=function(V,pt){var Ot={type:"scale",sx:V};return pt&&(Ot.sy=pt),[Ot]},tt=function(V,pt){var Ot={type:"rotate",angle:V};return pt&&(Ot.cx=pt[0],Ot.cy=pt[1]),[Ot]},bt=function(V){return[{type:"skewX",angle:V}]},ct=function(V){return[{type:"skewY",angle:V}]},Xt=function(V){return parseFloat(V.join(""))},It=function(V){return parseInt(V.join(""))},zt=function(V){return V},Ht=function(V,pt){return[V,pt]},Lt=function(V){return V.join("")},tr=function(V,pt){return[V,pt||null].join("")},Gr=function(V,pt){return[V,pt].join("")},re=function(V,pt){return[V?V.join(""):null,".",pt.join("")].join("")},ci=function(V){return V.join("")},Dt=function(V,pt){return["e",V,pt.join("")].join("")},rt=e.peg$currPos|0,At=[{line:1,column:1}],Vt=rt,de=e.peg$maxFailExpected||[],Rt=e.peg$silentFails|0,De;if(e.startRule){if(!(e.startRule in s))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');o=s[e.startRule]}function st(V,pt){return{type:"literal",text:V,ignoreCase:pt}}function ve(V,pt,Ot){return{type:"class",parts:V,inverted:pt,ignoreCase:Ot}}function Ct(){return{type:"end"}}function mi(V){return{type:"other",description:V}}function ws(V){var pt=At[V],Ot;if(pt)return pt;if(V>=At.length)Ot=At.length-1;else for(Ot=V;!At[--Ot];);for(pt=At[Ot],pt={line:pt.line,column:pt.column};Ot<V;)t.charCodeAt(Ot)===10?(pt.line++,pt.column=1):pt.column++,Ot++;return At[V]=pt,pt}function $r(V,pt,Ot){var ee=ws(V),qr=ws(pt),Oe={source:i,start:{offset:V,line:ee.line,column:ee.column},end:{offset:pt,line:qr.line,column:qr.column}};return Oe}function Ne(V){rt<Vt||(rt>Vt&&(Vt=rt,de=[]),de.push(V))}function mo(V,pt,Ot){return new F2(F2.buildMessage(V,pt),V,pt,Ot)}function Es(){var V,pt,Ot,ee,qr;for(V=rt,pt=[],Ot=lr();Ot!==r;)pt.push(Ot),Ot=lr();for(Ot=z(),Ot===r&&(Ot=null),ee=[],qr=lr();qr!==r;)ee.push(qr),qr=lr();return V=G(Ot),V}function z(){var V,pt,Ot,ee;if(V=rt,pt=ut(),pt!==r){if(Ot=[],ee=Ye(),ee!==r)for(;ee!==r;)Ot.push(ee),ee=Ye();else Ot=r;Ot!==r?(ee=z(),ee!==r?V=Y(pt,ee):(rt=V,V=r)):(rt=V,V=r)}else rt=V,V=r;return V===r&&(V=ut()),V}function ut(){var V;return V=M(),V===r&&(V=D(),V===r&&(V=k(),V===r&&(V=j(),V===r&&(V=Q(),V===r&&(V=ft()))))),V}function M(){var V,pt,Ot,ee,qr,Oe,mt,Pt,He,ui,kl,rc,Kg,Wd,qg,jd,Jf,kc;if(V=rt,t.substr(rt,6)===n?(pt=n,rt+=6):(pt=r,Rt===0&&Ne(_)),pt!==r){for(Ot=[],ee=lr();ee!==r;)Ot.push(ee),ee=lr();if(t.charCodeAt(rt)===40?(ee=a,rt++):(ee=r,Rt===0&&Ne(w)),ee!==r){for(qr=[],Oe=lr();Oe!==r;)qr.push(Oe),Oe=lr();if(Oe=ht(),Oe!==r)if(mt=Ye(),mt!==r)if(Pt=ht(),Pt!==r)if(He=Ye(),He!==r)if(ui=ht(),ui!==r)if(kl=Ye(),kl!==r)if(rc=ht(),rc!==r)if(Kg=Ye(),Kg!==r)if(Wd=ht(),Wd!==r)if(qg=Ye(),qg!==r)if(jd=ht(),jd!==r){for(Jf=[],kc=lr();kc!==r;)Jf.push(kc),kc=lr();t.charCodeAt(rt)===41?(kc=l,rt++):(kc=r,Rt===0&&Ne(E)),kc!==r?V=q(Oe,Pt,ui,rc,Wd,jd):(rt=V,V=r)}
7156else rt=V,V=r;else rt=V,V=r;else rt=V,V=r;else rt=V,V=r;else rt=V,V=r;else rt=V,V=r;else rt=V,V=r;else rt=V,V=r;else rt=V,V=r;else rt=V,V=r;else rt=V,V=r}else rt=V,V=r}else rt=V,V=r;return V}function D(){var V,pt,Ot,ee,qr,Oe,mt,Pt,He;if(V=rt,t.substr(rt,9)===c?(pt=c,rt+=9):(pt=r,Rt===0&&Ne(A)),pt!==r){for(Ot=[],ee=lr();ee!==r;)Ot.push(ee),ee=lr();if(t.charCodeAt(rt)===40?(ee=a,rt++):(ee=r,Rt===0&&Ne(w)),ee!==r){for(qr=[],Oe=lr();Oe!==r;)qr.push(Oe),Oe=lr();if(Oe=ht(),Oe!==r){for(mt=ge(),mt===r&&(mt=null),Pt=[],He=lr();He!==r;)Pt.push(He),He=lr();t.charCodeAt(rt)===41?(He=l,rt++):(He=r,Rt===0&&Ne(E)),He!==r?V=L(Oe,mt):(rt=V,V=r)}else rt=V,V=r}else rt=V,V=r}else rt=V,V=r;return V}function k(){var V,pt,Ot,ee,qr,Oe,mt,Pt,He;if(V=rt,t.substr(rt,5)===h?(pt=h,rt+=5):(pt=r,Rt===0&&Ne(x)),pt!==r){for(Ot=[],ee=lr();ee!==r;)Ot.push(ee),ee=lr();if(t.charCodeAt(rt)===40?(ee=a,rt++):(ee=r,Rt===0&&Ne(w)),ee!==r){for(qr=[],Oe=lr();Oe!==r;)qr.push(Oe),Oe=lr();if(Oe=ht(),Oe!==r){for(mt=ge(),mt===r&&(mt=null),Pt=[],He=lr();He!==r;)Pt.push(He),He=lr();t.charCodeAt(rt)===41?(He=l,rt++):(He=r,Rt===0&&Ne(E)),He!==r?V=J(Oe,mt):(rt=V,V=r)}else rt=V,V=r}else rt=V,V=r}else rt=V,V=r;return V}function j(){var V,pt,Ot,ee,qr,Oe,mt,Pt,He;if(V=rt,t.substr(rt,6)===u?(pt=u,rt+=6):(pt=r,Rt===0&&Ne(S)),pt!==r){for(Ot=[],ee=lr();ee!==r;)Ot.push(ee),ee=lr();if(t.charCodeAt(rt)===40?(ee=a,rt++):(ee=r,Rt===0&&Ne(w)),ee!==r){for(qr=[],Oe=lr();Oe!==r;)qr.push(Oe),Oe=lr();if(Oe=ht(),Oe!==r){for(mt=Ge(),mt===r&&(mt=null),Pt=[],He=lr();He!==r;)Pt.push(He),He=lr();t.charCodeAt(rt)===41?(He=l,rt++):(He=r,Rt===0&&Ne(E)),He!==r?V=tt(Oe,mt):(rt=V,V=r)}else rt=V,V=r}else rt=V,V=r}else rt=V,V=r;return V}function Q(){var V,pt,Ot,ee,qr,Oe,mt,Pt;if(V=rt,t.substr(rt,5)===d?(pt=d,rt+=5):(pt=r,Rt===0&&Ne(T)),pt!==r){for(Ot=[],ee=lr();ee!==r;)Ot.push(ee),ee=lr();if(t.charCodeAt(rt)===40?(ee=a,rt++):(ee=r,Rt===0&&Ne(w)),ee!==r){for(qr=[],Oe=lr();Oe!==r;)qr.push(Oe),Oe=lr();if(Oe=ht(),Oe!==r){for(mt=[],Pt=lr();Pt!==r;)mt.push(Pt),Pt=lr();t.charCodeAt(rt)===41?(Pt=l,rt++):(Pt=r,Rt===0&&Ne(E)),Pt!==r?V=bt(Oe):(rt=V,V=r)}else rt=V,V=r}else rt=V,V=r}else rt=V,V=r;return V}function ft(){var V,pt,Ot,ee,qr,Oe,mt,Pt;if(V=rt,t.substr(rt,5)===f?(pt=f,rt+=5):(pt=r,Rt===0&&Ne(R)),pt!==r){for(Ot=[],ee=lr();ee!==r;)Ot.push(ee),ee=lr();if(t.charCodeAt(rt)===40?(ee=a,rt++):(ee=r,Rt===0&&Ne(w)),ee!==r){for(qr=[],Oe=lr();Oe!==r;)qr.push(Oe),Oe=lr();if(Oe=ht(),Oe!==r){for(mt=[],Pt=lr();Pt!==r;)mt.push(Pt),Pt=lr();t.charCodeAt(rt)===41?(Pt=l,rt++):(Pt=r,Rt===0&&Ne(E)),Pt!==r?V=ct(Oe):(rt=V,V=r)}else rt=V,V=r}else rt=V,V=r}else rt=V,V=r;return V}function ht(){var V,pt,Ot,ee;return V=rt,pt=rt,Ot=zs(),Ot===r&&(Ot=null),ee=hi(),ee!==r?(Ot=[Ot,ee],pt=Ot):(rt=pt,pt=r),pt!==r&&(pt=Xt(pt)),V=pt,V===r&&(V=rt,pt=rt,Ot=zs(),Ot===r&&(Ot=null),ee=Wr(),ee!==r?(Ot=[Ot,ee],pt=Ot):(rt=pt,pt=r),pt!==r&&(pt=It(pt)),V=pt),V}function ge(){var V,pt,Ot;return V=rt,pt=Ye(),pt!==r?(Ot=ht(),Ot!==r?V=zt(Ot):(rt=V,V=r)):(rt=V,V=r),V}function Ge(){var V,pt,Ot,ee,qr;return V=rt,pt=Ye(),pt!==r?(Ot=ht(),Ot!==r?(ee=Ye(),ee!==r?(qr=ht(),qr!==r?V=Ht(Ot,qr):(rt=V,V=r)):(rt=V,V=r)):(rt=V,V=r)):(rt=V,V=r),V}function Ye(){var V,pt,Ot,ee,qr;if(V=rt,pt=[],Ot=lr(),Ot!==r)for(;Ot!==r;)pt.push(Ot),Ot=lr();else pt=r;if(pt!==r){for(Ot=Ki(),Ot===r&&(Ot=null),ee=[],qr=lr();qr!==r;)ee.push(qr),qr=lr();pt=[pt,Ot,ee],V=pt}else rt=V,V=r;if(V===r)if(V=rt,pt=Ki(),pt!==r){for(Ot=[],ee=lr();ee!==r;)Ot.push(ee),ee=lr();pt=[pt,Ot],V=pt}else rt=V,V=r;return V}function Ki(){var V;return t.charCodeAt(rt)===44?(V=g,rt++):(V=r,Rt===0&&Ne(B)),V}function Wr(){var V,pt;return V=rt,pt=qu(),pt!==r&&(pt=Lt(pt)),V=pt,V}function hi(){var V,pt,Ot;return V=rt,pt=Xs(),pt!==r?(Ot=Kr(),Ot===r&&(Ot=null),V=tr(pt,Ot)):(rt=V,V=r),V===r&&(V=rt,pt=qu(),pt!==r?(Ot=Kr(),Ot!==r?V=Gr(pt,Ot):(rt=V,V=r)):(rt=V,V=r)),V}function Xs(){var V,pt,Ot,ee;return Rt++,V=rt,pt=qu(),pt===r&&(pt=null),t.charCodeAt(rt)===46?(Ot=p,rt++):(Ot=r,Rt===0&&Ne(C)),Ot!==r?(ee=qu(),ee!==r?V=re(pt,ee):(rt=V,V=r)):(rt=V,V=r),V===r&&(V=rt,pt=qu(),pt!==r?(t.charCodeAt(rt)===46?(Ot=p,rt++):(Ot=r,Rt===0&&Ne(C)),Ot!==r?V=ci(pt):(rt=V,V=r)):(rt=V,V=r)),Rt--,V===r&&(pt=r,Rt===0&&Ne(O)),V}function Kr(){var V,pt,Ot,ee;return V=rt,pt=t.charAt(rt),m.test(pt)?rt++:(pt=r,Rt===0&&Ne(F)),pt!==r?(Ot=zs(),Ot===r&&(Ot=null),ee=qu(),ee!==r?V=Dt(Ot,ee):(rt=V,V=r)):(rt=V,V=r),V}function zs(){var V;return V=t.charAt(rt),v.test(V)?rt++:(V=r,Rt===0&&Ne(U)),V}function qu(){var V,pt;if(V=[],pt=vv(),pt!==r)for(;pt!==r;)V.push(pt),pt=vv();else V=r;return V}function vv(){var V;return V=t.charAt(rt),b.test(V)?rt++:(V=r,Rt===0&&Ne(H)),V}function lr(){var V;return V=t.charAt(rt),y.test(V)?rt++:(V=r,Rt===0&&Ne(N)),V}if(De=o(),e.peg$library)return{peg$result:De,peg$currPos:rt,peg$FAILED:r,peg$maxFailExpected:de,peg$maxFailPos:Vt};
7156if(De!==r&&rt===t.length)return De;throw De!==r&&rt<t.length&&Ne(Ct()),mo(de,Vt<t.length?t.charAt(Vt):null,Vt<t.length?$r(Vt,Vt+1):$r(Vt,Vt))}function m9t(t){return g9t(t)}function y9t(t,e=!1,r=!1){e?r?t=$j(t,P2(-1,-1)):t=$j(t,P2(1,-1)):r&&(t=$j(t,P2(-1,1)));const i=t.a,s=t.b,o=t.c,n=t.d;let a,l,c;if(i!==0||o!==0){const h=Math.hypot(i,o);a=h,l=(i*n-s*o)/h;const u=Math.acos(i/h);c=o>0?-u:u}else if(s!==0||n!==0){const h=Math.hypot(s,n);a=(i*n-s*o)/h,l=h;const u=Math.acos(s/h);c=Math.PI/2+(n>0?-u:u)}else a=0,l=0,c=0;return r&&(a=-a),e&&(l=-l),{translate:{tx:t.e,ty:t.f},scale:{sx:a,sy:l},rotation:{angle:c}}}var Hj={exports:{}},Dgt;function v9t(){if(Dgt)return Hj.exports;Dgt=1,Hj.exports=function(s){return t(e(s),s)},Hj.exports.array=t;function t(s,o){var n=s.length,a=new Array(n),l={},c=n,h=r(o),u=i(s);for(o.forEach(function(f){if(!u.has(f[0])||!u.has(f[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});c--;)l[c]||d(s[c],c,new Set);return a;function d(f,g,p){if(p.has(f)){var m;try{m=", node was:"+JSON.stringify(f)}catch{m=""}throw new Error("Cyclic dependency"+m)}if(!u.has(f))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(f));if(!l[g]){l[g]=!0;var v=h.get(f)||new Set;if(v=Array.from(v),g=v.length){p.add(f);do{var b=v[--g];d(b,u.get(b),p)}while(g);p.delete(f)}a[--n]=f}}}function e(s){for(var o=new Set,n=0,a=s.length;n<a;n++){var l=s[n];o.add(l[0]),o.add(l[1])}return Array.from(o)}function r(s){for(var o=new Map,n=0,a=s.length;n<a;n++){var l=s[n];o.has(l[0])||o.set(l[0],new Set),o.has(l[1])||o.set(l[1],new Set),o.get(l[0]).add(l[1])}return o}function i(s){for(var o=new Map,n=0,a=s.length;n<a;n++)o.set(s[n],n);return o}return Hj.exports}var _9t=v9t();const Pgt=Sv(_9t),Fgt=100;function Ngt(t){return t.has(Lo)}function b9t(t){var e;const r=Hx(t);if(!r)return[.25,.55,.95,1];const i=Wo(r),s=pj(t);return[i.r/255,i.g/255,i.b/255,((e=i.opacity)!==null&&e!==void 0?e:1)*s]}function kgt(t){if(!(t===void 0||t===!1))return t===!0?Fgt:typeof t=="number"&&Number.isFinite(t)&&t>0?t:Fgt}function w9t(t,e,r,i,s){const o=c=>(c+s)/(2*s),n=c=>(c+s)/(2*s),[,a,l]=i;return Math.abs(l)>0?[o(t),n(e)]:Math.abs(a)>0?[o(t),n(r)]:[o(r),n(e)]}function Lgt(){const t=[{normal:[0,0,1],verts:[[-.5,-.5,.5],[.5,-.5,.5],[.5,.5,.5],[-.5,.5,.5]]},{normal:[0,0,-1],verts:[[-.5,-.5,-.5],[-.5,.5,-.5],[.5,.5,-.5],[.5,-.5,-.5]]},{normal:[0,1,0],verts:[[-.5,.5,-.5],[-.5,.5,.5],[.5,.5,.5],[.5,.5,-.5]]},{normal:[0,-1,0],verts:[[-.5,-.5,-.5],[.5,-.5,-.5],[.5,-.5,.5],[-.5,-.5,.5]]},{normal:[1,0,0],verts:[[.5,-.5,-.5],[.5,.5,-.5],[.5,.5,.5],[.5,-.5,.5]]},{normal:[-1,0,0],verts:[[-.5,-.5,-.5],[-.5,-.5,.5],[-.5,.5,.5],[-.5,.5,-.5]]}],e=[],r=[],i=[],s=[];let o=0;for(const{normal:n,verts:a}of t){for(const[l,c,h]of a){e.push(l,c,h),r.push(...n);const[u,d]=w9t(l,c,h,n,.5);i.push(u,d)}s.push(o,o+1,o+2,o,o+2,o+3),o+=4}return{positions:new Float32Array(e),normals:new Float32Array(r),uvs:new Float32Array(i),indices:new Uint32Array(s)}}function Ugt(t,e,r,i,s,o){const n=S=>[s[S*3],s[S*3+1],s[S*3+2]],[a,l,c]=n(e),[h,u,d]=n(r),[f,g,p]=n(i),m=h-a,v=u-l,b=d-c,y=f-a,_=g-l,w=p-c,E=v*w-b*_,A=b*y-m*w,x=m*_-v*y;E*o[0]+A*o[1]+x*o[2]>=0?t.push(e,r,i):t.push(e,i,r)}function E9t(t=24,e=!0){const r=[],i=[],s=[];for(let o=0;o<=t;o++){const n=o/t*Math.PI*2,a=Math.cos(n),l=Math.sin(n);r.push(a*.5,-.5,l*.5,a*.5,.5,l*.5),i.push(a,0,l,a,0,l)}for(let o=0;o<t;o++){const n=o*2,a=n+1,l=n+2,c=n+3;s.push(n,a,c,n,c,l)}if(e){const o=r.length/3;for(let c=0;c<=t;c++){const h=c/t*Math.PI*2;r.push(Math.cos(h)*.5,-.5,Math.sin(h)*.5),i.push(0,-1,0)}const n=[0,-1,0];for(let c=1;c<t;c++)Ugt(s,o,o+c,o+c+1,r,n);const a=r.length/3;for(let c=0;c<=t;c++){const h=c/t*Math.PI*2;r.push(Math.cos(h)*.5,.5,Math.sin(h)*.5),i.push(0,1,0)}const l=[0,1,0];for(let c=1;c<t;c++)Ugt(s,a,a+c+1,a+c,r,l)}return{positions:new Float32Array(r),normals:new Float32Array(i),indices:new Uint32Array(s)}}function A9t(){return{positions:new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),normals:new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1]),indices:new Uint32Array([0,1,2,0,2,3])}}function x9t(t=[24,16]){const[e,r]=t,i=.5,s=[],o=[],n=[],a=[];for(let l=0;l<=r;l++){const c=l/r*Math.PI,h=Math.sin(c),u=Math.cos(c);for(let d=0;d<=e;
7156d++){const f=d/e*Math.PI*2,g=Math.sin(f),p=Math.cos(f),m=-i*h*p,v=i*u,b=i*h*g;s.push(m,v,b),o.push(m/i,v/i,b/i),n.push(1-d/e,1-l/r)}}for(let l=0;l<r;l++)for(let c=0;c<e;c++){const h=l*(e+1)+c,u=h+e+1;a.push(h,u,h+1,u+1,h+1,u)}return{positions:new Float32Array(s),normals:new Float32Array(o),uvs:new Float32Array(n),indices:new Uint32Array(a)}}const S9t=new Set(["cube","sphere","cylinder","plane"]);function Kj(t){return t.type==="gltf"}function iZ(){return{positions:new Float32Array(0),normals:new Float32Array(0),indices:new Uint32Array(0)}}function T9t(t,e){var r,i,s,o,n,a,l,c;if(t.positions.length!==e.positions.length||t.normals.length!==e.normals.length||((i=(r=t.uvs)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0)!==((o=(s=e.uvs)===null||s===void 0?void 0:s.length)!==null&&o!==void 0?o:0)||((a=(n=t.indices)===null||n===void 0?void 0:n.length)!==null&&a!==void 0?a:0)!==((c=(l=e.indices)===null||l===void 0?void 0:l.length)!==null&&c!==void 0?c:0))return!1;for(let h=0;h<t.positions.length;h++)if(t.positions[h]!==e.positions[h])return!1;if(t.uvs&&e.uvs){for(let h=0;h<t.uvs.length;h++)if(t.uvs[h]!==e.uvs[h])return!1}return!0}function yw(t){return t==null?{type:"cube"}:typeof t=="string"?t==="gltf"||!S9t.has(t)?{type:"cube"}:{type:t}:t}function qj(t){return JSON.stringify(t)}function Ggt(t){var e;switch(t.type){case"cube":return Lgt();case"sphere":return x9t(t.segments);case"cylinder":return E9t(t.segments,(e=t.cap)!==null&&e!==void 0?e:!0);case"plane":return A9t();case"gltf":return iZ()}}let Wgt=!1;function Zj(t){Wgt=t}function Jj(){return Wgt}const jgt=new WeakMap,Qj=new WeakSet;function tX(t,e){jgt.set(t,e),Qj.add(t)}function R9t(t){var e;return(e=jgt.get(t))!==null&&e!==void 0?e:!1}bh=function(t){Qj.add(t)};function C9t(t){return Qj.has(t)?(Qj.delete(t),!0):!1}const f3=new WeakMap;function M9t(t="cube"){const e=yw(t);return Kj(e)?iZ():Ggt(e)}function Xgt(t,e){var r;if(!t.has(je)||!e.has(Ns))return!1;const i=yw(t.read(je).geometry),s=qj(i);if(Kj(i))return f3.get(t)===s?!1:(f3.delete(t),Object.assign(e.write(Ns),iZ()),!0);const o=Ggt(i),n=e.read(Ns);return T9t(n,o)?!1:(f3.set(t,s),Object.assign(e.write(Ns),o),e.write(Ns).uvs=(r=o.uvs)!==null&&r!==void 0?r:null,!0)}function B9t(t){f3.delete(t)}function zgt(t){if(!t.has(je))return;const e=yw(t.read(je).geometry);f3.set(t,qj(e))}function sZ(t){return typeof t=="number"?[t,t,t]:t}function N2(t){return t.has(je)||t.has(fh)}function Vgt(t){if(t.has(fe)){const e=t.read(fe).geometryWorldBounds;return[(e.minX+e.maxX)/2,(e.minY+e.maxY)/2]}if(t.has(_e)&&t.has($t)){const{x:e,y:r}=t.read(_e).translation,{width:i,height:s}=t.read($t);return[e+i/2,r+s/2]}}function eX(t,e){var r,i,s;if(!t.has(je))return!1;const o=Vgt(t);if(!o)return!1;const n=t.read(je),[a,l]=o;Object.assign(e.write(ki),{translation:[a,l,n.z],rotation:[...n.rotation3d],scale:sZ(n.scale3d)});const c=e.write(Ni);return c.baseColor=[...n.baseColor],c.ambient=n.ambient,c.diffuse=n.diffuse,c.specular=n.specular,c.shininess=n.shininess,c.metallic=n.metallic,c.roughness=n.roughness,c.map=(r=n.map)!==null&&r!==void 0?r:null,c.specularMap=(i=n.specularMap)!==null&&i!==void 0?i:null,c.bumpMap=(s=n.bumpMap)!==null&&s!==void 0?s:null,c.bumpScale=n.bumpScale,!0}function O9t(t,e){if(!t.has(je)||!e.has(ki))return!1;const{translation:r,rotation:i,scale:s}=e.read(ki),o=t.write(je);o.z=r[2],o.rotation3d=[...i];const[n,a,l]=s;if(o.scale3d=Math.abs(n-a)<1e-4&&Math.abs(a-l)<1e-4?n:[n,a,l],t.has(_e)){let c=0,h=0;if(t.has($t)){const u=t.read($t);c=u.width,h=u.height}Object.assign(t.write(_e).translation,{x:r[0]-c/2,y:r[1]-h/2})}return!0}function oZ(t,e,r){t.has(ks)&&(e.has(ar)||e.add(ar,{mode:"transform",activeAxis:"none",activePartKind:null,dragging:!1}),tX(r,!0))}function nZ(t,e=[1,1,1,1]){if(t==null)return e;if(Array.isArray(t))return t;const r=t.trim();if(r.startsWith("#")){const s=r.slice(1);if(s.length===3){const o=parseInt(s[0]+s[0],16)/255,n=parseInt(s[1]+s[1],16)/255,a=parseInt(s[2]+s[2],16)/255;return[o,n,a,1]}if(s.length>=6){const o=parseInt(s.slice(0,2),16)/255,n=parseInt(s.slice(2,4),16)/255,a=parseInt(s.slice(4,6),16)/255,l=s.length>=8?parseInt(s.slice(6,8),16)/255:1;return[o,n,a,l]}}const i=r.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?\s*\)/);if(i){const s=o=>o>1?o/255:o;return[s(Number(i[1])),s(Number(i[2])),s(Number(i[3])),i[4]!=null?s(Number(i[4])):1]}return e}function Ygt(t,e=[1,1,1]){if(Array.isArray(t))return t;const r=nZ(t,[...e,1]);return[r[0],r[1],r[2]]}var p3=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
7156a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};class Qe{constructor(e=1/0,r=1/0,i=-1/0,s=-1/0,o=ie.IDENTITY){this.minX=e,this.minY=r,this.maxX=i,this.maxY=s,this.matrix=o}addBounds(e,r){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,r||this.matrix)}addFrame(e,r,i,s,o){o||(o=this.matrix);const n=o.m00,a=o.m01,l=o.m10,c=o.m11,h=o.m20,u=o.m21;let d=this.minX,f=this.minY,g=this.maxX,p=this.maxY,m=n*e+l*r+h,v=a*e+c*r+u;m<d&&(d=m),v<f&&(f=v),m>g&&(g=m),v>p&&(p=v),m=n*i+l*r+h,v=a*i+c*r+u,m<d&&(d=m),v<f&&(f=v),m>g&&(g=m),v>p&&(p=v),m=n*e+l*s+h,v=a*e+c*s+u,m<d&&(d=m),v<f&&(f=v),m>g&&(g=m),v>p&&(p=v),m=n*i+l*s+h,v=a*i+c*s+u,m<d&&(d=m),v<f&&(f=v),m>g&&(g=m),v>p&&(p=v),this.minX=d,this.minY=f,this.maxX=g,this.maxY=p}}p3([P({type:$.float32,default:1/0})],Qe.prototype,"minX",void 0),p3([P({type:$.float32,default:1/0})],Qe.prototype,"minY",void 0),p3([P({type:$.float32,default:-1/0})],Qe.prototype,"maxX",void 0),p3([P({type:$.float32,default:-1/0})],Qe.prototype,"maxY",void 0),p3([P({type:Xx,default:ie.IDENTITY})],Qe.prototype,"matrix",void 0);const g3=$.vector($.float32,["minX","minY","maxX","maxY"],Qe);class Ai{static fromArray(e){return new Ai(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}static fromGLMat4(e){return Ai.fromArray(e)}static toGLMat4(e){return ROt(e.m00,e.m01,e.m02,e.m03,e.m10,e.m11,e.m12,e.m13,e.m20,e.m21,e.m22,e.m23,e.m30,e.m31,e.m32,e.m33)}static perspective(e,r,i,s){const o=cc();return OOt(o,e,r,i,s),Ai.fromGLMat4(o)}static lookAt(e,r,i){const s=cc();return POt(s,e,r,i),Ai.fromGLMat4(s)}static ortho(e,r,i,s,o,n){const a=cc();return DOt(a,e,r,i,s,o,n),Ai.fromGLMat4(a)}static multiply(e,r){const i=cc();return B$(i,Ai.toGLMat4(e),Ai.toGLMat4(r)),Ai.fromGLMat4(i)}toFloat32Array(){return new Float32Array([this.m00,this.m01,this.m02,this.m03,this.m10,this.m11,this.m12,this.m13,this.m20,this.m21,this.m22,this.m23,this.m30,this.m31,this.m32,this.m33])}constructor(e=0,r=0,i=0,s=0,o=0,n=0,a=0,l=0,c=0,h=0,u=0,d=0,f=0,g=0,p=0,m=0){this.m00=e,this.m01=r,this.m02=i,this.m03=s,this.m10=o,this.m11=n,this.m12=a,this.m13=l,this.m20=c,this.m21=h,this.m22=u,this.m23=d,this.m30=f,this.m31=g,this.m32=p,this.m33=m}}Ai.IDENTITY=Ai.fromArray([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);const I9t=$.vector($.float32,["m00","m01","m02","m03","m10","m11","m12","m13","m20","m21","m22","m23","m30","m31","m32","m33"],Ai);var Qx=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};class Yu{constructor(e={}){var r,i,s,o,n,a,l;this.x=(r=e.x)!==null&&r!==void 0?r:0,this.y=(i=e.y)!==null&&i!==void 0?i:0,this.width=(s=e.width)!==null&&s!==void 0?s:0,this.height=(o=e.height)!==null&&o!==void 0?o:0,this.rotation=(n=e.rotation)!==null&&n!==void 0?n:0,this.scaleX=(a=e.scaleX)!==null&&a!==void 0?a:1,this.scaleY=(l=e.scaleY)!==null&&l!==void 0?l:1}}Qx([P({type:$.float32,default:0})],Yu.prototype,"x",void 0),Qx([P({type:$.float32,default:0})],Yu.prototype,"y",void 0),Qx([P({type:$.float32,default:0})],Yu.prototype,"width",void 0),Qx([P({type:$.float32,default:0})],Yu.prototype,"height",void 0),Qx([P({type:$.float32,default:0})],Yu.prototype,"rotation",void 0),Qx([P({type:$.float32,default:1})],Yu.prototype,"scaleX",void 0),Qx([P({type:$.float32,default:1})],Yu.prototype,"scaleY",void 0);const rX=$.vector($.float32,["x","y","width","height","rotation","scaleX","scaleY"],Yu);var iX=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};ae=class{static getGeometryBounds(t){const{cx:e,cy:r,rx:i,ry:s}=t;return new Qe(e-i,r-s,e+i,r+s)}static getRenderBounds(t,e){const{cx:r,cy:i,rx:s,ry:o}=t,n=o3(e);return new Qe(r-s-n,i-o-n,r+s+n,i+o+n)}constructor(t){this.cx=t==null?void 0:t.cx,this.cy=t==null?void 0:t.cy,this.rx=t==null?void 0:t.rx,this.ry=t==null?void 0:t.ry}},iX([P({type:$.float32,default:0})],ae.prototype,"cx",void 0),iX([P({type:$.float32,default:0})],ae.prototype,"cy",void 0),iX([P({type:$.float32,default:0})],ae.prototype,"rx",void 0),iX([P({type:$.float32,default:0})],ae.prototype,"ry",void 0);var m3=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
7156a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};function $gt(t){const{x1:e,y1:r,x2:i,y2:s}=t;return e==null||r==null||i==null||s==null?"":`M ${e} ${r} L ${i} ${s}`}ktt=function(t){return e=>{const r=$gt(e);if(!r)return new Qe(0,0,0,0);try{const o=t({d:r});if(o&&Number.isFinite(o.minX+o.minY+o.maxX+o.maxY))return new Qe(o.minX,o.minY,o.maxX,o.maxY)}catch{}const i=Mt.geometryBoundsProvider;Mt.geometryBoundsProvider=null;const s=Mt.getGeometryBounds(e);return Mt.geometryBoundsProvider=i,s}},Ltt=function(t){return(e,r,i)=>{const s=$gt(e);if(!s)return new Qe(0,0,0,0);try{const a={d:s};r&&r.width>0&&(a.stroke={width:r.width,linecap:r.linecap,linejoin:r.linejoin,miterLimit:r.miterlimit,alignment:r.alignment,dasharray:r.dasharray?[...r.dasharray]:void 0,dashoffset:r.dashoffset,blur:0}),i&&(a.markerStart=i.start,a.markerEnd=i.end,a.markerFactor=i.factor);const l=t(a);if(l&&Number.isFinite(l.minX+l.minY+l.maxX+l.maxY))return new Qe(l.minX,l.minY,l.maxX,l.maxY)}catch{}const o=Mt.renderBoundsProvider;Mt.renderBoundsProvider=null;const n=Mt.getRenderBounds(e,r,i);return Mt.renderBoundsProvider=o,n}},Wtt=function(t){return e=>{const r=`M ${e.x1} ${e.y1} L ${e.x2} ${e.y2}`;try{const i={d:r,x:e.x,y:e.y,fill:!1,fillRule:"nonzero"};return e.stroke&&e.stroke.width>0&&(i.stroke={width:e.stroke.width,linecap:e.stroke.linecap,linejoin:e.stroke.linejoin,miterLimit:e.stroke.miterlimit,alignment:e.stroke.alignment,dasharray:e.stroke.dasharray?[...e.stroke.dasharray]:void 0,dashoffset:e.stroke.dashoffset,blur:0}),t(i)}catch{return!1}}},Mt=class{static getGeometryBounds(t){if(Mt.geometryBoundsProvider)return Mt.geometryBoundsProvider(t);const{x1:e,y1:r,x2:i,y2:s}=t;return new Qe(Math.min(e,i),Math.min(r,s),Math.max(e,i),Math.max(r,s))}static getRenderBounds(t,e,r){if(Mt.renderBoundsProvider)return Mt.renderBoundsProvider(t,e,r);const{width:i=0,linecap:s="butt"}=e??{};let o=.5;s==="square"&&(o=Math.SQRT1_2),o*=i;const{minX:n,minY:a,maxX:l,maxY:c}=Mt.getGeometryBounds(t);return new Qe(n-o,a-o,l+o,c+o)}constructor(t){Object.assign(this,t)}},Mt.geometryBoundsProvider=null,Mt.renderBoundsProvider=null,Mt.hitTestProvider=null,m3([P({type:$.float32,default:0})],Mt.prototype,"x1",void 0),m3([P({type:$.float32,default:0})],Mt.prototype,"y1",void 0),m3([P({type:$.float32,default:0})],Mt.prototype,"x2",void 0),m3([P({type:$.float32,default:0})],Mt.prototype,"y2",void 0),m3([P({type:$.float32,default:-1})],Mt.prototype,"hitStrokeWidth",void 0);let tS;tS=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},(function(t){t.EARCUT="earcut",t.LIBTESS="libtess"})(im||(im={})),Dtt=function(t){return(e,r)=>{if(!e.d)return new Qe(1/0,1/0,-1/0,-1/0);try{const o=t({d:e.d}
7156);if(o&&Number.isFinite(o.minX+o.minY+o.maxX+o.maxY))return new Qe(o.minX,o.minY,o.maxX,o.maxY)}catch{}const i=xt.geometryBoundsProvider;xt.geometryBoundsProvider=null;const s=xt.getGeometryBounds(e,r);return xt.geometryBoundsProvider=i,s}},Ptt=function(t){return(e,r,i,s)=>{try{const a={d:e.d};i&&i.width>0&&(a.stroke={width:i.width,linecap:i.linecap,linejoin:i.linejoin,miterLimit:i.miterlimit,alignment:i.alignment,dasharray:i.dasharray?[...i.dasharray]:void 0,dashoffset:i.dashoffset,blur:0}),s&&(a.markerStart=s.start,a.markerEnd=s.end,a.markerFactor=s.factor);const l=t(a);if(l&&Number.isFinite(l.minX+l.minY+l.maxX+l.maxY))return new Qe(l.minX,l.minY,l.maxX,l.maxY)}catch{}const o=xt.renderBoundsProvider;xt.renderBoundsProvider=null;const n=xt.getRenderBounds(e,r,i,s);return xt.renderBoundsProvider=o,n}},Utt=function(t){return e=>{try{const r={d:e.d,x:e.x,y:e.y,fill:e.fill,fillRule:e.fillRule};return e.stroke&&e.stroke.width>0&&(r.stroke={width:e.stroke.width,linecap:e.stroke.linecap,linejoin:e.stroke.linejoin,miterLimit:e.stroke.miterlimit,alignment:e.stroke.alignment,dasharray:e.stroke.dasharray?[...e.stroke.dasharray]:void 0,dashoffset:e.stroke.dashoffset,blur:0}),t(r)}catch{return!1}}},xt=class{static getGeometryBounds(t,e){if(xt.geometryBoundsProvider)return xt.geometryBoundsProvider(t,e);const{d:r}=t;let{points:i}=e||{};if(!r)return new Qe(1/0,1/0,-1/0,-1/0);if(!i){const{subPaths:c}=a3(r);i=c.map(h=>h.getPoints().map(u=>[u[0],u[1]]))}const s=i.flat(),o=Math.min(...s.map(c=>c[0])),n=Math.max(...s.map(c=>c[0])),a=Math.min(...s.map(c=>c[1])),l=Math.max(...s.map(c=>c[1]));return new Qe(o,a,n,l)}static getRenderBounds(t,e,r,i){if(xt.renderBoundsProvider)return xt.renderBoundsProvider(t,e,r,i);const{width:s=0,linecap:o="butt",linejoin:n="miter",miterlimit:a=4}=r??{};let l=.5;o==="square"&&(l=Math.SQRT1_2);const c=n==="miter"?a*.5:.5,h=Math.max(l,c)*s,{minX:u,minY:d,maxX:f,maxY:g}=xt.getGeometryBounds(t,e);return new Qe(u-h,d-h,f+h,g+h)}constructor(t){Object.assign(this,t)}},xt.geometryBoundsProvider=null,xt.renderBoundsProvider=null,xt.hitTestProvider=null,tS([P({type:$.object})],xt.prototype,"d",void 0),tS([P({type:$.staticString(["nonzero","evenodd"]),default:"nonzero"})],xt.prototype,"fillRule",void 0),tS([P({type:$.staticString(["earcut","libtess"]),default:"earcut"})],xt.prototype,"tessellationMethod",void 0),tS([P({type:$.float32,default:-1})],xt.prototype,"hitStrokeWidth",void 0),wo=class{},tS([P({type:$.object})],wo.prototype,"points",void 0),tS([P({type:$.object})],wo.prototype,"shiftedPoints",void 0),su=function(t){var e,r;if(Array.isArray(t.fills)){delete t.fill,delete t.fillOpacity,delete t.fillLayers;return}if(Array.isArray(t.fillLayers)){t.fills=t.fillLayers.map(o=>Object.assign({},o)),delete t.fillLayers,delete t.fill,delete t.fillOpacity;return}const i=t.fill,s=t.fillOpacity;if(i!=null&&typeof i=="object"&&Dv(i)){const o=i,n=o.image;typeof n=="string"&&n.trim()!==""&&(t.fills=[{type:"pattern",value:n,repetition:(e=o.repetition)!==null&&e!==void 0?e:"repeat",transform:(r=o.transform)!==null&&r!==void 0?r:"",opacity:aZ(s)}],delete t.fill,delete t.fillOpacity,delete t.fillLayers);return}if(i!=null&&String(i).trim()!==""){t.fills=[{type:"solid",value:String(i),opacity:aZ(s)}],delete t.fill,delete t.fillOpacity,delete t.fillLayers;return}if(s!=null){t.fills=[{type:"solid",value:"#000000",opacity:aZ(s)}],delete t.fill,delete t.fillOpacity,delete t.fillLayers;return}delete t.fill,delete t.fillOpacity,delete t.fillLayers};function aZ(t){if(t==null)return;const e=typeof t=="number"?t:parseFloat(String(t));if(Number.isFinite(e))return Math.max(0,Math.min(1,e))}Ky=function(t){var e;if(!Array.isArray(t)||t.length===0)return null;const r=t.find(Dd);return r?{fill:r.value,fillOpacity:(e=r.opacity)!==null&&e!==void 0?e:1}:null},oT=function(t){var e;return(e=Ky(t.fills))===null||e===void 0?void 0:e.fill};function sX(t){if(t==null)return;const e=String(t).trim().toLowerCase();if(e===""||e==="none"||e==="butt")return"none";if(e==="square")return"square";if(e==="round")return"round"}function D9t(t){if(!("strokeOpacity"in t)||t.strokeOpacity===void 0)return!1;if(t.strokeOpacity===null)return!0;const e=typeof t.strokeOpacity=="number"?t.strokeOpacity:parseFloat(String(t.strokeOpacity));return Number.isFinite(e)?!(e===1&&!("stroke"in t)):!0}zc=function(t){var e,r,i,s,o;const n="stroke"in t&&t.stroke!==void 0&&t.stroke!==null||D9t(t);if(Array.isArray(t.strokes))if(n)delete t.strokes;else{delete t.stroke,delete t.strokeOpacity;return}
7156const a=t.stroke,l=t.strokeOpacity;if(a!=null&&typeof a=="object"&&Dv(a)){const c=a,h=c.image;typeof h=="string"&&h.trim()!==""&&(t.strokes=[{type:"pattern",value:h,repetition:(e=c.repetition)!==null&&e!==void 0?e:"repeat",transform:(r=c.transform)!==null&&r!==void 0?r:"",opacity:(i=lZ(l))!==null&&i!==void 0?i:1}],delete t.stroke,delete t.strokeOpacity);return}if(a!=null&&String(a).trim()!==""){t.strokes=[{type:"solid",value:String(a),opacity:(s=lZ(l))!==null&&s!==void 0?s:1}],delete t.stroke,delete t.strokeOpacity;return}if(l!=null){t.strokes=[{type:"solid",value:"#000000",opacity:(o=lZ(l))!==null&&o!==void 0?o:1}],delete t.stroke,delete t.strokeOpacity;return}delete t.stroke,delete t.strokeOpacity};function lZ(t){if(t==null)return;const e=typeof t=="number"?t:parseFloat(String(t));if(Number.isFinite(e))return Math.max(0,Math.min(1,e))}function rv(t){var e;if(!Array.isArray(t)||t.length===0)return null;const r=t.find(Dd);return r?{stroke:r.value,strokeOpacity:(e=r.opacity)!==null&&e!==void 0?e:1}:null}function oX(t){var e;return(e=rv(t.strokes))===null||e===void 0?void 0:e.stroke}function P9t(t,e){const r=e!=null&&typeof e.left=="number"&&Number.isFinite(e.left)?e.left:0,i=e!=null&&typeof e.top=="number"&&Number.isFinite(e.top)?e.top:0,s=e==null?void 0:e.width,o=e==null?void 0:e.height;return typeof s=="number"&&Number.isFinite(s)&&s>0&&typeof o=="number"&&Number.isFinite(o)&&o>0?{viewW:s,viewH:o,viewLeft:r,viewTop:i}:t.viewWidth>0&&t.viewHeight>0&&Number.isFinite(t.viewWidth)&&Number.isFinite(t.viewHeight)?{viewW:t.viewWidth,viewH:t.viewHeight,viewLeft:r,viewTop:i}:{viewW:0,viewH:0,viewLeft:r,viewTop:i}}function nX(t,e,r,i){var s,o;const n=t;su(n),zc(n);const a=oX(t),l=oT(t),c=t.strokeWidth,h=a!=null?ds(a,e,r):void 0,u=l!=null?ds(l,e,r):void 0;let d=c!=null?ds(c,e,r):void 0,f=h==null?void 0:typeof h=="string"?h:String(h),g=u==null?void 0:typeof u=="string"?u:String(u);if(f==null||`${f}`.trim()===""){const p=(s=i==null?void 0:i.stroke)===null||s===void 0?void 0:s.trim();p&&(f=p)}if(g==null||`${g}`.trim()===""){const p=(o=i==null?void 0:i.fill)===null||o===void 0?void 0:o.trim();p&&(g=p)}if(d==null&&i){const p=i.strokeWidth;typeof p=="number"&&Number.isFinite(p)&&p>=0&&(d=p)}return{userColorStroke:f,userColorFill:g,rSw:d}}const cZ=Symbol.for("@infinite-canvas-tutorial/ecs/iconify-icon-store");function y3(){const t=globalThis;return t[cZ]||(t[cZ]={sets:new Map,bodyCache:new Map}),t[cZ]}ttt=function(t,e){var r;const i=t==null?void 0:t.trim().toLowerCase();if(!i||e==null)return;const s=typeof e=="object"&&e!==null&&"default"in e&&e.default!=null?e.default:e,{sets:o,bodyCache:n}=y3(),a=s,l=typeof a.width=="number"&&Number.isFinite(a.width)&&a.width>0?a.width:0,c=typeof a.height=="number"&&Number.isFinite(a.height)&&a.height>0?a.height:0;o.set(i,{icons:Object.assign({},(r=a.icons)!==null&&r!==void 0?r:{}),viewWidth:l,viewHeight:c});for(const h of Array.from(n.keys()))h.startsWith(`body:${i}:`)&&n.delete(h)};function F9t(t){const{sets:e,bodyCache:r}=y3();if(t==null){e.clear(),r.clear();return}const i=t.trim().toLowerCase();e.delete(i);for(const s of Array.from(r.keys()))s.startsWith(`body:${i}:`)&&r.delete(s)}VV=function(){return Array.from(y3().sets.keys())},eet=function(t){const e=((t==null?void 0:t.trim())||"lucide").toLowerCase();if(!e)return[];const r=y3().sets.get(e);return r!=null&&r.icons?Object.keys(r.icons).sort((i,s)=>i.localeCompare(s,void 0,{sensitivity:"base"})):[]};function N9t(t){return t.trim().replace(/Icon$/,"").replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase()}function aX(t){const e={};if(!t)return e;const r=/\s([a-zA-Z0-9:-]+)\s*=\s*"([^"]*)"/g;let i;for(;(i=r.exec(t))!=null;)e[i[1]]=i[2];return e}function lX(t){var e,r,i,s,o,n,a;return{fill:(e=t.fill)!==null&&e!==void 0?e:void 0,fillRule:(i=(r=t["fill-rule"])===null||r===void 0?void 0:r.trim().toLowerCase())!==null&&i!==void 0?i:void 0,stroke:(s=t.stroke)!==null&&s!==void 0?s:void 0,strokeWidth:(o=t["stroke-width"])!==null&&o!==void 0?o:void 0,strokeLinecap:(n=t["stroke-linecap"])!==null&&n!==void 0?n:void 0,strokeLinejoin:(a=t["stroke-linejoin"])!==null&&a!==void 0?a:void 0}}function cX(t){var e;const r=(e=t.fillRule)===null||e===void 0?void 0:e.trim().toLowerCase();return r==="evenodd"||r==="even-odd"?"evenodd":"nonzero"}function hZ(t,e){const r=Object.assign({},t);return Object.keys(e).forEach(i=>
7156{const s=e[i];s!==void 0&&(r[i]=s)}),r}const k9t=/<(path|circle|line|ellipse|rect)\b([^/]*?)\s*\/>/g;function hX(t){return xt.getGeometryBounds({d:t})}function Hgt(t,e,r,i){return Mt.getGeometryBounds({x1:t,y1:e,x2:r,y2:i})}function uX(t,e,r,i){return ae.getGeometryBounds({cx:t,cy:e,rx:r,ry:i})}function uy(t){return Number.isFinite(t.minX)&&Number.isFinite(t.minY)&&Number.isFinite(t.maxX)&&Number.isFinite(t.maxY)}function L9t(t,e){let r=e;for(;r<t.length&&/\s/.test(t[r]);)r++;return r}function Kgt(t){var e,r,i,s;const o=parseFloat(String((e=t.x)!==null&&e!==void 0?e:0))||0,n=parseFloat(String((r=t.y)!==null&&r!==void 0?r:0))||0,a=parseFloat(String((i=t.width)!==null&&i!==void 0?i:0))||0,l=parseFloat(String((s=t.height)!==null&&s!==void 0?s:0))||0;if(!Number.isFinite(a)||!Number.isFinite(l)||a<=0||l<=0)return null;let c=0,h=0;if(t.rx!=null&&String(t.rx).trim()!==""){const d=parseFloat(String(t.rx));Number.isFinite(d)&&d>0&&(c=d)}if(t.ry!=null&&String(t.ry).trim()!==""){const d=parseFloat(String(t.ry));Number.isFinite(d)&&d>0&&(h=d)}else c>0&&(h=c);if(c===0&&t.r!=null&&String(t.r).trim()!==""){const d=parseFloat(String(t.r));Number.isFinite(d)&&d>0&&(c=d,h=d)}h===0&&c>0&&(h=c),c===0&&h>0&&(c=h);const u=Math.min(a,l)*.5;return c>0&&(c=Math.min(c,u)),h>0&&(h=Math.min(h,u)),c<=0||h<=0?`M${o} ${n}h${a}v${l}h${-a}Z`:`M${o+c} ${n}h${a-2*c}a${c} ${h} 0 0 1 ${c} ${h}v${l-2*h}a${c} ${h} 0 0 1 ${-c} ${h}h${-(a-2*c)}a${c} ${h} 0 0 1 ${-c} ${-h}v${-(l-2*h)}a${c} ${h} 0 0 1 ${c} ${-h}Z`}function U9t(t,e){if(t[e]!=="<"||t.slice(e,e+2)==="</")return null;const r=t.indexOf(">",e+1);if(r<0)return null;const i=t.slice(e,r+1),s=i.match(/^<\s*([a-zA-Z][\w-]*)\b/);if(!s)return null;const o=s[1].toLowerCase();if(!/^(g|path|circle|line|ellipse|rect)$/.test(o))return null;const n=i.replace(/\s/g,"").endsWith("/>"),a=s[0].length,l=(n?i.slice(a,i.length-2):i.slice(a,i.length-1)).trim();return{name:o,attr:l,selfClose:n,end:r+1}}function qgt(t){if(typeof t=="number"&&Number.isFinite(t)&&t>0)return t;if(typeof t=="string"&&t.trim()!==""){const e=parseFloat(t);if(Number.isFinite(e)&&e>0)return e}return 0}function Zgt(t,e){let r=qgt(t),i=qgt(e);return r>0&&i<=0?i=r:i>0&&r<=0&&(r=i),r<=0&&i<=0&&(r=24,i=24),{w:r,h:i}}function uZ(t,e,r,i=0,s=0,o=0,n=0){var a,l,c,h,u,d,f,g,p,m,v,b,y;const{w:_,h:w}=Zgt(e,r),E=t.trim();if(!E)return null;let A=(G=>{const Y=[],q=[{}];let L=0;const J=G.length,tt=(bt,ct)=>{var Xt,It,zt,Ht,Lt,tr,Gr,re,ci,Dt,rt,At;const Vt=hZ(q[q.length-1],lX(ct));if(bt==="path"){const de=(Xt=ct.d)===null||Xt===void 0?void 0:Xt.trim();if(!de)return;const Rt=hX(de);if(!uy(Rt))return;Y.push({prim:{kind:"path",d:de,style:Vt},b:Rt});return}if(bt==="circle"){const de=parseFloat(String((It=ct.cx)!==null&&It!==void 0?It:0)),Rt=parseFloat(String((zt=ct.cy)!==null&&zt!==void 0?zt:0)),De=parseFloat(String((Ht=ct.r)!==null&&Ht!==void 0?Ht:0));if(!Number.isFinite(De)||De<0)return;const st=uX(de,Rt,De,De);if(!uy(st))return;Y.push({prim:{kind:"ellipse",cx:de,cy:Rt,rx:De,ry:De,style:Vt},b:st});return}if(bt==="ellipse"){const de=parseFloat(String((Lt=ct.cx)!==null&&Lt!==void 0?Lt:0)),Rt=parseFloat(String((tr=ct.cy)!==null&&tr!==void 0?tr:0)),De=parseFloat(String((Gr=ct.rx)!==null&&Gr!==void 0?Gr:0)),st=parseFloat(String((re=ct.ry)!==null&&re!==void 0?re:0));if(De<0||st<0)return;const ve=uX(de,Rt,De,st);if(!uy(ve))return;Y.push({prim:{kind:"ellipse",cx:de,cy:Rt,rx:De,ry:st,style:Vt},b:ve});return}if(bt==="line"){const de=parseFloat(String((ci=ct.x1)!==null&&ci!==void 0?ci:0)),Rt=parseFloat(String((Dt=ct.y1)!==null&&Dt!==void 0?Dt:0)),De=parseFloat(String((rt=ct.x2)!==null&&rt!==void 0?rt:0)),st=parseFloat(String((At=ct.y2)!==null&&At!==void 0?At:0)),ve=Hgt(de,Rt,De,st);if(!uy(ve))return;Y.push({prim:{kind:"line",x1:de,y1:Rt,x2:De,y2:st,style:Vt},b:ve});return}if(bt==="rect"){const de=Kgt(ct);if(!de)return;const Rt=hX(de);if(!uy(Rt))return;Y.push({prim:{kind:"path",d:de,style:Vt},b:Rt});return}};for(;L<J&&(L=L9t(G,L),!(L>=J));){if(G[L]==="<"&&G.slice(L,L+2)==="</"){const Xt=G.slice(L).match(/^<\/\s*g\s*>/i);if(Xt){q.length>1&&q.pop(),L+=Xt[0].length;continue}const It=G.indexOf(">",L);L=It<0?L+1:It+1;continue}const bt=U9t(G,L);if(!bt){const Xt=G.indexOf(">",L);Xt<0?L++:L=Xt+1;continue}if(L=bt.end,bt.name==="g"){if(bt.selfClose)continue;const Xt=aX(` ${bt.attr}`),It=q[q.length-1];q.push(hZ(It,lX(Xt)));continue}if(!bt.selfClose)continue;const ct=aX(` ${bt.attr}`);tt(bt.name,ct)}return Y.length>0?Y:null})(E);if(!A||A.length===0){const G=t.match(/^\s*<g\s([^>]+)>([\s\S]*)<\/g>\s*$/i),Y=G?aX((a=G[1])!==null&&a!==void 0?a:""):{},q=G?lX(Y):{},L=G?G[2]:t;if(!L.trim())return null;const J=[];for(const tt of L.matchAll(k9t)){const bt=tt[1].toLowerCase(),ct=aX(tt[2]||""),Xt=hZ(q,lX(ct));if(bt==="path"){const It=(l=ct.d)===null||l===void 0?void 0:l.trim();if(!It)continue;
7156const zt=hX(It);if(!uy(zt))continue;J.push({prim:{kind:"path",d:It,style:Xt},b:zt})}else if(bt==="circle"){const It=parseFloat(String((c=ct.cx)!==null&&c!==void 0?c:0)),zt=parseFloat(String((h=ct.cy)!==null&&h!==void 0?h:0)),Ht=parseFloat(String((u=ct.r)!==null&&u!==void 0?u:0));if(!Number.isFinite(Ht)||Ht<0)continue;const Lt=uX(It,zt,Ht,Ht);if(!uy(Lt))continue;J.push({prim:{kind:"ellipse",cx:It,cy:zt,rx:Ht,ry:Ht,style:Xt},b:Lt})}else if(bt==="ellipse"){const It=parseFloat(String((d=ct.cx)!==null&&d!==void 0?d:0)),zt=parseFloat(String((f=ct.cy)!==null&&f!==void 0?f:0)),Ht=parseFloat(String((g=ct.rx)!==null&&g!==void 0?g:0)),Lt=parseFloat(String((p=ct.ry)!==null&&p!==void 0?p:0));if(Ht<0||Lt<0)continue;const tr=uX(It,zt,Ht,Lt);if(!uy(tr))continue;J.push({prim:{kind:"ellipse",cx:It,cy:zt,rx:Ht,ry:Lt,style:Xt},b:tr})}else if(bt==="line"){const It=parseFloat(String((m=ct.x1)!==null&&m!==void 0?m:0)),zt=parseFloat(String((v=ct.y1)!==null&&v!==void 0?v:0)),Ht=parseFloat(String((b=ct.x2)!==null&&b!==void 0?b:0)),Lt=parseFloat(String((y=ct.y2)!==null&&y!==void 0?y:0)),tr=Hgt(It,zt,Ht,Lt);if(!uy(tr))continue;J.push({prim:{kind:"line",x1:It,y1:zt,x2:Ht,y2:Lt,style:Xt},b:tr})}else if(bt==="rect"){const It=Kgt(ct);if(!It)continue;const zt=hX(It);if(!uy(zt))continue;J.push({prim:{kind:"path",d:It,style:Xt},b:zt})}}if(J.length===0)return null;A=J}if(A.length===0)return null;const x=Object.assign({},A[0].b);for(let G=1;G<A.length;G++){const Y=Object.assign({},A[G].b);x.minX=Math.min(x.minX,Y.minX),x.minY=Math.min(x.minY,Y.minY),x.maxX=Math.max(x.maxX,Y.maxX),x.maxY=Math.max(x.maxY,Y.maxY)}const S=x.maxX-x.minX,T=x.maxY-x.minY;if(S<=0||T<=0)return null;const{minX:R,minY:B}=x,O=i>0&&s>0&&Number.isFinite(i)&&Number.isFinite(s),C=typeof o=="number"&&Number.isFinite(o)?o:0,F=typeof n=="number"&&Number.isFinite(n)?n:0;if(O){const G=i,Y=s,q=Math.min(_/G,w/Y),L=(_-q*G)*.5,J=(w-q*Y)*.5;return A.map(({prim:tt})=>tt.kind==="path"?{kind:"path",d:xy(EU(xy(tt.d,-C,-F),qst(Bt(),[q,q])),L,J),style:tt.style}:tt.kind==="ellipse"?{kind:"ellipse",cx:(tt.cx-C)*q+L,cy:(tt.cy-F)*q+J,rx:tt.rx*q,ry:tt.ry*q,style:tt.style}:{kind:"line",x1:(tt.x1-C)*q+L,y1:(tt.y1-F)*q+J,x2:(tt.x2-C)*q+L,y2:(tt.y2-F)*q+J,style:tt.style})}const U=Math.min(_/S,w/T),H=(_-U*S)*.5,N=(w-U*T)*.5;return A.map(({prim:G})=>G.kind==="path"?{kind:"path",d:xy(EU(xy(G.d,-R,-B),qst(Bt(),[U,U])),H,N),style:G.style}:G.kind==="ellipse"?{kind:"ellipse",cx:(G.cx-R)*U+H,cy:(G.cy-B)*U+N,rx:G.rx*U,ry:G.ry*U,style:G.style}:{kind:"line",x1:(G.x1-R)*U+H,y1:(G.y1-B)*U+N,x2:(G.x2-R)*U+H,y2:(G.y2-B)*U+N,style:G.style})}function dX(t,e,r,i){var s;const o=t==null?void 0:t.trim();if(!o)return null;const n=(e==null?void 0:e.trim().toLowerCase())||"lucide",a=o.indexOf(":"),[l,c]=a>=0?[o.slice(0,a),o.slice(a+1)]:[n,o],h=l.trim().toLowerCase(),{sets:u,bodyCache:d}=y3();if(!u.has(h))return null;const f=N9t((c??o).trim()||o),g=u.get(h),p=g.icons[f],{viewW:m,viewH:v,viewLeft:b,viewTop:y}=P9t(g,p),_=`body:${h}:${f}`;if(d.has(_)){const E=d.get(_);return E==null?null:uZ(E,r,i,m,v,b,y)}const w=(s=p==null?void 0:p.body)!==null&&s!==void 0?s:null;return d.set(_,w),w==null?null:uZ(w,r,i,m,v,b,y)}function fX(t,e,r){var i,s,o;const n=r==null?void 0:r.primKind,a=(i=t.stroke)===null||i===void 0?void 0:i.trim(),l=a!=null&&a!==""&&a!=="none",c=((s=t.fill)!==null&&s!==void 0?s:"none").trim(),h=n==="line"||c==="none"||c==="transparent"||l;if(e!=null&&h){const f=typeof e=="number"?e:parseFloat(String(e));if(Number.isFinite(f)&&f>=0)return f}const u=(o=t.stroke)===null||o===void 0?void 0:o.trim();if(u==null||u===""||u==="none")return(r==null?void 0:r.primKind)==="line"?2:0;const d=t.strokeWidth;if(d!=null&&d!==""){const f=parseFloat(d);if(Number.isFinite(f)&&f>0)return f}return 2}function pX(t,e,r){var i,s,o;const n=((i=t.stroke)!==null&&i!==void 0?i:"currentColor").trim();return n==="currentColor"||n===""?(s=e??r)!==null&&s!==void 0?s:"#000":n==="none"?(o=e??r)!==null&&o!==void 0?o:"#000":n}function Jgt(t){var e;const r=((e=t.fill)!==null&&e!==void 0?e:"none").trim();return r==="none"||r==="transparent"}function dZ(t,e,r){return e===!0&&t.kind==="ellipse"&&Jgt(t.style)&&!!r&&r!=="none"}function gX(t,e,r,i,s){var o,n,a;const l=((o=t.fill)!==null&&o!==void 0?o:"none").trim();return l==="none"||l==="transparent"?i==="path"||i==="line"?"none":i==="ellipse"&&s===!0?(n=r??e)!==null&&n!==void 0?n:"#000":"none":l==="currentColor"?(a=e??r)!==null&&a!==void 0?a:"#000":l}function mX(t){const e=t==null?void 0:t.trim().toLowerCase();return e==="round"||e==="square"||e==="butt"?e:"butt"}function yX(t){const e=t==null?void 0:t.trim().toLowerCase();return e==="round"||e==="bevel"||e==="miter"?e:"miter"}nc=function(t){if(t.includes(" "))return t.split(" ").map(i=>i.split(",").map(Number));const e=t.split(",").map(Number),r=[];for(let i=0;i<e.length;i+=2)i+1<e.length&&r.push([e[i],e[i+1]]);return r};function v3(t){return t.split(" ").map(e=>{const[r,i,s]=e.split(",").map(Number);return{x:r,y:i,radius:s}})}const G9t=["fills","strokes","strokeWidth","fillRule","opacity","strokeLinecap","strokeLinejoin"];function W9t(t,e){return Object.prototype.hasOwnProperty.call(t,e)?t[e]!==void 0:!1}function Qgt(t,e){const r=Object.assign({},t),i=e;for(const s of G9t)W9t(e,s)&&(s==="fills"&&Array.isArray(i.fills)?r.fills=i.fills.map(o=>
7156typeof o=="object"&&o!==null?Object.assign({},o):o):s==="strokes"&&Array.isArray(i.strokes)?r.strokes=i.strokes.map(o=>typeof o=="object"&&o!==null?Object.assign({},o):o):r[s]=i[s]);return r}function fZ(t){const e=new Map;for(const l of t)e.set(l.id,l);const r=new Map,i=new Map,s=new Set,o=new Set,n=l=>{if(!l||!e.has(l))return{};if(i.has(l))return i.get(l);if(s.has(l))return{};s.add(l);const c=e.get(l);if(c.type==="g"){const u=c.parentId&&e.has(c.parentId)?n(c.parentId):{},d=Qgt(u,c);return s.delete(l),i.set(l,d),d}const h=c.parentId&&e.has(c.parentId)?n(c.parentId):{};return s.delete(l),i.set(l,h),h},a=l=>{if(r.has(l))return r.get(l);if(o.has(l))return{};o.add(l);const c=e.get(l);if(!c){o.delete(l);const d={};return r.set(l,d),d}const h=c.parentId?n(c.parentId):{},u=Qgt(h,c);return o.delete(l),r.set(l,u),u};for(const l of t)a(l.id);return r}function tmt(t,e){var r;return(r=fZ(e).get(t))!==null&&r!==void 0?r:{}}function _3(t,e,r){if(t==null)return"";const i=ds(t,e,r);return i==null?"":String(i)}function j9t(t,e,r){if(t==null)return-1;const i=ds(t,e,r);if(i==null)return-1;const s=typeof i=="number"?i:parseFloat(String(i));return!Number.isFinite(s)||s<0?-1:s}function pZ(t,e,r){if(t==null)return-1;const i=ds(t,e,r);if(i==null)return-1;const s=typeof i=="number"?i:parseFloat(String(i));return Number.isFinite(s)?Math.max(0,Math.min(1,s)):-1}function k2(t,e,r){const i=t;su(i),zc(i);const s=Ky(i.fills),o=rv(i.strokes);return{fill:s?_3(s.fill,e,r):"",stroke:o?_3(o.stroke,e,r):"",strokeWidth:j9t(t.strokeWidth,e,r),fillRule:_3(t.fillRule,e,r),opacity:pZ(t.opacity,e,r),fillOpacity:s?pZ(s.fillOpacity,e,r):-1,strokeOpacity:o?pZ(o.strokeOpacity,e,r):-1,strokeLinecap:_3(t.strokeLinecap,e,r),strokeLinejoin:_3(t.strokeLinejoin,e,r)}}function emt(t,e,r,i){const s=Math.cos(i),o=Math.sin(i),n=t.x-e,a=t.y-r;return{x:e+n*s-a*o,y:r+n*o+a*s}}function rmt(t,e,r){var i;const s=(i=t.rotation)!==null&&i!==void 0?i:0;if(s===0)return(t.type==="ellipse"?smt:imt)(t,e,r);const o=t.x,n=t.y,a=emt(e,o,n,-s),l=Object.assign(Object.assign({},t),{rotation:0}),c=(t.type==="ellipse"?smt:imt)(l,a,r);return emt(c,o,n,s)}function imt(t,e,r){const{x:i,y:s,width:o,height:n}=t,a=i+o/2,l=s+n/2,c=e.x-a,h=e.y-l,u=Math.atan2(h,c),d={x:0,y:0},f=Math.PI,g=Math.PI/2-u,p=Math.atan2(n,o);return u<-f+p||u>f-p?(d.x=i,d.y=l-o*Math.tan(u)/2):u<-p?(d.y=s,d.x=a-n*Math.tan(g)/2):u<p?(d.x=i+o,d.y=l+o*Math.tan(u)/2):(d.y=s+n,d.x=a+n*Math.tan(g)/2),r&&(e.x>=i&&e.x<=i+o?d.x=e.x:e.y>=s&&e.y<=s+n&&(d.y=e.y),e.x<i?d.x=i:e.x>i+o&&(d.x=i+o),e.y<s?d.y=s:e.y>s+n&&(d.y=s+n)),d}function smt(t,e,r){const{x:i,y:s,width:o,height:n}=t,a=o/2,l=n/2,c=i+a,h=s+l,u=e.x,d=e.y,f=u-c,g=d-h;if(f==0&&g!=0)return{x:c,y:h+l*g/Math.abs(g)};if(f==0&&g==0)return{x:u,y:d};if(r){if(d>=s&&d<=s+n){const O=d-h;let C=Math.sqrt(a*a*(1-O*O/(l*l)))||0;return u<=i&&(C=-C),{x:c+C,y:d}}if(u>=i&&u<=i+o){const O=u-c;let C=Math.sqrt(l*l*(1-O*O/(a*a)))||0;return d<=s&&(C=-C),{x:u,y:h+C}}}const p=g/f,m=h-p*c,v=a*a*p*p+l*l,b=-2*c*v,y=a*a*p*p*c*c+l*l*c*c-a*a*l*l,_=Math.sqrt(b*b-4*v*y),w=(-b+_)/(2*v),E=(-b-_)/(2*v),A=p*w+m,x=p*E+m,S=Math.sqrt(Math.pow(w-u,2)+Math.pow(A-d,2)),T=Math.sqrt(Math.pow(E-u,2)+Math.pow(x-d,2));let R=0,B=0;return S<T?(R=w,B=A):(R=E,B=x),{x:R,y:B}}let omt,Wf,dy,fy,Wh,b3;gO="north",mO="south",gG="east",pG="west",omt=0,Wf=1,dy=2,fy=4,Wh=8,b3=15;function nmt(t,e,r,i){var s,o;const n=(o=(s=t.portConstraint)!==null&&s!==void 0?s:r?e.sourcePortConstraint:e.targetPortConstraint)!==null&&o!==void 0?o:null;if(n==null)return i;{const a=n.toString();let l=omt,c=0;if(a.indexOf(gO)>=0)switch(c){case 0:l|=dy;break;case 1:l|=Wh;break;case 2:l|=fy;break;case 3:l|=Wf;break}if(a.indexOf(pG)>=0)switch(c){case 0:l|=Wf;break;case 1:l|=dy;break;case 2:l|=Wh;break;case 3:l|=fy;break}if(a.indexOf(mO)>=0)switch(c){case 0:l|=fy;break;case 1:l|=Wf;break;case 2:l|=dy;break;case 3:l|=Wh;break}if(a.indexOf(gG)>=0)switch(c){case 0:l|=Wh;break;case 1:l|=fy;break;case 2:l|=Wf;break;case 3:l|=dy;break}return l}}function vX(t){let e=0;return e=(t&Wf)<<3,e|=(t&dy)<<1,e|=(t&fy)>>1,e|=(t&Wh)>>3,e}const X9t=480,z9t=512,V9t=1024,Y9t=2048,amt=10,w3=[[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0]],L2=[],$9t=[[-1,0],[0,-1],[1,0],[0,1],[-1,0],[0,-1],[1,0]],Bn=[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],H9t=[[[513,2308,2081,2562],[513,1090,514,2184,2114,2561],[513,1090,514,2564,2184,2562],[513,2308,2561,1090,514,2568,2308]],[[514,1057,513,2308,2081,2562],[514,2184,2114,2561],[514,2184,2562,1057,513,2564,2184],[514,1057,513,2568,2308,2561]],[[1090,514,1057,513,2308,2081,2562],[2114,2561],[1090,2562,1057,513,2564,2184],[1090,514,1057,513,2308,2561,2568]],[[2081,2562],[1057,513,1090,514,2184,2114,2561],[1057,513,1090,514,2184,2562,2564],[1057,2561,1090,514,2568,2308]]];(function(t){t.ELBOW="elbowEdgeStyle",t.ENTITY_RELATION="entityRelationEdgeStyle",t.LOOP="loopEdgeStyle",t.SIDETOSIDE="sideToSideEdgeStyle",t.TOPTOBOTTOM="topToBottomEdgeStyle",t.ORTHOGONAL="orthogonalEdgeStyle",t.SEGMENT="segmentEdgeStyle"})(qh||(qh={}));function K9t(t,e,r,i,s){var o,n,a,l,c,h,u,d;const f=t.absolutePoints,g=f[0],p=f[f.length-1];let m=e!=null?(o=e.x)!==null&&o!==void 0?o:0:g.x,v=e!=null?(n=e.y)!==null&&n!==void 0?n:0:g.y,b=e!=null&&(a=e.width)!==null&&a!==void 0?a:1,y=e!=null&&(l=e.height)!==null&&l!==void 0?l:1,_=r!=null?(c=r.x)!==null&&c!==void 0?c:0:p.x,w=r!=null?(h=r.y)!==null&&h!==void 0?h:0:p.y,E=r!=null&&(u=r.width)!==null&&u!==void 0?u:1,A=r!=null&&(d=r.height)!==null&&d!==void 0?d:1,x=lmt(t,!0),S=lmt(t,!1);e!==null&&r===e&&(S=Math.max(x,S),x=S);const T=S+x;let R=!1;if(g!==null&&p!==null){const st=p.x-g.x,ve=p.y-g.y;R=st*st+ve*ve<T*T}if(R)return;const B=[b3,b3];if(e!==null&&(B[0]=nmt(e,t,!0,b3)),r!=null&&(B[1]=nmt(r,t,!1,b3)),b===0||y===0||E===0||A===0)return;let O=[0,0],C=[[m,v,b,y],[_,w,E,A]],F=[x,S];for(let st=0;st<2;st++)w3[st][1]=C[st][0]-F[st],w3[st][2]=C[st][1]-F[st],w3[st][4]=C[st][0]+C[st][2]+F[st],w3[st][8]=C[st][1]+C[st][3]+F[st];let U=C[0][0]+C[0][2]/2,H=C[0][1]+C[0][3]/2,N=C[1][0]+C[1][2]/2,G=C[1][1]+C[1][3]/2,Y=U-N,q=H-G,L=0;Y<0?q<0?L=2:L=1:q<=0&&(L=3,Y==0&&(L=2));let J=null;e!=null&&(J=g);let tt=[[.5,.5],[.5,.5]];e||(tt[0]=[0,0]),r||(tt[1]=[0,0]);for(let st=0;st<2;st++)J!=null&&(tt[st][0]=(J.x-C[st][0])/C[st][2],Math.abs(J.x-C[st][0])<=1?O[st]=Wf:Math.abs(J.x-C[st][0]-C[st][2])<=1&&(O[st]=Wh),tt[st][1]=(J.y-C[st][1])/C[st][3],Math.abs(J.y-C[st][1])<=1?O[st]=dy:Math.abs(J.y-C[st][1]-C[st][3])<=1&&(O[st]=fy)),J=null,r!=null&&(J=p);let bt=C[0][1]-(C[1][1]+C[1][3]),ct=C[0][0]-(C[1][0]+C[1][2]),Xt=C[1][1]-(C[0][1]+C[0][3]),It=C[1][0]-(C[0][0]+C[0][2]);L2[1]=Math.max(ct-T,0),L2[2]=Math.max(bt-T,0),L2[4]=Math.max(Xt-T,0),L2[3]=Math.max(It-T,0);let zt=[],Ht=[],Lt=[];Ht[0]=ct>=It?Wf:Wh,Lt[0]=bt>=Xt?dy:fy,Ht[1]=vX(Ht[0]),Lt[1]=vX(Lt[0]);let tr=ct>=It?ct:It,Gr=bt>=Xt?bt:Xt,re=[[0,0],[0,0]],ci=!1;for(let st=0;st<2;st++)O[st]==0&&((Ht[st]&B[st])==0&&(Ht[st]=vX(Ht[st])),(Lt[st]&B[st])==0&&(Lt[st]=vX(Lt[st])),re[st][0]=Lt[st],re[st][1]=Ht[st]);Gr>0&&tr>0&&((Ht[0]&B[0])>0&&(Lt[1]&B[1])>0?(re[0][0]=Ht[0],re[0][1]=Lt[0],re[1][0]=Lt[1],re[1][1]=Ht[1],ci=!0):(Lt[0]&B[0])>0&&(Ht[1]&B[1])>0&&(re[0][0]=Lt[0],re[0][1]=Ht[0],re[1][0]=Ht[1],re[1][1]=Lt[1],ci=!0)),Gr>0&&!ci&&(re[0][0]=Lt[0],re[0][1]=Ht[0],re[1][0]=Lt[1],re[1][1]=Ht[1],ci=!0),tr>0&&!ci&&(re[0][0]=Ht[0],re[0][1]=Lt[0],re[1][0]=Ht[1],re[1][1]=Lt[1],ci=!0);for(let st=0;st<2;st++)O[st]==0&&((re[st][0]&B[st])==0&&(re[st][0]=re[st][1]),zt[st]=re[st][0]&B[st],zt[st]|=(re[st][1]&B[st])<<8,zt[st]|=(re[1-st][st]&B[st])<<16,zt[st]|=(re[1-st][1-st]&B[st])<<24,(zt[st]&15)==0&&(zt[st]=zt[st]<<8),(zt[st]&3840)==0&&(zt[st]=zt[st]&15|zt[st]>>8),(zt[st]&983040)==0&&(zt[st]=zt[st]&65535|(zt[st]&251658240)>>8),O[st]=zt[st]&15,(B[st]==Wf||B[st]==dy||B[st]==Wh||B[st]==fy)&&(O[st]=B[st]));let Dt=O[0]==Wh?3:O[0],rt=O[1]==Wh?3:O[1];Dt-=L,rt-=L,Dt<1&&(Dt+=4),rt<1&&(rt+=4);let At=H9t[Dt-1][rt-1];switch(Bn[0][0]=C[0][0],Bn[0][1]=C[0][1],O[0]){case Wf:Bn[0][0]-=x,Bn[0][1]+=tt[0][1]*C[0][3];break;case fy:Bn[0][0]+=tt[0][0]*C[0][2],Bn[0][1]+=C[0][3]+x;break;case Wh:Bn[0][0]+=C[0][2]+x,Bn[0][1]+=tt[0][1]*C[0][3];break;case dy:Bn[0][0]+=tt[0][0]*C[0][2],Bn[0][1]-=x;break}let Vt=0,de=(O[0]&(Wh|Wf))>0?0:1,Rt=de,De=0;for(let st=0;st<At.length;st++){let ve=At[st]&15,Ct=ve==Wh?3:ve;Ct+=L,Ct>4&&(Ct-=4);let mi=$9t[Ct-1];De=Ct%2>0?0:1,De!=de&&(Vt++,Bn[Vt][0]=Bn[Vt-1][0],Bn[Vt][1]=Bn[Vt-1][1]);let ws=(At[st]&Y9t)>0,$r=(At[st]&V9t)>0,Ne=(At[st]&X9t)>>5;Ne=Ne<<L,Ne>15&&(Ne=Ne>>4);let mo=(At[st]&z9t)>0;if(($r||ws)&&Ne<9){let Es=0,z=$r?0:1;if(mo&&De==0?Es=C[z][0]+tt[z][0]*C[z][2]:mo?Es=C[z][1]+tt[z][1]*C[z][3]:Es=w3[z][Ne],De==0){let ut=Bn[Vt][0],M=(Es-ut)*mi[0];M>
71560&&(Bn[Vt][0]+=mi[0]*M)}else{let ut=Bn[Vt][1],M=(Es-ut)*mi[1];M>0&&(Bn[Vt][1]+=mi[1]*M)}}else mo&&(Bn[Vt][0]+=mi[0]*Math.abs(L2[Ct]/2),Bn[Vt][1]+=mi[1]*Math.abs(L2[Ct]/2));Vt>0&&Bn[Vt][De]==Bn[Vt-1][De]?Vt--:de=De}for(let st=0;st<=Vt&&!(st==Vt&&(((O[1]&(Wh|Wf))>0?0:1)==Rt?0:1)!=(Vt+1)%2);st++)s.push({x:Bn[st][0],y:Bn[st][1]})}function lmt(t,e){var r,i;const{sourceJettySize:s,targetJettySize:o,jettySize:n}=t;return e?(r=s??n)!==null&&r!==void 0?r:amt:(i=o??n)!==null&&i!==void 0?i:amt}function q9t(t,e,r,i){const s=Math.cos(i),o=Math.sin(i),n=t.x-e,a=t.y-r;return{x:e+n*s-a*o,y:r+n*o+a*s}}function Z9t(t,e,r){let i=null;const s=r?t.exitX:t.entryX;if(!me(s)){const l=r?t.exitY:t.entryY;me(l)||(i={x:s,y:l})}let o=!1,n=0,a=0;return me(i)||(o=r?t.exitPerimeter:t.entryPerimeter,n=r?t.exitDx:t.entryDx,a=r?t.exitDy:t.entryDy,n=isFinite(n)?n:0,a=isFinite(a)?a:0),{x:i==null?void 0:i.x,y:i==null?void 0:i.y,perimeter:o,dx:n,dy:a}}function J9t(t,e,r){const i=t.absolutePoints;let s=null;if(!me(i)&&i.length>=2){const o=i.length;s=i[r?Math.min(1,o-1):Math.max(0,o-2)]}return me(s)&&!me(e)&&(s={x:e.x+e.width/2,y:e.y+e.height/2}),s}function Q9t(t,e,r,i){const s=J9t(t,r,i),o=t.orthogonal;return rmt(e,s,o)}function t7t(t,e,r,i){let s=null;if(e!=null&&!me(i)&&!me(i.x)&&!me(i.y)&&(s=e7t(e,i)),s==null&&e==null){const o=r?t.sourcePoint:t.targetPoint;o!=null&&Number.isFinite(o.x)&&Number.isFinite(o.y)&&(s={x:o.x,y:o.y})}return s}function e7t(t,e){var r,i,s;let o=null;if(!me(t)&&!me(e.x)&&!me(e.y)){const{x:n,y:a,width:l,height:c}=t,h={x:n+e.x*l+((r=e.dx)!==null&&r!==void 0?r:0),y:a+e.y*c+((i=e.dy)!==null&&i!==void 0?i:0)},u=(s=t.rotation)!==null&&s!==void 0?s:0;o=u===0?h:q9t(h,n,a,u),e.perimeter&&(o=rmt(t,o,!1))}return o}function cmt(t,e,r){const i=t.absolutePoints;if(!me(i)){const s=i[0],o=i[i.length-1];me(o)&&r!=null&&hmt(t,r,e,!1),me(s)&&e!=null&&hmt(t,e,r,!0)}}function hmt(t,e,r,i){dmt(t,Q9t(t,e,r,i),i)}function umt(t,e,r){const i=e!=null?Z9t(t,e,r):null;dmt(t,t7t(t,e,r,i),r)}function dmt(t,e,r){r?(me(t.absolutePoints)&&(t.absolutePoints=[]),t.absolutePoints.length===0?t.absolutePoints.push(e):t.absolutePoints[0]=e):me(t.absolutePoints)?(t.absolutePoints=[],t.absolutePoints.push(null),t.absolutePoints.push(e)):t.absolutePoints.length===1?t.absolutePoints.push(e):t.absolutePoints[t.absolutePoints.length-1]=e}function r7t(t,e){return e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height}function i7t(t){return Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.width)&&Number.isFinite(t.height)?{x:t.x,y:t.y,width:t.width,height:t.height}:null}function s7t(t,e,r,i){var s,o,n;const a=t.absolutePoints,l=a[0],c=a[a.length-1];if(!me(l)&&!me(c)){if(!me(r)&&r.length>0)for(let y=0;y<r.length;y++){const _=r[y];me(_)||i.push(gZ(t,{x:_.x,y:_.y}))}return}if(me(e))return;const h=i7t(e);if(me(h))return;let u=!me(r)&&r.length>0?r[0]:null;me(u)||(u=gZ(t,{x:u.x,y:u.y}),r7t(h,u)&&(u=null));let d=0,f=0,g=0,p=0;const m=(s=t.scaleX)!==null&&s!==void 0?s:1,v=((o=t.segment)!==null&&o!==void 0?o:10)*m,b=(n=t.direction)!==null&&n!==void 0?n:pG;b===gO||b===mO?(d=h.x+h.width/2,f=v):(g=h.y+h.height/2,p=v),me(u)||u.x<h.x||u.x>h.x+h.width?me(u)?b===gO?g=h.y-2*f:b===mO?g=h.y+h.height+2*f:b===gG?d=h.x-2*p:d=h.x+h.width+2*p:(d=u.x,p=Math.max(Math.abs(g-u.y),p)):me(u)||(d=h.x+h.width/2,f=Math.max(Math.abs(d-u.x),p),g=u.y,p=0),i.push({x:d-f,y:g-p}),i.push({x:d+f,y:g+p})}function fmt(t,e,r,i){if(t!==null&&t.absolutePoints!==null&&t.absolutePoints.length>0){const s=[];if(s.push(t.absolutePoints[0]),!me(t.edgeStyle))t.edgeStyle===qh.ORTHOGONAL?K9t(t,r,i,e,s):t.edgeStyle===qh.SEGMENT||t.edgeStyle===qh.LOOP&&s7t(t,r,e,s);else if(!me(e)){for(let n=0;n<e.length;n++)if(!me(e[n])){const a={x:e[n].x,y:e[n].y};s.push(gZ(t,a))}}const o=t.absolutePoints;s.push(o[o.length-1]),t.absolutePoints=s}}function gZ(t,e,r=!1){var i,s,o,n;if(t!=null&&e!=null){const a=r?1:(i=t.scaleX)!==null&&i!==void 0?i:1,l=r?1:(s=t.scaleY)!==null&&s!==void 0?s:1,c=(o=t.x)!==null&&o!==void 0?o:0,h=(n=t.y)!==null&&n!==void 0?n:0;return{x:a*(e.x+c),y:l*(e.y+h)}}return null}function pmt(t,e,r){umt(t,e,!0),umt(t,r,!1)}function gmt(t,e){return[t[0]*2-e[0],t[1]*2-e[1]]}function _X(t){const e=ep(t),r=[];let i=[0,0],s=[0,0],o=null,n=null;return e.forEach(a=>{const l=a[0],c=a.slice(1);switch(l){case"M":{for(let h=0;h<c.length;h+=2){const u=c[h],d=c[h+1];h===0?(r.push(["M",u,d]),s=[u,d]):r.push(["L",u,d]),i=[u,d]}o=null,n=null;break}case"L":{for(let h=0;h<c.length;h+=2){const u=c[h],d=c[h+1];r.push(["L",u,d]),i=[u,d]}o=null,n=null;break}
7156case"H":{c.forEach(h=>{r.push(["L",h,i[1]]),i=[h,i[1]]}),o=null,n=null;break}case"V":{c.forEach(h=>{r.push(["L",i[0],h]),i=[i[0],h]}),o=null,n=null;break}case"C":{for(let h=0;h<c.length;h+=6){const u=c[h],d=c[h+1],f=c[h+2],g=c[h+3],p=c[h+4],m=c[h+5];r.push(["C",u,d,f,g,p,m]),i=[p,m],o=[f,g],n=null}break}case"S":{for(let h=0;h<c.length;h+=4){const u=o?gmt(i,o):i,d=c[h],f=c[h+1],g=c[h+2],p=c[h+3];r.push(["C",u[0],u[1],d,f,g,p]),i=[g,p],o=[d,f],n=null}break}case"Q":{for(let h=0;h<c.length;h+=4){const u=c[h],d=c[h+1],f=c[h+2],g=c[h+3];r.push(["Q",u,d,f,g]),i=[f,g],o=null,n=[u,d]}break}case"T":{for(let h=0;h<c.length;h+=2){const u=n?gmt(i,n):i,d=c[h],f=c[h+1];r.push(["Q",u[0],u[1],d,f]),i=[d,f],o=null,n=u}break}case"A":{for(let h=0;h<c.length;h+=7){const u=c[h],d=c[h+1],f=c[h+2],g=c[h+3],p=c[h+4],m=c[h+5],v=c[h+6];r.push(["A",u,d,f,g,p,m,v]),i=[m,v],o=null,n=null}break}case"Z":{r.push(["Z"]),i=[...s],o=null,n=null;break}default:r.push([l,...c]),o=null,n=null}}),r}function o7t(t){const e=[];let r=[0,0],i=[0,0];for(const s of t){const o=s[0];if(o==="M"){const n=s[1],a=s[2];r=[n,a],i=[n,a]}else if(o==="L"){const n=s[1],a=s[2];r=[n,a]}else if(o==="C"){const n=s[1],a=s[2],l=s[3],c=s[4],h=s[5],u=s[6];e.push({x1:r[0],y1:r[1],x2:n,y2:a}),e.push({x1:h,y1:u,x2:l,y2:c}),r=[h,u]}else if(o==="Q"){const n=s[1],a=s[2],l=s[3],c=s[4];e.push({x1:r[0],y1:r[1],x2:n,y2:a}),r=[l,c]}else if(o==="Z")r=[...i];else if(o==="A"){const n=s[6],a=s[7];r=[n,a]}}return e}function mmt(t){const e=[];return t.forEach((r,i)=>{const s=r[0];if(s==="M"||s==="L"){e.push({x:r[1],y:r[2],meta:{commandIndex:i,coordOffset:1}});return}if(s==="Q"){e.push({x:r[1],y:r[2],meta:{commandIndex:i,coordOffset:1}}),e.push({x:r[3],y:r[4],meta:{commandIndex:i,coordOffset:3}});return}if(s==="C"){e.push({x:r[1],y:r[2],meta:{commandIndex:i,coordOffset:1}}),e.push({x:r[3],y:r[4],meta:{commandIndex:i,coordOffset:3}}),e.push({x:r[5],y:r[6],meta:{commandIndex:i,coordOffset:5}});return}s==="A"&&e.push({x:r[6],y:r[7],meta:{commandIndex:i,coordOffset:6}})}),e}function n7t(t,e,r,i){const s=t[e.commandIndex];s&&(s[e.coordOffset]=r,s[e.coordOffset+1]=i)}function ymt(t){return Bv(t)}function a7t(t,e){if(t.length===0)return[0,0];if(t.length===1)return[t[0][0],t[0][1]];const r=Math.max(0,Math.min(1,e)),i=[];let s=0;for(let a=0;a<t.length-1;a++){const[l,c]=t[a],[h,u]=t[a+1],d=Math.hypot(h-l,u-c);i.push(d),s+=d}if(s===0)return[t[0][0],t[0][1]];let o=r*s;for(let a=0;a<t.length-1;a++){const l=i[a],c=a===t.length-2;if(o<=l||c){const h=l===0?0:Math.min(1,o/l),[u,d]=t[a],[f,g]=t[a+1];return[u+(f-u)*h,d+(g-d)*h]}o-=l}const n=t[t.length-1];return[n[0],n[1]]}function vmt(t,e){if(t.length===0)return{point:[0,0],normal:[0,0]};if(t.length===1)return{point:[t[0][0],t[0][1]],normal:[0,0]};const r=Math.max(0,Math.min(1,e)),i=[];let s=0;for(let l=0;l<t.length-1;l++){const[c,h]=t[l],[u,d]=t[l+1],f=Math.hypot(u-c,d-h);i.push(f),s+=f}if(s===0)return{point:[t[0][0],t[0][1]],normal:[0,0]};let o=r*s;for(let l=0;l<t.length-1;l++){const c=i[l],h=l===t.length-2;if(o<=c||h){const u=c===0?0:Math.min(1,o/c),[d,f]=t[l],[g,p]=t[l+1],m=[d+(g-d)*u,f+(p-f)*u];if(c===0)return{point:m,normal:[0,0]};const v=g-d,b=p-f;return{point:m,normal:[-b/c,v/c]}}o-=c}const[n,a]=t[t.length-1];return{point:[n,a],normal:[0,0]}}var _mt={exports:{}},bmt;function l7t(){return bmt||(bmt=1,(function(t){(function(){function e(a,l){var c=a.x-l.x,h=a.y-l.y;return c*c+h*h}function r(a,l,c){var h=l.x,u=l.y,d=c.x-h,f=c.y-u;if(d!==0||f!==0){var g=((a.x-h)*d+(a.y-u)*f)/(d*d+f*f);g>1?(h=c.x,u=c.y):g>0&&(h+=d*g,u+=f*g)}return d=a.x-h,f=a.y-u,d*d+f*f}function i(a,l){for(var c=a[0],h=[c],u,d=1,f=a.length;d<f;d++)u=a[d],e(u,c)>l&&(h.push(u),c=u);return c!==u&&h.push(u),h}function s(a,l,c,h,u){for(var d=h,f,g=l+1;g<c;g++){var p=r(a[g],a[l],a[c]);p>d&&(f=g,d=p)}d>h&&(f-l>1&&s(a,l,f,h,u),u.push(a[f]),c-f>1&&s(a,f,c,h,u))}function o(a,l){var c=a.length-1,h=[a[0]];return s(a,0,c,l,h),h.push(a[c]),h}function n(a,l,c){if(a.length<=2)return a;var h=l!==void 0?l*l:1;return a=c?a:i(a,h),a=o(a,h),a}t.exports=n,t.exports.default=n})()})(_mt)),_mt.exports}var c7t=l7t();DV=Sv(c7t);function wmt(t,e,r){t.insert(new _e({translation:{x:0,y:0},rotation:0,scale:{x:1,y:1}})),t.insert(new Zi),e.kind==="path"?t.insert(new xt({d:e.d,tessellationMethod:im.LIBTESS,fillRule:cX(e.style)}
7156)):e.kind==="ellipse"?t.insert(new ae({cx:e.cx,cy:e.cy,rx:e.rx,ry:e.ry})):t.insert(new Mt({x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2}));const i=pX(e.style,r.userColorStroke,r.userColorFill);t.insert(new Gt({width:fX(e.style,r.rSw,{primKind:e.kind}),linecap:mX(e.style.strokeLinecap),linejoin:yX(e.style.strokeLinejoin)})),i&&i!=="none"&&t.insert(new Fs([{type:"solid",value:i}]));const s=gX(e.style,r.userColorFill,r.userColorStroke,e.kind,r.strokeAsPlaceholderFillForRasterFilter===!0);s&&s!=="none"&&(t.insert(new Ce([{type:"solid",value:s}])),dZ(e,r.strokeAsPlaceholderFillForRasterFilter,s)&&t.insert(new sm)),t.insert(new Ls(r.zIndex)),t.insert(new he(r.visibility)),t.insert(new ba(r.name))}class lh{constructor(e,r){this.deleted=e,this.inserted=r}static create(e,r,i,s){const o=i&&s!=="inserted"?i(e):e,n=i&&s!=="deleted"?i(r):r;return new lh(o,n)}static isLeftDifferent(e,r,i=!1){return!!this.distinctKeysIterator("left",e,r,i).next().value}static isRightDifferent(e,r,i=!1){return!!this.distinctKeysIterator("right",e,r,i).next().value}static calculate(e,r,i,s){if(e===r)return lh.empty();const o={},n={};for(const c of this.distinctKeysIterator("full",e,r))o[c]=e[c],n[c]=r[c];const[a,l]=s?s(o,n):[o,n];return lh.create(a,l,i)}static empty(){return new lh({},{})}static isEmpty(e){return!Object.keys(e.deleted).length&&!Object.keys(e.inserted).length}static*distinctKeysIterator(e,r,i,s=!1){if(r===i)return;let o=[];e==="left"?o=Object.keys(r):e==="right"?o=Object.keys(i):e==="full"&&(o=Array.from(new Set([...Object.keys(r),...Object.keys(i)])));for(const n of o){const a=r[n],l=i[n];if(a!==l){if(!s&&typeof a=="object"&&typeof l=="object"&&a!==null&&l!==null&&h7t(a,l))continue;yield n}}}}const h7t=(t,e,r,i=!1)=>{const s=Object.keys(t),o=Object.keys(e);return s.length!==o.length?(i&&console.warn("%cisShallowEqual: objects don't have same properties ->","color: #8B4000",t,e),!1):s.every(n=>{const a=t[n]===e[n]||u7t(t[n],e[n]);return!a&&i&&console.warn(`%cisShallowEqual: ${n} not equal ->`,"color: #8B4000",t[n],e[n]),a})},u7t=(t,e)=>Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e;let bX=null;xtt=function(t){bX=t};function mZ(){return bX}function d7t(){if(!bX)throw new Error("Filter plugin not registered. Import and add FilterPlugin from @infinite-canvas-tutorial/filter.");return bX}var f7t=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};class p7t{isReadyForSize(){return!1}destroy(){}invalidateEngineTimeCaches(){}syncEffects(){return!1}createPostProcessing(e,r,i,s){return{texture:r}}renderPostProcessingTextureSpace(e,r){throw new Error("Filter plugin not registered")}}class g7t{render(){}destroy(){}}const m7t={gamma:1,contrast:1,saturation:1,brightness:1,red:1,green:1,blue:1,alpha:1},y7t=1.25,v7t={},_7t={deviation:3},b7t={strength:1},w7t={},E7t={},A7t={},x7t={},S7t={},T7t={},R7t={},C7t={},M7t={},B7t={},O7t={},I7t={},D7t={},P7t={},F7t={};function N7t(t){return[]}function k7t(t){return""}function L7t(t){return!1}function U7t(t){return!1}function G7t(t){return!1}function W7t(t){return!1}function j7t(t){return t}function X7t(t){return[]}function z7t(t){return!1}function V7t(t){return!1}function Y7t(t){}function $7t(t){return f7t(this,void 0,void 0,function*(){})}class H7t{constructor(){this.raindrops=[]}update(e){}}const K7t={parseEffect:N7t,formatFilter:k7t,hasRasterPostEffects:W7t,filterRasterPostEffects:j7t,collectRainDropTextureUrlsFromFilterValue:X7t,filterStringUsesEngineTimePost:U7t,filterStringUsesEngineTimeCrt:L7t,filterStringUsesEngineTimeGlitch:G7t,isRainFxEffect:z7t,isRainCodropsRainEffect:V7t,setPostEffectEngineTimeSeconds:Y7t,preloadRaindropSprites:$7t,createDrawcallPostChain:t=>new p7t,createPostProcessingRenderer:()=>new g7t},q7t={spawnInterval:[.1,.1],spawnSize:[60,100],spawnLimit:2e3,slipRate:0,motionInterval:[.1,.4],xShifting:[0,.1],colliderSize:1,trailDropDensity:.2,trailDistance:[20,30],trailDropSize:[.3,.5],trailSpread:.6,initialSpread:.5,shrinkRate:.01,velocitySpread:.3,evaporate:10,gravity:2400},Z7t={backgroundBlurSteps:3,backgroundWrapMode:"clamp",mist:!0,mistColor:[.01,.01,.01,1],mistTime:10,mistBlurStep:4,dropletsPerSecond:500,droplet
7156Size:[10,30],raindropCompose:"smoother",raindropEraserSize:[.93,1]},J7t={smoothRaindrop:[.96,.99],refractBase:.4,refractScale:.6,raindropLightPos:[-1,1,2,0],raindropDiffuseLight:[.2,.2,.2],raindropShadowOffset:.8,raindropSpecularLight:[0,0,0],raindropSpecularShininess:256,raindropLightBump:1},Q7t="/raindrop.png",tKt=.03,eKt=1;function yZ(){var t;return(t=mZ())!==null&&t!==void 0?t:K7t}function Hi(t){return((...e)=>{const r=yZ()[t];if(typeof r!="function")throw new Error(`Filter backend missing ${t}`);return r(...e)})}let Emt,Amt,xmt,Smt,U2,Tmt,iv,G2,vZ,Rmt,Cmt,wX,_Z,Mmt,Bmt,Omt,Imt,Dmt,Pmt,Fmt,Nmt,kmt,Lmt,Umt,Gmt,Wmt,jmt,Xmt,zmt,Vmt,Ymt,$mt,Hmt,Kmt,qmt,Zmt;Iv=Hi("parseEffect"),Emt=Hi("formatFilter"),Amt=Hi("createDefaultEffect"),xmt=Hi("formatLutFilterSegment"),Smt=Hi("filterStringUsesEngineTimeCrt"),U2=Hi("filterStringUsesEngineTimePost"),Tmt=Hi("filterStringUsesEngineTimeGlitch"),iv=Hi("hasRasterPostEffects"),G2=Hi("filterRasterPostEffects"),vZ=Hi("collectRainDropTextureUrlsFromFilterValue"),YV=Hi("isRainFxEffect"),Rmt=Hi("isRainCodropsRainEffect"),Cmt=Hi("isSaturateOnlyAdjustment"),wX=Hi("setPostEffectEngineTimeSeconds"),_Z=Hi("preloadRaindropSprites"),Mmt=Hi("createDefaultRainEffect"),Bmt=Hi("rainFxRenderOptionsFromEffect"),Omt=Hi("raindropSimulatorOptionsForEffect"),Imt=Hi("raindropsSimulatorOptionsForEffect"),Dmt=Hi("halftoneDotsUniformValues"),Pmt=Hi("flutedGlassUniformValues"),Fmt=Hi("tsunamiUniformValues"),Nmt=Hi("rainUniformValues"),kmt=Hi("rainCodropsWaterUniformValues"),Lmt=Hi("burnUniformValues"),Umt=Hi("crtUniformValues"),Gmt=Hi("vignetteUniformValues"),Wmt=Hi("asciiUniformValues"),jmt=Hi("glitchUniformValues"),Xmt=Hi("liquidGlassUniformValues"),zmt=Hi("liquidMetalUniformValues"),Vmt=Hi("heatmapUniformValues"),Ymt=Hi("gemSmokeUniformValues"),$mt=Hi("kawaseKernelsForBlurEffect"),Hmt=Hi("kawaseBlurUniformValues"),Kmt=Hi("getPostEffectEngineTimeSeconds"),qmt=Hi("getRaindropSpriteBitmapIfReady"),Zmt=Hi("loadRaindropSpriteCached");function Jmt(t,e,r){return yZ().createPostProcessingRenderer(t,e,r)}function Qmt(t){return yZ().createDrawcallPostChain(t)}function Hl(t){if(t.has(La)){const r=t.read(La).value;if(r)return r}let e=t;for(let r=0;r<64;r++){if(!e.has(be))return;const i=e.read(be).parent;if(!i)return;if(i.has(Hn)&&i.has(La))return i.read(La).value||void 0;e=i}}function rKt(t){let e=t;for(let r=0;r<64;r++){if(!e.has(be))return!1;const i=e.read(be).parent;if(!i)return!1;if(i.has(Hn))return!0;e=i}return!1}function EX(t){if(kh(t)!=null)return!1;const e=Hl(t);if(!e||!iv(e)||!_ft(t))return!1;const r=t.read(Gt),[i,s]=r.dasharray;return i>0&&s>0||t.has(ue)?!1:rKt(t)?t.hasSomeOf(xt,Mt,ae,_t,et):t.hasSomeOf(_t,Mt,xt)?r.alignment==="center":!1}function iKt(){var t;return(t=globalThis._loadersgl_)!=null&&t.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.1"),globalThis._loadersgl_.version}const sKt=iKt();function oKt(t,e){if(!t)throw new Error("loaders.gl assertion failed.")}const W2=typeof process!="object"||String(process)!=="[object process]"||process.browser,bZ=typeof importScripts=="function",tyt=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version);tyt&&parseFloat(tyt[1]);const wZ={};function nKt(t={}){var s,o;const e=t.useLocalLibraries??((s=t.core)==null?void 0:s.useLocalLibraries),r=t.CDN??((o=t.core)==null?void 0:o.CDN),i=t.modules;return{...e!==void 0?{useLocalLibraries:e}:{},...r!==void 0?{CDN:r}:{},...i!==void 0?{modules:i}:{}}}async function E3(t,e=null,r={},i=null){return e&&(t=aKt(t,e,r,i)),wZ[t]=wZ[t]||lKt(t),await wZ[t]}function aKt(t,e,r={},i=null){if(r!=null&&r.core)throw new Error("loadLibrary: options.core must be pre-normalized");if(!r.useLocalLibraries&&t.startsWith("http"))return t;i=i||t;const s=r.modules||{};return s[i]?s[i]:W2?r.CDN?(oKt(r.CDN.startsWith("http")),`${r.CDN}/${e}@${sKt}/dist/libs/${i}`):bZ?`../src/libs/${i}`:`modules/${e}/src/libs/${i}`:`modules/${e}/dist/libs/${i}`}async function lKt(t){if(t.endsWith("wasm"))return await hKt(t);if(!W2){const{requireFromFile:r}=globalThis.loaders||{};try{const i=await(r==null?void 0:r(t));return i||!t.includes("/dist/libs/")?i:await(r==null?void 0:r(t.replace("/dist/libs/","/src/libs/")))}catch(i){if(t.includes("/dist/libs/"))try{return await(r==null?void 0:r(t.replace("/dist/libs/","/src/libs/")))}catch{}return console.error(i),null}}if(bZ)return importScripts(t);const e=await uKt(t);return cKt(e,t)}function cKt(t,e){if(!W2){const{requireFromString:i}=globalThis.loaders||{};return i==null?void 0:i(t,e)}if(bZ)return eval.call(globalThis,t),null;const r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch{r.text=t}return document.body.appendChild(r),null}async function hKt(t){const{readFileAsArrayBuffer:e}=globalThis.loaders||{};if(W2||!e||t.startsWith("http"))return await(await fetch(t)).arrayBuffer();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load ArrayBuffer from ${t}`)}}async function uKt(t){const{readFileAsText:e}=globalThis.loaders||{};if(W2||!e||t.startsWith("http"))return await(await fetch(t)).text();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load text from ${t}`)}}
7156const dKt="1.5.6",fKt="1.4.1",EZ=`https://www.gstatic.com/draco/versioned/decoders/${dKt}`,Kl={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},A3={[Kl.DECODER]:`${EZ}/${Kl.DECODER}`,[Kl.DECODER_WASM]:`${EZ}/${Kl.DECODER_WASM}`,[Kl.FALLBACK_DECODER]:`${EZ}/${Kl.FALLBACK_DECODER}`,[Kl.ENCODER]:`https://raw.githubusercontent.com/google/draco/${fKt}/javascript/${Kl.ENCODER}`};let AZ;async function pKt(t={},e){const r=t.modules||{};return r.draco3d?AZ||(AZ=r.draco3d.createDecoderModule({}).then(i=>({draco:i}))):AZ||(AZ=gKt(t,e)),await AZ}function eyt(t,e){if(t&&typeof t=="object"){if(t.default)return t.default;if(t[e])return t[e]}return t}async function gKt(t,e){let r,i;switch(e){case"js":r=await E3(A3[Kl.FALLBACK_DECODER],"draco",t,Kl.FALLBACK_DECODER);break;case"wasm":default:try{[r,i]=await Promise.all([await E3(A3[Kl.DECODER],"draco",t,Kl.DECODER),await E3(A3[Kl.DECODER_WASM],"draco",t,Kl.DECODER_WASM)])}catch{r=null,i=null}}return r=eyt(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule,!r&&!W2&&([r,i]=await Promise.all([await E3(A3[Kl.DECODER],"draco",{...t,useLocalLibraries:!0},Kl.DECODER),await E3(A3[Kl.DECODER_WASM],"draco",{...t,useLocalLibraries:!0},Kl.DECODER_WASM)]),r=eyt(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule),await mKt(r,i)}function mKt(t,e){if(typeof t!="function")throw new Error("DracoDecoderModule could not be loaded");const r={};return e&&(r.wasmBinary=e),new Promise(i=>{t({...r,onModuleLoaded:s=>i({draco:s})})})}const yKt="4.4.1";function vKt(t,e="float32"){return t instanceof Date?"date-millisecond":t instanceof Number?e:typeof t=="string"?"utf8":"null"}HEt=function(t){let e=ryt(t);return e!=="null"?{type:e,nullable:!1}:t.length>0?(e=vKt(t[0]),{type:e,nullable:!0}):{type:"null",nullable:!0}};function ryt(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}mtt=function(t){let e=1/0,r=1/0,i=1/0,s=-1/0,o=-1/0,n=-1/0;const a=t.POSITION?t.POSITION.value:[],l=a&&a.length;for(let c=0;c<l;c+=3){const h=a[c],u=a[c+1],d=a[c+2];e=h<e?h:e,r=u<r?u:r,i=d<i?d:i,s=h>s?h:s,o=u>o?u:o,n=d>n?d:n}return[[e,r,i],[s,o,n]]};function _Kt(t,e,r){const i=ryt(e.value),s=r||bKt(e);return{name:t,type:{type:"fixed-size-list",listSize:e.size,children:[{name:"value",type:i}]},nullable:!1,metadata:s}}function bKt(t){const e={};return"byteOffset"in t&&(e.byteOffset=t.byteOffset.toString(10)),"byteStride"in t&&(e.byteStride=t.byteStride.toString(10)),"normalized"in t&&(e.normalized=t.normalized.toString()),e}function wKt(t,e,r){const i=syt(e.metadata),s=[],o=EKt(e.attributes);for(const n in t){const a=t[n],l=iyt(n,a,o[n]);s.push(l)}if(r){const n=iyt("indices",r);s.push(n)}return{fields:s,metadata:i}}function EKt(t){const e={};for(const r in t){const i=t[r];e[i.name||"undefined"]=i}return e}function iyt(t,e,r){const i=r?syt(r.metadata):void 0;return _Kt(t,e,i)}function syt(t){Object.entries(t);const e={};for(const r in t)e[`${r}.string`]=JSON.stringify(t[r]);return e}const oyt={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},AKt={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},xKt=4;class SKt{constructor(e){W(this,"draco");W(this,"decoder");W(this,"metadataQuerier");this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,r={}){const i=new this.draco.DecoderBuffer;i.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(r);const s=this.decoder.GetEncodedGeometryType(i),o=s===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let n;switch(s){case this.draco.TRIANGULAR_MESH:n=this.decoder.DecodeBufferToMesh(i,o);break;case this.draco.POINT_CLOUD:n=this.decoder.DecodeBufferToPointCloud(i,o);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!n.ok()||!o.ptr){const u=`DRACO decompression failed: ${n.error_msg()}`;throw new Error(u)}const a=this._getDracoLoaderData(o,s,r),l=this._getMeshData(o,a,r),c=mtt(l.attributes),h=wKt(l.attributes,a,l.indices);return{loader:"draco",loaderData:a,header:{vertexCount:o.num_points(),boundingBox:c},...l,schema:h}}finally{this.draco.destroy(i),o&&this.draco.destroy(o)}}_getDracoLoaderData(e,r,i){const s=this._getTopLevelMetadata(e),o=this._getDracoAttributes(e,i);return{geometry_type:r,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:s,attributes:o}}_getDracoAttributes(e,r){const i={};for(let s=0;s<e.num_attributes();s++){const o=this.decoder.GetAttribute(e,s),n=this._getAttributeMetadata(e,s);i[o.unique_id()]={unique_id:o.unique_id(),attribute_type:o.attribute_type(),data_type:o.data_type(),num_components:o.num_components(),byte_offset:o.byte_offset(),byte_stride:o.byte_stride(),normalized:o.normalized(),attribute_index:s,metadata:n};const a=this._getQuantizationTransform(o,r);a&&(i[o.unique_id()].quantization_transform=a);const l=this._getOctahedronTransform(o,r);l&&(i[o.unique_id()].octahedron_transform=l)}return i}_getMeshData(e,r,i){const s=this._getMeshAttributes(r,e,i);if(!s.POSITION)throw new Error("DRACO: No position attribute found.");if(e instanceof this.draco.Mesh)switch(i.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:s,indices:{value:this._getTriangleStripIndices(e),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:s,indices:{value:this._getTriangleListIndices(e),size:1}}}return{topology:"point-list",mode:0,attributes:s}}_getMeshAttributes(e,r,i){const s={};for(const o of Object.values(e.attributes)){const n=this._deduceAttributeName(o,i);o.name=n;const a=this._getAttributeValues(r,o);if(a){const{value:l,size:c}=a;s[n]={value:l,size:c,byteOffset:o.byte_offset,byteStride:o.byte_stride,normalized:o.normalized}}}return s}
vendor: 3,489 bytes, line 7156
7156_getTriangleListIndices(e){const r=e.num_faces()*3,i=r*xKt,s=this.draco._malloc(i);try{return this.decoder.GetTrianglesUInt32Array(e,i,s),new Uint32Array(this.draco.HEAPF32.buffer,s,r).slice()}finally{this.draco._free(s)}}_getTriangleStripIndices(e){const r=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,r),CKt(r)}finally{this.draco.destroy(r)}}_getAttributeValues(e,r){const i=AKt[r.data_type];if(!i)return console.warn(`DRACO: Unsupported attribute type ${r.data_type}`),null;const s=r.num_components,o=e.num_points()*s,n=o*i.BYTES_PER_ELEMENT,a=TKt(this.draco,i);let l;const c=this.draco._malloc(n);try{const h=this.decoder.GetAttribute(e,r.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,h,a,n,c),l=new i(this.draco.HEAPF32.buffer,c,o).slice()}finally{this.draco._free(c)}return{value:l,size:s}}_deduceAttributeName(e,r){const i=e.unique_id;for(const[n,a]of Object.entries(r.extraAttributes||{}))if(a===i)return n;const s=e.attribute_type;for(const n in oyt)if(this.draco[n]===s)return oyt[n];const o=r.attributeNameEntry||"name";return e.metadata[o]?e.metadata[o].string:`CUSTOM_ATTRIBUTE_${i}`}_getTopLevelMetadata(e){const r=this.decoder.GetMetadata(e);return this._getDracoMetadata(r)}_getAttributeMetadata(e,r){const i=this.decoder.GetAttributeMetadata(e,r);return this._getDracoMetadata(i)}_getDracoMetadata(e){if(!e||!e.ptr)return{};const r={},i=this.metadataQuerier.NumEntries(e);for(let s=0;s<i;s++){const o=this.metadataQuerier.GetEntryName(e,s);r[o]=this._getDracoMetadataField(e,o)}return r}_getDracoMetadataField(e,r){const i=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,r,i);const s=RKt(i);return{int:this.metadataQuerier.GetIntEntry(e,r),string:this.metadataQuerier.GetStringEntry(e,r),double:this.metadataQuerier.GetDoubleEntry(e,r),intArray:s}}finally{this.draco.destroy(i)}}_disableAttributeTransforms(e){const{quantizedAttributes:r=[],octahedronAttributes:i=[]}=e,s=[...r,...i];for(const o of s)this.decoder.SkipAttributeTransform(this.draco[o])}_getQuantizationTransform(e,r){const{quantizedAttributes:i=[]}=r,s=e.attribute_type();if(i.map(o=>this.decoder[o]).includes(s)){const o=new this.draco.AttributeQuantizationTransform;try{if(o.InitFromAttribute(e))return{quantization_bits:o.quantization_bits(),range:o.range(),min_values:new Float32Array([1,2,3]).map(n=>o.min_value(n))}}finally{this.draco.destroy(o)}}return null}_getOctahedronTransform(e,r){const{octahedronAttributes:i=[]}=r,s=e.attribute_type();if(i.map(o=>this.decoder[o]).includes(s)){const o=new this.draco.AttributeQuantizationTransform;try{if(o.InitFromAttribute(e))return{quantization_bits:o.quantization_bits()}}finally{this.draco.destroy(o)}}return null}}function TKt(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}function RKt(t){const e=t.size(),r=new Int32Array(e);for(let i=0;i<e;i++)r[i]=t.GetValue(i);return r}function CKt(t){const e=t.size(),r=new Int32Array(e);for(let i=0;i<e;i++)r[i]=t.GetValue(i);return r}let nyt;nyt={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:yKt,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm"
7156:"js",extraAttributes:{},attributeNameEntry:void 0}}},xV={...nyt,parse:MKt};async function MKt(t,e){var s;const{draco:r}=await pKt(nKt(e),((s=e==null?void 0:e.draco)==null?void 0:s.decoderType)||"wasm"),i=new SKt(r);try{return i.parseSync(t,e==null?void 0:e.draco)}finally{i.destroy()}}async function ayt(t,e,r,i){return i._parse(t,e,r,i)}function x3(t,e){if(!t)throw new Error("loader assertion failed.")}const BKt=t=>typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer;function OKt(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?lyt(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?lyt(t,0,e):""}function lyt(t,e,r){if(t.byteLength<=e+r)return"";const i=new DataView(t);let s="";for(let o=0;o<r;o++)s+=String.fromCharCode(i.getUint8(e+o));return s}function IKt(t){try{return JSON.parse(t)}catch{throw new Error(`Failed to parse JSON from data starting with "${OKt(t)}"`)}}function cyt(t,e,r){const i=r!==void 0?new Uint8Array(t).subarray(e,e+r):new Uint8Array(t).subarray(e);return new Uint8Array(i).buffer}function S3(t,e){return x3(t>=0),x3(e>0),t+(e-1)&-4}function DKt(t,e,r){let i;if(t instanceof ArrayBuffer)i=new Uint8Array(t);else{const s=t.byteOffset,o=t.byteLength;i=new Uint8Array(t.buffer||t.arrayBuffer,s,o)}return e.set(i,r),r+S3(i.byteLength,4)}function AX(t){if(t instanceof ArrayBuffer)return t;if(BKt(t))return hyt(t);const{buffer:e,byteOffset:r,byteLength:i}=t;return e instanceof ArrayBuffer&&r===0&&i===e.byteLength?e:hyt(e,r,i)}function hyt(t,e=0,r=t.byteLength-e){const i=new Uint8Array(t,e,r),s=new Uint8Array(i.length);return s.set(i),s.buffer}function jf(t,e){if(!t)throw new Error(e||"assert failed: gltf")}const uyt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},dyt={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},fyt=["SCALAR","VEC2","VEC3","VEC4"],PKt=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],FKt=new Map(PKt),NKt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},kKt={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},LKt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function pyt(t){return fyt[t-1]||fyt[0]}function xX(t){const e=FKt.get(t.constructor);if(!e)throw new Error("Illegal typed array");return e}function gyt(t,e){const r=LKt[t.componentType],i=NKt[t.type],s=kKt[t.componentType],o=t.count*i,n=t.count*i*s;jf(n>=0&&n<=e.byteLength);const a=dyt[t.componentType],l=uyt[t.type];return{ArrayType:r,length:o,byteLength:n,componentByteSize:a,numberOfComponentsInElement:l}}function UKt(t,e,r){const i=t.bufferViews[r];jf(i);const s=i.buffer,o=e[s];jf(o);const n=(i.byteOffset||0)+o.byteOffset;return new Uint8Array(o.arrayBuffer,n,i.byteLength)}function GKt(t,e,r){var p,m;const i=typeof r=="number"?(p=t.accessors)==null?void 0:p[r]:r;if(!i)throw new Error(`No gltf accessor ${JSON.stringify(r)}`);const s=(m=t.bufferViews)==null?void 0:m[i.bufferView||0];if(!s)throw new Error(`No gltf buffer view for accessor ${s}`);const{arrayBuffer:o,byteOffset:n}=e[s.buffer],a=(n||0)+(i.byteOffset||0)+(s.byteOffset||0),{ArrayType:l,length:c,componentByteSize:h,numberOfComponentsInElement:u}=gyt(i,s),d=h*u,f=s.byteStride||d;if(typeof s.byteStride>"u"||s.byteStride===d)return new l(o,a,c);const g=new l(c);for(let v=0;v<i.count;v++){const b=new l(o,a+v*f,u);g.set(b,v*u)}return g}function WKt(){return{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]}}class ql{constructor(e){W(this,"gltf");W(this,"sourceBuffers");W(this,"byteLength");this.gltf={json:(e==null?void 0:e.json)||WKt(),buffers:(e==null?void 0:e.buffers)||[],images:(e==null?void 0:e.images)||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}hasExtension(e){const r=this.getUsedExtensions().find(s=>s===e),i=this.getRequiredExtensions().find(s=>s===e);return typeof r=="string"||typeof i=="string"}getExtension(e){const r=this.getUsedExtensions().find(s=>s===e),i=this.json.extensions||{};return r?i[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(r=>r===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,r){return(e.extensions||{})[r]}getScene(e){return this.getObject("scenes",e)}
vendor: 9,988 bytes, line 7156
7156getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,r){if(typeof r=="object")return r;const i=this.json[e]&&this.json[e][r];if(!i)throw new Error(`glTF file error: Could not find ${e}[${r}]`);return i}getTypedArrayForBufferView(e){e=this.getBufferView(e);const r=e.buffer,i=this.gltf.buffers[r];jf(i);const s=(e.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,s,e.byteLength)}getTypedArrayForAccessor(e){const r=this.getAccessor(e);return GKt(this.gltf.json,this.gltf.buffers,r)}getTypedArrayForImageData(e){e=this.getAccessor(e);const r=this.getBufferView(e.bufferView),i=this.getBuffer(r.buffer).data,s=r.byteOffset||0;return new Uint8Array(i,s,r.byteLength)}addApplicationData(e,r){return this.json[e]=r,this}addExtraData(e,r){return this.json.extras=this.json.extras||{},this.json.extras[e]=r,this}addObjectExtension(e,r,i){return e.extensions=e.extensions||{},e.extensions[r]=i,this.registerUsedExtension(r),this}setObjectExtension(e,r,i){const s=e.extensions||{};s[r]=i}removeObjectExtension(e,r){const i=(e==null?void 0:e.extensions)||{};if(i[r]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];const s=this.json.extensionsRemoved;s.includes(r)||s.push(r)}delete i[r]}addExtension(e,r={}){return jf(r),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=r,this.registerUsedExtension(e),r}addRequiredExtension(e,r={}){return jf(r),this.addExtension(e,r),this.registerRequiredExtension(e),r}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(r=>r===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(r=>r===e)||this.json.extensionsRequired.push(e)}removeExtension(e){var r;if((r=this.json.extensions)!=null&&r[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];const i=this.json.extensionsRemoved;i.includes(e)||i.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:r}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:r}),this.json.scenes.length-1}addNode(e){const{meshIndex:r,matrix:i}=e;this.json.nodes=this.json.nodes||[];const s={mesh:r};return i&&(s.matrix=i),this.json.nodes.push(s),this.json.nodes.length-1}addMesh(e){const{attributes:r,indices:i,material:s,mode:o=4}=e,n={primitives:[{attributes:this._addAttributes(r),mode:o}]};if(i){const a=this._addIndices(i);n.primitives[0].indices=a}return Number.isFinite(s)&&(n.primitives[0].material=s),this.json.meshes=this.json.meshes||[],this.json.meshes.push(n),this.json.meshes.length-1}addPointCloud(e){const r={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(r),this.json.meshes.length-1}addImage(e,r){const i=FY(e),s=r||(i==null?void 0:i.mimeType),o={bufferView:this.addBufferView(e),mimeType:s};return this.json.images=this.json.images||[],this.json.images.push(o),this.json.images.length-1}addBufferView(e,r=0,i=this.byteLength){const s=e.byteLength;jf(Number.isFinite(s)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const o={buffer:r,byteOffset:i,byteLength:s};return this.byteLength+=S3(s,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(o),this.json.bufferViews.length-1}addAccessor(e,r){const i={bufferView:e,type:pyt(r.size),componentType:r.componentType,count:r.count,max:r.max,min:r.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(i),this.json.accessors.length-1}addBinaryBuffer(e,r={size:3}){const i=this.addBufferView(e);let s={min:r.min,max:r.max};(!s.min||!s.max)&&(s=this._getAccessorMinMax(e,r.size));const o={size:r.size,componentType:xX(e),count:Math.round(e.length/r.size),min:s.min,max:s.max};return this.addAccessor(i,Object.assign(o,r))}addTexture(e){const{imageIndex:r}=e,i={source:r};return this.json.textures=this.json.textures||[],this.json.textures.push(i),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){var o,n;const e=this.byteLength,r=new ArrayBuffer(e),i=new Uint8Array(r);let s=0;for(const a of this.sourceBuffers||[])s=DKt(a,i,s);(n=(o=this.json)==null?void 0:o.buffers)!=null&&n[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=r,this.sourceBuffers=[r],this.gltf.buffers=[{arrayBuffer:r,byteOffset:0,byteLength:r.byteLength}]}_removeStringFromArray(e,r){let i=!0;for(;i;){const s=e.indexOf(r);s>-1?e.splice(s,1):i=!1}}_addAttributes(e={}){const r={};for(const i in e){const s=e[i],o=this._getGltfAttributeName(i),n=this.addBinaryBuffer(s.value,s);r[o]=n}return r}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,r){const i={min:null,max:null};if(e.length<r)return i;i.min=[],i.max=[];const s=e.subarray(0,r);for(const o of s)i.min.push(o),i.max.push(o);for(let o=r;o<e.length;o+=r)for(let n=0;n<r;n++)i.min[0+n]=Math.min(i.min[0+n],e[o+n]),i.max[0+n]=Math.max(i.max[0+n],e[o+n]);return i}}function myt(t){return(t%1+1)%1}const yyt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},jKt={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},vyt={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function xZ(t,e){return vyt[e]*yyt[t]}function SX(t,e,r,i){if(r!=="UINT8"&&r!=="UINT16"&&r!=="UINT32"&&r!=="UINT64")return null;const s=t.getTypedArrayForBufferView(e),o=TX(s,"SCALAR",r,i+1);return o instanceof BigInt64Array||o instanceof BigUint64Array?null:o}function TX(t,e,r,i=1){const s=yyt[e],o=jKt[r],n=vyt[r],a=i*s,l=a*n;let c=t.buffer,h=t.byteOffset;return h%n!==0&&(c=new Uint8Array(c).slice(h,h+l).buffer,h=0),new o(AX(c),h,a)}function SZ(t,e,r){var c,h,u,d,f;const i=`TEXCOORD_${e.texCoord||0}`,s=r.attributes[i],o=t.getTypedArrayForAccessor(s),n=t.gltf.json,a=e.index,l=(h=(c=n.textures)==null?void 0:c[a])==null?void 0:h.source;if(typeof l<"u"){const g=(d=(u=n.images)==null?void 0:u[l])==null?void 0:d.mimeType,p=(f=t.gltf.images)==null?void 0:f[l];if(p&&typeof p.width<"u"){const m=[];for(let v=0;v<o.length;v+=2){const b=XKt(p,g,o,v,e.channels);m.push(b)}return m}}return[]}function _yt(t,e,r,i,s){if(!(r!=null&&r.length))return;const o=[];for(const h of r){let u=i.findIndex(d=>d===h);u===-1&&(u=i.push(h)-1),o.push(u)}const n=new Uint32Array(o),a=t.gltf.buffers.push({arrayBuffer:n.buffer,byteOffset:n.byteOffset,byteLength:n.byteLength})-1,l=t.addBufferView(n,a,0),c=t.addAccessor(l,{size:1,componentType:xX(n),count:n.length});s.attributes[e]=c}function XKt(t,e,r,i,s=[0]){const o={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},n=r[i],a=r[i+1];let l=1;e&&(e.indexOf("image/jpeg")!==-1||e.indexOf("image/png")!==-1)&&(l=4);const c=zKt(n,a,t,l);let h=0;for(const u of s){const d=typeof u=="number"?Object.values(o)[u]:o[u],f=c+d.offset,g=Vet(t);if(g.data.length<=f)throw new Error(`${g.data.length} <= ${f}`);const p=g.data[f];h|=p<<d.shift}return h}function zKt(t,e,r,i=1){const s=r.width,o=myt(t)*(s-1),n=Math.round(o),a=r.height,l=myt(e)*(a-1),c=Math.round(l),h=r.components?r.components:i;return(c*s+n)*h}function byt(t,e,r,i,s){const o=[];for(let n=0;n<e;n++){const a=r[n],l=r[n+1]-r[n];if(l+a>i)break;const c=a/s,h=l/s;o.push(t.slice(c,c+h))}return o}function wyt(t,e,r){const i=[];for(let s=0;s<e;s++){const o=s*r;i.push(t.slice(o,o+r))}return i}function Eyt(t,e,r,i){if(r)throw new Error("Not implemented - arrayOffsets for strings is specified");if(i){const s=[],o=new TextDecoder("utf8");let n=0;for(let a=0;a<t;a++){const l=i[a+1]-i[a];if(l+n<=e.length){const c=e.subarray(n,l+n),h=o.decode(c);s.push(h),n+=l}}return s}return[]}const j2="EXT_mesh_features",VKt=j2;async function YKt(t,e){const r=new ql(t);HKt(r,e)}function $Kt(t,e){const r=new ql(t);return qKt(r),r.createBinaryChunk(),r.gltf}function HKt(t,e){const r=t.gltf.json;if(r.meshes)for(const i of r.meshes)for(const s of i.primitives)KKt(t,s,e)}function KKt(t,e,r){var s,o,n,a;if(!((s=r==null?void 0:r.gltf)!=null&&s.loadBuffers))return;const i=(n=(o=e.extensions)==null?void 0:o[j2])==null?void 0:n.featureIds;if(i)for(const l of i){let c;if(typeof l.attribute<"u"){const h=`_FEATURE_ID_${l.attribute}`,u=e.attributes[h];c=t.getTypedArrayForAccessor(u)}else typeof l.texture<"u"&&((a=r==null?void 0:r.gltf)!=null&&a.loadImages)?c=SZ(t,l.texture,e):c=[];l.data=c}}function qKt(t,e){const r=t.gltf.json.meshes;if(r)for(const i of r)for(const s of i.primitives)JKt(t,s)}function ZKt(t,e,r,i){e.extensions||(e.extensions={});let s=e.extensions[j2];s||(s={featureIds:[]},e.extensions[j2]=s);const{featureIds:o}=s,n={featureCount:r.length,propertyTable:i,data:r};o.push(n),t.addObjectExtension(e,j2,s)}function JKt(t,e){var s;const r=(s=e.extensions)==null?void 0:s[j2];
7156if(!r)return;const i=r.featureIds;i.forEach((o,n)=>{if(o.data){const{accessorKey:a,index:l}=QKt(e.attributes),c=new Uint32Array(o.data);i[n]={featureCount:c.length,propertyTable:o.propertyTable,attribute:l},t.gltf.buffers.push({arrayBuffer:c.buffer,byteOffset:c.byteOffset,byteLength:c.byteLength});const h=t.addBufferView(c),u=t.addAccessor(h,{size:1,componentType:xX(c),count:c.length});e.attributes[a]=u}})}function QKt(t){const e="_FEATURE_ID_",r=Object.keys(t).filter(s=>s.indexOf(e)===0);let i=-1;for(const s of r){const o=Number(s.substring(e.length));o>i&&(i=o)}return i++,{accessorKey:`${e}${i}`,index:i}}const tqt=Object.freeze(Object.defineProperty({__proto__:null,createExtMeshFeatures:ZKt,decode:YKt,encode:$Kt,name:VKt},Symbol.toStringTag,{value:"Module"})),X2="EXT_structural_metadata",eqt=X2;async function rqt(t,e){const r=new ql(t);sqt(r,e)}function iqt(t,e){const r=new ql(t);return bqt(r),r.createBinaryChunk(),r.gltf}function sqt(t,e){var i,s;if(!((i=e.gltf)!=null&&i.loadBuffers))return;const r=t.getExtension(X2);r&&((s=e.gltf)!=null&&s.loadImages&&oqt(t,r),nqt(t,r))}function oqt(t,e){const r=e.propertyTextures,i=t.gltf.json;if(r&&i.meshes)for(const s of i.meshes)for(const o of s.primitives)lqt(t,r,o,e)}function nqt(t,e){const r=e.schema;if(!r)return;const i=r.classes,s=e.propertyTables;if(i&&s)for(const o in i){const n=aqt(s,o);n&&hqt(t,r,n)}}function aqt(t,e){for(const r of t)if(r.class===e)return r;return null}function lqt(t,e,r,i){var o,n;if(!e)return;const s=(n=(o=r.extensions)==null?void 0:o[X2])==null?void 0:n.propertyTextures;if(s)for(const a of s){const l=e[a];cqt(t,l,r,i)}}function cqt(t,e,r,i){var o;if(!e.properties)return;i.dataAttributeNames||(i.dataAttributeNames=[]);const s=e.class;for(const n in e.properties){const a=`${s}_${n}`,l=(o=e.properties)==null?void 0:o[n];if(!l)continue;l.data||(l.data=[]);const c=l.data,h=SZ(t,l,r);h!==null&&(_yt(t,a,h,c,r),l.data=c,i.dataAttributeNames.push(a))}}function hqt(t,e,r){var o,n;const i=(o=e.classes)==null?void 0:o[r.class];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);const s=r.count;for(const a in i.properties){const l=i.properties[a],c=(n=r.properties)==null?void 0:n[a];if(c){const h=uqt(t,e,l,s,c);c.data=h}}}function uqt(t,e,r,i,s){let o=[];const n=s.values,a=t.getTypedArrayForBufferView(n),l=dqt(t,r,s,i),c=fqt(t,s,i);switch(r.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":{o=pqt(r,i,a,l);break}case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${r.type}`);case"STRING":{o=Eyt(i,a,l,c);break}case"ENUM":{o=gqt(e,r,i,a,l);break}default:throw new Error(`Unknown classProperty type ${r.type}`)}return o}function dqt(t,e,r,i){return e.array&&typeof e.count>"u"&&typeof r.arrayOffsets<"u"?SX(t,r.arrayOffsets,r.arrayOffsetType||"UINT32",i):null}function fqt(t,e,r){return typeof e.stringOffsets<"u"?SX(t,e.stringOffsets,e.stringOffsetType||"UINT32",r):null}function pqt(t,e,r,i){const s=t.array,o=t.count,n=xZ(t.type,t.componentType),a=r.byteLength/n;let l;return t.componentType?l=TX(r,t.type,t.componentType,a):l=r,s?i?byt(l,e,i,r.length,n):o?wyt(l,e,o):[]:l}function gqt(t,e,r,i,s){var u;const o=e.enumType;if(!o)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");const n=(u=t.enums)==null?void 0:u[o];if(!n)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${o}`);const a=n.valueType||"UINT16",l=xZ(e.type,a),c=i.byteLength/l;let h=TX(i,e.type,a,c);if(h||(h=i),e.array){if(s)return mqt({valuesData:h,numberOfElements:r,arrayOffsets:s,valuesDataBytesLength:i.length,elementSize:l,enumEntry:n});const d=e.count;return d?yqt(h,r,d,n):[]}return TZ(h,0,r,n)}function mqt(t){const{valuesData:e,numberOfElements:r,arrayOffsets:i,valuesDataBytesLength:s,elementSize:o,enumEntry:n}=t,a=[];for(let l=0;l<r;l++){const c=i[l],h=i[l+1]-i[l];if(h+c>s)break;const u=c/o,d=h/o,f=TZ(e,u,d,n);a.push(f)}return a}function yqt(t,e,r,i){const s=[];for(let o=0;o<e;o++){const n=r*o,a=TZ(t,n,r,i);s.push(a)}return s}function TZ(t,e,r,i){const s=[];for(let o=0;o<r;o++)if(t instanceof BigInt64Array||t instanceof BigUint64Array)s.push("");else{const n=t[e+o],a=vqt(i,n);a?s.push(a.name):s.push("")}return s}function vqt(t,e){for(const r of t.values)if(r.value===e)return r;return null}const _qt="schemaClassId";function bqt(t,e){var i,s;const r=t.getExtension(X2);if(r&&r.propertyTables)for(const o of r.propertyTables){const n=o.class,a=(s=(i=r.schema)==null?void 0:i.classes)==null?void 0:s[n];o.properties&&a&&wqt(o,a,t)}}function wqt(t,e,r){for(const i in t.properties){const s=t.properties[i].data;if(s){const o=e.properties[i];if(o){const n=Sqt(s,o,r);t.properties[i]=n}}}}function Eqt(t,e,r=_qt){let i=t.getExtension(X2);i||(i=t.addExtension(X2)),i.schema=Aqt(e,r,i.schema);const s=xqt(e,r,i.schema);return i.propertyTables||(i.propertyTables=[]),i.propertyTables.push(s)-1}function Aqt(t,e,r){const i=r??{id:"schema_id"},s={properties:{}};for(const o of t){const n={type:o.elementType,componentType:o.componentType};s.properties[o.name]=n}return i.classes={},i.classes[e]=s,i}function xqt(t,e,r){var n;const i={class:e,count:0};let s=0;const o=(n=r.classes)==null?void 0:n[e];for(const a of t){if(s===0&&(s=a.values.length),s!==a.values.length&&a.values.length)throw new Error("Illegal values in attributes");o!=null&&o.properties[a.name]&&(i.properties||(i.properties={}),i.properties[a.name]={values:0,data:a.values})}return i.count=s,i}function Sqt(t,e,r){const i={values:0};if(e.type==="STRING"){const{stringData:s,stringOffsets:o}=Cqt(t);
7156i.stringOffsets=RZ(o,r),i.values=RZ(s,r)}else if(e.type==="SCALAR"&&e.componentType){const s=Rqt(t,e.componentType);i.values=RZ(s,r)}return i}const Tqt={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:Int32Array,UINT64:Uint32Array,FLOAT32:Float32Array,FLOAT64:Float64Array};function Rqt(t,e){const r=[];for(const s of t)r.push(Number(s));const i=Tqt[e];if(!i)throw new Error("Illegal component type");return new i(r)}function Cqt(t){const e=new TextEncoder,r=[];let i=0;for(const l of t){const c=e.encode(l);i+=c.length,r.push(c)}const s=new Uint8Array(i),o=[];let n=0;for(const l of r)s.set(l,n),o.push(n),n+=l.length;o.push(n);const a=new Uint32Array(o);return{stringData:s,stringOffsets:a}}function RZ(t,e){return e.gltf.buffers.push({arrayBuffer:AX(t.buffer),byteOffset:t.byteOffset,byteLength:t.byteLength}),e.addBufferView(t)}const Mqt=Object.freeze(Object.defineProperty({__proto__:null,createExtStructuralMetadata:Eqt,decode:rqt,encode:iqt,name:eqt},Symbol.toStringTag,{value:"Module"})),Ayt="EXT_feature_metadata",Bqt=Ayt;async function Oqt(t,e){const r=new ql(t);Iqt(r,e)}function Iqt(t,e){var i,s;if(!((i=e.gltf)!=null&&i.loadBuffers))return;const r=t.getExtension(Ayt);r&&((s=e.gltf)!=null&&s.loadImages&&Dqt(t,r),Pqt(t,r))}function Dqt(t,e){const r=e.schema;if(!r)return;const i=r.classes,{featureTextures:s}=e;if(i&&s)for(const o in i){const n=i[o],a=Nqt(s,o);a&&Lqt(t,a,n)}}function Pqt(t,e){const r=e.schema;if(!r)return;const i=r.classes,s=e.featureTables;if(i&&s)for(const o in i){const n=Fqt(s,o);n&&kqt(t,r,n)}}function Fqt(t,e){for(const r in t){const i=t[r];if(i.class===e)return i}return null}function Nqt(t,e){for(const r in t){const i=t[r];if(i.class===e)return i}return null}function kqt(t,e,r){var o,n;if(!r.class)return;const i=(o=e.classes)==null?void 0:o[r.class];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);const s=r.count;for(const a in i.properties){const l=i.properties[a],c=(n=r.properties)==null?void 0:n[a];if(c){const h=Uqt(t,e,l,s,c);c.data=h}}}function Lqt(t,e,r){var s;const i=e.class;for(const o in r.properties){const n=(s=e==null?void 0:e.properties)==null?void 0:s[o];if(n){const a=zqt(t,n,i);n.data=a}}}function Uqt(t,e,r,i,s){let o=[];const n=s.bufferView,a=t.getTypedArrayForBufferView(n),l=Gqt(t,r,s,i),c=Wqt(t,r,s,i);return r.type==="STRING"||r.componentType==="STRING"?o=Eyt(i,a,l,c):jqt(r)&&(o=Xqt(r,i,a,l)),o}function Gqt(t,e,r,i){return e.type==="ARRAY"&&typeof e.componentCount>"u"&&typeof r.arrayOffsetBufferView<"u"?SX(t,r.arrayOffsetBufferView,r.offsetType||"UINT32",i):null}function Wqt(t,e,r,i){return typeof r.stringOffsetBufferView<"u"?SX(t,r.stringOffsetBufferView,r.offsetType||"UINT32",i):null}function jqt(t){const e=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return e.includes(t.type)||typeof t.componentType<"u"&&e.includes(t.componentType)}function Xqt(t,e,r,i){const s=t.type==="ARRAY",o=t.componentCount,n="SCALAR",a=t.componentType||t.type,l=xZ(n,a),c=r.byteLength/l,h=TX(r,n,a,c);return s?i?byt(h,e,i,r.length,l):o?wyt(h,e,o):[]:h}function zqt(t,e,r){const i=t.gltf.json;if(!i.meshes)return[];const s=[];for(const o of i.meshes)for(const n of o.primitives)Vqt(t,r,e,s,n);return s}function Vqt(t,e,r,i,s){const o={channels:r.channels,...r.texture},n=SZ(t,o,s);n&&_yt(t,e,n,i,s)}const Yqt=Object.freeze(Object.defineProperty({__proto__:null,decode:Oqt,name:Bqt},Symbol.toStringTag,{value:"Module"})),$qt="4.4.1",Hqt="4.5.2",RX={TRANSCODER:"basis_transcoder.js",TRANSCODER_WASM:"basis_transcoder.wasm",ENCODER:"basis_encoder.js",ENCODER_WASM:"basis_encoder.wasm"};let xyt;async function Syt(t){return BRt(t.modules),ORt("basis")||(xyt||(xyt=Kqt(t)),await xyt)}async function Kqt(t){let e=null,r=null;return[e,r]=await Promise.all([await WG(RX.TRANSCODER,"textures",t),await WG(RX.TRANSCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await qqt(e,r)}function qqt(t,e){const r={};return e&&(r.wasmBinary=e),new Promise(i=>{t(r).then(s=>{const{BasisFile:o,initializeBasis:n}=s;n(),i({BasisFile:o})})})}let CZ;async function Tyt(t){const e=t.modules||{};return e.basisEncoder?e.basisEncoder:(CZ=CZ||Zqt(t),await CZ)}async function Zqt(t){let e=null,r=null;return[e,r]=await Promise.all([await WG(RX.ENCODER,"textures",t),await WG(RX.ENCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await Jqt(e,r)}function Jqt(t,e){const r={};return e&&(r.wasmBinary=e),new Promise(i=>{t(r).then(s=>{const{BasisFile:o,KTX2File:n,initializeBasis:a,BasisEncoder:l}=s;a(),i({BasisFile:o,KTX2File:n,BasisEncoder:l})})})}const Qqt=32854,tZt=32856,Ryt=36194,eZt=33776,rZt=33779,iZt=37493,sZt=35840,oZt=35842,nZt=36196,aZt=35986,lZt=34798,cZt=37808,hZt=36283,uZt=36285,Cyt=36492,dZt=["","WEBKIT_","MOZ_"],Myt={WEBGL_compressed_texture_s3tc:["bc1-rgb-un
7156orm-webgl","bc1-rgba-unorm","bc2-rgba-unorm","bc3-rgba-unorm"],WEBGL_compressed_texture_s3tc_srgb:["bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm-srgb","bc2-rgba-unorm-srgb","bc3-rgba-unorm-srgb"],EXT_texture_compression_rgtc:["bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm"],EXT_texture_compression_bptc:["bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"],WEBGL_compressed_texture_etc1:["etc1-rgb-unorm-webgl"],WEBGL_compressed_texture_etc:["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"],WEBGL_compressed_texture_pvrtc:["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"],WEBGL_compressed_texture_atc:["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"],WEBGL_compressed_texture_astc:["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]};let CX=null;function fZt(t){if(!CX){t=t||pZt()||void 0,CX=new Set;for(const e of dZt)for(const r in Myt)if(t&&t.getExtension(`${e}${r}`))for(const i of Myt[r])CX.add(i)}return CX}function pZt(){try{return document.createElement("canvas").getContext("webgl")}catch{return null}}const Nd=[171,75,84,88,32,50,48,187,13,10,26,10];function gZt(t){const e=new Uint8Array(t);return!(e.byteLength<Nd.length||e[0]!==Nd[0]||e[1]!==Nd[1]||e[2]!==Nd[2]||e[3]!==Nd[3]||e[4]!==Nd[4]||e[5]!==Nd[5]||e[6]!==Nd[6]||e[7]!==Nd[7]||e[8]!==Nd[8]||e[9]!==Nd[9]||e[10]!==Nd[10]||e[11]!==Nd[11])}let Byt=Promise.resolve();const Oyt={etc1:{basisFormat:0,compressed:!0,format:nZt,textureFormat:"etc1-rgb-unorm-webgl"},etc2:{basisFormat:1,compressed:!0,format:iZt,textureFormat:"etc2-rgba8unorm"},bc1:{basisFormat:2,compressed:!0,format:eZt,textureFormat:"bc1-rgb-unorm-webgl"},bc3:{basisFormat:3,compressed:!0,format:rZt,textureFormat:"bc3-rgba-unorm"},bc4:{basisFormat:4,compressed:!0,format:hZt,textureFormat:"bc4-r-unorm"},bc5:{basisFormat:5,compressed:!0,format:uZt,textureFormat:"bc5-rg-unorm"},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0,format:Cyt,textureFormat:"bc7-rgba-unorm"},"bc7-m5":{basisFormat:7,compressed:!0,format:Cyt,textureFormat:"bc7-rgba-unorm"},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:sZt,textureFormat:"pvrtc-rgb4unorm-webgl"},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:oZt,textureFormat:"pvrtc-rgba4unorm-webgl"},"astc-4x4":{basisFormat:10,compressed:!0,format:cZt,textureFormat:"astc-4x4-unorm"},"atc-rgb":{basisFormat:11,compressed:!0,format:aZt,textureFormat:"atc-rgb-unorm-webgl"},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0,format:lZt,textureFormat:"atc-rgbai-unorm-webgl"},rgba32:{basisFormat:13,compressed:!1,format:tZt,textureFormat:"rgba8unorm"},rgb565:{basisFormat:14,compressed:!1,format:Ryt,textureFormat:"rgb565unorm-webgl"},bgr565:{basisFormat:15,compressed:!1,format:Ryt,textureFormat:"rgb565unorm-webgl"},rgba4444:{basisFormat:16,compressed:!1,format:Qqt,textureFormat:"rgba4unorm-webgl"}};Object.freeze(Object.keys(Oyt));async function mZt(t){const e=Byt;let r;Byt=new Promise(i=>{r=i}),await e;try{return await t()}finally{r()}}async function yZt(t,e={}){const r=XRt(e);return await mZt(async()=>{var i;if(!((i=e.basis)!=null&&i.containerFormat)||e.basis.containerFormat==="auto"){if(gZt(t)){const o=await Tyt(r);return Iyt(o.KTX2File,t,e)}const{BasisFile:s}=await Syt(r);return MZ(s,t,e)}switch(e.basis.module){case"encoder":const s=await Tyt(r);switch(e.basis.containerFormat){case"ktx2":return Iyt(s.KTX2File,t,e);case"basis":default:return MZ(s.BasisFile,t,e)}case"transcoder":default:const{BasisFile:o}=await Syt(r);return MZ(o,t,e)}})}function MZ(t,e,r){const i=new t(new Uint8Array(e));try{if(!i.startTranscoding())throw new Error("Failed to start basis transcoding");const s=i.getNumImages(),o=[];for(let n=0;n<s;n++){const a=i.getNumLevels(n),l=[];for(let c=0;c<a;
7156c++)l.push(vZt(i,n,c,r));o.push(l)}return o}finally{i.close(),i.delete()}}function vZt(t,e,r,i){const s=t.getImageWidth(e,r),o=t.getImageHeight(e,r),n=t.getHasAlpha(),{compressed:a,format:l,basisFormat:c,textureFormat:h}=Dyt(i,n),u=t.getImageTranscodedSizeInBytes(e,r,c),d=new Uint8Array(u);if(!t.transcodeImage(d,e,r,c,0,0))throw new Error("failed to start Basis transcoding");return{shape:"texture-level",width:s,height:o,data:d,compressed:a,...l!==void 0?{format:l}:{},...h!==void 0?{textureFormat:h}:{},hasAlpha:n}}function Iyt(t,e,r){const i=new t(new Uint8Array(e));try{if(!i.startTranscoding())throw new Error("failed to start KTX2 transcoding");const s=i.getLevels(),o=[];for(let n=0;n<s;n++)o.push(_Zt(i,n,r));return[o]}finally{i.close(),i.delete()}}function _Zt(t,e,r){const{alphaFlag:i,height:s,width:o}=t.getImageLevelInfo(e,0,0),{compressed:n,format:a,basisFormat:l,textureFormat:c}=Dyt(r,i),h=t.getImageTranscodedSizeInBytes(e,0,0,l),u=new Uint8Array(h);if(!t.transcodeImage(u,e,0,0,l,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{shape:"texture-level",width:o,height:s,data:u,compressed:n,...a!==void 0?{format:a}:{},...c!==void 0?{textureFormat:c}:{},levelSize:h,hasAlpha:i}}function Dyt(t,e){var o,n;let r=((o=t.basis)==null?void 0:o.format)||"auto";r==="auto"&&(r=(n=t.basis)!=null&&n.supportedTextureFormats?Pyt(t.basis.supportedTextureFormats):Pyt()),typeof r=="object"&&(r=e?r.alpha:r.noAlpha);const i=r.toLowerCase(),s=Oyt[i];if(!s)throw new Error(`Unknown Basis format ${r}`);return s}function Pyt(t=fZt()){const e=new Set(t);return z2(e,["astc-4x4-unorm","astc-4x4-unorm-srgb"])?"astc-4x4":z2(e,["bc7-rgba-unorm","bc7-rgba-unorm-srgb"])?{alpha:"bc7-m5",noAlpha:"bc7-m6-opaque-only"}:z2(e,["bc1-rgb-unorm-webgl","bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb"])?{alpha:"bc3",noAlpha:"bc1"}:z2(e,["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"])?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:z2(e,["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"])?"etc2":e.has("etc1-rgb-unorm-webgl")?"etc1":z2(e,["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"])?{alpha:"atc-rgba-interpolated-alpha",noAlpha:"atc-rgb"}:"rgb565"}function z2(t,e){return e.some(r=>t.has(r))}const bZt={dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:Hqt,worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",containerFormat:"auto",module:"transcoder"}}},wZt={...bZt,parse:yZt},V2=!0,Fyt=1735152710,BZ=12,MX=8,EZt=1313821514,AZt=5130562,xZt=0,SZt=0,TZt=1;function RZt(t,e=0){return`${String.fromCharCode(t.getUint8(e+0))}${String.fromCharCode(t.getUint8(e+1))}${String.fromCharCode(t.getUint8(e+2))}${String.fromCharCode(t.getUint8(e+3))}`}function CZt(t,e=0,r={}){const i=new DataView(t),{magic:s=Fyt}=r,o=i.getUint32(e,!1);return o===s||o===Fyt}function MZt(t,e,r=0,i={}){const s=new DataView(e),o=RZt(s,r+0),n=s.getUint32(r+4,V2),a=s.getUint32(r+8,V2);switch(Object.assign(t,{header:{byteOffset:r,byteLength:a,hasBinChunk:!1},type:o,version:n,json:{},binChunks:[]}),r+=BZ,t.version){case 1:return BZt(t,s,r);case 2:return OZt(t,s,r,i={});default:throw new Error(`Invalid GLB version ${t.version}. Only supports version 1 and 2.`)}}function BZt(t,e,r){x3(t.header.byteLength>BZ+MX);const i=e.getUint32(r+0,V2),s=e.getUint32(r+4,V2);return r+=MX,x3(s===xZt),OZ(t,e,r,i),r+=i,r+=IZ(t,e,r,t.header.byteLength),r}function OZt(t,e,r,i){return x3(t.header.byteLength>BZ+MX),IZt(t,e,r,i),r+t.header.byteLength}function IZt(t,e,r,i){for(;r+8<=t.header.byteLength;){const s=e.getUint32(r+0,V2),o=e.getUint32(r+4,V2);switch(r+=MX,o){case EZt:OZ(t,e,r,s);break;case AZt:IZ(t,e,r,s);break;case SZt:i.strict||OZ(t,e,r,s);break;case TZt:i.strict||IZ(t,e,r,s);break}r+=S3(s,4)}return r}function OZ(t,e,r,i){const s=new Uint8Array(e.buffer,r,i),o=new TextDecoder("utf8").decode(s);return t.json=JSON.parse(o),S3(i,4)}function IZ(t,e,r,i){return t.header.hasBinChunk=!0,t.binChunks.push({byteOffset:r,byteLength:i,arrayBuffer:e.buffer}),S3(i,4)}function Nyt(t,e,r){var s;if(t.startsWith("data:")||t.startsWith("http:")||t.startsWith("https:"))return t;
7156const i=(r==null?void 0:r.baseUrl)||DZt((s=e==null?void 0:e.core)==null?void 0:s.baseUrl);if(!i)throw new Error(`'baseUrl' must be provided to resolve relative url ${t}`);return i.endsWith("/")?`${i}${t}`:`${i}/${t}`}function DZt(t){if(!t)return;if(t.endsWith("/"))return t;const e=t.lastIndexOf("/");return e>=0?t.slice(0,e+1):""}const PZt="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIA
7156LAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",FZt=
vendor: 10,661 bytes, line 7156
7156"B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",
vendor: 8,319 bytes, line 7156
7156NZt=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),kZt=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),LZt={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},UZt={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function GZt(t,e,r,i,s,o="NONE"){const n=await WZt();zZt(n,n.exports[UZt[s]],t,e,r,i,n.exports[LZt[o||"NONE"]])}let DZ;async function WZt(){return DZ||(DZ=jZt()),DZ}async function jZt(){let t=PZt;WebAssembly.validate(NZt)&&(t=FZt,console.log("Warning: meshopt_decoder is using experimental SIMD support"));const e=await WebAssembly.instantiate(XZt(t),{});return await e.instance.exports.__wasm_call_ctors(),e.instance}function XZt(t){const e=new Uint8Array(t.length);for(let i=0;i<t.length;++i){const s=t.charCodeAt(i);e[i]=s>96?s-71:s>64?s-65:s>47?s+4:s>46?63:62}let r=0;for(let i=0;i<t.length;++i)e[r++]=e[i]<60?kZt[e[i]]:(e[i]-60)*64+e[++i];return e.buffer.slice(0,r)}function zZt(t,e,r,i,s,o,n){const a=t.exports.sbrk,l=i+3&-4,c=a(l*s),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,i,s,h,o.length);if(d===0&&n&&n(c,l,s),r.set(u.subarray(c,c+i*s)),a(c-a(0)),d!==0)throw new Error(`Malformed buffer data: ${d}`)}const BX="EXT_meshopt_compression",VZt=BX;async function YZt(t,e){var s,o;const r=new ql(t);if(!((s=e==null?void 0:e.gltf)!=null&&s.decompressMeshes)||!((o=e.gltf)!=null&&o.loadBuffers))return;const i=[];for(const n of t.json.bufferViews||[])i.push($Zt(r,n));await Promise.all(i),r.removeExtension(BX)}async function $Zt(t,e){const r=t.getObjectExtension(e,BX);if(r){const{byteOffset:i=0,byteLength:s=0,byteStride:o,count:n,mode:a,filter:l="NONE",buffer:c}=r,h=t.gltf.buffers[c],u=new Uint8Array(h.arrayBuffer,h.byteOffset+i,s),d=new Uint8Array(t.gltf.buffers[e.buffer].arrayBuffer,e.byteOffset,e.byteLength);await GZt(d,n,o,u,a,l),t.removeObjectExtension(e,BX)}}const HZt=Object.freeze(Object.defineProperty({__proto__:null,decode:YZt,name:VZt},Symbol.toStringTag,{value:"Module"})),Y2="EXT_texture_webp",KZt=Y2;function qZt(t,e){const r=new ql(t);if(!DCt("image/webp")){if(r.getRequiredExtensions().includes(Y2))throw new Error(`gltf: Required extension ${Y2} not supported by browser`);return}const{json:i}=r;for(const s of i.textures||[]){const o=r.getObjectExtension(s,Y2);o&&(s.source=o.source),r.removeObjectExtension(s,Y2)}r.removeExtension(Y2)}const ZZt=Object.freeze(Object.defineProperty({__proto__:null,name:KZt,preprocess:qZt},Symbol.toStringTag,{value:"Module"})),OX="KHR_texture_basisu",JZt=OX;function QZt(t,e){const r=new ql(t),{json:i}=r;for(const s of i.textures||[]){const o=r.getObjectExtension(s,OX);o&&(s.source=o.source,r.removeObjectExtension(s,OX))}r.removeExtension(OX)}const tJt=Object.freeze(Object.defineProperty({__proto__:null,name:JZt,preprocess:QZt},Symbol.toStringTag,{value:"Module"}));function eJt(t){const e={};for(const r in t){const i=t[r];if(r!=="indices"){const s=kyt(i);e[r]=s}}return e}function kyt(t){const{buffer:e,size:r,count:i}=rJt(t);return{value:e,size:r,byteOffset:0,count:i,type:pyt(r),componentType:xX(e)}}function rJt(t){let e=t,r=1,i=0;return t&&t.value&&(e=t.value,r=t.size||1),e&&(ArrayBuffer.isView(e)||(e=iJt(e,Float32Array)),i=e.length/r),{buffer:e,size:r,count:i}}function iJt(t,e,r=!1){return t?Array.isArray(t)?new e(t):r&&!(t instanceof e)?new e(t):t:null}const vw="KHR_draco_mesh_compression",sJt=vw;function oJt(t,e,r){const i=new ql(t);for(const s of Lyt(i))i.getObjectExtension(s,vw)}async function nJt(t,e,r){var o;if(!((o=e==null?void 0:e.gltf)!=null&&o.decompressMeshes))return;const i=new ql(t),s=[];for(const n of Lyt(i))i.getObjectExtension(n,vw)&&s.push(lJt(i,n,e,r));await Promise.all(s),i.removeExtension(vw)}function aJt(t,e={}){const r=new ql(t);for(const i of r.json.meshes||[])cJt(i),r.addRequiredExtension(vw)}async function lJt(t,e,r,i){const s=t.getObjectExtension(e,vw);if(!s)return;const o=t.getTypedArrayForBufferView(s.bufferView),n=cyt(o.buffer,o.byteOffset),a={...r};delete a["3d-tiles"];const l=await ayt(n,xV,a,i),c=eJt(l.attributes);for(const[h,u]of Object.entries(c))if(h in e.attributes){const d=e.attributes[h],f=t.getAccessor(d);f!=null&&f.min&&(f!=null&&f.max)&&(u.min=f.min,u.max=f.max)}e.attributes=c,l.indices&&(e.indices=kyt(l.indices)),t.removeObjectExtension(e,vw),hJt(e)}function cJt(t,e,r=4,i,s){var c;if(!i.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const o=i.DracoWriter.encodeSync({attributes:t}),n=(c=s==null?void 0:s.parseSync)==null?void 0:c.call(s,{attributes:t}),a=i._addFauxAttributes(n.attributes),l=i.addBufferView(o);return{primitives:[{attributes:a,mode:r,extensions:{[vw]:{bufferView:l,attributes:a}}}]}}function hJt(t){if(!t.attributes&&Object.keys(t.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function*Lyt(t){for(const e of t.json.meshes||[])for(const r of e.primitives)yield r}const uJt=Object.freeze(Object.defineProperty({__proto__:null,decode:nJt,encode:aJt,name:sJt,preprocess:oJt},Symbol.toStringTag,{value:"Module"})),dJt={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...dJt}};const Xf=globalThis.mathgl.config;function fJt(t,{precision:e=Xf.precision}={}){return t=pJt(t),`${parseFloat(t.toPrecision(e))}`}function IX(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Uyt(t,e,r){const i=Xf.EPSILON;try{if(t===e)return!0;if(IX(t)&&IX(e)){if(t.length!==e.length)return!1;for(let s=0;s<t.length;++s)if(!Uyt(t[s],e[s]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=Xf.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{Xf.EPSILON=i}}function pJt(t){return Math.round(t/Xf.EPSILON)*Xf.EPSILON}class Gyt extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let i=0;i<this.ELEMENTS;++i)this[i]=e[i+r];return this.check()}toArray(e=[],r=0){for(let i=0;i<this.ELEMENTS;++i)e[r+i]=this[i];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:IX(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(Xf)}formatString(e){let r="";for(let i=0;i<this.ELEMENTS;++i)r+=(i>0?", ":"")+fJt(this[i],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Uyt(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,i){if(i===void 0)return this.lerp(this,e,r);for(let s=0;s<this.ELEMENTS;++s){const o=e[s],n=typeof r=="number"?r:r[s];this[s]=o+i*(n-o)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],e[i]),r[i]);return this.check()}add(...e){for(const r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]+=r[i];return this.check()}subtract(...e){for(const r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]-=r[i];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(Xf.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name}
7156 some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],e),r);return this.check()}get elements(){return this}}function gJt(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function kd(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function mJt(t,e,r=""){if(Xf.debug&&!gJt(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}function Wyt(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}class yJt extends Gyt{get x(){return this[0]}set x(e){this[0]=kd(e)}get y(){return this[1]}set y(e){this[1]=kd(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*this[r];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let r=0;for(let i=0;i<this.ELEMENTS;++i){const s=this[i]-e[i];r+=s*s}return kd(r)}dot(e){let r=0;for(let i=0;i<this.ELEMENTS;++i)r+=this[i]*e[i];return kd(r)}normalize(){const e=this.magnitude();if(e!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e;return this.check()}multiply(...e){for(const r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]*=r[i];return this.check()}divide(...e){for(const r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]/=r[i];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return Wyt(e>=0&&e<this.ELEMENTS,"index is out of range"),kd(this[e])}setComponent(e,r){return Wyt(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=r,this.check()}addVectors(e,r){return this.copy(e).add(r)}subVectors(e,r){return this.copy(e).subtract(r)}multiplyVectors(e,r){return this.copy(e).multiply(r)}addScaledVector(e,r){return this.add(new this.constructor(e).multiplyScalar(r))}}let DX=typeof Float32Array<"u"?Float32Array:Array;function vJt(){const t=new DX(2);return DX!=Float32Array&&(t[0]=0,t[1]=0),t}function _Jt(t,e,r){const i=e[0],s=e[1];return t[0]=r[0]*i+r[3]*s+r[6],t[1]=r[1]*i+r[4]*s+r[7],t}(function(){const t=vJt();return function(e,r,i,s,o,n){let a,l;for(r||(r=2),i||(i=0),s?l=Math.min(s*r+i,e.length):l=e.length,a=i;a<l;a+=r)t[0]=e[a],t[1]=e[a+1],o(t,t,n),e[a]=t[0],e[a+1]=t[1];return e}})();function bJt(t,e,r){const i=e[0],s=e[1],o=e[2],n=r[3]*i+r[7]*s+r[11]*o||1;return t[0]=(r[0]*i+r[4]*s+r[8]*o)/n,t[1]=(r[1]*i+r[5]*s+r[9]*o)/n,t[2]=(r[2]*i+r[6]*s+r[10]*o)/n,t}function wJt(t,e,r){const i=e[0],s=e[1];return t[0]=r[0]*i+r[2]*s,t[1]=r[1]*i+r[3]*s,t[2]=e[2],t}function EJt(t,e,r){const i=e[0],s=e[1],o=e[2];return t[0]=r[0]*i+r[3]*s+r[6]*o,t[1]=r[1]*i+r[4]*s+r[7]*o,t[2]=r[2]*i+r[5]*s+r[8]*o,t[3]=e[3],t}function AJt(){const t=new DX(3);return DX!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function xJt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function SJt(t,e,r){const i=e[0],s=e[1],o=e[2],n=r[0],a=r[1],l=r[2];return t[0]=s*l-o*a,t[1]=o*n-i*l,t[2]=i*a-s*n,t}function TJt(t,e,r){const i=e[0],s=e[1],o=e[2];let n=r[3]*i+r[7]*s+r[11]*o+r[15];return n=n||1,t[0]=(r[0]*i+r[4]*s+r[8]*o+r[12])/n,t[1]=(r[1]*i+r[5]*s+r[9]*o+r[13])/n,t[2]=(r[2]*i+r[6]*s+r[10]*o+r[14])/n,t}function jyt(t,e,r){const i=e[0],s=e[1],o=e[2];return t[0]=i*r[0]+s*r[3]+o*r[6],t[1]=i*r[1]+s*r[4]+o*r[7],t[2]=i*r[2]+s*r[5]+o*r[8],t}function RJt(t,e,r){const i=r[0],s=r[1],o=r[2],n=r[3],a=e[0],l=e[1],c=e[2];let h=s*c-o*l,u=o*a-i*c,d=i*l-s*a,f=s*d-o*u,g=o*h-i*d,p=i*u-s*h;const m=n*2;return h*=m,u*=m,d*=m,f*=2,g*=2,p*=2,t[0]=a+h+f,t[1]=l+u+g,t[2]=c+d+p,t}function CJt(t,e,r,i){const s=[],o=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],o[0]=s[0],o[1]=s[1]*Math.cos(i)-s[2]*Math.sin(i),o[2]=s[1]*Math.sin(i)+s[2]*Math.cos(i),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function MJt(t,e,r,i){const s=[],o=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],o[0]=s[2]*Math.sin(i)+s[0]*Math.cos(i),o[1]=s[1],o[2]=s[2]*
vendor: 5,008 bytes, line 7156
7156Math.cos(i)-s[0]*Math.sin(i),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function BJt(t,e,r,i){const s=[],o=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],o[0]=s[0]*Math.cos(i)-s[1]*Math.sin(i),o[1]=s[0]*Math.sin(i)+s[1]*Math.cos(i),o[2]=s[2],t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function OJt(t,e){const r=t[0],i=t[1],s=t[2],o=e[0],n=e[1],a=e[2],l=Math.sqrt((r*r+i*i+s*s)*(o*o+n*n+a*a)),c=l&&xJt(t,e)/l;return Math.acos(Math.min(Math.max(c,-1),1))}(function(){const t=AJt();return function(e,r,i,s,o,n){let a,l;for(r||(r=3),i||(i=0),s?l=Math.min(s*r+i,e.length):l=e.length,a=i;a<l;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],o(t,t,n),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}})();const PZ=[0,0,0];let PX;class FZ extends yJt{static get ZERO(){return PX||(PX=new FZ(0,0,0),Object.freeze(PX)),PX}constructor(e=0,r=0,i=0){super(-0,-0,-0),arguments.length===1&&IX(e)?this.copy(e):(Xf.debug&&(kd(e),kd(r),kd(i)),this[0]=e,this[1]=r,this[2]=i)}set(e,r,i){return this[0]=e,this[1]=r,this[2]=i,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return Xf.debug&&(kd(e.x),kd(e.y),kd(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=kd(e)}angle(e){return OJt(this,e)}cross(e){return SJt(this,this,e),this.check()}rotateX({radians:e,origin:r=PZ}){return CJt(this,this,r,e),this.check()}rotateY({radians:e,origin:r=PZ}){return MJt(this,this,r,e),this.check()}rotateZ({radians:e,origin:r=PZ}){return BJt(this,this,r,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return TJt(this,this,e),this.check()}transformAsVector(e){return bJt(this,this,e),this.check()}transformByMatrix3(e){return jyt(this,this,e),this.check()}transformByMatrix2(e){return wJt(this,this,e),this.check()}transformByQuaternion(e){return RJt(this,this,e),this.check()}}class IJt extends Gyt{toString(){let e="[";if(Xf.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let i=0;i<this.RANK;++i)e+=` ${this[i*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,i){return this[r*this.RANK+e]=kd(i),this}getColumn(e,r=new Array(this.RANK).fill(-0)){const i=e*this.RANK;for(let s=0;s<this.RANK;++s)r[s]=this[i+s];return r}setColumn(e,r){const i=e*this.RANK;for(let s=0;s<this.RANK;++s)this[i+s]=r[s];return this}}function DJt(t,e){if(t===e){const r=e[1],i=e[2],s=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=i,t[7]=s}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function PJt(t,e){const r=e[0],i=e[1],s=e[2],o=e[3],n=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=h*n-a*c,d=-h*o+a*l,f=c*o-n*l;let g=r*u+i*d+s*f;return g?(g=1/g,t[0]=u*g,t[1]=(-h*i+s*c)*g,t[2]=(a*i-s*n)*g,t[3]=d*g,t[4]=(h*r-s*l)*g,t[5]=(-a*r+s*o)*g,t[6]=f*g,t[7]=(-c*r+i*l)*g,t[8]=(n*r-i*o)*g,t):null}function FJt(t){const e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],n=t[5],a=t[6],l=t[7],c=t[8];return e*(c*o-n*l)+r*(-c*s+n*a)+i*(l*s-o*a)}function Xyt(t,e,r){const i=e[0],s=e[1],o=e[2],n=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=r[0],f=r[1],g=r[2],p=r[3],m=r[4],v=r[5],b=r[6],y=r[7],_=r[8];return t[0]=d*i+f*n+g*c,t[1]=d*s+f*a+g*h,t[2]=d*o+f*l+g*u,t[3]=p*i+m*n+v*c,t[4]=p*s+m*a+v*h,t[5]=p*o+m*l+v*u,t[6]=b*i+y*n+_*c,t[7]=b*s+y*a+_*h,t[8]=b*o+y*l+_*u,t}function NJt(t,e,r){const i=e[0],s=e[1],o=e[2],n=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=r[0],f=r[1];return t[0]=i,t[1]=s,t[2]=o,t[3]=n,t[4]=a,t[5]=l,t[6]=d*i+f*n+c,t[7]=d*s+f*a+h,t[8]=d*o+f*l+u,t}function kJt(t,e,r){const i=e[0],s=e[1],o=e[2],n=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=Math.sin(r),f=Math.cos(r);return t[0]=f*i+d*n,t[1]=f*s+d*a,t[2]=f*o+d*l,t[3]=f*n-d*i,t[4]=f*a-d*s,t[5]=f*l-d*o,t[6]=c,t[7]=h,t[8]=u,t}function zyt(t,e,r){const i=r[0],s=r[1];return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=s*e[3],t[4]=s*e[4],t[5]=s*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function LJt(t,e){const r=e[0],i=e[1],s=e[2],o=e[3],n=r+r,a=i+i,l=s+s,c=r*n,h=i*n,u=i*a,d=s*n,f=s*a,g=s*l,p=o*n,m=o*a,v=o*l;return t[0]=1-u-g,t[3]=h-v,t[6]=d+m,t[1]=h+v,t[4]=1-c-g,t[7]=f-p,t[2]=d-m,t[5]=f+p,t[8]=1-c-u,t}var NZ;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL1ROW0=3]="COL1ROW0",t[t.COL1ROW1=4]="COL1ROW1",t[t.COL1ROW2=5]="COL1ROW2",t[t.COL2ROW0=6]="COL2ROW0",t[t.COL2ROW1=7]="COL2ROW1",t[t.COL2ROW2=8]="COL2ROW2"})(NZ||(NZ={}));const UJt=Object.freeze([1,0,0,0,1,0,0,0,1]);class T3 extends IJt{static get IDENTITY(){return WJt()}static get ZERO(){return GJt()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return NZ}constructor(e,...r){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):r.length>0?this.copy([e,...r]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5
7156]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(UJt)}fromObject(e){return this.check()}fromQuaternion(e){return LJt(this,e),this.check()}set(e,r,i,s,o,n,a,l,c){return this[0]=e,this[1]=r,this[2]=i,this[3]=s,this[4]=o,this[5]=n,this[6]=a,this[7]=l,this[8]=c,this.check()}setRowMajor(e,r,i,s,o,n,a,l,c){return this[0]=e,this[1]=s,this[2]=a,this[3]=r,this[4]=o,this[5]=l,this[6]=i,this[7]=n,this[8]=c,this.check()}determinant(){return FJt(this)}transpose(){return DJt(this,this),this.check()}invert(){return PJt(this,this),this.check()}multiplyLeft(e){return Xyt(this,e,this),this.check()}multiplyRight(e){return Xyt(this,this,e),this.check()}rotate(e){return kJt(this,this,e),this.check()}scale(e){return Array.isArray(e)?zyt(this,this,e):zyt(this,this,[e,e]),this.check()}translate(e){return NJt(this,this,e),this.check()}transform(e,r){let i;switch(e.length){case 2:i=_Jt(r||[-0,-0],e,this);break;case 3:i=jyt(r||[-0,-0,-0],e,this);break;case 4:i=EJt(r||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return mJt(i,e.length),i}transformVector(e,r){return this.transform(e,r)}transformVector2(e,r){return this.transform(e,r)}transformVector3(e,r){return this.transform(e,r)}}let FX,NX=null;function GJt(){return FX||(FX=new T3([0,0,0,0,0,0,0,0,0]),Object.freeze(FX)),FX}function WJt(){return NX||(NX=new T3,Object.freeze(NX)),NX}const kX="KHR_texture_transform",jJt=kX,LX=new FZ,XJt=new T3,zJt=new T3;async function VJt(t,e){var i;if(!new ql(t).hasExtension(kX)||!((i=e.gltf)!=null&&i.loadBuffers))return;const r=t.json.materials||[];for(let s=0;s<r.length;s++)YJt(s,t)}function YJt(t,e){var o,n,a,l;const r=(o=e.json.materials)==null?void 0:o[t],i=[(n=r==null?void 0:r.pbrMetallicRoughness)==null?void 0:n.baseColorTexture,r==null?void 0:r.emissiveTexture,r==null?void 0:r.normalTexture,r==null?void 0:r.occlusionTexture,(a=r==null?void 0:r.pbrMetallicRoughness)==null?void 0:a.metallicRoughnessTexture],s=[];for(const c of i)c&&((l=c==null?void 0:c.extensions)!=null&&l[kX])&&$Jt(e,t,c,s)}function $Jt(t,e,r,i){const s=HJt(r,i);if(!s)return;const o=t.json.meshes||[];for(const n of o)for(const a of n.primitives){const l=a.material;Number.isFinite(l)&&e===l&&KJt(t,a,s)}}function HJt(t,e){var o;const r=(o=t.extensions)==null?void 0:o[kX],{texCoord:i=0}=t,{texCoord:s=i}=r;if(e.findIndex(([n,a])=>n===i&&a===s)===-1){const n=JJt(r);return i!==s&&(t.texCoord=s),e.push([i,s]),{originalTexCoord:i,texCoord:s,matrix:n}}return null}function KJt(t,e,r){var a,l;const{originalTexCoord:i,texCoord:s,matrix:o}=r,n=e.attributes[`TEXCOORD_${i}`];if(Number.isFinite(n)){const c=(a=t.json.accessors)==null?void 0:a[n];if(c&&c.bufferView!==void 0){const h=(l=t.json.bufferViews)==null?void 0:l[c.bufferView];if(h){const{arrayBuffer:u,byteOffset:d}=t.buffers[h.buffer],f=(d||0)+(c.byteOffset||0)+(h.byteOffset||0),{ArrayType:g,length:p}=gyt(c,h),m=dyt[c.componentType],v=uyt[c.type],b=h.byteStride||m*v,y=new Float32Array(p);for(let _=0;_<c.count;_++){const w=new g(u,f+_*b,2);LX.set(w[0],w[1],1),LX.transformByMatrix3(o),y.set([LX[0],LX[1]],_*v)}i===s?qJt(c,t,y,c.bufferView):ZJt(s,c,e,t,y)}}}}function qJt(t,e,r,i){t.componentType=5126,t.byteOffset=0;const s=(e.json.accessors||[]).reduce((a,l)=>l.bufferView===i?a+1:a,0)>1;e.buffers.push({arrayBuffer:AX(r.buffer),byteOffset:0,byteLength:r.buffer.byteLength});const o=e.buffers.length-1;if(e.json.bufferViews=e.json.bufferViews||[],s){e.json.bufferViews.push({buffer:o,byteLength:r.buffer.byteLength,byteOffset:0}),t.bufferView=e.json.bufferViews.length-1;return}const n=e.json.bufferViews[i];n&&(n.buffer=o,n.byteOffset=0,n.byteLength=r.buffer.byteLength,n.byteStride!==void 0&&delete n.byteStride)}function ZJt(t,e,r,i,s){i.buffers.push({arrayBuffer:AX(s.buffer),byteOffset:0,byteLength:s.buffer.byteLength}),i.json.bufferViews=i.json.bufferViews||[];const o=i.json.bufferViews;o.push({buffer:i.buffers.length-1,byteLength:s.buffer.byteLength,byteOffset:0});const n=i.json.accessors;n&&(n.push({bufferView:(o==null?void 0:o.length)-1,byteOffset:0,componentType:5126,count:e.count,type:"VEC2"}),r.attributes[`TEXCOORD_${t}`]=n.length-1)}function JJt(t){const{offset:e=[0,0],rotation:r=0,scale:i=[1,1]}=t,s=new T3().set(1,0,0,0,1,0,e[0],e[1],1),o=XJt.set(Math.cos(r),Math.sin(r),0,-Math.sin(r),Math.cos(r),0,0,0,1),n=zJt.set(i[0],0,0,0,i[1],0,0,0,1);return s.multiplyRight(o).multiplyRight(n)}const QJt=Object.freeze(Object.defineProperty({__proto__:null,decode:VJt,name:jJt},Symbol.toStringTag,{value:"Module"})),eS="KHR_lights_punctual",tQt=eS;async function eQt(t){const e=new ql(t),{json:r}=e,i=e.getExtension(eS);i&&(e.json.lights=i.lights,e.removeExtension(eS));for(const s of r.nodes||[]){const o=e.getObjectExtension(s,eS);o&&(s.light=o.light),e.removeObjectExtension(s,eS)}}async function rQt(t){const e=new ql(t),{json:r}=e;if(r.lights){const i=e.addExtension(eS);jf(!i.lights),i.lights=r.lights,delete r.lights}if(e.json.lights){for(const i of e.json.lights){const s=i.node;e.addObjectExtension(s,eS,i)}delete e.json.lights}}const iQt=Object.freeze(Object.defineProperty({__proto__:null,decode:eQt,encode:rQt,name:tQt},Symbol.toStringTag,{value:"Module"})),R3="KHR_materials_unlit",sQt=R3;async function oQt(t){const e=new ql(t),{json:r}=e;for(const i of r.materials||[])i.extensions&&i.extensions.KHR_materials_unlit&&(i.unlit=!0),e.removeObjectExtension(i,R3);e.removeExtension(R3)}function nQt(t){const e=new ql(t),{json:r}=e;if(e.materials)for(const i of r.materials||[])i.unlit&&(delete i.unlit,e.addObjectExtension(i,R3,{}),e.addExtension(R3))}const aQt=Object.freeze(Object.defineProperty({__proto__:null,decode:oQt,encode:nQt,name:sQt},Symbol.toStringTag,{value:"Module"})),C3="KHR_techniques_webgl",lQt=C3;async function cQt(t){const e=new ql(t),{json:r}=e,i=e.getExtension(C3);if(i){const s=uQt(i,e);for(const o of r.materials||[]){const n=e.getObjectExtension(o,C3);n&&(o.technique=Object.assign({},n,s[n.technique]),o.technique.values=dQt(o.technique,e)),e.removeObjectExtension(o,C3)}e.removeExtension(C3)}}async function hQt(t,e){}function uQt(t,e){const{programs:r=[],shaders:i=[],techniques:s=[]}=t,o=new TextDecoder;
vendor: 4,268 bytes, line 7156
7156return i.forEach(n=>{if(Number.isFinite(n.bufferView))n.code=o.decode(e.getTypedArrayForBufferView(n.bufferView));else throw new Error("KHR_techniques_webgl: no shader code")}),r.forEach(n=>{n.fragmentShader=i[n.fragmentShader],n.vertexShader=i[n.vertexShader]}),s.forEach(n=>{n.program=r[n.program]}),s}function dQt(t,e){const r=Object.assign({},t.values);return Object.keys(t.uniforms||{}).forEach(i=>{t.uniforms[i].value&&!(i in r)&&(r[i]=t.uniforms[i].value)}),Object.keys(r).forEach(i=>{typeof r[i]=="object"&&r[i].index!==void 0&&(r[i].texture=e.getTexture(r[i].index))}),r}const fQt=Object.freeze(Object.defineProperty({__proto__:null,decode:cQt,encode:hQt,name:lQt},Symbol.toStringTag,{value:"Module"})),Vyt=[Mqt,tqt,HZt,ZZt,tJt,uJt,iQt,aQt,fQt,QJt,Yqt];function pQt(t,e={},r){var s;const i=Vyt.filter(o=>Yyt(o.name,e));for(const o of i)(s=o.preprocess)==null||s.call(o,t,e,r)}async function gQt(t,e={},r){var s;const i=Vyt.filter(o=>Yyt(o.name,e));for(const o of i)await((s=o.decode)==null?void 0:s.call(o,t,e,r))}function Yyt(t,e){var i;const r=((i=e==null?void 0:e.gltf)==null?void 0:i.excludeExtensions)||{};return!(t in r&&!r[t])}const kZ="KHR_binary_glTF";function mQt(t){const e=new ql(t),{json:r}=e;for(const i of r.images||[]){const s=e.getObjectExtension(i,kZ);s&&Object.assign(i,s),e.removeObjectExtension(i,kZ)}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,e.removeExtension(kZ)}const $yt={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},yQt={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class vQt{constructor(){W(this,"idToIndexMap",{animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}});W(this,"json")}normalize(e,r){this.json=e.json;const i=e.json;switch(i.asset&&i.asset.version){case"2.0":return;case void 0:case"1.0":break;default:console.warn(`glTF: Unknown version ${i.asset.version}`);return}if(!r.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(i),this._convertTopLevelObjectsToArrays(i),mQt(e),this._convertObjectIdsToArrayIndices(i),this._updateObjects(i),this._updateMaterial(i)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const r in $yt)this._convertTopLevelObjectToArray(e,r)}_convertTopLevelObjectToArray(e,r){const i=e[r];if(!(!i||Array.isArray(i))){e[r]=[];for(const s in i){const o=i[s];o.id=o.id||s;const n=e[r].length;e[r].push(o),this.idToIndexMap[r][s]=n}}}_convertObjectIdsToArrayIndices(e){for(const r in $yt)this._convertIdsToIndices(e,r);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const r of e.textures)this._convertTextureIds(r);for(const r of e.meshes)this._convertMeshIds(r);for(const r of e.nodes)this._convertNodeIds(r);for(const r of e.scenes)this._convertSceneIds(r)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const r of e.primitives){const{attributes:i,indices:s,material:o}=r;for(const n in i)i[n]=this._convertIdToIndex(i[n],"accessor");s&&(r.indices=this._convertIdToIndex(s,"accessor")),o&&(r.material=this._convertIdToIndex(o,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(r=>this._convertIdToIndex(r,"node"))),e.meshes&&(e.meshes=e.meshes.map(r=>this._convertIdToIndex(r,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(r=>this._convertIdToIndex(r,"node")))}_convertIdsToIndices(e,r){e[r]||(console.warn(`gltf v1: json doesn't contain attribute ${r}`),e[r]=[]);for(const i of e[r])for(const s in i){const o=i[s],n=this._convertIdToIndex(o,s);i[s]=n}}_convertIdToIndex(e,r){const i=yQt[r];if(i in this.idToIndexMap){const s=this.idToIndexMap[i][e];if(!Number.isFinite(s))throw new Error(`gltf v1: failed to resolve ${r}
7156 with id ${e}`);return s}return e}_updateObjects(e){for(const r of this.json.buffers)delete r.type}_updateMaterial(e){var r,i,s;for(const o of e.materials){o.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const n=((r=o.values)==null?void 0:r.tex)||((i=o.values)==null?void 0:i.texture2d_0)||((s=o.values)==null?void 0:s.diffuseTex),a=e.textures.findIndex(l=>l.id===n);a!==-1&&(o.pbrMetallicRoughness.baseColorTexture={index:a})}}}function _Qt(t,e={}){return new vQt().normalize(t,e)}async function bQt(t,e,r=0,i,s){var o,n,a;return wQt(t,e,r,i),_Qt(t,{normalize:(o=i==null?void 0:i.gltf)==null?void 0:o.normalize}),pQt(t,i,s),(n=i==null?void 0:i.gltf)!=null&&n.loadBuffers&&t.json.buffers&&await EQt(t,i,s),(a=i==null?void 0:i.gltf)!=null&&a.loadImages&&await AQt(t,i,s),await gQt(t,i,s),t}function wQt(t,e,r,i){var n,a;if((n=i.core)!=null&&n.baseUrl&&(t.baseUri=(a=i.core)==null?void 0:a.baseUrl),e instanceof ArrayBuffer&&!CZt(e,r,i.glb)&&(e=new TextDecoder().decode(e)),typeof e=="string")t.json=IKt(e);else if(e instanceof ArrayBuffer){const l={};r=MZt(l,e,r,i.glb),jf(l.type==="glTF",`Invalid GLB magic string ${l.type}`),t._glb=l,t.json=l.json}else jf(!1,"GLTF: must be ArrayBuffer or string");const s=t.json.buffers||[];if(t.buffers=new Array(s.length).fill(null),t._glb&&t._glb.header.hasBinChunk){const{binChunks:l}=t._glb;t.buffers[0]={arrayBuffer:l[0].arrayBuffer,byteOffset:l[0].byteOffset,byteLength:l[0].byteLength}}const o=t.json.images||[];t.images=new Array(o.length).fill({})}async function EQt(t,e,r){var s,o,n;const i=t.json.buffers||[];for(let a=0;a<i.length;++a){const l=i[a];if(l.uri){const{fetch:c}=r;jf(c);const h=Nyt(l.uri,e,r),u=await((n=(o=await((s=r==null?void 0:r.fetch)==null?void 0:s.call(r,h)))==null?void 0:o.arrayBuffer)==null?void 0:n.call(o));t.buffers[a]={arrayBuffer:u,byteOffset:0,byteLength:u.byteLength},delete l.uri}else t.buffers[a]===null&&(t.buffers[a]={arrayBuffer:new ArrayBuffer(l.byteLength),byteOffset:0,byteLength:l.byteLength})}}async function AQt(t,e,r){const i=xQt(t),s=t.json.images||[],o=[];for(const n of i)o.push(SQt(t,s[n],n,e,r));return await Promise.all(o)}function xQt(t){const e=new Set,r=t.json.textures||[];for(const i of r)i.source!==void 0&&e.add(i.source);return Array.from(e).sort()}async function SQt(t,e,r,i,s){let o;if(e.uri&&!e.hasOwnProperty("bufferView")){const c=Nyt(e.uri,i,s),{fetch:h}=s;o=await(await h(c)).arrayBuffer(),e.bufferView={data:o}}if(Number.isFinite(e.bufferView)){const c=UKt(t.json,t.buffers,e.bufferView);o=cyt(c.buffer,c.byteOffset,c.byteLength)}jf(o,"glTF image has no data");const n=i,a={...n,core:{...n==null?void 0:n.core,mimeType:e.mimeType}};let l=await ayt(o,[Hh,wZt],a,s);l&&l[0]&&(l={compressed:!0,mipmaps:!1,width:l[0].width,height:l[0].height,data:l[0]}),t.images=t.images||[],t.images[r]=l}tG={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:$qt,extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:TQt,options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0}}};async function TQt(t,e={},r){var o;const i={...tG.options,...e};i.gltf={...tG.options.gltf,...i.gltf};const s=((o=e==null?void 0:e.glb)==null?void 0:o.byteOffset)||0;return await bQt({},t,s,i,r)}function UX(t,e){var r,i,s,o,n;const a=t.json.accessors[e],l=t.json.bufferViews[a.bufferView],c=t.buffers[l.buffer];if(!(c!=null&&c.arrayBuffer))throw new Error("glTF buffer missing (external .bin not loaded?)");const h=((r=c.byteOffset)!==null&&r!==void 0?r:0)+((i=l.byteOffset)!==null&&i!==void 0?i:0)+((s=a.byteOffset)!==null&&s!==void 0?s:0),u=c.arrayBuffer,d=a.type==="SCALAR"?1:a.type==="VEC2"?2:a.type==="VEC3"?3:a.type==="VEC4"?4:3;if(a.componentType===5126&&a.type==="VEC2"){const f=a.count,g=(o=l.byteStride)!==null&&o!==void 0?o:8;if(g===8)return{array:new Float32Array(u,h,f*2),components:2};const p=new Float32Array(f*2),m=new DataView(u);let v=h;for(let b=0;b<f;b++)p[b*2]=m.getFloat32(v,!0),p[b*2+1]=m.getFloat32(v+4,!0),v+=g;return{array:p,components:2}}if(a.componentType===5126&&a.type==="VEC3"){const f=a.count,g=(n=l.byteStride)!==null&&n!==void 0?n:12;if(g===12)return{array:new Float32Array(u,h,f*3),components:3};const p=new Float32Array(f*3),m=new DataView(u);let v=h;for(let b=0;b<f;b++)p[b*3]=m.getFloat32(v,!0),p[b*3+1]=m.getFloat32(v+4,!0),p[b*3+2]=m.getFloat32(v+8,!0),v+=g;return{array:p,components:3}}if(a.componentType===5123)return{array:new Uint16Array(u,h,a.count*d),components:d};if(a.componentType===5125)return{array:new Uint32Array(u,h,a.count*d),components:d};throw new Error(`Unsupported glTF accessor type ${a.type} / component ${a.componentType}`)}function RQt(t,e){const r=new Float32Array(t.length);for(let i=0;i<e.length;i+=3){const s=e[i]*3,o=e[i+1]*3,n=e[i+2]*3,a=t[o]-t[s],l=t[o+1]-t[s+1],c=t[o+2]-t[s+2],h=t[n]-t[s],u=t[n+1]-t[s+1],d=t[n+2]-t[s+2],f=l*d-c*u,g=c*h-a*d,p=a*u-l*h;for(const m of[s,o,n])r[m]+=f,r[m+1]+=g,r[m+2]+=p}for(let i=0;i<r.length;i+=3){const s=Math.hypot(r[i],r[i+1],r[i+2]);s>1e-8?(r[i]/=s,r[i+1]/=s,r[i+2]/=s):r[i+2]=1}return r}function CQt(t){if(t.length<3)return;let e=1/0,r=1/0,i=1/0,s=-1/0,o=-1/0,n=-1/0;for(let d=0;d<t.length;
7156d+=3){const f=t[d],g=t[d+1],p=t[d+2];e=Math.min(e,f),r=Math.min(r,g),i=Math.min(i,p),s=Math.max(s,f),o=Math.max(o,g),n=Math.max(n,p)}const a=(e+s)/2,l=(r+o)/2,c=(i+n)/2,h=Math.max(s-e,o-r,n-i),u=h>1e-8?1/h:1;for(let d=0;d<t.length;d+=3)t[d]=(t[d]-a)*u,t[d+1]=(t[d+1]-l)*u,t[d+2]=(t[d+2]-c)*u}function MQt(t,e){if(e.startsWith("data:")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/"))return e;const r=t.replace(/[#?].*$/,""),i=r.lastIndexOf("/");return(i>=0?r.slice(0,i+1):"")+e}function BQt(t,e,r){var i,s,o,n,a,l,c,h;const u=(n=(o=(s=(i=t.materials)===null||i===void 0?void 0:i[e])===null||s===void 0?void 0:s.pbrMetallicRoughness)===null||o===void 0?void 0:o.baseColorTexture)===null||n===void 0?void 0:n.index;if(u==null)return null;const d=(l=(a=t.textures)===null||a===void 0?void 0:a[u])===null||l===void 0?void 0:l.source;if(d==null)return null;const f=(h=(c=t.images)===null||c===void 0?void 0:c[d])===null||h===void 0?void 0:h.uri;return f?MQt(r,f):null}function OQt(t,e){var r,i,s;if(e==null)return[1,1,1,1];const o=(s=(i=(r=t.materials)===null||r===void 0?void 0:r[e])===null||i===void 0?void 0:i.pbrMetallicRoughness)===null||s===void 0?void 0:s.baseColorFactor;return!o||o.length<3?[1,1,1,1]:[o[0],o[1],o[2],o.length>=4?o[3]:1]}function IQt(t){var e,r,i;const s=cc();return t.matrix&&t.matrix.length===16?(TOt(s,t.matrix),s):(MOt(s,(e=t.rotation)!==null&&e!==void 0?e:[0,0,0,1],(r=t.translation)!==null&&r!==void 0?r:[0,0,0],(i=t.scale)!==null&&i!==void 0?i:[1,1,1]),s)}function DQt(t,e){const r=Xa();for(let i=0;i<t.length;i+=3)d0(r,t[i],t[i+1],t[i+2]),sf(r,r,e),t[i]=r[0],t[i+1]=r[1],t[i+2]=r[2]}function PQt(t,e){const r=cc();M4(r,e),M$(r,r);const i=Xa();for(let s=0;s<t.length;s+=3){d0(i,t[s],t[s+1],t[s+2]),sf(i,i,r);const o=Zst(i);o>1e-8&&FOt(i,i,1/o),t[s]=i[0],t[s+1]=i[1],t[s+2]=i[2]}}function Hyt(t,e,r,i,s,o,n,a,l,c,h,u){var d,f,g;const p=(d=e.meshes)===null||d===void 0?void 0:d[r];if(p)for(const m of(f=p.primitives)!==null&&f!==void 0?f:[]){if(((g=m.mode)!==null&&g!==void 0?g:4)!==4)continue;const v=m.attributes.POSITION;if(v===void 0)continue;const b=UX(t,v);if(b.components!==3||!(b.array instanceof Float32Array))continue;const y=new Float32Array(b.array),_=y.length/3;DQt(y,i);let w;const E=m.attributes.NORMAL;if(E!==void 0){const S=UX(t,E);S.components===3&&S.array instanceof Float32Array&&S.array.length===y.length?(w=new Float32Array(S.array),PQt(w,i)):w=new Float32Array(y.length)}else w=new Float32Array(y.length);let A;const x=m.attributes.TEXCOORD_0;if(x!==void 0){const S=UX(t,x);S.components===2&&S.array instanceof Float32Array&&S.array.length===_*2?A=new Float32Array(S.array):A=new Float32Array(_*2)}else A=new Float32Array(_*2);if(s.push(y),o.push(w),n.push(A),m.material!==void 0&&(c.value[0]===1&&(c.value=OQt(e,m.material)),h.value==null&&u&&(h.value=BQt(e,m.material,u))),m.indices!==void 0){const S=UX(t,m.indices);let T;if(S.array instanceof Uint32Array)T=S.array;else if(S.array instanceof Uint16Array){T=new Uint32Array(S.array.length);for(let R=0;R<S.array.length;R++)T[R]=S.array[R]}else continue;for(let R=0;R<T.length;R++)a.push(l.value+T[R])}else for(let S=0;S<_;S+=3)a.push(l.value+S,l.value+S+1,l.value+S+2);l.value+=_}}function Kyt(t,e,r,i,s,o,n,a,l,c,h,u,d){var f,g;const p=(f=e.nodes)===null||f===void 0?void 0:f[r];if(!p)return;const m=IQt(p),v=cc();B$(v,i,m),p.mesh!==void 0&&(d==null||p.mesh===d)&&Hyt(t,e,p.mesh,v,s,o,n,a,l,c,h,u);for(const b of(g=p.children)!==null&&g!==void 0?g:[])Kyt(t,e,b,v,s,o,n,a,l,c,h,u,d)}function FQt(t,e){var r,i;const s=t.json,o=[],n=[],a=[],l=[],c={value:0},h={value:[1,1,1,1]},u={value:null},d=cc(),f=(r=e==null?void 0:e.scene)!==null&&r!==void 0?r:0,g=(i=s.scenes)===null||i===void 0?void 0:i[f];if(g!=null&&g.nodes)for(const A of g.nodes)Kyt(t,s,A,d,o,n,a,l,c,h,u,e==null?void 0:e.baseUrl,e==null?void 0:e.mesh);else(e==null?void 0:e.mesh)!=null&&Hyt(t,s,e.mesh,d,o,n,a,l,c,h,u,e==null?void 0:e.baseUrl);if(o.length===0)return{positions:new Float32Array(0),normals:new Float32Array(0),indices:new Uint32Array(0),baseColor:h.value,map:u.value};const p=o.reduce((A,x)=>A+x.length,0),m=new Float32Array(p),v=new Float32Array(p),b=new Float32Array(p/3*2);let y=0,_=0;for(let A=0;A<o.length;A++){m.set(o[A],y);const x=n[A];x.length===o[A].length&&v.set(x,y);const S=a[A];S.length===o[A].length/3*2&&b.set(S,_),y+=o[A].length,_+=S.length}const w=new Uint32Array(l);for(let A=0;A<v.length;A+=3)Math.hypot(v[A],v[A+1],v[A+2])<1e-6&&(v[A]=NaN);const E=RQt(m,w);for(let A=0;A<v.length;A+=3)Number.isFinite(v[A])||(v[A]=E[A],v[A+1]=E[A+1],v[A+2]=E[A+2]);return CQt(m),{positions:m,normals:v,indices:w,uvs:b,baseColor:h.value,map:u.value}}var qyt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};const NQt={gltf:{loadBuffers:!0,loadImages:!0},DracoLoader:xV},Zyt=new Map;function kQt(t,e){return JSON.stringify({url:t,mesh:e??null})}function LQt(t,e){return qyt(this,void 0,void 0,function*(){const r=kQt(t,e==null?void 0:e.mesh);let i=Zyt.get(r);
7156return i||(i=qyt(this,void 0,void 0,function*(){const s=yield nu(t,tG,NQt);return FQt(s,Object.assign(Object.assign({},e),{baseUrl:t}))}),Zyt.set(r,i)),i})}function UQt(t){return LQt(t.url,{mesh:t.mesh})}const Jyt=new WeakMap;function GX(t){if(!t.has(je))return;const e=yw(t.read(je).geometry);if(!Kj(e))return;const r=t.read(je).meshEntity;if(!r||!nr(r)||!r.has(Ns)||r.read(Ns).positions.length>0||!r.has(js))return;const i=r.read(js).canvas;if(!nr(i))return;const s=i.read(wt).api;if(!s)return;let o=Jyt.get(s);o||(o=new Set,Jyt.set(s,o));const n=qj(e),a=`${t.__id}:${n}`;o.has(a)||(o.add(a),UQt(e).then(l=>{s.runAtNextTick(()=>{var c;if(!nr(t)||!t.has(je)||qj(yw(t.read(je).geometry))!==n)return;const h=t.read(je).meshEntity;if(!h||!nr(h)||!h.has(Ns))return;const u=h.write(Ns);if(Object.assign(u,{positions:l.positions,normals:l.normals,indices:l.indices}),u.uvs=(c=l.uvs)!==null&&c!==void 0?c:null,h.has(Ni)){const d=h.read(Ni);d.baseColor[0]!==1||d.baseColor[1]!==1||d.baseColor[2]!==1||d.baseColor[3]!==1||(h.write(Ni).baseColor=[...l.baseColor]),l.map&&!d.map&&(h.write(Ni).map=l.map,t.has(je)&&!t.read(je).map&&(t.write(je).map=l.map))}zgt(t)})}).catch(l=>{console.warn("[requestGltfMeshLoad] failed to load glTF",e.url,l),B9t(t)}).finally(()=>{o.delete(a)}))}const LZ={linear:cr(0,0,1,1),ease:cr(.25,.1,.25,1),"ease-in":cr(.42,0,1,1),"ease-out":cr(0,0,.58,1),"ease-in-out":cr(.42,0,.58,1)},rS={duration:300,delay:0,iterations:1,direction:"normal",fill:"none",easing:"linear"},Qyt=new Set(["offset","easing"]);function jh(t){return Math.max(0,Math.min(1,t))}function sv(t){return typeof t=="number"&&Number.isFinite(t)}function GQt(t){if(sv(t.offset))return jh(t.offset)}function UZ(t,e){return t&&(LZ[t]||/^spring\(\s*[-\d.]+\s*,\s*[-\d.]+\s*,\s*[-\d.]+\s*\)$/.test(t))?t:e}function GZ(t){var e,r,i;const s=sv(t.duration)?Math.max(0,t.duration):rS.duration,o=sv(t.delay)?Math.max(0,t.delay):rS.delay,n=(e=t.direction)!==null&&e!==void 0?e:rS.direction,a=(r=t.fill)!==null&&r!==void 0?r:rS.fill,l=(i=t.iterations)!==null&&i!==void 0?i:rS.iterations,c=UZ(t.easing,rS.easing),h=t.transformOrigin&&sv(t.transformOrigin.x)&&sv(t.transformOrigin.y)?{x:t.transformOrigin.x,y:t.transformOrigin.y}:void 0;return{duration:s,delay:o,direction:n,fill:a,iterations:l,easing:c,transformOrigin:h}}function WX(t,e=rS.easing){if(!Array.isArray(t)||t.length===0)throw new Error("keyframes must contain at least one item.");const r=t.map(n=>Object.assign({},n)),i=r.length,s=new Array(i);for(let n=0;n<i;n++){const a=GQt(r[n]);s[n]=a??NaN}Number.isNaN(s[0])&&(s[0]=0),Number.isNaN(s[i-1])&&(s[i-1]=1);let o=0;for(;o<i;){if(!Number.isNaN(s[o])){o++;continue}const n=o-1;let a=o;for(;a<i&&Number.isNaN(s[a]);)a++;const l=n>=0?s[n]:0,c=a<i?s[a]:1,h=a-n;for(let u=1;u<h;u++)s[n+u]=l+(c-l)*u/h;o=a}return r.map((n,a)=>{const l={};return Object.keys(n).forEach(c=>{Qyt.has(c)||(l[c]=n[c])}),Object.assign(Object.assign({},l),{offset:jh(s[a]),easing:UZ(n.easing,UZ(e,"linear"))})}).sort((n,a)=>n.offset-a.offset)}function WZ(t){return t==="infinite"?1/0:Math.max(0,t)}function t0t(t){return t==="backwards"||t==="both"}function e0t(t){return t==="forwards"||t==="both"}function WQt(t){const e=t.match(/^spring\(\s*([-\d.]+)\s*,\s*([-\d.]+)\s*,\s*([-\d.]+)\s*\)$/);if(!e)return null;const r=Number(e[1]),i=Number(e[2]),s=Number(e[3]);return!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(s)||r<=0||i<=0?null:{mass:r,stiffness:i,damping:s}}function jQt(t,e){const r=WQt(e);if(!r)return t;const{mass:i,stiffness:s,damping:o}=r,n=Math.sqrt(s/i),a=o/(2*Math.sqrt(s*i));if(a<1){const c=n*Math.sqrt(1-a*a),h=1-Math.exp(-a*n*t)*(Math.cos(c*t)+a/Math.sqrt(1-a*a)*Math.sin(c*t));return jh(h)}const l=1-Math.exp(-n*t);return jh(l)}function XQt(t,e){const r=jh(e),i=LZ[t];return i?jh(i(r)):t.startsWith("spring(")?jQt(r,t):r}function ov(t){return Math.max(0,Math.min(255,t))}function jZ(t){if(typeof t!="string")return null;const e=t.trim();if(!e)return null;const r=sr.color(e);if(r){const i=r.rgb(),s=Number.isFinite(i.r)?i.r:0,o=Number.isFinite(i.g)?i.g:0,n=Number.isFinite(i.b)?i.b:0,a=Number.isFinite(i.opacity)?i.opacity:1;return{r:ov(s),g:ov(o),b:ov(n),a:jh(a)}}return null}function zQt(t){return`rgba(${Math.round(ov(t.r))}, ${Math.round(ov(t.g))}, ${Math.round(ov(t.b))}, ${jh(t.a)})`}function gn(t,e,r){return t+(e-t)*r}function r0t(t){let e;try{e=nm(t)}catch{return null}if(!e||e.length===0)return null;const r=e[0];if(!r||r.type!=="linear-gradient")return null;const i=r,s=i.steps.map(o=>{const n=jZ(o.color);if(!n)return null;let a=o.offset.value;
7156return o.offset.type==="%"&&(a/=100),{offset:jh(a),r:n.r,g:n.g,b:n.b,a:n.a}}).filter(o=>!!o);return s.length===0?null:{angleDeg:i.angle,stops:s}}function VQt(t,e){const r=[...t].sort((n,a)=>n.offset-a.offset),i=jh(e);if(r.length===1){const n=r[0];return{r:n.r,g:n.g,b:n.b,a:n.a}}if(i<=r[0].offset){const n=r[0];return{r:n.r,g:n.g,b:n.b,a:n.a}}const s=r[r.length-1];if(i>=s.offset)return{r:s.r,g:s.g,b:s.b,a:s.a};for(let n=0;n<r.length-1;n++){const a=r[n],l=r[n+1];if(i>=a.offset&&i<=l.offset){const c=l.offset-a.offset,h=c<1e-12?0:(i-a.offset)/c;return{r:gn(a.r,l.r,h),g:gn(a.g,l.g,h),b:gn(a.b,l.b,h),a:gn(a.a,l.a,h)}}}const o=r[0];return{r:o.r,g:o.g,b:o.b,a:o.a}}function i0t(t,e){if(t.length===0||e<1)return[];const r=[];for(let i=0;i<e;i++){const s=e===1?t[0].offset:i/(e-1),o=VQt(t,s);r.push({offset:s,r:o.r,g:o.g,b:o.b,a:o.a})}return r}function YQt(t){const e=t*100;return`${Math.round(e*1e6)/1e6}%`}function $Qt(t){const e=t.stops.map(r=>{const i=Math.round(ov(r.r)),s=Math.round(ov(r.g)),o=Math.round(ov(r.b)),n=r.a;return`${n<.999999?`rgba(${i}, ${s}, ${o}, ${jh(n)})`:`rgb(${i}, ${s}, ${o})`} ${YQt(r.offset)}`});return`linear-gradient(${t.angleDeg}deg, ${e.join(", ")})`}function HQt(t,e,r){if(typeof t!="string"||typeof e!="string")return null;const i=r0t(t.trim()),s=r0t(e.trim());if(!i||!s)return null;const o=Math.max(i.stops.length,s.stops.length,2),n=i0t(i.stops,o),a=i0t(s.stops,o);if(n.length!==o||a.length!==o)return null;const l=gn(i.angleDeg,s.angleDeg,r),c=n.map((h,u)=>({offset:jh(gn(h.offset,a[u].offset,r)),r:gn(h.r,a[u].r,r),g:gn(h.g,a[u].g,r),b:gn(h.b,a[u].b,r),a:gn(h.a,a[u].a,r)}));return c.sort((h,u)=>h.offset-u.offset),$Qt({angleDeg:l,stops:c})}function s0t(t){if(Array.isArray(t)&&t.length>=2){const e=Number(t[0]),r=Number(t[1]);return Number.isFinite(e)&&Number.isFinite(r)?[e,r]:null}if(typeof t=="string"){const e=t.trim().split(/[\s,]+/).filter(Boolean).map(r=>Number(r));if(e.length>=2&&e.every(r=>Number.isFinite(r)))return[e[0],e[1]]}return null}function o0t(t){if(typeof t!="string")return!1;const e=t.trim();return e?/^(linear|radial|conic)-gradient\(/i.test(e)||/^url\(/i.test(e)||/^(none|inherit|currentcolor)$/i.test(e):!1}function n0t(t){if(t===""||Array.isArray(t)&&t.length===0)return{absolutePath:[],curve:null};let e;try{e=O4(t)}catch{e=O4(""),console.error(`[g]: Invalid SVG Path definition: ${t}`)}return{absolutePath:e,curve:null}}function KQt(t,e){let r=t.curve,i=e.curve;(!r||r.length===0)&&(r=F$(t.absolutePath,!1),t.curve=r),(!i||i.length===0)&&(i=F$(e.absolutePath,!1),e.curve=i);let s=[r,i];r.length!==i.length&&(s=hot(r,i));const o=lot(s[0])!==lot(s[1])?QOt(s[0]):JOt(s[0]);return[o,aIt(s[1],o),n=>n]}function a0t(t){return Array.isArray(t)&&t.length>0&&Array.isArray(t[0])&&typeof t[0][0]=="string"}function qQt(t,e,r){const i=[],s=Math.min(t.length,e.length);for(let o=0;o<s;o++){const n=t[o],a=e[o],l=n[0];l==="M"?i.push(["M",gn(n[1],a[1],r),gn(n[2],a[2],r)]):l==="C"?i.push(["C",gn(n[1],a[1],r),gn(n[2],a[2],r),gn(n[3],a[3],r),gn(n[4],a[4],r),gn(n[5],a[5],r),gn(n[6],a[6],r)]):i.push([...n])}return i}function ZQt(t,e,r){const i=typeof t=="string"||a0t(t),s=typeof e=="string"||a0t(e);if(!i||!s||o0t(t)||o0t(e))return null;const o=n0t(t),n=n0t(e);if(o.absolutePath.length===0||n.absolutePath.length===0)return null;try{const[a,l]=KQt(o,n),c=qQt(a,l,r);return Bv(c,"off")}catch{return null}}function JQt(t,e,r){if(sv(t)&&sv(e))return gn(t,e,r);const i=s0t(t),s=s0t(e);if(i&&s)return[gn(i[0],s[0],r),gn(i[1],s[1],r)];const o=jZ(t),n=jZ(e);if(o&&n)return zQt({r:gn(o.r,n.r,r),g:gn(o.g,n.g,r),b:gn(o.b,n.b,r),a:gn(o.a,n.a,r)});const a=HQt(t,e,r);if(a!==null)return a;const l=ZQt(t,e,r);return l!==null?l:r<1?t:e}function jX(t){const e=new Set;return t.forEach(r=>{Object.keys(r).forEach(i=>{Qyt.has(i)||e.add(i)})}),[...e]}class XX{constructor(e,r){this.playState="idle",this.holdTime=0,this.currentTime=0,this.playbackRate=1,this.options=GZ(r),this.keyframes=WX(e,this.options.easing)}getKeyframes(){return this.keyframes}getAnimatedProperties(){return jX(this.keyframes)}getOptions(){return this.options}serialize(){return{keyframes:this.keyframes.map(e=>Object.assign({},e)),options:Object.assign({},this.options)}}getDuration(){const e=WZ(this.options.iterations),r=Number.isFinite(e)?this.options.duration*e:this.options.duration;return this.options.delay+r}setKeyframes(e){this.keyframes=WX(e,this.options.easing)}setOptions(e){var r;const i=Object.assign(Object.assign({},this.options),e);"transformOrigin"in e&&(i.transformOrigin=(r=e.transformOrigin)!==null&&r!==void 0?r:void 0),this.options=GZ(i),this.keyframes=WX(this.keyframes,this.options.easing)}updateKeyframe(e,r){if(e<0||e>=this.keyframes.length)return;const i=this.keyframes.map(s=>Object.assign({},s));i[e]=Object.assign(Object.assign({},i[e]),r),this.setKeyframes(i)}insertKeyframe(e){const r=this.keyframes.map(i=>Object.assign({},i));r.push(Object.assign({},e)),this.setKeyframes(r)}removeKeyframe(e){if(e<0||e>=this.keyframes.length||this.keyframes.length<=1)return;const r=this.keyframes.filter((i,s)=>s!==e).map(i=>Object.assign({},i));this.setKeyframes(r)}getPlaybackRate(){return this.playbackRate}setPlaybackRate(e){if(!sv(e)||e===0)throw new Error("playbackRate must be a finite non-zero number.");this.playbackRate=e}getPlayState(){return this.playState}getCurrentTime(){return this.currentTime}play(e=performance.now()){this.playState!=="running"&&(this.startTime=e-this.holdTime/Math.abs(this.playbackRate),this.playState="running")}pause(){this.playState==="running"&&(this.holdTime=this.currentTime,this.playState="paused")}reverse(e=performance.now()){this.playbackRate=-this.playbackRate,this.playState==="running"&&(this.startTime=e-this.currentTime/Math.abs(this.playbackRate))}cancel(){this.playState="cancelled",this.currentTime=0,this.holdTime=0,this.startTime=void 0}finish(){const e=WZ(this.options.iterations),r=this.options.duration*e;this.currentTime=Number.isFinite(r)?this.options.delay+r:this.currentTime,this.holdTime=this.currentTime,this.playState="finished"}seek(e){if(!sv(e))throw new Error("seek time must be finite.");this.currentTime=Math.max(0,e),this.holdTime=this.currentTime,this.playState==="idle"&&(this.playState="paused")}
7156tick(e=performance.now()){if(this.playState!=="running")return this.getSnapshot();this.startTime===void 0&&(this.startTime=e);const r=(e-this.startTime)*Math.abs(this.playbackRate);return this.currentTime=Math.max(0,r),this.getSnapshot()}getSnapshot(){const{delay:e,duration:r,iterations:i,direction:s,fill:o}=this.options,n=WZ(i),a=r*n,l=this.currentTime-e,c=l<0,h=l>a,u=!Number.isFinite(a),d=!c&&(u||!h);let f=0,g=0;if(d&&r>0){const m=u?Math.max(0,l):Math.min(l,a);g=Math.floor(m/r);let v=m%r;!u&&v===0&&g>=n&&(g=n-1,v=r),f=v/r}else h&&e0t(o)&&r>0?(f=1,g=Math.max(0,Number.isFinite(n)?n-1:0)):c&&t0t(o)&&(f=0,g=0);let p=this.playbackRate>=0?"forward":"backward";return(s==="reverse"||s==="alternate"&&g%2===1)&&(p=p==="forward"?"backward":"forward"),this.playState==="running"&&!u&&l>=a&&(this.playState="finished"),{currentTime:this.currentTime,localTime:l,activeDuration:a,progress:jh(f),currentIteration:g,isActive:d,isBefore:c,isAfter:h,direction:p,playState:this.playState}}getCurrentValues(e=this.getSnapshot()){const{fill:r}=this.options;if(!(e.isActive||e.isBefore&&t0t(r)||e.isAfter&&e0t(r))||this.keyframes.length===0)return null;const i=e.direction==="forward"?e.progress:1-e.progress,s=jh(i),o=this.keyframes[0],n=this.keyframes[this.keyframes.length-1];if(s<=o.offset){const g={};return jX(this.keyframes).forEach(p=>{g[p]=o[p]}),g}if(s>=n.offset){const g={};return jX(this.keyframes).forEach(p=>{g[p]=n[p]}),g}let a=o,l=n;for(let g=0;g<this.keyframes.length-1;g++){const p=this.keyframes[g],m=this.keyframes[g+1];if(s>=p.offset&&s<=m.offset){a=p,l=m;break}}const c=Math.max(1e-6,l.offset-a.offset),h=jh((s-a.offset)/c),u=XQt(l.easing||this.options.easing,h),d=jX(this.keyframes),f={};return d.forEach(g=>{const p=a[g],m=l[g];if(p===void 0&&m!==void 0){f[g]=m;return}if(m===void 0&&p!==void 0){f[g]=p;return}f[g]=JQt(p,m,u)}),f}}function _w(t,e){if(t===e)return!0;if(!t||!e||typeof t!="object"||typeof e!="object"||Array.isArray(t)!==Array.isArray(e))return!1;const r=Object.keys(t);return r.length===Object.keys(e).length&&r.every(i=>Object.prototype.hasOwnProperty.call(e,i)&&_w(t[i],e[i]))}function XZ(t){const e=new Map;for(const i of t){if(!i.id||e.has(i.id))throw new Error(`Duplicate or missing node id: ${i.id}`);e.set(i.id,i)}const r=new Set;for(const i of t){const s=new Set;let o=i;for(;o&&!r.has(o.id);){if(s.has(o.id))throw new Error(`Cyclic node hierarchy: ${o.id}`);if(s.add(o.id),o.parentId!=null&&!e.has(o.parentId))throw new Error(`Missing parent ${o.parentId} for node ${o.id}`);o=e.get(o.parentId)}s.forEach(n=>r.add(n))}}var $2={},zX={},l0t;function QQt(){if(l0t)return zX;
7156l0t=1,Object.defineProperty(zX,"__esModule",{value:!0}),zX.convolution1D=e;const t={wrap:(r,i)=>r>=0&&r<i?r:(r+i)%i,extend:(r,i)=>r<0?0:r>=i?i-1:r,mirror:(r,i)=>{if(r>=0&&r<i)return r;const s=(r<0?-r-1:r)%(i*2);return s<i?s:i*2-s-1}};function e(r,i,s,o={}){const[n,a=1]=r,{edge:l="wrap"}=o,c=n.length,h=i.length,u=Math.floor(c/2),d=t[l];for(let f=0;f<h;++f){let g=0;for(let p=0;p<c;++p){const m=f+(p-u),v=d(m,h);g+=i[v]*n[p]}s[f]=g/a}return s}return zX}var VX={},c0t;function tte(){if(c0t)return VX;c0t=1,Object.defineProperty(VX,"__esModule",{value:!0}),VX.convolution2D=t;function t(e,r,[i,s],o){const[n,[a,l],c=1]=e,[h,u]=[Math.floor(a/2),Math.floor(l/2)];for(let d=0;d<s;++d)for(let f=0;f<i;++f){let g=0;for(let p=0;p<l;++p)for(let m=0;m<a;++m){const v=d+(p-u),b=f+(m-h);v>=0&&v<s&&b>=0&&b<i&&(g+=r[v*i+b]*n[m+p*a])}o[d*i+f]=g/c}return o}return VX}var Zl={},h0t;function ete(){return h0t||(h0t=1,Object.defineProperty(Zl,"__esModule",{value:!0}),Zl.K_GAUSS_BLUR_7x7=Zl.K_GAUSS_BLUR_5x5=Zl.K_GAUSS_BLUR_3x3=Zl.K_BOX_BLUR_3x3=Zl.K_GAUSS_BLUR_7=Zl.K_GAUSS_BLUR_5=Zl.K_GAUSS_BLUR_3=Zl.K_BOX_BLUR_3=void 0,Zl.K_BOX_BLUR_3=[Uint8Array.of(1,1,1),3],Zl.K_GAUSS_BLUR_3=[Uint8Array.of(1,2,1),4],Zl.K_GAUSS_BLUR_5=[Uint8Array.of(1,4,6,4,1),16],Zl.K_GAUSS_BLUR_7=[Uint8Array.of(2,7,14,18,14,7,2),64],Zl.K_BOX_BLUR_3x3=[Uint8ClampedArray.of(1,1,1,1,1,1,1,1,1),[3,3],9],Zl.K_GAUSS_BLUR_3x3=[Uint8ClampedArray.of(1,2,1,2,4,4,1,2,1),[3,3],16],Zl.K_GAUSS_BLUR_5x5=[Uint8ClampedArray.of(1,4,6,4,1,4,16,24,16,4,6,24,36,24,6,4,16,24,16,4,1,4,6,4,1),[5,5],256],Zl.K_GAUSS_BLUR_7x7=[Uint8ClampedArray.of(0,0,1,2,1,0,0,0,3,13,22,13,3,0,1,13,59,97,59,13,1,2,22,97,159,97,22,2,1,13,59,97,59,13,1,0,3,13,22,13,3,0,0,0,1,2,1,0,0),[7,7],1003]),Zl}var u0t;function d0t(){return u0t||(u0t=1,(function(t){var e=$2&&$2.__createBinding||(Object.create?(function(o,n,a,l){l===void 0&&(l=a);var c=Object.getOwnPropertyDescriptor(n,a);(!c||("get"in c?!n.__esModule:c.writable||c.configurable))&&(c={enumerable:!0,get:function(){return n[a]}}),Object.defineProperty(o,l,c)}):(function(o,n,a,l){l===void 0&&(l=a),o[l]=n[a]})),r=$2&&$2.__exportStar||function(o,n){for(var a in o)a!=="default"&&!Object.prototype.hasOwnProperty.call(n,a)&&e(n,o,a)};Object.defineProperty(t,"__esModule",{value:!0}),t.convolution2D=t.convolution1D=void 0;var i=QQt();Object.defineProperty(t,"convolution1D",{enumerable:!0,get:function(){return i.convolution1D}});var s=tte();Object.defineProperty(t,"convolution2D",{enumerable:!0,get:function(){return s.convolution2D}}),r(ete(),t)})($2)),$2}var f0t=d0t(),p0t={},YX={},H2={},$X={},g0t;function rte(){if(g0t)return $X;g0t=1,$X.__esModule=!0;function t(a,l){return a*a+l*l}function e(a,l){return t(a[0]-l[0],a[1]-l[1])}function r(a,l,c){var h=l[0],u=l[1],d=c[0]-h,f=c[1]-u;if(d!==0||f!==0){var g=((a[0]-h)*d+(a[1]-u)*f)/t(d,f);g>1?(h=c[0],u=c[1]):g>0&&(h+=d*g,u+=f*g)}return t(a[0]-h,a[1]-u)}function i(a,l){for(var c=a[0],h,u=[c],d=1,f=a.length;d<f;d++)h=a[d],e(h,c)>l&&(u.push(h),c=h);return c!==h&&u.push(h),u}function s(a,l,c,h,u){for(var d=h,f,g=l+1;g<c;g++){var p=r(a[g],a[l],a[c]);p>d&&(f=g,d=p)}d>h&&(f-l>1&&s(a,l,f,h,u),u.push(a[f]),c-f>1&&s(a,f,c,h,u))}function o(a,l){var c=a.length-1,h=[a[0]];return s(a,0,c,l,h),h.push(a[c]),h}function n(a,l,c){if(l===void 0&&(l=1),c===void 0&&(c=!1),a.length<=2)return a;var h=l*l;return a=c?a:i(a,h),a=o(a,h),a}return $X.SimplifyAP=n,$X}var HX={},m0t;function ite(){if(m0t)return HX;m0t=1,HX.__esModule=!0;function t(a,l){return a*a+l*l}function e(a,l){return t(a.longitude-l.longitude,a.latitude-l.latitude)}function r(a,l,c){var h=l.longitude,u=l.latitude,d=c.longitude-h,f=c.latitude-u;if(d!==0||f!==0){var g=((a.longitude-h)*d+(a.latitude-u)*f)/t(d,f);g>1?(h=c.longitude,u=c.latitude):g>0&&(h+=d*g,u+=f*g)}return t(a.longitude-h,a.latitude-u)}function i(a,l){for(var c=a[0],h,u=[c],d=1,f=a.length;d<f;d++)h=a[d],e(h,c)>l&&(u.push(h),c=h);return c!==h&&u.push(h),u}function s(a,l,c,h,u){for(var d=h,f,g=l+1;g<c;g++){var p=r(a[g],a[l],a[c]);p>d&&(f=g,d=p)}d>h&&(f-l>1&&s(a,l,f,h,u),u.push(a[f]),c-f>1&&s(a,f,c,h,u))}function o(a,l){var c=a.length-1,h=[a[0]];return s(a,0,c,l,h),h.push(a[c]),h}function n(a,l,c){if(l===void 0&&(l=1),c===void 0&&(c=!1),a.length<=2)return a;var h=l*l;return a=c?a:i(a,h),a=o(a,h),a}return HX.SimplifyLL=n,HX}var KX={},y0t;function ste(){if(y0t)return KX;y0t=1,KX.__esModule=!0;function t(a,l){return a*a+l*l}function e(a,l){return t(a.x-l.x,a.y-l.y)}function r(a,l,c){var h=l.x,u=l.y,d=c.x-h,f=c.y-u;if(d!==0||f!==0){var g=((a.x-h)*d+(a.y-u)*f)/t(d,f);g>1?(h=c.x,u=c.y):g>0&&(h+=d*g,u+=f*g)}return t(a.x-h,a.y-u)}function i(a,l){for(var c=a[0],h,u=[c],d=1,f=a.length;d<f;d++)h=a[d],e(h,c)>l&&(u.push(h),c=h);return c!==h&&u.push(h),u}function s(a,l,c,h,u){for(var d=h,f,g=l+1;g<c;g++){var p=r(a[g],a[l],a[c]);p>d&&(f=g,d=p)}d>h&&(f-l>1&&s(a,l,f,h,u),u.push(a[f]),c-f>1&&s(a,f,c,h,u))}function o(a,l){var c=a.length-1,h=[a[0]];return s(a,0,c,l,h),h.push(a[c]),h}function n(a,l,c){if(l===void 0&&(l=1),c===void 0&&(c=!1),a.length<=2)return a;var h=l*l;return a=c?a:i(a,h),a=o(a,h),a}return KX.Simplify=n,KX}var v0t;function _0t(){if(v0t)return H2;
7156v0t=1,H2.__esModule=!0;var t=rte();H2.SimplifyAP=t.SimplifyAP;var e=ite();H2.SimplifyLL=e.SimplifyLL;var r=ste();return H2.Simplify=r.Simplify,H2}var qX={},K2={},b0t={},M3={},w0t;function ote(){if(w0t)return M3;w0t=1,Object.defineProperty(M3,"__esModule",{value:!0}),M3.scalarLerp=void 0;const t=(e,r,i)=>e*(1-i)+r*i;return M3.scalarLerp=t,M3}var E0t;function nte(){return E0t||(E0t=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.lerp=t.toString=t.length=t.squaredLength=t.distanceBetween=t.normalize=t.squaredDistanceBetween=t.isEqual=t.project=t.rotate=t.dot=t.scale=t.sub=t.add=t.round=t.set=t.assign=t.clone=t.vec2=t.ZERO=void 0;const e=ote();t.ZERO=[0,0];const r=(w=0,E=0)=>[w,E];t.vec2=r;const i=w=>(0,t.assign)(w,[0,0]);t.clone=i;const s=(w,E)=>([E[0],E[1]]=w,E);t.assign=s;const o=(w,E,A)=>(A[0]=w,A[1]=E,A);t.set=o;const n=([w,E],A=[0,0],x=Math.round)=>(0,t.set)(x(w),x(E),A);t.round=n;const a=([w,E],[A,x],S=[0,0])=>(0,t.set)(w+A,E+x,S);t.add=a;const l=([w,E],[A,x],S=[0,0])=>(0,t.set)(w-A,E-x,S);t.sub=l;const c=([w,E],A,x=[0,0])=>(0,t.set)(w*A,E*A,x);t.scale=c;const h=(w,E)=>w[0]*E[0]+w[1]*E[1];t.dot=h;const u=(w,E,A=w)=>{const x=Math.sin(E),S=Math.cos(E);return[A[0],A[1]]=[w[0]*S-w[1]*x,w[0]*x+w[1]*S]};t.rotate=u;const d=(w,E,A,x=[0,0])=>{const S=(0,t.sub)(E,w),T=(0,t.sub)(A,w),R=(0,t.squaredLength)(S);if(R===0)return(0,t.assign)(w,x);const B=(0,t.dot)(S,T)/R;return B<0?(0,t.assign)(w,x):B>=1?(0,t.assign)(E,x):((0,t.scale)(S,B,x),(0,t.add)(w,x,x))};t.project=d;const f=(w,E)=>w[0]===E[0]&&w[1]===E[1];t.isEqual=f;const g=(w,E)=>{const[A,x]=(0,t.sub)(E,w);return A**2+x**2};t.squaredDistanceBetween=g;const p=(w,E)=>(0,t.scale)(w,1/(0,t.length)(w),E);t.normalize=p;const m=(w,E)=>Math.sqrt((0,t.squaredDistanceBetween)(w,E));t.distanceBetween=m;const v=w=>(0,t.squaredDistanceBetween)(t.ZERO,w);t.squaredLength=v;const b=w=>(0,t.distanceBetween)(t.ZERO,w);t.length=b;const y=([w,E],{angleBrackets:A=!1}={})=>`${A?"\u27E8":"("}${w}, ${E}${A?"\u27E9":")"}`;t.toString=y;const _=(w,E,A,x=[0,0])=>{const[S,T]=typeof A=="number"?[A,A]:A;return(0,t.set)((0,e.scalarLerp)(w[0],E[0],S),(0,e.scalarLerp)(w[1],E[1],T),x)};t.lerp=_})(b0t)),b0t}var A0t;function x0t(){return A0t||(A0t=1,(function(t){var e=K2&&K2.__createBinding||(Object.create?(function(i,s,o,n){n===void 0&&(n=o);var a=Object.getOwnPropertyDescriptor(s,o);(!a||("get"in a?!s.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return s[o]}}),Object.defineProperty(i,n,a)}):(function(i,s,o,n){n===void 0&&(n=o),i[n]=s[o]})),r=K2&&K2.__exportStar||function(i,s){for(var o in i)o!=="default"&&!Object.prototype.hasOwnProperty.call(s,o)&&e(s,i,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(nte(),t)})(K2)),K2}var B3={},S0t;function zZ(){if(S0t)return B3;S0t=1,Object.defineProperty(B3,"__esModule",{value:!0}),B3.segments=t,B3.triplets=e;function*t(r){const i=r.length;for(let s=0;s<r.length;s++){const o=(s+1)%i;yield[r[s],r[o],s,o]}}function*e(r){for(let i=0;i<r.length;i++){const s=(i-1+r.length)%r.length,o=(i+1)%r.length;yield[r[s],r[i],r[o],i]}}return B3}var q2={},T0t;function VZ(){if(T0t)return q2;T0t=1,Object.defineProperty(q2,"__esModule",{value:!0}),q2.unsafeGaussRng=void 0,q2.createGaussianRng=t;function t(e){return function(r=0,i=1){const s=1-e(),o=e();return Math.sqrt(-2*Math.log(s))*Math.cos(2*Math.PI*o)*i+r}}return q2.unsafeGaussRng=t(Math.random),q2}var iS={},R0t;function ate(){if(R0t)return iS;R0t=1,Object.defineProperty(iS,"__esModule",{value:!0}),iS.clamp=iS.lerp=void 0;const t=(r,i,s)=>r*(1-s)+i*s;iS.lerp=t;const e=(r,i,s)=>Math.max(Math.min(i,s),r);return iS.clamp=e,iS}var ZX={},O3={},C0t;function M0t(){if(C0t)return O3;C0t=1,Object.defineProperty(O3,"__esModule",{value:!0}),O3.assertOK=void 0;const t=(r=>{let i=0,s=0;return()=>{s+=1,i||(i=requestAnimationFrame(()=>{console.warn(`${r}: ${s} times\u2026`),i=0,s=0}))}})("bad maths!"),e=r=>{for(const[i,s]of r)(isNaN(i)||isNaN(s))&&t();return r};return O3.assertOK=e,O3}var B0t;function lte(){if(B0t)return ZX;B0t=1,Object.defineProperty(ZX,"__esModule",{value:!0}),ZX.wigglePolygon=s;const t=x0t(),e=zZ(),r=M0t(),i=VZ();function s(o,n,a={}){const{gaussRng:l=i.unsafeGaussRng}=a,c=[];for(const[h,u,d,f]of(0,e.triplets)(o)){const g=(0,t.sub)(u,h),p=(0,t.sub)(u,d),m=(0,t.add)(g,p);if((0,t.isEqual)(m,[0,0])){c.push(u);continue}(0,t.normalize)(m,m),(0,t.rotate)(m,l(0,.5),m);const v=n[f],b=((0,t.length)(g)+(0,t.length)(p))/2/3;(0,t.scale)(m,Math.abs(l(0,b/3))*v,m),c.push((0,t.add)(u,m))}return(0,r.assertOK)(c)}return ZX}var JX={},O0t;function cte(){if(O0t)return JX;O0t=1,Object.defineProperty(JX,"__esModule",{value:!0}),JX.zipper=t;function*t(...e){const r=e.reduce((i,{length:s})=>s>i?s:i,0);for(let i=0;i<r;i++)for(let s=0;s<e.length;s++)i<e[s].length&&(yield e[s][i])}return JX}var I0t;function hte(){if(I0t)return qX;I0t=1,Object.defineProperty(qX,"__esModule",{value:!0}),qX.distortPolygon=l;const t=x0t(),e=d0t(),r=zZ(),i=VZ(),s=ate(),o=lte(),n=cte(),a=M0t();function l([c,h],u={}){var d,f;const{blurWeightsOnDistort:g=!1,gaussRng:p=i.unsafeGaussRng,thetaFn:m=()=>p(0,Math.PI/12),midPointFn:v=()=>(0,s.clamp)(.001,.999,p(.5,.4/3)),magnitudeFn:b=(T,R)=>{const B=p(0,T/3);return(B<0?B/5:B)*R},wiggle:y=!0,windingOrder:_="cw"}=u,w=[],E=[];for(const T of(0,r.segments)(c)){const[R,B,O,C]=T,F=(d=h[O])!==null&&d!==void 0?d:1,U=(f=h[C])!==null&&f!==void 0?f:1,H=(0,t.distanceBetween)(R,B),N=v(H,[F,U]),G=(0,t.lerp)(R,B,N),Y=(0,s.lerp)(F,U,N),q=(0,t.vec2)();(0,t.sub)(B,R,q),(0,t.normalize)(q,q);const L=(_==="cw"?Math.PI/2:-Math.PI/2)+m(H,Y);(0,t.rotate)(q,L,q);const J=b(H,Y);(0,t.scale)(q,J,q),(0,t.add)(G,q,G),w.push(G),E.push(Y)}const A=y?(0,o.wigglePolygon)(c,h,{gaussRng:p}):c,x=Array.from((0,n.zipper)(A,w));let S=Array.from((0,n.zipper)(h,E));return g&&(S=(0,e.convolution1D)(e.K_GAUSS_BLUR_3,S,Array.from({length:S.length}))),[(0,a.assertOK)(x),S]}return qX}var D0t={},P0t;function ute(){return P0t||(P0t=1,(function(t){Object.defineProperty(t,"__esMo
7156dule",{value:!0}),t.simplifyWithWeights=t.warnOnce=void 0;const e=_0t(),r=(o,n)=>{let a=!1;return(l=n)=>(a||(console.warn(o),a=!0),l)};t.warnOnce=r;const i=(0,t.warnOnce)("cache hit missed: using fallback value",1),s=([o,n],a)=>{const l=new WeakMap(o.map((d,f)=>[d,n[f]])),c=[...o,o[0]],h=(0,e.SimplifyAP)(c,a).slice(0,-1),u=h.map(d=>{var f;return(f=l.get(d))!==null&&f!==void 0?f:i()});return[h,u]};t.simplifyWithWeights=s})(D0t)),D0t}var QX={},F0t;function dte(){if(F0t)return QX;F0t=1,Object.defineProperty(QX,"__esModule",{value:!0}),QX.windingOrderOf=e;const t=zZ();function e(r){let i=0;for(const[[s,o],[n,a]]of(0,t.segments)(r))i+=(n-s)*(a+o);return i>=0?"cw":"ccw"}return QX}var N0t;function fte(){if(N0t)return YX;N0t=1,Object.defineProperty(YX,"__esModule",{value:!0}),YX.watercolorize=a;const t=_0t(),e=hte(),r=ute(),i=VZ(),s=dte(),o=(l,c,h)=>Array.from({length:l}).reduce((u,d,f)=>c(u,f),h),n=l=>Array.from({length:l}).fill(1);function*a(l,c={}){const{preEvolutions:h=0,evolutions:u=5,layersPerEvolution:d=3,layerEvolutions:f=3,vertexWeights:g=n(l.length),blurWeightsOnDistort:p=!1,simplifyAfterPreEvolution:m=!1,simplifyEachEvolution:v=!1,random:b=Math.random,windingOrder:y=(0,s.windingOrderOf)(l)}=c,_=(0,i.createGaussianRng)(b),w={blurWeightsOnDistort:p,windingOrder:y,gaussRng:_},E=x=>(0,e.distortPolygon)(x,w);let A=[l,g];A=o(h,E,A),h>0&&m&&(A=(0,r.simplifyWithWeights)(A,m));for(let x=0;x<u;x++){for(let S=0;S<d;S++){const[T]=o(f,E,E(A));yield(0,t.SimplifyAP)([...T,T[0]],1).slice(0,-1)}A=E(A),v&&(A=(0,r.simplifyWithWeights)(A,v))}}return YX}var k0t;function pte(){return k0t||(k0t=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.watercolorize=void 0;var e=fte();Object.defineProperty(t,"watercolorize",{enumerable:!0,get:function(){return e.watercolorize}})})(p0t)),p0t}var gte=pte();const mte=t=>t.reduce(([e,r],i)=>[Math.min(e,i),Math.max(r,i)],[1/0,-1/0]);function yte(t){let e=t>>>0;return function(){e+=1831565813;let r=Math.imul(e^e>>>15,e|1);return r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}}function vte(t,e,r=.1){if(t===0)return[];const i=yte(e>>>0),s=Array.from({length:t},()=>i()),o=f0t.convolution1D(f0t.K_GAUSS_BLUR_5,s,Array.from({length:t})),[n,a]=mte(o),l=a-n;return l<=1e-12?Array.from({length:t},()=>1):o.map(c=>(c-n)/l).map(c=>c*(1-r)+r)}const _te={preEvolutions:4,evolutions:2,layersPerEvolution:4,layerEvolutions:2},bte={preEvolutions:3,evolutions:2,layersPerEvolution:3,layerEvolutions:2},wte=.1;function Ete(t){return!t||t<=0?1:Math.floor(t)>>>0}function Ate(t,e,r){return Math.min(r,Math.max(e,t))}function xte(t,e,r,i){const s=Ate(r,0,10)/10,o=(Ete(e)^2654435769)>>>0,n=.05+.1*(1-s),a=i==="rect"?Math.min(.22,n+.06):n,l=vte(t.length,o,a);return Object.assign(Object.assign({},i==="rect"?bte:_te),{vertexWeights:l})}function Ste(t){if(t.length===0)return"";const[e,r]=t[0],i=t.slice(1);return`M ${e} ${r} `+i.map(([s,o])=>`L ${s} ${o}`).join(" ")+" Z"}function YZ(t,e,r,i,s){const o=[];for(let n=0;n<s;n++){const a=n/s*Math.PI*2;o.push([t+r*Math.cos(a),e+i*Math.sin(a)])}return o}function L0t(t,e,r){const i=Math.max(2,Math.floor(r)),s=[];for(let o=0;o<i;o++)s.push([t*o/i,0]);for(let o=1;o<i;o++)s.push([t,e*o/i]);for(let o=1;o<i;o++)s.push([t*(i-o)/i,e]);for(let o=1;o<i;o++)s.push([0,e*(i-o)/i]);return s}function U0t(t,e,r=1e-6){return Math.abs(t[0]-e[0])<=r&&Math.abs(t[1]-e[1])<=r}function Tte(t){if(t.length===0)return t;const e=[t[0]];for(let r=1;r<t.length;r++)U0t(t[r],e[e.length-1])||e.push(t[r]);return e.length>=2&&U0t(e[0],e[e.length-1])&&e.pop(),e}function G0t(t,e,r,i){if(!t)return[];const s=Tte(t);if(s.length<3)return[];const o=xte(s,e,r,i),n=[];for(const a of gte.watercolorize(s,o))a.length>=3&&n.push(a.map(([l,c])=>[l,c]));return n}function Rte(t){const e=t.read(ue);if(e.fillStyle!=="watercolor")return null;let r=null,i="default";if(t.has($t)){const{width:o,height:n}=t.read($t),a=Math.max(4,Math.min(16,Math.round(Math.hypot(o,n)/40
7156)));r=L0t(o,n,a),i="rect"}else if(t.has(et)){const{cx:o,cy:n,r:a}=t.read(et);r=YZ(o,n,a,a,36)}else if(t.has(ae)){const{cx:o,cy:n,rx:a,ry:l}=t.read(ae);r=YZ(o,n,a,l,40)}else if(t.has(xt)){const o=t.read(wo).points;o.length>0&&(r=o[0].map(([n,a])=>[n,a]))}const s=G0t(r,e.seed,e.roughness,i);return s.length?s:null}function Cte(t){const{roughFillStyle:e,roughSeed:r,roughRoughness:i}=t;if(e!=="watercolor")return null;const{x:s,y:o,width:n,height:a,type:l}=t;let c=null,h="default";if(l==="ellipse"||l==="rough-ellipse"){const{cx:d,cy:f,rx:g,ry:p}=t;c=YZ(d-s,f-o,g,p,40)}else if(l==="rect"||l==="rough-rect"){const d=Math.max(4,Math.min(16,Math.round(Math.hypot(n,a)/40)));c=L0t(n,a,d),h="rect"}else if(!(l==="path"||l==="rough-path")&&(l==="polyline"||l==="rough-polyline")){const{points:d}=t;if(!d)return null;const f=nc(d);f.length>=3&&(c=f.map(([g,p])=>[g,p]))}const u=G0t(c,r,i,h);return u.length?u:null}function I3(t){var e,r;if(!t.has(ue))return;let i;const s=t.read(ue);e=Hx(t);const o=t.has(Gt)?t.read(Gt):{width:0,dasharray:[0,0],dashoffset:0},{width:n,dasharray:a,dashoffset:l}=o,c=(r=H0(t))!==null&&r!==void 0?r:"none",h=vG({stroke:c,strokeWidth:n,strokeDasharray:[a[0],a[1]].join(","),strokeDashoffset:l,roughSeed:s.seed,roughRoughness:s.roughness,roughBowing:s.bowing,roughFillStyle:s.fillStyle,roughFillWeight:s.fillWeight,roughHachureAngle:s.hachureAngle,roughHachureGap:s.hachureGap,roughCurveStepCount:s.curveStepCount,roughCurveFitting:s.curveFitting,roughFillLineDash:s.fillLineDash,roughFillLineDashOffset:s.fillLineDashOffset,roughDisableMultiStroke:s.disableMultiStroke,roughDisableMultiStrokeFill:s.disableMultiStrokeFill,roughSimplification:s.simplification,roughDashOffset:s.dashOffset,roughDashGap:s.dashGap,roughZigzagOffset:s.zigzagOffset});if(t.has(et)){const{cx:p,cy:m,r:v}=t.read(et);i=Bg.circle(p,m,v*2,h)}else if(t.has(ae)){const{cx:p,cy:m,rx:v,ry:b}=t.read(ae);i=Bg.ellipse(p,m,v*2,b*2,h)}else if(t.has($t)){const{x:p,y:m,width:v,height:b}=t.read($t);i=Bg.rectangle(p,m,v,b,h)}else if(t.has(Mt)){const{x1:p,y1:m,x2:v,y2:b}=t.read(Mt);i=Bg.line(p,m,v,b,h)}else if(t.has(_t)){const{points:p}=t.read(_t);i=Bg.linearPath(p,h)}else if(t.has(xt)){const{d:p}=t.read(xt);i=Bg.path(p,h)}else return;const u=i.sets;let d=[],f=[],g=[];if(u.forEach(p=>{const{subPaths:m}=a3(p),v=m.map(b=>b.getPoints().map(y=>[y[0],y[1]]));p.type==="path"?d=v:p.type==="fillPath"?g=v:p.type==="fillSketch"&&(f=v)}),s.fillStyle==="watercolor"){const p=Rte(t);p&&(g=p,f=[])}nt(t,iu,{drawableSets:u,strokePoints:d,fillPoints:f,fillPathPoints:g}),nt(t,Sn)}class W0t extends We{constructor(){super(),this.roughs=this.query(e=>e.addedOrChanged.with(ue).and.withAny(et,ae,$t,Mt,_t,xt,Ce,Gt,Fs).trackWrites),this.query(e=>e.using(iu,Sn).write.and.using(wt,Gs,wo).read)}execute(){this.roughs.addedOrChanged.forEach(e=>{I3(e)})}}function j0t(t){let e;const r=vG(t),{x:i,y:s,width:o,height:n,type:a}=t;if(a==="ellipse"||a==="rough-ellipse"){const{cx:l,cy:c,rx:h,ry:u}=t;e=Bg.ellipse(l-i,c-s,h*2,u*2,r)}else if(a==="rect"||a==="rough-rect")e=Bg.rectangle(0,0,o,n,r);else if(a==="line"||a==="rough-line"){const{x1:l,y1:c,x2:h,y2:u}=t;e=Bg.line(l-i,c-s,h-i,u-s,r)}else if(a==="polyline"||a==="rough-polyline"){const{points:l}=t;e=Bg.linearPath(nc(l),r)}else if(a==="path"||a==="rough-path"){const{d:l}=t;e=Bg.path(xy(l,-i,-s),r)}return e.sets}let D3,P3,Dg,F3,zf,$Z;rG=We.group(),D3=We.group(),iG=We.group(),P3=We.group(),uO=We.group(),Dg=We.group(),F3=We.group(),zf=We.group(),An=We.group(),$Z=[rG,D3,iG,P3,uO,Dg,F3,zf,An];function HZ(){$Z.forEach((t,e)=>{Reflect.deleteProperty(t,"__systems"),t.__executed=!1,t.__scheduleBuilder=void 0;const r=$Z[e+1];r&&t.schedule(i=>i.before(r))})}HZ();class KZ extends We{constructor(){super(...arguments),this.canvases=this.query(e=>e.current.with(wt).usingAll.write)}execute(){const e=this.canvases.current.map(r=>r.read(wt).api);for(const r of e)r==null||r.flushPendingEdits()}}var tz=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
7156return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},qZ=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Z2,N3;function mn(t){return typeof t=="number"&&Number.isFinite(t)}function Mte(t){return Array.isArray(t)&&t.length>=2&&mn(t[0])&&mn(t[1])}function X0t(t){const{currentTranslation:e,currentScale:r,currentRotation:i,nextScale:s,nextRotation:o,origin:n}=t,a=Math.cos(i),l=Math.sin(i),c=n.x*r.x,h=n.y*r.y,u=e.x+c*a-h*l,d=e.y+c*l+h*a,f=Math.cos(o),g=Math.sin(o),p=n.x*s.x,m=n.y*s.y;return{x:u-(p*f-m*g),y:d-(p*g+m*f)}}class z0t extends We{constructor(){super(...arguments),this.animations=this.query(e=>e.current.with(_a).using(wt).read.using(_e,bo,Ce,Fs,Gt,xt,_a).write),this.canvases=this.query(e=>e.current.with(wt).read),Z2.set(this,void 0),N3.set(this,!1)}execute(){var e;const r=performance.now(),i=this.getApi(),s=(e=i==null?void 0:i.getAppState)===null||e===void 0?void 0:e.call(i);if(s!=null&&s.animationEditing){this.executeEditing(r,i,s),tz(this,N3,!0,"f");return}qZ(this,N3,"f")&&(this.animations.current.forEach(o=>{const n=o.write(_a).controller;n&&n.getPlayState()==="paused"&&n.play(r)}),tz(this,N3,!1,"f")),tz(this,Z2,void 0,"f"),this.animations.current.forEach(o=>{const n=o.write(_a).controller;if(!n)return;n.getPlayState()==="idle"&&n.play(r);const a=n.tick(r);this.applyValues(o,n,a)})}getApi(){let e;return this.canvases.current.forEach(r=>{e||(e=r.read(wt).api)}),e}executeEditing(e,r,i){var s,o;const n=!!i.animationPlaying,a=!!i.animationLoop;let l=mn(i.animationCurrentTime)?Math.max(0,i.animationCurrentTime):0,c=0;if(this.animations.current.forEach(h=>{const u=h.read(_a).controller;u&&(c=Math.max(c,u.getDuration()))}),n){const h=qZ(this,Z2,"f")===void 0?0:Math.max(0,e-qZ(this,Z2,"f"));l+=h,c>0&&l>=c&&(a?l=l%c:(l=c,(s=r.setAppState)===null||s===void 0||s.call(r,{animationPlaying:!1}))),(o=r.setAppState)===null||o===void 0||o.call(r,{animationCurrentTime:l})}tz(this,Z2,e,"f"),this.animations.current.forEach(h=>{const u=h.write(_a).controller;if(!u)return;u.seek(l);const d=u.getSnapshot();this.applyValues(h,u,d)})}applyValues(e,r,i){const s=r.getCurrentValues(i);s&&Bte(e,r,s)}}Z2=new WeakMap,N3=new WeakMap;function Bte(t,e,r){{if(t.has(_e)){const s=t.write(_e),o={x:s.translation.x,y:s.translation.y},n={x:s.scale.x,y:s.scale.y},a=s.rotation,l={x:mn(r.x)?r.x:o.x,y:mn(r.y)?r.y:o.y},c={x:mn(r.scaleX)?r.scaleX:mn(r.scale)?r.scale:n.x,y:mn(r.scaleY)?r.scaleY:mn(r.scale)?r.scale:n.y},h=mn(r.rotation)?r.rotation:a,u=!!e.getOptions().transformOrigin,d=mn(r.scale)||mn(r.scaleX)||mn(r.scaleY)||mn(r.rotation),f=mn(r.x)&&mn(r.y);if(u&&d&&!f){const g=X0t({currentTranslation:o,currentScale:n,currentRotation:a,nextScale:c,nextRotation:h,origin:e.getOptions().transformOrigin});l.x=g.x,l.y=g.y}s.translation.x=l.x,s.translation.y=l.y,s.scale.x=c.x,s.scale.y=c.y,s.rotation=h}if(mn(r.opacity)||mn(r.fillOpacity)||mn(r.strokeOpacity)){const s={};if(mn(r.opacity)&&(s.opacity=r.opacity),mn(r.fillOpacity)&&t.has(Ce)){const o=t.write(Ce),n=[...o.layers],a=n.findIndex(Dd);a>=0&&(n[a]=Object.assign(Object.assign({},n[a]),{opacity:r.fillOpacity}),o.layers=n)}if(mn(r.strokeOpacity)&&t.has(Fs)){const o=t.write(Fs),n=[...o.layers],a=n.findIndex(Dd);a>=0&&(n[a]=Object.assign(Object.assign({},n[a]),{opacity:r.strokeOpacity}),o.layers=n)}Object.keys(s).length>0&&nt(t,bo,s)}if(typeof r.fill=="string"&&(sT(r.fill)?nt(t,Ce,{layers:[{type:"gradient",value:r.fill}]}):nt(t,Ce,{layers:[{type:"solid",value:r.fill}]})),mn(r.strokeWidth)&&nt(t,Gt,{width:r.strokeWidth}),typeof r.stroke=="string"){if(t.has(Fs)){const s=t.write(Fs),o=s.layers.map(a=>Object.assign({},a)),n=o.findIndex(Dd);if(n>=0){const a=o[n];a&&"value"in a&&(o[n]=Object.assign(Object.assign({},a),{value:r.stroke}),s.layers=o)}else s.layers=[{type:"solid",value:r.stroke}]}else nt(t,Fs,{layers:[{type:"solid",value:r.stroke}]});t.has(Gt)||nt(t,Gt,{width:1})}Mte(r.strokeDasharray)&&nt(t,Gt,{dasharray:[r.strokeDasharray[0],r.strokeDasharray[1]]});const i=mn(r.strokeDashoffset)?r.strokeDashoffset:mn(r.dashoffset)?r.dashoffset:void 0;if(i!==void 0&&nt(t,Gt,{dashoffset:i}),typeof r.d=="string"){const s=t.write(_e),o={d:r.d},n=ou(Object.assign(Object.assign({},o),{id:"",type:"path",zIndex:0}));
7156s.translation.x=n.x,s.translation.y=n.y,nt(t,xt,{d:n.d})}}}var ez=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},On=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Pg,Vf,sS,J2;class V0t{constructor(){Pg.set(this,void 0),Vf.set(this,void 0),sS.set(this,{}),J2.set(this,{}),ez(this,Pg,Pr.get().createCanvas(128,128),"f"),ez(this,Vf,On(this,Pg,"f").getContext("2d"),"f")}destroy(){ez(this,sS,{},"f"),ez(this,J2,{},"f")}getOrCreatePattern(e){const{pattern:r,width:i,height:s}=e,{image:o,repetition:n}=r;if(On(this,Pg,"f").width=i,On(this,Pg,"f").height=s,Na(o))return On(this,Pg,"f");let a=null;const l=$0t(e);return On(this,J2,"f")[l]?a=On(this,J2,"f")[l]:(a=o&&On(this,Vf,"f").createPattern(o,n),On(this,J2,"f")[l]=a),On(this,Vf,"f").fillStyle=a,On(this,Vf,"f").fillRect(0,0,i,s),Pr.get().createTexImageSource(On(this,Pg,"f"))}getOrCreateGradient(e,r=!0){const{width:i,height:s,gradients:o}=e;return r&&(On(this,Pg,"f").width=i,On(this,Pg,"f").height=s),[...o].reverse().forEach(n=>{if(!n||n.type==="mesh-gradient")return;if(n.type==="linear-gradient"){Xdt(On(this,Vf,"f"),0,0,i,s,n);return}const a=this.getOrCreateGradientInternal(Object.assign(Object.assign({},n),{width:i,height:s,min:[0,0]}));On(this,Vf,"f").fillStyle=a,r&&On(this,Vf,"f").fillRect(0,0,i,s)}),Pr.get().createTexImageSource(On(this,Pg,"f"))}getOrCreateGradientInternal(e){const r=Y0t(e),{type:i,steps:s,min:o,width:n,height:a}=e;if(On(this,sS,"f")[r])return On(this,sS,"f")[r];let l=null;if(i==="linear-gradient"){const{x1:c,y1:h,x2:u,y2:d}=dE(o,n,a,e.angle);l=On(this,Vf,"f").createLinearGradient(c,h,u,d)}else if(i==="radial-gradient"){const{cx:c,cy:h,size:u}=e,{x:d,y:f,r:g}=pO(o,n,a,c,h,u);l=On(this,Vf,"f").createRadialGradient(d,f,0,d,f,g)}else if(i==="conic-gradient"){const{cx:c,cy:h,angle:u}=e,{x:d,y:f}=dG(o,n,a,c,h);l=On(this,Vf,"f").createConicGradient(u,d,f)}return l&&(s.forEach(({offset:c,color:h})=>{c.type==="%"&&(l==null||l.addColorStop(c.value/100,h.toString()))}),On(this,sS,"f")[r]=l),On(this,sS,"f")[r]}}Pg=new WeakMap,Vf=new WeakMap,sS=new WeakMap,J2=new WeakMap;function Y0t(t){const{type:e,min:r,width:i,height:s,steps:o}=t,n=`${e}-${Math.round(r[0])}-${Math.round(r[1])}-${Math.round(i)}-${Math.round(s)}-${o.map(({offset:a,color:l})=>`${a.value}${l}`).join("-")}`;if(e==="linear-gradient"){const{angle:a}=t;return`gradient-${QL(`${Math.round(a)}-${n}`)}`}else if(e==="radial-gradient"){const{cx:a,cy:l,size:c}=t;return`gradient-${QL(`${Math.round(a.value)}-${Math.round(l.value)}-${Math.round(Number((c==null?void 0:c.value)||0))}-${n}`)}`}else if(e==="conic-gradient"){const{cx:a,cy:l,angle:c}=t;return`gradient-${QL(`${Math.round(a.value)}-${Math.round(l.value)}-${Math.round(c||0)}-${n}`)}`}}function $0t(t){const{image:e,repetition:r,transform:i}=t.pattern;return`pattern-${QL(`pattern-${e}-${r}-${i}`)}`}var In;(function(t){t[t.Color0=0]="Color0",t[t.Color1=1]="Color1",t[t.Color2=2]="Color2",t[t.Color3=3]="Color3",t[t.ColorMax=3]="ColorMax",t[t.DepthStencil=4]="DepthStencil"})(In||(In={}));class Ote{constructor(){this.renderTargetIDs=[],this.renderTargetLevels=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureOutputExternalTextureLevel=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.resolveTextureInputTextures=[],this.renderTargets=[],this.descriptor={colorAttachment:[],colorAttachmentLevel:[],colorResolveTo:[],colorResolveToLevel:[],colorStore:[],depthStencilAttachment:null,depthStencilResolveTo:null,depthStencilStore:!0,colorClearColor:["load"],depthClearValue:"load",stencilClearValue:"load",occlusionQueryPool:null},this.viewportX=0,this.viewportY=0,this.viewportW=1,this.viewportH=1,this.execFunc=null,this.postFunc=null,this.debugThumbnails=[]}
7156setDebugName(e){this.debugName=e}pushDebugThumbnail(e){this.debugThumbnails[e]=!0}setViewport(e,r,i,s){this.viewportX=e,this.viewportY=r,this.viewportW=i,this.viewportH=s}attachRenderTargetID(e,r,i=0){pe(this.renderTargetIDs[e]===void 0),this.renderTargetIDs[e]=r,this.renderTargetLevels[e]=i}attachResolveTexture(e){this.resolveTextureInputIDs.push(e)}attachOcclusionQueryPool(e){this.descriptor.occlusionQueryPool=e}exec(e){pe(this.execFunc===null),this.execFunc=e}post(e){pe(this.postFunc===null),this.postFunc=e}addExtraRef(e){this.renderTargetExtraRefs[e]=!0}}class Ite{constructor(e,r){this.dimension=Xr.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.width=0,this.height=0,this.sampleCount=0,this.usage=vi.RENDER_TARGET,this.needsClear=!0,this.texture=null,this.age=0,this.format=r.format,this.width=r.width,this.height=r.height,this.sampleCount=r.sampleCount,this.sampledForShaderRead=r.sampledForShaderRead,pe(this.sampleCount>=1),this.sampledForShaderRead&&(this.usage=vi.RENDER_TARGET|vi.SAMPLED),this.sampleCount>1?this.attachment=e.createRenderTarget(this):(this.texture=e.createTexture(this),this.attachment=e.createRenderTargetFromTexture(this.texture))}setDebugName(e,r){this.debugName=r,this.texture!==null&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)}matchesDescription(e){return this.format===e.format&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount&&this.sampledForShaderRead===e.sampledForShaderRead}reset(e){pe(this.matchesDescription(e)),this.age=0}destroy(){this.attachment.destroy()}}class Dte{constructor(e,r){this.dimension=Xr.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.usage=vi.RENDER_TARGET,this.width=0,this.height=0,this.age=0,this.format=r.format,this.width=r.width,this.height=r.height,this.texture=e.createTexture(this)}matchesDescription(e){return this.format===e.format&&this.width===e.width&&this.height===e.height}reset(e){pe(this.matchesDescription(e)),this.age=0}destroy(){this.texture.destroy()}}class Pte{constructor(){this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]}}class Fte{constructor(e){this.currentPass=null,this.renderTargetDeadPool=[],this.singleSampledTextureDeadPool=[],this.currentGraph=null,this.renderTargetOutputCount=[],this.renderTargetResolveCount=[],this.resolveTextureUseCount=[],this.renderTargetAliveForID=[],this.singleSampledTextureForResolveTextureID=[],this.device=e}acquireRenderTargetForDescription(e){for(let r=0;r<this.renderTargetDeadPool.length;r++){const i=this.renderTargetDeadPool[r];if(i.matchesDescription(e))return i.reset(e),this.renderTargetDeadPool.splice(r--,1),i}return new Ite(this.device,e)}acquireSingleSampledTextureForDescription(e){for(let r=0;r<this.singleSampledTextureDeadPool.length;r++){const i=this.singleSampledTextureDeadPool[r];if(i.matchesDescription(e))return i.reset(e),this.singleSampledTextureDeadPool.splice(r--,1),i}return new Dte(this.device,e)}beginGraphBuilder(){pe(this.currentGraph===null),this.currentGraph=new Pte}pushPass(e){const r=new Ote;e(r),this.currentGraph.passes.push(r)}createRenderTargetID(e,r){return this.currentGraph.renderTargetDebugNames.push(r),this.currentGraph.renderTargetDescriptions.push(e)-1}createResolveTextureID(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1}findMostRecentPassThatAttachedRenderTarget(e){for(let r=this.currentGraph.passes.length-1;r>=0;r--){const i=this.currentGraph.passes[r];if(i.renderTargetIDs.includes(e))return i}return null}resolveRenderTargetPassAttachmentSlot(e,r){const i=e;if(i.resolveTextureOutputIDs[r]===void 0){const s=i.renderTargetIDs[r],o=this.createResolveTextureID(s);i.resolveTextureOutputIDs[r]=o}return i.resolveTextureOutputIDs[r]}findPassForResolveRenderTarget(e){const r=oh(this.findMostRecentPassThatAttachedRenderTarget(e)),i=r.renderTargetIDs.indexOf(e);return pe(r.resolveTextureOutputExternalTextures[i]===void 0),r}resolveRenderTarget(e){const r=this.findPassForResolveRenderTarget(e),i=r.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(r,i)}resolveRenderTargetToExternalTexture(e,r,i=0){const s=this.findPassForResolveRenderTarget(e),o=s.renderTargetIDs.indexOf(e);pe(s.resolveTextureOutputIDs[o]===void 0),s.resolveTextureOutputExternalTextures[o]=r,s.resolveTextureOutputExternalTextureLevel[o]=i}getRenderTargetDescription(e){return oh(this.currentGraph.renderTargetDescriptions[e])}scheduleAddUseCount(e,r){for(let i=0;i<r.renderTargetIDs.length;i++){const s=r.renderTargetIDs[i];s!==void 0&&(this.renderTargetOutputCount[s]++,r.renderTargetExtraRefs[i]&&this.renderTargetOutputCount[s]++)}for(let i=0;i<r.resolveTextureInputIDs.length;i++){const s=r.resolveTextureInputIDs[i];if(s===void 0)continue;this.resolveTextureUseCount[s]++;const o=e.resolveTextureRenderTargetIDs[s];this.renderTargetResolveCount[o]++}}acquireRenderTargetForID(e,r){if(r===void 0)return null;if(pe(this.renderTargetOutputCount[r]>0),!this.renderTargetAliveForID[r]){const i=e.renderTargetDescriptions[r],s=this.acquireRenderTargetForDescription(i);s.setDebugName(this.device,e.renderTargetDebugNames[r]),this.renderTargetAliveForID[r]=s}return this.renderTargetAliveForID[r]}releaseRenderTargetForID(e,r){if(e===void 0)return null;const i=oh(this.renderTargetAliveForID[e]);return r?(pe(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(pe(this.renderTargetResolveCount[e]>0),this.renderTargetResolveCount[e]--),this.renderTargetOutputCount[e]===0&&this.renderTargetResolveCount[e]===0&&(i.needsClear=!0,this.renderTargetAliveForID[e]=void 0,this.renderTargetDeadPool.pu
7156sh(i)),i}acquireResolveTextureInputTextureForID(e,r){const i=e.resolveTextureRenderTargetIDs[r];pe(this.resolveTextureUseCount[r]>0),this.resolveTextureUseCount[r]--;const s=oh(this.releaseRenderTargetForID(i,!1));if(this.singleSampledTextureForResolveTextureID[r]!==void 0){const o=this.singleSampledTextureForResolveTextureID[r];return this.resolveTextureUseCount[r]===0&&this.singleSampledTextureDeadPool.push(o),o.texture}return oh(s.texture)}determineResolveParam(e,r,i){const s=r.renderTargetIDs[i],o=r.resolveTextureOutputIDs[i],n=r.resolveTextureOutputExternalTextures[i],a=o!==void 0,l=n!==void 0;pe(!(a&&l));let c=null,h=!1,u=0;if(this.renderTargetOutputCount[s]>1&&(h=!0),a){pe(e.resolveTextureRenderTargetIDs[o]===s),pe(this.resolveTextureUseCount[o]>0),pe(this.renderTargetOutputCount[s]>0);const d=oh(this.renderTargetAliveForID[s]);if(d.texture!==null&&this.renderTargetOutputCount[s]===1)c=null,h=!0;else{if(!this.singleSampledTextureForResolveTextureID[o]){const f=oh(e.renderTargetDescriptions[s]);this.singleSampledTextureForResolveTextureID[o]=this.acquireSingleSampledTextureForDescription(f),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[o].texture,`${d.debugName} (Resolve ${o})`)}c=this.singleSampledTextureForResolveTextureID[o].texture}}else l?(c=n,u=r.resolveTextureOutputExternalTextureLevel[i]):c=null;return{resolveTo:c,store:h,level:u}}schedulePass(e,r){const i=r.renderTargetIDs[In.DepthStencil];for(let h=In.Color0;h<=In.ColorMax;h++){const u=r.renderTargetIDs[h],d=this.acquireRenderTargetForID(e,u);r.renderTargets[h]=d,r.descriptor.colorAttachment[h]=d!==null?d.attachment:null,r.descriptor.colorAttachmentLevel[h]=r.renderTargetLevels[h];const{resolveTo:f,store:g,level:p}=this.determineResolveParam(e,r,h);r.descriptor.colorResolveTo[h]=f,r.descriptor.colorResolveToLevel[h]=p,r.descriptor.colorStore[h]=g,r.descriptor.colorClearColor[h]=d!==null&&d.needsClear?e.renderTargetDescriptions[u].colorClearColor:"load"}const s=this.acquireRenderTargetForID(e,i);r.renderTargets[In.DepthStencil]=s,r.descriptor.depthStencilAttachment=s!==null?s.attachment:null;const{resolveTo:o,store:n}=this.determineResolveParam(e,r,In.DepthStencil);r.descriptor.depthStencilResolveTo=o,r.descriptor.depthStencilStore=n,r.descriptor.depthClearValue=s!==null&&s.needsClear?e.renderTargetDescriptions[i].depthClearValue:"load",r.descriptor.stencilClearValue=s!==null&&s.needsClear?e.renderTargetDescriptions[i].stencilClearValue:"load";let a=0,l=0,c=0;for(let h=0;h<r.renderTargets.length;h++){const u=r.renderTargets[h];if(!u)continue;const d=u.width>>>r.renderTargetLevels[h],f=u.height>>>r.renderTargetLevels[h];a===0&&(a=d,l=f,c=u.sampleCount),pe(d===a),pe(f===l),pe(u.sampleCount===c),u.needsClear=!1}a>0&&l>0&&(r.viewportX*=a,r.viewportY*=l,r.viewportW*=a,r.viewportH*=l);for(let h=0;h<r.resolveTextureInputIDs.length;h++){const u=r.resolveTextureInputIDs[h];r.resolveTextureInputTextures[h]=this.acquireResolveTextureInputTextureForID(e,u)}for(let h=0;h<r.renderTargetIDs.length;h++)this.releaseRenderTargetForID(r.renderTargetIDs[h],!0);for(let h=0;h<r.renderTargetExtraRefs.length;h++)r.renderTargetExtraRefs[h]&&this.releaseRenderTargetForID(r.renderTargetIDs[h],!0)}scheduleGraph(e){pe(this.renderTargetOutputCount.length===0),pe(this.renderTargetResolveCount.length===0),pe(this.resolveTextureUseCount.length===0);for(let i=0;i<this.renderTargetDeadPool.length;i++)this.renderTargetDeadPool[i].age++;for(let i=0;i<this.singleSampledTextureDeadPool.length;i++)this.singleSampledTextureDeadPool[i].age++;hq(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),hq(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),hq(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(let i=0;i<e.passes.length;i++)this.scheduleAddUseCount(e,e.passes[i]);for(let i=0;i<e.passes.length;i++)this.schedulePass(e,e.passes[i]);for(let i=0;i<this.renderTargetOutputCount.length;i++)pe(this.renderTargetOutputCount[i]===0);for(let i=0;i<this.renderTargetResolveCount.length;i++)pe(this.renderTargetResolveCount[i]===0);for(let i=0;i<this.resolveTextureUseCount.length;i++)pe(this.resolveTextureUseCount[i]===0);for(let i=0;i<this.renderTargetAliveForID.length;i++)pe(this.renderTargetAliveForID[i]===void 0);const r=1;for(let i=0;i<this.renderTargetDeadPool.length;i++)this.renderTargetDeadPool[i].age>=r&&(this.renderTargetDeadPool[i].destroy(),this.renderTargetDeadPool.splice(i--,1));for(let i=0;i<this.singleSampledTextureDeadPool.length;i++)this.singleSampledTextureDeadPool[i].age>=r&&(this.singleSampledTextureDeadPool[i].destroy(),this.singleSampledTextureDeadPool.splice(i--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0}compactPassColorAttachments(e){var r,i,s,o,n;const a=e.descriptor,l=[],c=[],h=[],u=[],d=[],f=[];for(let g=In.Color0;g<=In.ColorMax;g++){const p=a.colorAttachment[g];p&&(l.push(p),c.push((r=a.colorResolveTo[g])!==null&&r!==void 0?r:null),h.push((i=a.colorAttachmentLevel[g])!==null&&i!==void 0?i:0),u.push((s=a.colorResolveToLevel[g])!==null&&s!==void 0?s:0),d.push((o=a.colorClearColor[g])!==null&&o!==void 0?o:"load"),f.push((n=a.colorStore[g])!==null&&n!==void 0?n:!1))}a.colorAttachment=l,a.colorResolveTo=c,a.colorAttachmentLevel=h,a.colorResolveToLevel=u,a.colorClearColor=d,a.colorStore=f}execPass(e){pe(this.currentPass===null),this.currentPass=e,this.compactPassColorAttachments(e);const r=this.device.createRenderPass(e.descriptor);r.pushDebugGroup(e.debugName),r.setViewport(e.viewportX,e.viewportY,e.viewportW,e.viewportH),e.execFunc!==null&&e.execFunc(r,this),r.popDebugGroup(),this.device.submitPass(r),e.postFunc!==null&&e.postFunc(this),this.currentPass=null}execGraph(e){this.scheduleGraph(e),this.device.beginFrame(),e.passes.forEac
7156h(r=>{this.execPass(r)}),this.device.endFrame(),this.singleSampledTextureForResolveTextureID.length=0}execute(){const e=oh(this.currentGraph);this.execGraph(e),this.currentGraph=null}getDebug(){return this}getPasses(){return this.currentGraph.passes}getPassDebugThumbnails(e){return e.debugThumbnails}getPassRenderTargetID(e,r){return e.renderTargetIDs[r]}getRenderTargetIDDebugName(e){return this.currentGraph.renderTargetDebugNames[e]}getResolveTextureForID(e){const r=this.currentPass,i=r.resolveTextureInputIDs.indexOf(e);return pe(i>=0),oh(r.resolveTextureInputTextures[i])}getRenderTargetAttachment(e){const r=this.currentPass.renderTargets[e];return r?r.attachment:null}getRenderTargetTexture(e){const r=this.currentPass.renderTargets[e];return r?r.texture:null}newGraphBuilder(){return this.beginGraphBuilder(),this}destroy(){for(let e=0;e<this.renderTargetAliveForID.length;e++)pe(this.renderTargetAliveForID[e]===void 0);for(let e=0;e<this.singleSampledTextureForResolveTextureID.length;e++)pe(this.singleSampledTextureForResolveTextureID[e]===void 0);for(let e=0;e<this.renderTargetDeadPool.length;e++)this.renderTargetDeadPool[e].destroy();for(let e=0;e<this.singleSampledTextureDeadPool.length;e++)this.singleSampledTextureDeadPool[e].destroy()}}class H0t{constructor(){this.callbacks=new Set,this.disposed=!1}add(e){let r=!0;const i=()=>{r&&(r=!1,this.callbacks.delete(i),e())};return this.disposed?i():this.callbacks.add(i),i}dispose(){if(this.disposed)return;this.disposed=!0;const e=[];if([...this.callbacks].reverse().forEach(r=>{try{r()}catch(i){e.push(i)}}),e.length)throw new AggregateError(e,"Resource cleanup failed")}}var Nte={},K0t=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,[])).next())})},k3=function(t,e,r,i,s){if(typeof e=="function"?t!==e||!0:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,r),r},Da=function(t,e,r,i){if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},L3,oS,Q2,U3,bw,nS;class G3 extends We{constructor(){super(),this.canvases=this.query(e=>e.added.and.changed.and.removed.and.current.with(wt).trackWrites),L3.set(this,void 0),oS.set(this,void 0),Q2.set(this,void 0),U3.set(this,void 0),bw.set(this,new Map),nS.set(this,!1),this.query(e=>e.using(cs,wt,ul,rd).write),k3(this,L3,new V0t)}getOffscreenGPUResource(){return Da(this,oS,"f")}resizeOffscreen(e,r){!Da(this,Q2,"f")||!Da(this,oS,"f")||(Da(this,Q2,"f").width=e,Da(this,Q2,"f").height=r,Da(this,oS,"f").swapChain.configureSwapChain(e,r))}execute(){this.canvases.removed.forEach(e=>{var r;const i=Da(this,bw,"f").get(e.__id);i&&(i.cancelled=!0,(r=i.resource)===null||r===void 0||r.scope.dispose(),Da(this,bw,"f").delete(e.__id))}),this.canvases.added.forEach(e=>{e.has(ul)||e.add(ul),e.has(rd)||e.add(rd);const r={canvas:e.hold(),attached:!1,cancelled:!1};Da(this,bw,"f").set(e.__id,r);const{renderer:i,shaderCompilerPath:s,element:o,width:n,height:a,devicePixelRatio:l}=e.read(wt),c={renderer:i,shaderCompilerPath:s,element:o,width:n,height:a,devicePixelRatio:l};this.initializeCanvas(r,c).catch(h=>{!Da(this,nS,"f")&&!r.cancelled&&console.error("Failed to initialize canvas GPU resources",h)})}),Da(this,bw,"f").forEach(e=>{if(e.resource&&!e.attached){const{width:r,height:i,devicePixelRatio:s}=e.canvas.read(wt);e.resource.swapChain.configureSwapChain(Math.floor(r*s),Math.floor(i*s)),e.canvas.add(cs,e.resource),e.attached=!0}}),this.canvases.changed.forEach(e=>{if(!e.has(cs))return;const{width:r,height:i,devicePixelRatio:s}=e.read(wt),o=r*s,n=i*s,{swapChain:a}=e.read(cs);a.configureSwapChain(Math.floor(o),Math.floor(n))})}finalize(){var e;k3(this,nS,!0),Da(this,bw,"f").forEach(r=>{var i;r.cancelled=!0,(i=r.resource)===null||i===void 0||i.scope.dispose()}),Da(this,bw,"f").clear(),(e=Da(this,oS,"f"))===null||e===void 0||e.scope.dispose(),Da(this,L3,"f").destroy()}initializeCanvas(e,r){return K0t(this,void 0,void 0,function*(){const{renderer:i,shaderCompilerPath:s,element:o,width:n,height:a,devicePixelRatio:l}=r,c=typeof process<"u"&&Nte.JEST_WORKER_ID;if(Zo&&!c){if(!Da(this,U3,"f")){const u=Pr.get().createCanvas(Math.floor(n*l),Math.floor(a*l));k3(this,Q2,u),k3(this,U3,this.createGPUResource(i,s,u,n,a,l).then(d=>{Da(this,nS,"f")?d.scope.dispose():k3(this,oS,d,"f")}))}yield Da(this,U3,"f")}if(Da(this,nS,"f")||e.cancelled)return;const h=yield this.createGPUResource(i,s,o,n,a,l);Da(this,nS,"f")||e.cancelled?h.scope.dispose():e.resource=h})}createGPUResource(e,r,i,s,o,n){return K0t(this,void 0,void 0,function*(){const a=s*n,l=o*n;let c;e==="webgl"?c=new eVt({targets:["webgl2","webgl1"],antialias:!0,preserveDrawingBuffer:!0,shaderDebug:!0,trackResources:!1,onContextCreationError:()=>{},onContextLost:()=>{},onContextRestored(f){}}):c=new $Vt({shaderCompilerPath:r,onContextLost:()=>{}});const h=yield c.createSwapChain(i),u=h.getDevice(),d=new H0t;d.add(()=>{u.destroy(),u.checkForLeaks()});try{h.configureSwapChain(Math.floor(a),Math.floor(l));const f=new rYt(u);d.add(()=>f.destroy());const g=new Fte(u);return d.add(()=>g.destroy()),{device:u,swapChain:h,renderCache:f,renderGraph:g,scope:d,texturePool:Da(this,L3,"f")}}catch(f){throw d.dispose(),f}})}}L3=new WeakMap,oS=new WeakMap,Q2=new WeakMap,U3=new WeakMap,bw=new WeakMap,nS=new WeakMap;let py=null;function ZZ(t){py=t}BV=function(){return(py==null?void 0:py.kind)==="animation"?py:null},Ett=function(){return(py==null?void 0:py.kind)==="png"?py:null};function rz(){py=null}var kte=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};const JZ=new Map,QZ=new Map;wtt=function(t){return QZ.get(t.trim())},OV=function(t){const e=t.trim();if(!e)return Promise.reject(new Error("rain drop texture URL is empty"));const r=QZ.get(e);if(r)return Promise.resolve(r);let i=JZ.get(e);
7156return i||(i=nj(e).then(s=>(QZ.set(e,s),s)).catch(s=>{throw JZ.delete(e),s}),JZ.set(e,i)),i};function Lte(t){return kte(this,void 0,void 0,function*(){const e=[...new Set(t.map(r=>r.trim()).filter(Boolean))];e.length!==0&&(yield Promise.all(e.map(r=>OV(r))))})}const Ute=` 7157layout(std140) uniform SceneUniforms { 7158 mat3 u_ProjectionMatrix; 7159 mat3 u_ViewMatrix; 7160 mat3 u_ViewProjectionInvMatrix; 7161 vec4 u_BackgroundColor; 7162 vec4 u_GridColor; 7163 float u_ZoomScale; 7164 float u_CheckboardStyle; 7165}; 7166 7167layout(location = 0) in vec2 a_Position; 7168 7169out vec2 v_Position; 7170 7171vec2 project_clipspace_to_world(vec2 p) { 7172 return (u_ViewProjectionInvMatrix * vec3(p, 1)).xy; 7173} 7174 7175void main() { 7176 v_Position = project_clipspace_to_world(a_Position); 7177 gl_Position = vec4(a_Position, 0, 1); 7178} 7179`,Gte=` 7180layout(std140) uniform SceneUniforms { 7181 mat3 u_ProjectionMatrix; 7182 mat3 u_ViewMatrix; 7183 mat3 u_ViewProjectionInvMatrix; 7184 vec4 u_BackgroundColor; 7185 vec4 u_GridColor; 7186 float u_ZoomScale; 7187 float u_CheckboardStyle; 7188}; 7189 7190out vec4 outputColor; 7191 7192in vec2 v_Position; 7193 7194const int CHECKERBOARD_STYLE_NONE = 0; 7195const int CHECKERBOARD_STYLE_GRID = 1; 7196const int CHECKERBOARD_STYLE_DOTS = 2; 7197const float BASE_GRID_PIXEL_SIZE = 100.0; 7198const float BASE_DOT_SIZE = 8.0; 7199 7200vec2 scale_grid_size(float zoom) { 7201 if (zoom < 0.125) return vec2(BASE_GRID_PIXEL_SIZE * 125.0, 0.125); 7202 else if (zoom < 0.25) return vec2(BASE_GRID_PIXEL_SIZE * 25.0, 0.25); 7203 else if (zoom < 0.5) return vec2(BASE_GRID_PIXEL_SIZE * 5.0, 0.5); 7204 return vec2(BASE_GRID_PIXEL_SIZE, 4.0); 7205} 7206 7207vec4 render_grid_checkerboard(vec2 coord) { 7208 float alpha = 0.0; 7209 7210 vec2 size = scale_grid_size(u_ZoomScale); 7211 float gridSize1 = size.x; 7212 float gridSize2 = gridSize1 / 10.0; 7213 float zoomStep = size.y; 7214 int checkboardStyle = int(floor(u_CheckboardStyle + 0.5)); 7215 7216 if (checkboardStyle == CHECKERBOARD_STYLE_GRID) { 7217 vec2 grid1 = abs(fract(coord / gridSize1 - 0.5) - 0.5) / fwidth(coord) * gridSize1 / 2.0; 7218 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2; 7219 float v1 = 1.0 - min(min(grid1.x, grid1.y), 1.0); 7220 float v2 = 1.0 - min(min(grid2.x, grid2.y), 1.0); 7221 7222 if (v1 > 0.0) { 7223 alpha = v1; 7224 } else { 7225 alpha = v2 * clamp(u_ZoomScale / zoomStep, 0.0, 1.0); 7226 } 7227 } else if (checkboardStyle == CHECKERBOARD_STYLE_DOTS) { 7228 vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2;
7229 alpha = 1.0 - smoothstep(0.0, 1.0, length(grid2) - BASE_DOT_SIZE * u_ZoomScale / zoomStep); 7230 } 7231 7232 return mix(u_BackgroundColor, u_GridColor, alpha); 7233} 7234 7235void main() { 7236 outputColor = render_grid_checkerboard(v_Position); 7237} 7238`;var Jl=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},W3=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},ww,tB,eB,j3,X3,z3;class Wte{constructor(){ww.set(this,void 0),tB.set(this,void 0),eB.set(this,void 0),j3.set(this,void 0),X3.set(this,void 0),z3.set(this,new Jjt)}appendVertex(e,r){Jl(this,z3,"f").appendFloat(e).appendFloat(r)}render(e,r,i,s){if(!Jl(this,ww,"f")){W3(this,ww,e.createProgram({vertex:{glsl:Ute},fragment:{glsl:Gte}}),"f"),W3(this,eB,e.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:Pi.VERTEX,attributes:[{format:X.F32_RG,offset:0,shaderLocation:0}]}],indexBufferFormat:null,program:Jl(this,ww,"f")}),"f"),W3(this,tB,e.createRenderPipeline({inputLayout:Jl(this,eB,"f"),program:Jl(this,ww,"f"),colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:X.D24_S8,topology:Ia.TRIANGLE_STRIP}),"f"),Jl(this,z3,"f").clear(),this.appendVertex(-1,-1),this.appendVertex(-1,1),this.appendVertex(1,-1),this.appendVertex(1,1);const o=Jl(this,z3,"f").bytes(),n=e.createBuffer({viewOrSize:o.byteLength,usage:Ee.VERTEX,hint:rr.DYNAMIC});W3(this,X3,n,"f"),n.setSubData(0,o),W3(this,j3,e.createBindings({pipeline:Jl(this,tB,"f"),uniformBufferBindings:[{buffer:i}]}),"f")}s&&Jl(this,ww,"f").setUniformsLegacy(s),r.setBindings(Jl(this,j3,"f")),r.setPipeline(Jl(this,tB,"f")),r.setVertexInput(Jl(this,eB,"f"),[{buffer:Jl(this,X3,"f")}],null),r.draw(4)}destroy(){var e,r,i,s,o;(e=Jl(this,ww,"f"))===null||e===void 0||e.destroy(),(r=Jl(this,X3,"f"))===null||r===void 0||r.destroy(),(i=Jl(this,tB,"f"))===null||i===void 0||i.destroy(),(s=Jl(this,eB,"f"))===null||s===void 0||s.destroy(),(o=Jl(this,j3,"f"))===null||o===void 0||o.destroy()}}ww=new WeakMap,tB=new WeakMap,eB=new WeakMap,j3=new WeakMap,X3=new WeakMap,z3=new WeakMap;class jte{constructor(e){this.format=e,this.width=0,this.height=0,this.sampleCount=0,this.colorClearColor="load",this.depthClearValue="load",this.stencilClearValue="load",this.sampledForShaderRead=!1}setDimensions(e,r,i){this.width=e,this.height=r,this.sampleCount=i}copyDimensions(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount}}function iz(t){return{colorClearColor:t,depthClearValue:1,stencilClearValue:0}}const Xte=iz(cq),zte={colorClearColor:cq,depthClearValue:0,stencilClearValue:0};var V3;(function(t){t[t.None=0]="None",t[t.FXAA=1]="FXAA",t[t.MSAAx4=2]="MSAAx4"})(V3||(V3={}));function Vte(t){if(t===In.Color0)return X.U8_RGBA_RT;if(t===In.DepthStencil)return X.D24_S8;throw new Error("whoops")}function Yte(t){return t.antialiasingMode===V3.MSAAx4?4:1}function $te(t,e){const r=Yte(e);t.setDimensions(e.backbufferWidth,e.backbufferHeight,r)}function sz(t,e,r){const i=Vte(t),s=new jte(i);return $te(s,e),r!==null&&(s.colorClearColor=r.colorClearColor,s.depthClearValue=r.depthClearValue,s.stencilClearValue=r.stencilClearValue),s}function Hte(t,e){const r=sz(In.Color0,t,e);
7238return r.sampledForShaderRead=!0,r}var oz;(function(t){t[t.BARYCENTRIC=0]="BARYCENTRIC"})(oz||(oz={}));const rB=` 7239#ifdef USE_WIREFRAME 7240 v_Barycentric = a_Barycentric; 7241#endif 7242`,iB=` 7243#ifdef USE_WIREFRAME 7244 layout(location = ${oz.BARYCENTRIC}) in vec3 a_Barycentric; 7245 out vec3 v_Barycentric; 7246#endif 7247`,nv=` 7248#ifdef USE_WIREFRAME 7249 vec3 u_WireframeLineColor = vec3(0.0, 0.0, 0.0); 7250 7251 outputColor.xyz = mix(outputColor.xyz, u_WireframeLineColor, (1.0 - edgeFactor())); 7252 if (any(lessThan(v_Barycentric, vec3(0.01)))) { 7253 outputColor.a = 0.95; 7254 } 7255#endif 7256`,aS=` 7257#ifdef USE_WIREFRAME 7258 in vec3 v_Barycentric; 7259 7260 float edgeFactor() { 7261 float u_WireframeLineWidth = 1.0; 7262 vec3 d = fwidth(v_Barycentric); 7263 vec3 a3 = smoothstep(vec3(0.0), d * u_WireframeLineWidth, v_Barycentric); 7264 return min(min(a3.x, a3.y), a3.z); 7265 } 7266#endif 7267`;function gy(t,e){if(!e.length||e.some(i=>!Number.isInteger(i)||!t[i]))return null;const r=t[e[0]];for(const i of[!1,!0]){const s=i?r.end:r.start;let o=s;const n=[];for(let a=0;a<e.length;a++){const l=e[a],c=t[l],h=a===0?i:c.start!==o,u=h?c.end:c.start,d=h?c.start:c.end;if(u!==o)break;n.push({segmentIndex:l,from:u,to:d,reversed:h}),o=d}if(n.length===e.length&&o===s)return n}return null}const my=1e-6;function Kte(t){const e=[];for(let r=t.length-2;r>=0;r-=2)e.push(t[r],t[r+1]);return e}function q0t(t,e,r,i){return D$(t,e)<my*my&&D$(r,i)<my*my}function qte(t,e,r,i){if(q0t(t,e,r,i))return 1;const s=Hy(t,i),o=Hy(t,e)+Hy(e,r)+Hy(r,i),n=Math.max(s,o*.35);let a=Math.ceil(n/6);return a=Math.min(64,Math.max(8,a)),a}function tJ(t,e){var r,i,s,o;const n=t[e.start],a=t[e.end];if(!n||!a)return[];const l=Be(n.x,n.y),c=Be(a.x,a.y),h=e.tangentStart,u=e.tangentEnd,d=it(),f=it();if(Aa(d,l,Be((r=h==null?void 0:h.x)!==null&&r!==void 0?r:0,(i=h==null?void 0:h.y)!==null&&i!==void 0?i:0)),Aa(f,c,Be((s=u==null?void 0:u.x)!==null&&s!==void 0?s:0,(o=u==null?void 0:u.y)!==null&&o!==void 0?o:0)),D$(l,c)<my*my&&q0t(l,d,f,c))return[l[0],l[1],c[0],c[1]];const g=qte(l,d,f,c),p=new Rq(Ta(l),Ta(d),Ta(f),Ta(c)).getPoints(g),m=[];for(let v=0;v<p.length;v++)m.push(p[v][0],p[v][1]);return m}function Zte(t,e){const r=tJ(t,e),i=r.length/2;if(i===0)return{xy:r,vid:[]};const s=new Array(i).fill(-1);return s[0]=e.start,s[i-1]=e.end,{xy:r,vid:s}}function Jte(t){return[...t].reverse()}function eJ(t,e,r,i){const{xy:s,vid:o}=Zte(t,e);return s.length===0?{xy:s,vid:[]}:e.start===r&&e.end===i?{xy:s,vid:o}:e.end===r&&e.start===i?{xy:Kte(s),vid:Jte(o)}:{xy:[],vid:[]}}function Qte(t,e,r,i){if(r.length!==0){if(t.length>=2){const s=t[t.length-2],o=t[t.length-1],n=r[0],a=r[1];if(Math.abs(s-n)<my&&Math.abs(o-a)<my){t.push(...r.slice(2)),e.push(...i.slice(1));return}}t.push(...r),e.push(...i)}}function tee(t,e,r,i){if(r.length!==0){if(t.length>=2&&r.length>=2){const s=t[0],o=t[1],n=r[r.length-2],a=r[r.length-1];if(Math.abs(n-s)<my&&Math.abs(a-o)<my){t.unshift(...r.slice(0,-2)),e.unshift(...i.slice(0,-1));return}}t.unshift(...r),e.unshift(...i)}}function eee(t,e,r){const i=new Array(r),s=new Array(r);for(let o=0;o<r;o++){i[o]=void 0,s[o]=void 0;const n=e[o];if(n<0)continue;const a=t[n];a&&((o===0||o===r-1)&&a.strokeLinecap!==void 0&&(s[o]=a.strokeLinecap),o>0&&o<r-1&&n>=0&&a.strokeLinejoin!==void 0&&(i[o]=a.strokeLinejoin))}return{linejoin:i,linecap:s}}function ree(t,e){if(!(t!=null&&t.length)||!(e!=null&&e.length))return{points:[]};const r=t.length,i=iee(e,r),s=new Array(e.length).fill(!1),o=[],n=[],a=[];for(let l=0;l<e.length;l++){if(s[l])continue;const c=e[l],h=eJ(t,c,c.start,c.end),u=h.xy,d=h.vid;s[l]=!0;let f=c.end;for(;;){const m=Z0t(f,i,s);if(!m)break;const v=eJ(t,e[m.seg],f,m.other);Qte(u,d,v.xy,v.vid),s[m.seg]=!0,f=m.other}for(f=c.start;;){const m=Z0t(f,i,s);if(!m)break;const v=eJ(t,e[m.seg],m.other,f);tee(u,d,v.xy,v.vid),s[m.seg]=!0,f=m.other}if(u.length===0)continue;const g=u.length/2,p=eee(t,d,g);o.length>0&&(o.push(NaN,NaN),n.push(void 0),a.push(void 0));for(let m=0;m<g;m++)n.push(p.linejoin[m]),a.push(p.linecap[m]);o.push(...u)}return!(n.some(l=>l!==void 0)||a.some(l=>l!==void 0))||o.length===0?{points:o}:{points:o,linejoin:n,linecap:a}}function iee(t,e){const r=Array.from({length:e},()=>[]);for(let i=0;i<t.length;i++){const s=t[i];s.start<0||s.end<0||s.start>=e||s.end>=e||(r[s.start].push({seg:i,other:s.end}),r[s.end].push({seg:i,other:s.start}))}return r}function Z0t(t,e,r){const i=e[t];if(!i)return null;let s=null;for(const o of i)if(!r[o.seg]){if(s)return null;s=o}return s}function J0t(t,e,r,i,s,o){var n,a,l,c,h,u,d,f;let g=r,p=i,m=s,v=o;const b=(y,_)=>{!Number.isFinite(y)||!Number.isFinite(_)||(g=Math.min(g,y),p=Math.min(p,_),m=Math.max(m,y),v=Math.max(v,_))};for(const y of e){const _=t[y.start],w=t[y.end];if(!_||!w)continue;const E=_.x,A=_.y,x=w.x,S=w.y,T=E+((a=(n=y.tangentStart)===null||n===void 0?void 0:n.x)!==null&&a!==void 0?a:0),R=A+((c=(l=y.tangentStart)===null||l===void 0?void 0:l.y)!==null&&c!==void 0?c:0),B=x+((u=(h=y.tangentEnd)===null||h===void 0?void 0:h.x)!==null&&u!==void 0?u:0),O=S+((f=(d=y.tangentEnd)===null||d===void 0?void 0:d.y)!==null&&f!==void 0?f:0);b(E,A),b(T,R),b(B,O),b(x,S)}return{minX:g,minY:p,maxX:m,maxY:v}}const Q0t=1e-6;function see(t){if(t.fillRule)return t.fillRule;const e=t.windingRule;return e==="EVENODD"||e==="evenodd"?"evenodd":"nonzero"}function tvt(t,e){return Math.abs(t[0]-e[0])<Q0t&&Math.abs(t[1]-e[1])<Q0t}function oee(t){const e=[];for(let r=0;r<t.length;r+=2)e.push([t[r],t[r+1]]);return e}function evt(t,e,r){const i=[];for(const{segmentIndex:s,from:o,to:n,reversed:a}of r){if(!t[o]||!t[n])return[];const l=oee(tJ(t,e[s]));a&&l.reverse();for(const c of l){if(!Number.isFinite(c[0])||!Number.isFinite(c[1]))return[];(!i.length||!tvt(i[i.length-1],c))&&i.push(c)}}return i.length>=2&&tvt(i[0],i[i.length-1])&&i.pop(),i}function rvt(t,e,r){const i=gy(e,r);return i?evt(t,e,i):[]}KV=function(t,e,r){var i;if(!(r!=null&&r.length))return{points:[],indices:[]};const s=[],o=[];let n=0;for(const a of r){const l=(i=a.loops)!==null&&i!==void 0?i:[],c=[];for(const d of l){const f=rvt(t,e,d);f.length>=3&&c.push(f)}if(c.length===0||c.length!==l.length)continue;const h=kq(c,see(a)),u=h.length/2;s.push(...h);for(let d=0;d<u;d++)o.push(n+d);n+=u}return{points:s,indices:o}};function Y3(t,e,r,i){const s=e.maxX-e.minX,o=e.maxY-e.minY;if(s<=1e-8||o<=1e-8){t.setTransform(1,0,0,1,0,0);return}
7267t.setTransform(r/s,0,0,i/o,-e.minX*r/s,-e.minY*i/o)}function ivt(t,e,r){var i;if(!e.has(Yt)||!e.has(Ji))return!1;const s=e.read(Yt);if(s.bitmapFont)return!1;const o=e.read(Ji),{lines:n,lineMetrics:a,font:l,fontMetrics:c,lineHeight:h}=o;if(!l||!(n!=null&&n.length)||!(a!=null&&a.length)||!c)return!1;if(t.fillStyle=r,t.font=l,t.textBaseline="top",t.textAlign=s.textAlign,"fontKerning"in t)try{t.fontKerning=s.fontKerning?"normal":"none"}catch{}const u=s.letterSpacing;u&&"letterSpacing"in t&&(t.letterSpacing=`${u}px`);const{anchorX:d,anchorY:f}=s,g=s.lineHeight||c.fontSize,p=f+u3(s.textBaseline,c)-(g-c.fontSize)/2;for(let m=0;m<n.length;m++){const v=a[m];v&&t.fillText((i=n[m])!==null&&i!==void 0?i:"",d+v.x,p+m*h)}return!0}function nee(t,e,r,i,s){const o=t.getContext("2d");o&&(o.globalCompositeOperation="destination-in",Y3(o,r,i,s),ivt(o,e,"rgba(255,255,255,1)"),o.globalCompositeOperation="source-over",o.globalAlpha=1,o.setTransform(1,0,0,1,0,0))}function svt(t,e){const r=Math.max(0,Math.min(1,t.opacity*e));return`rgba(${t.r},${t.g},${t.b},${r})`}function lS(t){if(t.has(fe)){const e=t.read(fe).geometryBounds,r=e.maxX-e.minX,i=e.maxY-e.minY;if(r>=.5&&i>=.5)return{minX:e.minX,minY:e.minY,maxX:e.maxX,maxY:e.maxY}}if(t.has($t)){const e=$t.getGeometryBounds(t.read($t));return{minX:e.minX,minY:e.minY,maxX:e.maxX,maxY:e.maxY}}if(t.has(ae)){const e=ae.getGeometryBounds(t.read(ae));return{minX:e.minX,minY:e.minY,maxX:e.maxX,maxY:e.maxY}}if(t.has(et)){const e=et.getGeometryBounds(t.read(et));return{minX:e.minX,minY:e.minY,maxX:e.maxX,maxY:e.maxY}}return{minX:0,minY:0,maxX:1,maxY:1}}function ovt(t,e){const r=e*.5;return{minX:t.minX-r,minY:t.minY-r,maxX:t.maxX+r,maxY:t.maxY+r}}function nvt(t,e){if(t.has(fe)){const s=t.read(fe).renderBounds,o=s.maxX-s.minX,n=s.maxY-s.minY;if(o>=.5&&n>=.5)return{minX:s.minX,minY:s.minY,maxX:s.maxX,maxY:s.maxY}}const r=e(),i=t.has(Gt)?t.read(Gt).width:0;return ovt(r,i)}function aee(t,e,r,i){let s;if(typeof document<"u"){const a=document.createElement("canvas");a.width=r,a.height=i,s=a}else s=new OffscreenCanvas(r,i);const o=s.getContext("2d");if(!o)throw new Error("Canvas 2D required for stroke silhouette filter raster");o.clearRect(0,0,r,i),Y3(o,e,r,i);const n=t.read(Gt);if(o.lineWidth=n.width,o.lineJoin=n.linejoin,o.lineCap=n.linecap,o.miterLimit=n.miterlimit,o.strokeStyle="rgba(255,255,255,1)",t.has(xt)){const{d:a}=t.read(xt);if(a&&String(a).trim())try{o.stroke(new Path2D(String(a)))}catch{}return s}if(t.has(Mt)){const{x1:a,y1:l,x2:c,y2:h}=t.read(Mt);return o.beginPath(),o.moveTo(a,l),o.lineTo(c,h),o.stroke(),s}if(t.has(_t)){const a=t.read(_t).points;if(a.length>=2){o.beginPath(),o.moveTo(a[0][0],a[0][1]);for(let l=1;l<a.length;l++)o.lineTo(a[l][0],a[l][1]);o.stroke()}return s}if(t.has(ae)){const{cx:a,cy:l,rx:c,ry:h}=t.read(ae);return o.beginPath(),o.ellipse(a,l,Math.max(0,c),Math.max(0,h),0,0,Math.PI*2),o.stroke(),s}if(t.has(et)){const{cx:a,cy:l,r:c}=t.read(et);return o.beginPath(),o.arc(a,l,Math.max(0,c),0,Math.PI*2),o.stroke(),s}return s}function nz(t){const e=Hl(t);if(!e||!iv(e)||!t.hasSomeOf($t,ae,et)||t.has(yh)||t.has(Ce)&&(!WXt(t)||aw(Nh(t)))||t.has(ue)||!t.has(Gt)||kh(t)!=null)return!1;const r=t.read(Gt);if(r.width<=0||r.alignment!=="center")return!1;const[i,s]=r.dasharray;return!(i>0&&s>0)}function lee(t,e,r,i){var s,o;let n;if(typeof document<"u"){const y=document.createElement("canvas");y.width=r,y.height=i,n=y}else n=new OffscreenCanvas(r,i);const a=n.getContext("2d");if(!a)throw new Error("Canvas 2D required for fill+stroke filter raster");a.clearRect(0,0,r,i),Y3(a,e,r,i);const l=pj(t),{strokeColorAlphaMul:c,strokeUniformOpacityMul:h}=b2(t),u=(s=Hx(t))!==null&&s!==void 0?s:"none",d=Wo(u&&u!=="none"?u:"transparent"),f=svt(d,l),g=t.read(Gt),p=Wo((o=H0(t))!==null&&o!==void 0?o:"transparent"),m=svt(p,c*h);a.lineWidth=g.width,a.lineJoin=g.linejoin,a.lineCap=g.linecap,a.miterLimit=g.miterlimit;const v=t.has(sm),b=u!=="none"&&d.opacity*l>1e-8&&!v;if(t.has(ae)){const{cx:y,cy:_,rx:w,ry:E}=t.read(ae);return a.beginPath(),a.ellipse(y,_,Math.max(0,w),Math.max(0,E),0,0,Math.PI*2),b&&(a.fillStyle=f,a.fill()),a.strokeStyle=m,a.stroke(),n}if(t.has(et)){const{cx:y,cy:_,r:w}=t.read(et);return a.beginPath(),a.arc(y,_,Math.max(0,w),0,Math.PI*2),b&&(a.fillStyle=f,a.fill()),a.strokeStyle=m,a.stroke(),n}if(t.has($t)){const{x:y,y:_,width:w,height:E,cornerRadius:A}=t.read($t),x=y+w,S=_+E,T=Math.min(y,x),R=Math.min(_,S),B=Math.abs(w),O=Math.abs(E),C=Math.max(0,A);return a.beginPath(),C>0&&"roundRect"in a&&typeof a.roundRect=="function"?a.roundRect(T,R,B,O,C):a.rect(T,R,B,O),b&&(a.fillStyle=f,a.fill()),a.strokeStyle=m,a.stroke(),n}return n}function rJ(t,e){for(const r of e){const i=r.offset.type==="%"?r.offset.value/100:Math.max(0,Math.min(1,r.offset.value));t.addColorStop(i,r.color)}}function cee(t,e,r){const i=[r.minX,r.minY],s=r.maxX-r.minX,o=r.maxY-r.minY;if(s<=1e-8||o<=1e-8)return null;if(e.type==="linear-gradient"){const{x1:n,y1:a,x2:l,y2:c}=dE(i,s,o,e.angle),h=t.createLinearGradient(n,a,l,c);return rJ(h,e.steps),h}if(e.type==="radial-gradient"){const{x:n,y:a,r:l}=pO(i,s,o,e.cx,e.cy,e.size),c=t.createRadialGradient(n,a,0,n,a,l);return rJ(c,e.steps),c}if(e.type==="conic-gradient"){const{x:n,y:a}=dG(i,s,o,e.cx,e.cy),l=t.createConicGradient(e.angle*Math.PI/180,n,a);return rJ(l,e.steps),l}return null}function avt(t,e,r){const i=r.maxX-r.minX,s=r.maxY-r.minY;for(const o of e){if(Zy(o))continue;if(o.type==="linear-gradient"){Xdt(t,r.minX,r.minY,i,s,o);continue}const n=cee(t,o,r);
7267n&&(t.fillStyle=n,t.fillRect(r.minX,r.minY,i,s))}}function hee(t,e,r,i,s,o){let n;if(typeof document<"u"){const l=document.createElement("canvas");l.width=r,l.height=i,n=l}else n=new OffscreenCanvas(r,i);const a=n.getContext("2d");if(!a)throw new Error("Canvas 2D required for gradient text + filter");return a.clearRect(0,0,r,i),a.globalAlpha=Math.max(0,Math.min(1,o)),Y3(a,e,r,i),avt(a,s,e),a.globalCompositeOperation="destination-in",ivt(a,t,"rgba(255,255,255,1)"),a.globalCompositeOperation="source-over",a.globalAlpha=1,a.setTransform(1,0,0,1,0,0),n}const uee=` 7268vec4 permute(vec4 x) { 7269 return mod(((x*34.0)+1.0)*x, 289.0); 7270} 7271vec4 taylorInvSqrt(vec4 r) { 7272 return 1.79284291400159 - 0.85373472095314 * r; 7273} 7274float snoise(vec3 v) { 7275 const vec2 C = vec2(1.0/6.0, 1.0/3.0) ; 7276 const vec4 D = vec4(0.0, 0.5, 1.0, 2.0); 7277 7278 // First corner 7279 7280 vec3 i = floor(v + dot(v, C.yyy) ); 7281 vec3 x0 = v - i + dot(i, C.xxx) ; 7282 7283 // Other corners 7284 7285 vec3 g = step(x0.yzx, x0.xyz); 7286 vec3 l = 1.0 - g; 7287 vec3 i1 = min( g.xyz, l.zxy ); 7288 vec3 i2 = max( g.xyz, l.zxy ); 7289 vec3 x1 = x0 - i1 + 1.0 * C.xxx; 7290 vec3 x2 = x0 - i2 + 2.0 * C.xxx; 7291 vec3 x3 = x0 - 1. + 3.0 * C.xxx; 7292 7293 // Permutations 7294 7295 i = mod(i, 289.0 ); 7296 vec4 p = permute( permute( permute( 7297 i.z + vec4(0.0, i1.z, i2.z, 1.0 )) 7298 + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) 7299 + i.x + vec4(0.0, i1.x, i2.x, 1.0 )); 7300 7301 // Gradients 7302 7303 float n_ = 1.0/7.0; // N = 7 7304 7305 vec3 ns = n_ * D.wyz - D.xzx; 7306 vec4 j = p - 49.0 * floor(p * ns.z *ns.z); // mod(p, N*N) 7307 7308 7309 vec4 x_ = floor(j * ns.z); 7310 vec4 y_ = floor(j - 7.0 * x_ ); // mod(j, N) 7311 7312 7313 vec4 x = x_ *ns.x + ns.yyyy; 7314 vec4 y = y_ *ns.x + ns.yyyy; 7315 vec4 h = 1.0 - abs(x) - abs(y); 7316 vec4 b0 = vec4( x.xy, y.xy ); 7317 vec4 b1 = vec4( x.zw, y.zw ); 7318 vec4 s0 = floor(b0)*2.0 + 1.0; 7319 vec4 s1 = floor(b1)*2.0 + 1.0; 7320 vec4 sh = -step(h, vec4(0.0)); 7321 vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ; 7322 vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ; 7323 vec3 p0 = vec3(a0.xy, h.x); 7324 vec3 p1 = vec3(a0.zw, h.y); 7325 vec3 p2 = vec3(a1.xy, h.z); 7326 vec3 p3 = vec3(a1.zw, h.w); 7327 7328 // Normalise gradients 7329 7330 vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3))); 7331 p0 *= norm.x; 7332 p1 *= norm.y; 7333 p2 *= norm.z; 7334 p3 *= norm.w; 7335 7336 // Mix final noise value 7337 7338 vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); 7339 m = m * m; 7340 return 42.0 * dot( m*m, vec4( dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3) ) ); 7341}`,dee=` 7342#define MAX_POINTS 10 7343 7344struct Point { 7345 vec3 color; 7346 vec2 position; 7347}; 7348 7349layout(std140) uniform Uniforms { 7350 Point u_Points[MAX_POINTS]; 7351 vec3 u_BgColor; 7352 float u_PointsNum; 7353 float u_NoiseRatio; 7354 float u_NoiseTime; 7355 float u_WarpShapeIndex; 7356 float u_WarpSize; 7357 float u_WarpRatio; 7358 float u_GradientTypeIndex; 7359 float u_Time; 7360}; 7361 7362layout(location = 0) in vec2 a_Position; 7363 7364out vec2 v_TexCoord; 7365 7366void main() { 7367 v_TexCoord = 0.5 * (a_Position + 1.0); 7368 gl_Position = vec4(a_Position, 0.0, 1.0); 7369 7370 #ifdef VIEWPORT_ORIGIN_TL 7371 v_TexCoord.y = 1.0 - v_TexCoord.y; 7372 #endif 7373} 7374`,fee=` 7375#define MAX_POINTS 10 7376 7377struct Point { 7378 vec3 color; 7379 vec2 position; 7380}; 7381 7382layout(std140) uniform Uniforms { 7383 Point u_Points[MAX_POINTS]; 7384 vec3 u_BgColor; 7385 float u_PointsNum; 7386 float u_NoiseRatio; 7387 float u_NoiseTime; 7388 float u_WarpShapeIndex; 7389 float u_WarpSize; 7390 float u_WarpRatio; 7391 float u_GradientTypeIndex; 7392 float u_Time; 7393}; 7394 7395in vec2 v_TexCoord; 7396 7397out vec4 outputColor; 7398 7399float rand(vec2 n) { 7400 return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453); 7401} 7402 7403${uee} 7404 7405// Value Noise with increased contrast 7406float valueNoise(vec2 st) { 7407 vec2 i = floor(st); 7408 vec2 f = fract(st); 7409 float a = rand(i); 7410 float b = rand(i + vec2(1.0, 0.0)); 7411 float c = rand(i + vec2(0.0, 1.0)); 7412 float d = rand(i + vec2(1.0, 1.0)); 7413 vec2 u = f * f * (3.0 - 2.0 * f); 7414 float n = mix(a, b, u.x) + (c - a)* u.y * (1.0 - u.x) + (d - b) * u.x * u.y; 7415 // Increase contrast 7416 7417 return (n - 0.5) * 2.0; 7418} 7419// Worley Noise with inverted and scaled output 7420float worleyNoise(vec2 st) { 7421 vec2 i_st = floor(st); 7422 vec2 f_st = fract(st); 7423 float m_dist = 1.0; 7424 for (int y = -1; y <= 1; y++) { 7425 for (int x = -1; x <= 1; x++) { 7426 vec2 neighbor = vec2(float(x), float(y)); 7427 vec2 point = vec2(rand(i_st + neighbor), rand(i_st + neighbor + vec2(12.9898, 78.233))); 7428 vec2 diff = neighbor + point - f_st; 7429 float dist = length(diff); 7430 m_dist = min(m_dist, dist); 7431 } 7432 7433 } 7434 // Invert and scale the output 7435 return (1.0 - m_dist) * 2.0; 7436} 7437float fbm(vec2 st) { 7438 const int OCTAVES = 6; 7439 float value = 0.0; 7440 float amplitude = 0.5; 7441 float frequency = 0.0; 7442 // Lacunarity: Increase in frequency with each octave 7443 7444 float lacunarity = 2.0; 7445 // Gain: Decrease in amplitude with each octave 7446 7447 float gain = 0.5; 7448 for (int i = 0; i < OCTAVES; i++) { 7449 value += amplitude * valueNoise(st); 7450 st *= lacunarity; 7451 amplitude *= gain; 7452 } 7453 return value; 7454} 7455// Voronoi Noise 7456float voronoiNoise(vec2 st) { 7457 vec2 i_st = floor(st); 7458 vec2 f_st = fract(st); 7459 float m_dist = 1.0; 7460 for (int y = -1; y <= 1; y++) { 7461 for (int x = -1; x <= 1; x++) { 7462 vec2 neighbor = vec2(float(x), float(y)); 7463 vec2 point = vec2(rand(i_st + neighbor), rand(i_st + neighbor + vec2(1.0))); 7464 point = 0.5 + 0.5 * sin(u_Time + 6.2831 * point); 7465 vec2 diff = neighbor + point - f_st; 7466 float dist = length(diff); 7467 m_dist = min(m_dist, dist); 7468 } 7469 7470 } 7471 return m_dist; 7472} 7473// Domain Warping 7474vec2 domainWarp(vec2 p) { 7475 float n1 = snoise(vec3(p + u_Time * 0.1, 0.0)); 7476 float n2 = snoise(vec3(p + u_Time * 0.1 + 5.0, 0.0)); 7477 return vec2(p.x + n1 * 0.2, p.y + n2 * 0.2); 7478} 7479// Smooth layered sine waves 7480float wavesNoise(vec2 st) { 7481 float noise = 0.0; 7482 7483 // Layer 1: Primary waves 7484 7485 vec2 pos1 = st * 3.0; 7486 noise += sin(pos1.x + u_Time * 0.2) * 0.5 + 0.5; 7487 noise += sin(pos1.y + u_Time * 0.2) * 0.5 + 0.5; 7488 7489 // Layer 2: Secondary waves at different angle 7490 7491 vec2 pos2 = vec2( 7492 st.x * cos(0.7854) - st.y * sin(0.7854), st.x * sin(0.7854) + st.y * cos(0.7854) 7493 ) * 4.0; 7494 noise += sin(pos2.x) * 0.25 + 0.25; 7495 noise += sin(pos2.y) * 0.25 + 0.25; 7496 return noise / 3.0; 7497} 7498// Gradient noise with controlled smoothness 7499float smoothGradient(vec2 st) { 7500 vec2 i = floor(st); 7501 vec2 f = fract(st); 7502 7503 // Smoother interpolation 7504 7505 vec2 u = f * f * f * (f * (f * 6.0 - 15.0) + 10.0); 7506 float a = rand(i); 7507 float b = rand(i + vec2(1.0, 0.0)); 7508 float c = rand(i + vec2(0.0, 1.0)); 7509 float d = rand(i + vec2(1.0, 1.0)); 7510 float noise = mix( 7511 mix(a, b, u.x), mix(c, d, u.x), u.y 7512 ); 7513 return noise * 0.8 + 0.1; // Adjust contrast 7514} 7515// Sphere effect 7516float sphereNoise(vec2 st) { 7517 vec2 center = vec2(0.5); 7518 float dist = distance(st, center); 7519 7520 // Create smooth sphere falloff 7521 7522 float sphere = 1.0 - smoothstep(0.0, 0.5, dist); 7523 7524 // Add subtle movement 7525 7526 float angle = atan(st.y - 0.5, st.x - 0.5); 7527 float movement = sin(angle * 2.0 + u_Time * 0.2) * 0.02; 7528 return sphere + movement; 7529} 7530// Stepped rows effect 7531float rowsNoise(vec2 st) { 7532 // Number of rows 7533 float rows = 15.0; 7534 7535 // Create base row pattern 7536 7537 float y = st.y * rows; 7538 float row = floor(y); 7539 7540 // Add horizontal offset based on row number 7541 7542 float offset = row * 0.1; 7543 float x = st.x + offset; 7544 7545 // Add movement 7546 7547 float movement = sin(u_Time * 0.2 + row * 0.5) * 0.02; 7548 x += movement; 7549 7550 // Smooth stepping between rows 7551 7552 float smoothRow = smoothstep(0.0, 0.1, fract(y)); 7553 return mix(x, x + 0.1, smoothRow); 7554} 7555float columnsNoise(vec2 st) { 7556 // Number of columns 7557 float cols = 15.0; 7558 7559 // Create base column pattern 7560 7561 float x = st.x * cols; 7562 float col = floor(x); 7563 7564 // Add vertical offset based on column number 7565 7566 float offset = col * 0.1; 7567 float y = st.y + offset; 7568 7569 // Add movement 7570 7571 float movement = sin(u_Time * 0.2 + col * 0.5) * 0.02; 7572 y += movement; 7573 7574 // Smooth stepping between columns 7575 7576 float smoothCol = smoothstep(0.0, 0.1, fract(x)); 7577 return mix(y, y + 0.1, smoothCol); 7578} 7579// Flat/Stable pattern - minimal movement 7580float flatNoise(vec2 st) { 7581 // Create a very subtle, stable pattern 7582 float pattern = sin(st.x * 2.0) * 0.02 + cos(st.y * 2.0) * 0.02; 7583 return pattern; 7584} 7585float blackHoleNoise(vec2 st) { 7586 vec2 center = vec2(0.5); 7587 float dist = distance(st, center); 7588 7589 // Calculate angle for spiral effect
7590 7591 float angle = atan(st.y - center.y, st.x - center.x); 7592 7593 // Wider, more gradual falloff 7594 7595 float pull = 1.0 - smoothstep(0.0, 1.5, dist); 7596 7597 // Gentler spiral effect 7598 7599 float spiral = angle + u_Time * 0.1; 7600 7601 // Layer multiple subtle distortions 7602 7603 float distortion = 0.0; 7604 distortion += sin(spiral * 2.0 + dist * 4.0) * 0.3; 7605 distortion += cos(spiral * 1.5 - dist * 3.0) * 0.2; 7606 7607 // Combine with pull for smoother falloff 7608 7609 distortion *= pull * pull; 7610 7611 // Add subtle secondary vortex 7612 7613 float secondaryDist = distance(st, center + vec2(0.2, 0.0)); 7614 float secondaryPull = 1.0 - smoothstep(0.0, 1.2, secondaryDist); 7615 float secondarySpiral = angle + u_Time * 0.08; 7616 distortion += sin(secondarySpiral * 1.5) * secondaryPull * 0.15; 7617 return distortion; 7618} 7619 7620vec2 applyWarpShape(vec2 st, float warpSize, float time) { 7621 vec2 warp; 7622 if (int(u_WarpShapeIndex) == 0) { 7623 warp = vec2(snoise(vec3(st * warpSize, time))); 7624 } else if (int(u_WarpShapeIndex) == 1) { 7625 warp = vec2(sin(length(st-0.5)*warpSize + time), cos(length(st-0.5)*warpSize + time)) * 0.5; 7626 } else if (int(u_WarpShapeIndex) == 2) { 7627 warp = vec2(valueNoise(st*warpSize + time * 0.5)) * 0.5; 7628 } else if (int(u_WarpShapeIndex) == 3) { 7629 warp = vec2(worleyNoise(st*warpSize + time * 0.5)) * 0.5; 7630 } else if (int(u_WarpShapeIndex) == 4) { 7631 warp = vec2(fbm(st*warpSize + time * 0.2)) * 0.4; 7632 } else if (int(u_WarpShapeIndex) == 5) { 7633 warp = vec2(voronoiNoise(st*warpSize + time * 0.2)) * 0.5; 7634 } else if (int(u_WarpShapeIndex) == 6) { 7635 warp = vec2(domainWarp(st*warpSize) * 0.5); 7636 } else if (int(u_WarpShapeIndex) == 7) { 7637 warp = vec2(wavesNoise(st*warpSize + time * 0.1)) * 0.4; 7638 } else if (int(u_WarpShapeIndex) == 8) { 7639 warp = vec2(smoothGradient(st*warpSize + time * 0.1)) * 0.5; 7640 } else if (int(u_WarpShapeIndex) == 9) { 7641 warp = vec2(sphereNoise(st)) * warpSize * 0.8; 7642 } else if (int(u_WarpShapeIndex) == 10) { 7643 warp = vec2(rowsNoise(st)) * warpSize * 0.5; 7644 } else if (int(u_WarpShapeIndex) == 11) { 7645 warp = vec2(columnsNoise(st)) * warpSize * 0.5; 7646 } else if (int(u_WarpShapeIndex) == 12) { 7647 warp = vec2(flatNoise(st)) * warpSize; 7648 } else if (int(u_WarpShapeIndex) == 13) { 7649 float effect = blackHoleNoise(st); 7650 vec2 toCenter = st - vec2(0.5); 7651 float len = length(toCenter); 7652 if (len > 0.0) { 7653 vec2 dir = toCenter / len; 7654 warp = dir * effect * warpSize * 1.5; 7655 } 7656 else { 7657 warp = vec2(0.0); 7658 } 7659 } 7660 return warp; 7661} 7662 7663vec3 calculateOriginalWarpGradient(vec2 st) { 7664 float pointGradient = 0.0; 7665 vec3 colorGradient = vec3(0.0); 7666 float totalLight = 1.0; 7667 for(int i = 0; i < MAX_POINTS; i++) { 7668 if(i < int(u_PointsNum)) { 7669 vec3 color = u_Points[i].color;
7670 vec2 pointPos = u_Points[i].position; 7671 float dist = 1.0 - distance(st, pointPos) * 1.1; 7672 float clampedDist = clamp(dist, 0.0, 1.0); 7673 pointGradient += clampedDist; 7674 colorGradient += color * clampedDist; 7675 totalLight *= (1.0 - clampedDist) * (1.0 - clampedDist); 7676 } 7677 } 7678 totalLight = smoothstep(0.0, 1.0, clamp(1.0 - totalLight, 0.0, 1.0)); 7679 colorGradient = (colorGradient / pointGradient) * totalLight; 7680 vec3 bgGradient = (1.0 - totalLight) * u_BgColor; 7681 return clamp(colorGradient, 0.0, 1.0) + bgGradient; 7682} 7683 7684vec3 calculateBezierGradient(vec2 st) { 7685 vec3 color = vec3(0.0); 7686 float totalWeight = 0.0; 7687 float sigma = 0.2; // Standard deviation for Gaussian distribution 7688 7689 float twoSigmaSquare = 2.0 * sigma * sigma; 7690 for (int i = 0; i < MAX_POINTS; i++) { 7691 if (i < int(u_PointsNum)) { 7692 vec2 pointPos = u_Points[i].position; 7693 float dist = distance(st, pointPos); 7694 7695 // Gaussian weight 7696 7697 float weight = exp(-dist * dist / twoSigmaSquare); 7698 color += u_Points[i].color * weight; 7699 totalWeight += weight; 7700 } 7701 } 7702 if (totalWeight > 0.0) { 7703 color /= totalWeight; 7704 } 7705 else { 7706 color = u_BgColor; 7707 } 7708 return color; 7709} 7710 7711vec3 calculateMeshGradient(vec2 st) { 7712 const int GRID_SIZE = 3; // 3x3 grid 7713 7714 vec2 gridSt = st * float(GRID_SIZE - 1); 7715 vec2 gridCell = floor(gridSt); 7716 vec2 gridFract = fract(gridSt); 7717 vec3 colorBottomLeft = u_BgColor; 7718 vec3 colorBottomRight = u_BgColor; 7719 vec3 colorTopLeft = u_BgColor; 7720 vec3 colorTopRight = u_BgColor; 7721 int index = int(gridCell.y) * GRID_SIZE + int(gridCell.x); 7722 7723 int pointsNum = int(u_PointsNum); 7724 7725 // Bottom Left 7726 7727 if (index == 0 && 0 < pointsNum) colorBottomLeft = u_Points[0].color; 7728 if (index == 1 && 1 < pointsNum) colorBottomLeft = u_Points[1].color; 7729 if (index == 2 && 2 < pointsNum) colorBottomLeft = u_Points[2].color; 7730 if (index == 3 && 3 < pointsNum) colorBottomLeft = u_Points[3].color; 7731 if (index == 4 && 4 < pointsNum) colorBottomLeft = u_Points[4].color; 7732 if (index == 5 && 5 < pointsNum) colorBottomLeft = u_Points[5].color; 7733 if (index == 6 && 6 < pointsNum) colorBottomLeft = u_Points[6].color; 7734 if (index == 7 && 7 < pointsNum) colorBottomLeft = u_Points[7].color; 7735 if (index == 8 && 8 < pointsNum) colorBottomLeft = u_Points[8].color; 7736 7737 // Bottom Right 7738 7739 if (index + 1 == 0 && 0 < pointsNum) colorBottomRight = u_Points[0].color; 7740 if (index + 1 == 1 && 1 < pointsNum) colorBottomRight = u_Points[1].color; 7741 if (index + 1 == 2 && 2 < pointsNum) colorBottomRight = u_Points[2].color; 7742 if (index + 1 == 3 && 3 < pointsNum) colorBottomRight = u_Points[3].color; 7743 if (index + 1 == 4 && 4 < pointsNum) colorBottomRight = u_Points[4].color; 7744 if (index + 1 == 5 && 5 < pointsNum) colorBottomRight = u_Points[5].color; 7745 if (index + 1 == 6 && 6 < pointsNum) colorBottomRight = u_Points[6].color; 7746 if (index + 1 == 7 && 7 < pointsNum) colorBottomRight = u_Points[7].color; 7747 if (index + 1 == 8 && 8 < pointsNum) colorBottomRight = u_Points[8].color; 7748 7749 // Top Left 7750 7751 if (index + GRID_SIZE == 0 && 0 < pointsNum) colorTopLeft = u_Points[0].color; 7752 if (index + GRID_SIZE == 1 && 1 < pointsNum) colorTopLeft = u_Points[1].color; 7753 if (index + GRID_SIZE == 2 && 2 < pointsNum) colorTopLeft = u_Points[2].color; 7754 if (index + GRID_SIZE == 3 && 3 < pointsNum) colorTopLeft = u_Points[3].color; 7755 if (index + GRID_SIZE == 4 && 4 < pointsNum) colorTopLeft = u_Points[4].color; 7756 if (index + GRID_SIZE == 5 && 5 < pointsNum) colorTopLeft = u_Points[5].color; 7757 if (index + GRID_SIZE == 6 && 6 < pointsNum) colorTopLeft = u_Points[6].color; 7758 if (index + GRID_SIZE == 7 && 7 < pointsNum) colorTopLeft = u_Points[7].color; 7759 if (index + GRID_SIZE == 8 && 8 < pointsNum) colorTopLeft = u_Points[8].color; 7760 7761 // Top Right 7762 7763 if (index + GRID_SIZE + 1 == 0 && 0 < pointsNum) colorTopRight = u_Points[0].color; 7764 if (index + GRID_SIZE + 1 == 1 && 1 < pointsNum) colorTopRight = u_Points[1].color; 7765 if (index + GRID_SIZE + 1 == 2 && 2 < pointsNum) colorTopRight = u_Points[2].color; 7766 if (index + GRID_SIZE + 1 == 3 && 3 < pointsNum) colorTopRight = u_Points[3].color; 7767 if (index + GRID_SIZE + 1 == 4 && 4 < pointsNum) colorTopRight = u_Points[4].color; 7768 if (index + GRID_SIZE + 1 == 5 && 5 < pointsNum) colorTopRight = u_Points[5].color; 7769 if (index + GRID_SIZE + 1 == 6 && 6 < pointsNum) colorTopRight = u_Points[6].color; 7770 if (index + GRID_SIZE + 1 == 7 && 7 < pointsNum) colorTopRight = u_Points[7].color; 7771 if (index + GRID_SIZE + 1 == 8 && 8 < pointsNum) colorTopRight = u_Points[8].color; 7772 7773 // Bilinear interpolation 7774 7775 vec3 colorBottom = mix(colorBottomLeft, colorBottomRight, gridFract.x); 7776 vec3 colorTop = mix(colorTopLeft, colorTopRight, gridFract.x); 7777 return mix(colorBottom, colorTop, gridFract.y); 7778} 7779 7780vec3 calculateEnhancedBezier(vec2 st) { 7781 vec3 color = vec3(0.0); 7782 float totalWeight = 0.0; 7783 7784 // Adjustable parameters for gradient behavior 7785 7786 float baseSigma = 0.25; // Base spread of each color point 7787 7788 float weightExponent = 1.8; // Controls how quickly influence drops off 7789 7790 float smoothingFactor = 1.2; // Controls color transition smoothness 7791 7792 7793 // Calculate weighted contribution from each point 7794 for (int i = 0; i < MAX_POINTS; i++) { 7795 if (i < int(u_PointsNum)) {
7796 vec2 pointPos = u_Points[i].position; 7797 float dist = distance(st, pointPos); 7798 7799 // Enhanced weight calculation with smoother falloff 7800 7801 float weight = exp(-dist * dist / (2.0 * baseSigma * baseSigma)); 7802 weight = pow(weight, weightExponent); 7803 7804 // Apply smoothing to weight 7805 7806 weight = smoothstep(0.0, smoothingFactor, weight); 7807 color += u_Points[i].color * weight; 7808 totalWeight += weight; 7809 } 7810 } 7811 // Normalize colors with enhanced blending 7812 if (totalWeight > 0.0) { 7813 color = color / totalWeight; 7814 // Subtle enhancement of color vibrancy 7815 color = mix(color, pow(color, vec3(0.95)), 0.3); 7816 } 7817 else { 7818 color = u_BgColor; 7819 } 7820 return color; 7821} 7822 7823void main() { 7824 vec2 st = v_TexCoord; 7825 7826 vec2 warp = applyWarpShape(st, u_WarpSize, u_Time) * u_WarpRatio; 7827 vec2 warpedSt = st + warp; 7828 7829 vec3 gradientColor; 7830 if (int(u_GradientTypeIndex) == 0) { 7831 gradientColor = calculateOriginalWarpGradient(warpedSt); 7832 } else if (int(u_GradientTypeIndex) == 1) { 7833 gradientColor = calculateBezierGradient(warpedSt); 7834 } else if (int(u_GradientTypeIndex) == 2) { 7835 gradientColor = calculateMeshGradient(warpedSt); 7836 } else if (int(u_GradientTypeIndex) == 3) { 7837 gradientColor = calculateEnhancedBezier(warpedSt); 7838 } else { 7839 gradientColor = u_BgColor; // Default fallback 7840 } 7841 7842 outputColor = vec4(gradientColor, 1.0); 7843} 7844`;var Yf=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},$3=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},iJ,cS,H3,K3,az,q3,lvt;function cvt(t){const{r:e,g:r,b:i}=Wo(t);return[e/255,r/255,i/255]}function hvt(t){const e=Math.floor(Number(t));return!Number.isFinite(e)||e<1?1:Math.min(e,16384)}class pee{constructor(e,r){iJ.add(this),this.device=e,this.renderCache=r,cS.set(this,null),H3.set(this,null),K3.set(this,null),az.set(this,null),q3.set(this,null)}render(e,r,i){var s,o,n,a,l,c,h,u,d,f,g;const p=hvt(r),m=hvt(i);Yf(this,iJ,"m",lvt).call(this);const v=this.device.createTexture({format:X.U8_RGBA_NORM,width:p,height:m,usage:vi.RENDER_TARGET|vi.SAMPLED}),b=this.device.createRenderTargetFromTexture(v),y=Array.from({length:10},(F,U)=>{var H;return U<9?cvt((H=e.colors[U])!==null&&H!==void 0?H:"#000"):[0,0,0]}),_=Array.from({length:10},(F,U)=>{var H;const N=(H=e.positions)===null||H===void 0?void 0:H[U];return N!=null&&Array.isArray(N)&&N.length>=2&&Number.isFinite(N[0])&&Number.isFinite(N[1])?[N[0],N[1]]:wG[U]}),[w,E,A]=cvt(e.backgroundColor),x=((s=e.gradientTypeIndex)!==null&&s!==void 0?s:2)===2?9:Ydt(e),S=tXt({backgroundRgb:[w,E,A],pointColors:y,pointPositions:_,pointsNum:x,noiseRatio:0,noiseTime:0,warpShapeIndex:(o=e.warpShapeIndex)!==null&&o!==void 0?o:0,warpSize:(n=e.warpSize)!==null&&n!==void 0?n:.5,warpRatio:(a=e.warpRatio)!==null&&a!==void 0?a:0,gradientTypeIndex:(l=e.gradientTypeIndex)!==null&&l!==void 0?l:2,time:(c=e.time)!==null&&c!==void 0?c:0}),T=new Float32Array(jdt);T.set(S,0),Yf(this,q3,"f").setSubData(0,new Uint8Array(T.buffer));const R=Object.assign({},...Array.from({length:10},(F,U)=>({[`u_Points[${U}].color`]:y[U],[`u_Points[${U}].position`]:_[U]})));Yf(this,cS,"f").setUniformsLegacy(Object.assign(Object.assign({},R),{u_BgColor:[w,E,A],u_PointsNum:x,u_NoiseRatio:0,u_NoiseTime:0,u_WarpShapeIndex:(h=e.warpShapeIndex)!==null&&h!==void 0?h:0,u_WarpSize:(u=e.warpSize)!==null&&u!==void 0?u:.5,u_WarpRatio:(d=e.warpRatio)!==null&&d!==void 0?d:0,u_GradientTypeIndex:(f=e.gradientTypeIndex)!==null&&f!==void 0?f:2,u_Time:(g=e.time)!==null&&g!==void 0?g:0}));const B=this.renderCache.createBindings({pipeline:Yf(this,H3,"f"),uniformBufferBindings:[{buffer:Yf(this,q3,"f")}]}),O=this.device.queryVendorInfo().platformString==="WebGPU",C=this.device.createRenderPass({colorAttachment:[b],colorResolveTo:[null],colorClearColor:[QU],colorStore:[!0],depthStencilAttachment:null,depthStencilResolveTo:null});return C.setPipeline(Yf(this,H3,"f")),C.setBindings(B),C.setVertexInput(Yf(this,K3,"f"),[{buffer:Yf(this,az,"f")}
7844],null),O||C.setViewport(0,0,p,m),C.draw(3),this.device.submitPass(C),B.destroy(),v}}cS=new WeakMap,H3=new WeakMap,K3=new WeakMap,az=new WeakMap,q3=new WeakMap,iJ=new WeakSet,lvt=function(){if(Yf(this,cS,"f"))return;const t=this.device.queryVendorInfo().platformString==="WebGPU"?`diagnostic(off,derivative_uniformity); 7845`:"";$3(this,q3,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*jdt,usage:Ee.UNIFORM,hint:rr.DYNAMIC}),"f"),$3(this,cS,this.renderCache.createProgram({vertex:{glsl:dee},fragment:{glsl:fee,postprocess:e=>t+e}}),"f"),$3(this,az,this.device.createBuffer({viewOrSize:new Float32Array([1,3,-3,-1,1,-1]),usage:Ee.VERTEX,hint:rr.DYNAMIC}),"f"),$3(this,K3,this.device.createInputLayout({vertexBufferDescriptors:[{arrayStride:8,stepMode:Pi.VERTEX,attributes:[{shaderLocation:0,offset:0,format:X.F32_RG}]}],indexBufferFormat:null,program:Yf(this,cS,"f")}),"f"),$3(this,H3,this.renderCache.createRenderPipeline({inputLayout:Yf(this,K3,"f"),program:Yf(this,cS,"f"),colorAttachmentFormats:[X.U8_RGBA_NORM],depthStencilAttachmentFormat:null}),"f")};var $u=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},yy=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},sJ,Z3,hS,uS,sB,oB,J3,oJ,uvt;const Ew=1e5,$f=1;function gee(t){let e=t.has(be)?t.read(be).parent:null;for(;e;){if(e.has(Gc))return e.read(Gc).value;e=e.has(be)?e.read(be).parent:null}return null}function mee(t){let e=t.has(be)?t.read(be).parent:null;for(;e;){if(e.has(Gc))return e.read(Gc).outsideAlpha;e=e.has(be)?e.read(be).parent:null}return .5}class dS{constructor(e,r,i,s,o,n,a){sJ.add(this),this.device=e,this.swapChain=r,this.renderCache=i,this.texturePool=s,this.instanced=o,this.index=n,this.api=a,this.uid=iYt(),this.shapes=[],this.maxInstances=1/0,this.geometryDirty=!0,this.materialDirty=!0,this.destroyed=!1,this.programSoftClipOutside=null,this.pipelineSoftClipOutside=null,this.inputLayoutSoftClipOutside=null,this.bindingsSoftClipOutside=null,this.vertexBuffers=[],this.vertexBufferDatas=[],this.vertexBufferOffsets=[],this.barycentricBufferDescriptor={arrayStride:12,stepMode:Pi.VERTEX,attributes:[{shaderLocation:oz.BARYCENTRIC,offset:0,format:X.F32_RGB}]},hS.set(this,null),uS.set(this,null),sB.set(this,0),oB.set(this,0),J3.set(this,null),this.sceneZoomScale=1}getPostChain(){return!$u(this,hS,"f")&&mZ()&&yy(this,hS,Qmt(this),"f"),$u(this,hS,"f")}isPostProcessingChainReadyForSize(e,r){var i;const s=this.getPostChain();return(i=s==null?void 0:s.isReadyForSize(e,r))!==null&&i!==void 0?i:!1}destroyFullPostProcessingChain(){var e;(e=$u(this,hS,"f"))===null||e===void 0||e.destroy(),yy(this,hS,null,"f")}destroy(){var e,r;this.program&&((e=this.indexBuffer)===null||e===void 0||e.destroy(),this.vertexBuffers.forEach(i=>i.destroy()),this.vertexBuffers=[],this.vertexBufferDatas=[],this.vertexBufferDescriptors=[]),(r=$u(this,uS,"f"))===null||r===void 0||r.destroy(),yy(this,uS,null,"f"),this.clearNodeLayerBlendSrcTextureReference(),this.destroyFullPostProcessingChain(),this.destroyed=!0}validate(e){return this.useStencil||this.useWireframe?!1:this.count()<=this.maxInstances-1}submit(e,r,i,s){var o;const n=i.u_ZoomScale;if(this.sceneZoomScale=typeof n=="number"&&Number.isFinite(n)&&n>0?n:1,this.geometryDirty&&((o=this.getPostChain())===null||o===void 0||o.invalidateEngineTimeCaches(),this.createGeometry()),this.materialDirty){let a="";this.instanced&&(a+=`#define USE_INSTANCES 7846`),this.useFillImage&&(a+=`#define USE_FILLIMAGE 7847`),this.useWireframe&&(a+=`#define USE_WIREFRAME 7848`),this.useStencil&&(a+=`#define USE_STENCIL 7849`),a+=this.extraShaderDefines,this.createMaterial(a,r);const{width:l,height:c}=this.swapChain.getCanvas();e.setViewport(0,0,l,c)}else if((this.useFillImage||this.useRasterFilterEngineTimeRefresh)&&this.shapes.length>0&&this.isPostProcessingChainReadyForSize($u(this,sB,"f"),$u(this,oB,"f"))){const a=this.shapes[0],l=Hl(a);if(l&&U2(l)){this.renderPostProcessingTextureSpace($u(this,sB,"f"),$u(this,oB,"f"));const{width:c,height:h}=this.swapChain.getCanvas();e.setViewport(0,0,c,h)}}this.render(e,r,i),this.geometryDirty&&(this.geometryDirty=!1),this.materialDirty&&(this.materialDirty=!1)}add(e){this.shapes.includes(e)||(this.shapes.push(e),this.geometryDirty=!0)}remove(e){if(this.shapes.includes(e)){const r=this.shapes.indexOf(e);this.shapes.splice(r,1),this.geometryDirty=!0}}count(){return this.shapes.length}needsNodeLayerBlend(){return this.instanced||this.shapes.length!==1?!1:Aq(Ij(this.api,this.shapes[0]))}setNodeLayerBlendSrcTexture(e){yy(this,J3,e,"f")}getNodeLayerBlendSrcTexture(){return $u(this,J3,"f")}clearNodeLayerBlendSrcTextureReference(){yy(this,J3,null,"f")}renderNodeLayerBlendSrcInPass(e,r,i){const{width:s,height:o}=this.swapChain.getCanvas();e.setViewport(0,0,s,o),this.submit(e,r,i,null)}submitNodeLayerBlendComposite(e,r,i,s,o,n,a){}get stencilDescriptor(){return{stencilWrite:this.useStencil,stencilFront:this.useStencil?{compare:li.ALWAYS,passOp:Oi.REPLACE}:this.parentClipMode?{compare:this.parentClipMode==="erase"?li.NOTEQUAL:li.EQUAL,passOp:Oi.KEEP}:{compare:li.ALWAYS,passOp:Oi.KEEP,failOp:Oi.KEEP,depthFailOp:Oi.KEEP},stencilBack:this.useStencil?{compare:li.ALWAYS,passOp:Oi.REPLACE}:this.parentClipMode?{compare:this.parentClipMode==="erase"?li.NOTEQUAL:li.EQUAL,passOp:Oi.KEEP}:{compare:li.ALWAYS,passOp:Oi.KEEP,failOp:Oi.KEEP,depthFailOp:Oi.KEEP}}}get stencilDescriptorForSoftOutside(){return{stencilWrite:!1,stencilFront:{compare:li.NOTEQUAL,passOp:Oi.KEEP},stencilBack:{compare:li.NOTEQUAL,passOp:Oi.KEEP}}}get useStencil(){var e;return(e=this.shapes[0])===null||e===void 0?void 0:e.has(Gc)}get parentClipMode(){const e=this.shapes[0];return e?gee(e):null}get parentOutsideAlpha(){const e=this.shapes[0];return e?mee(e):.5}get useWireframe(){var e,r;return!((e=this.shapes[0])===null||e===void 0)&&e.has(jy)?(r=this.shapes[0])===null||r===void 0?void 0:r.read(jy).enabled:!1}get useFillImage(){const e=this.shapes[0];if(!e)return!1;if(e.has(yh))return!0;
7849if(e.has(Ce)){const r=Nh(e);if(r.length>=2&&aw(r)||r.length>=2&&LL(r)||r.length===1)return!0}return e.has(Ce)&&Nh(e).length>=1&&iv(Hl(e))?!0:!this.instanced&&nz(e)}get useRasterFilterEngineTimeRefresh(){return!1}get extraShaderDefines(){return""}createProgram(e,r,i){const s=this.device.queryVendorInfo().platformString==="WebGPU"?`diagnostic(off,derivative_uniformity); 7850`:"";this.program=this.renderCache.createProgram({vertex:{glsl:i+e},fragment:{glsl:i+r,postprocess:n=>s+n}});const o=this.vertexBufferDescriptors;this.useWireframe&&o.push(this.barycentricBufferDescriptor),this.inputLayout=this.renderCache.createInputLayout({vertexBufferDescriptors:o,indexBufferFormat:X.U32_R,program:this.program})}generateWireframe(){const e=this.indexBufferData.length,r=this.vertexBufferDatas.map(n=>n.slice());for(let n=0;n<this.vertexBufferDatas.length;n++){const{arrayStride:a,stepMode:l}=this.vertexBufferDescriptors[n];l===Pi.VERTEX?this.vertexBufferDatas[n]=new Float32Array(a/Float32Array.BYTES_PER_ELEMENT*e):this.vertexBufferDatas[n]=r[n]}let i=0;const s=new Uint32Array(e);for(let n=0;n<e;n++){const a=this.indexBufferData[n];for(let l=0;l<this.vertexBufferDatas.length;l++){const{arrayStride:c,stepMode:h}=this.vertexBufferDescriptors[l];if(h===Pi.VERTEX){const u=c/Float32Array.BYTES_PER_ELEMENT;for(let d=0;d<u;d++)this.vertexBufferDatas[l][i*u+d]=r[l][a*u+d]}}s[n]=i,i++}for(let n=0;n<this.vertexBuffers.length;n++)this.vertexBuffers[n].destroy(),this.vertexBuffers[n]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[n],usage:Ee.VERTEX,hint:rr.DYNAMIC});const o=new Float32Array(e*3);for(let n=0;n<e;)for(let a=0;a<3;a++){const l=s[n++];o[l*3+a]=1}this.barycentricBuffer=this.device.createBuffer({viewOrSize:o,usage:Ee.VERTEX,hint:rr.DYNAMIC}),this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=this.device.createBuffer({viewOrSize:s,usage:Ee.INDEX,hint:rr.STATIC})}createSampler(){return this.renderCache.createSampler({addressModeU:ho.CLAMP_TO_EDGE,addressModeV:ho.CLAMP_TO_EDGE,minFilter:hs.POINT,magFilter:hs.BILINEAR,mipmapFilter:Ro.LINEAR,lodMinClamp:0,lodMaxClamp:0})}createLutSampler(){return this.renderCache.createSampler({addressModeU:ho.CLAMP_TO_EDGE,addressModeV:ho.CLAMP_TO_EDGE,addressModeW:ho.CLAMP_TO_EDGE,minFilter:hs.BILINEAR,magFilter:hs.BILINEAR,mipmapFilter:Ro.LINEAR,lodMinClamp:0,lodMaxClamp:0})}createLutPassInputSampler(){return this.renderCache.createSampler({addressModeU:ho.CLAMP_TO_EDGE,addressModeV:ho.CLAMP_TO_EDGE,minFilter:hs.BILINEAR,magFilter:hs.BILINEAR,mipmapFilter:Ro.LINEAR,lodMinClamp:0,lodMaxClamp:0})}readTextureRgba8Sync(e,r,i){const s=new Uint8Array(r*i*4);return $u(this,sJ,"m",uvt).call(this).readTextureSync(e,0,0,r,i,s),s}createPostProcessing(e,r,i,s){const o=this.getPostChain();return yy(this,sB,i,"f"),yy(this,oB,s,"f"),o?o.createPostProcessing(e,r,i,s):{texture:r}}renderPostProcessingTextureSpace(e,r){const i=this.getPostChain();if(!i)throw new Error("Filter plugin not registered");return yy(this,sB,e,"f"),yy(this,oB,r,"f"),i.renderPostProcessingTextureSpace(e,r)}renderMeshGradientTexture(e,r,i){let s=$u(Z3,Z3,"f",oJ).get(this.device);return s||(s=new pee(this.device,this.renderCache),$u(Z3,Z3,"f",oJ).set(this.device,s)),s.render(e,r,i)}}Z3=dS,hS=new WeakMap,uS=new WeakMap,sB=new WeakMap,oB=new WeakMap,J3=new WeakMap,sJ=new WeakSet,uvt=function(){return $u(this,uS,"f")||yy(this,uS,this.device.createReadback(),"f"),$u(this,uS,"f")},oJ={value:new WeakMap};var Dn;(function(t){t[t.BARYCENTRIC=0]="BARYCENTRIC",t[t.FRAG_COORD=1]="FRAG_COORD",t[t.ABCD=2]="ABCD",t[t.TXTY=3]="TXTY",t[t.POSITION=4]="POSITION",t[t.SIZE=5]="SIZE",t[t.FILL_COLOR=6]="FILL_COLOR",t[t.STROKE_COLOR=7]="STROKE_COLOR",t[t.ZINDEX_STROKE_WIDTH=8]="ZINDEX_STROKE_WIDTH",t[t.OPACITY=9]="OPACITY",t[t.INNER_SHADOW_COLOR=10]="INNER_SHADOW_COLOR",t[t.INNER_SHADOW=11]="INNER_SHADOW"})(Dn||(Dn={}));const dvt=` 7851#define SHIFT_RIGHT23 1.0 / 8388608.0 7852#define SHIFT_LEFT23 8388608.0 7853#define SHIFT_RIGHT22 1.0 / 4194304.0 7854#define SHIFT_LEFT22 4194304.0 7855 7856layout(std140) uniform SceneUniforms { 7857 mat3 u_ProjectionMatrix; 7858 mat3 u_ViewMatrix; 7859 mat3 u_ViewProjectionInvMatrix;
7860 vec4 u_BackgroundColor; 7861 vec4 u_GridColor; 7862 float u_ZoomScale; 7863 float u_CheckboardStyle; 7864}; 7865 7866${iB} 7867layout(location = ${Dn.FRAG_COORD}) in vec2 a_FragCoord; 7868 7869#ifdef USE_INSTANCES 7870 layout(location = ${Dn.ABCD}) in vec4 a_Abcd; 7871 layout(location = ${Dn.TXTY}) in vec2 a_Txty; 7872 layout(location = ${Dn.POSITION}) in vec4 a_Position; 7873 layout(location = ${Dn.SIZE}) in vec4 a_Size; 7874 layout(location = ${Dn.FILL_COLOR}) in vec4 a_FillColor; 7875 layout(location = ${Dn.STROKE_COLOR}) in vec4 a_StrokeColor; 7876 layout(location = ${Dn.ZINDEX_STROKE_WIDTH}) in vec4 a_ZIndexStrokeWidth; 7877 layout(location = ${Dn.OPACITY}) in vec4 a_Opacity; 7878 layout(location = ${Dn.INNER_SHADOW_COLOR}) in vec4 a_InnerShadowColor; 7879 layout(location = ${Dn.INNER_SHADOW}) in vec4 a_InnerShadow; 7880#else 7881 layout(std140) uniform ShapeUniforms { 7882 mat3 u_ModelMatrix; 7883 vec4 u_Position; 7884 vec4 u_Size; 7885 vec4 u_FillColor; 7886 vec4 u_StrokeColor; 7887 vec4 u_ZIndexStrokeWidth; 7888 vec4 u_Opacity; 7889 vec4 u_InnerShadowColor; 7890 vec4 u_InnerShadow; 7891 vec4 u_FilterExtras; 7892 }; 7893#endif 7894 7895out vec2 v_FragCoord; 7896#ifdef USE_INSTANCES 7897 out vec4 v_FillColor; 7898 out vec4 v_StrokeColor; 7899 out float v_StrokeWidth; 7900 out vec4 v_Opacity; 7901 out float v_CornerRadius; 7902 out float v_StrokeAlignment; 7903 out vec4 v_InnerShadowColor; 7904 out vec4 v_InnerShadow; 7905#else 7906#endif 7907out vec2 v_Radius; 7908 7909#ifdef USE_FILLIMAGE 7910 out vec2 v_Uv; 7911#endif 7912 7913void main() { 7914 ${rB} 7915 7916 mat3 model; 7917 vec3 position; 7918 vec2 size; 7919 vec4 fillColor; 7920 vec4 strokeColor; 7921 float zIndex; 7922 float strokeWidth; 7923 float strokeAlignment; 7924 float shapeSizeAttenuation; 7925 7926 #ifdef USE_INSTANCES 7927 model = mat3(a_Abcd.x, a_Abcd.y, 0, a_Abcd.z, a_Abcd.w, 0, a_Txty.x, a_Txty.y, 1); 7928 position = a_Position.xyz; 7929 size = a_Size.xy; 7930 fillColor = a_FillColor; 7931 strokeColor = a_StrokeColor; 7932 zIndex = a_ZIndexStrokeWidth.x; 7933 strokeWidth = a_ZIndexStrokeWidth.y; 7934 strokeAlignment = a_ZIndexStrokeWidth.w; 7935 shapeSizeAttenuation = a_Opacity.w; 7936 7937 v_FillColor = fillColor; 7938 v_StrokeColor = strokeColor; 7939 v_StrokeWidth = strokeWidth; 7940 v_Opacity = a_Opacity; 7941 v_CornerRadius = a_ZIndexStrokeWidth.z; 7942 v_StrokeAlignment = a_ZIndexStrokeWidth.w; 7943 v_InnerShadowColor = a_InnerShadowColor; 7944 v_InnerShadow = a_InnerShadow; 7945 #else 7946 model = u_ModelMatrix; 7947 position = u_Position.xyz; 7948 size = u_Size.xy; 7949 fillColor = u_FillColor; 7950 strokeColor = u_StrokeColor; 7951 zIndex = u_ZIndexStrokeWidth.x; 7952 strokeWidth = u_ZIndexStrokeWidth.y; 7953 strokeAlignment = u_ZIndexStrokeWidth.w; 7954 shapeSizeAttenuation = u_Opacity.w; 7955 #endif 7956 7957 float compressed = shapeSizeAttenuation; 7958 float sizeAttenuation = floor(compressed * SHIFT_RIGHT23); 7959 compressed -= sizeAttenuation * SHIFT_LEFT23; 7960 float strokeAttenuation = floor(compressed * SHIFT_RIGHT22); 7961 7962 float scale = 1.0; 7963 if (sizeAttenuation > 0.5) { 7964 scale = 1.0 / u_ZoomScale; 7965 } 7966 if (strokeAttenuation > 0.5 && sizeAttenuation < 0.5) { 7967 strokeWidth = strokeWidth / u_ZoomScale; 7968 } 7969 7970#ifdef USE_FILLIMAGE_BAKED_STROKE 7971 float bakedHalfStroke = u_FilterExtras.y * 0.5; 7972 vec2 radius = size + vec2(bakedHalfStroke); 7973 v_FragCoord = vec2(a_FragCoord * radius); 7974 v_Radius = abs(radius); 7975 #ifdef USE_FILLIMAGE 7976 v_Uv = (a_FragCoord * radius / size + 1.0) / 2.0; 7977 #endif 7978#else 7979 float strokeOffset; 7980 if (strokeAlignment < 0.5) { 7981 strokeOffset = strokeWidth / 2.0; 7982 } else if (strokeAlignment < 1.5) { 7983 strokeOffset = 0.0; 7984 } else if (strokeAlignment < 2.5) { 7985 strokeOffset = strokeWidth; 7986 } 7987 7988 vec2 radius = size + vec2(strokeOffset); 7989 v_FragCoord = vec2(a_FragCoord * radius); 7990 v_Radius = abs(radius); 7991 7992 #ifdef USE_FILLIMAGE 7993 v_Uv = (a_FragCoord * radius / size + 1.0) / 2.0; 7994 #endif 7995#endif 7996 7997 gl_Position = vec4((u_ProjectionMatrix 7998 * u_ViewMatrix 7999 * model 8000 * vec3(position.xy + v_FragCoord * scale, 1)).xy, zIndex, 1); 8001} 8002`,fvt=` 8003#define SHIFT_RIGHT23 1.0 / 8388608.0 8004#define SHIFT_LEFT23 8388608.0 8005#define SHIFT_RIGHT22 1.0 / 4194304.0 8006#define SHIFT_LEFT22 4194304.0 8007 8008layout(std140) uniform SceneUniforms { 8009 mat3 u_ProjectionMatrix; 8010 mat3 u_ViewMatrix; 8011 mat3 u_ViewProjectionInvMatrix;
8012 vec4 u_BackgroundColor; 8013 vec4 u_GridColor; 8014 float u_ZoomScale; 8015 float u_CheckboardStyle; 8016}; 8017 8018#ifdef USE_INSTANCES 8019#else 8020 layout(std140) uniform ShapeUniforms { 8021 mat3 u_ModelMatrix; 8022 vec4 u_Position; 8023 vec4 u_Size; 8024 vec4 u_FillColor; 8025 vec4 u_StrokeColor; 8026 vec4 u_ZIndexStrokeWidth; 8027 vec4 u_Opacity; 8028 vec4 u_InnerShadowColor; 8029 vec4 u_InnerShadow; 8030 vec4 u_FilterExtras; 8031 }; 8032#endif 8033 8034out vec4 outputColor; 8035 8036${aS} 8037in vec2 v_FragCoord; 8038 8039#ifdef USE_INSTANCES 8040 in vec4 v_FillColor; 8041 in vec4 v_StrokeColor; 8042 in float v_StrokeWidth; 8043 in vec4 v_Opacity; 8044 in float v_CornerRadius; 8045 in float v_StrokeAlignment; 8046 in vec4 v_InnerShadowColor; 8047 in vec4 v_InnerShadow; 8048#else 8049#endif 8050in vec2 v_Radius; 8051 8052#ifdef USE_FILLIMAGE 8053 in vec2 v_Uv; 8054 uniform sampler2D u_Texture; 8055#endif 8056 8057float epsilon = 0.000001; 8058 8059float sdf_circle(vec2 p, float r) { 8060 return length(p) - r; 8061} 8062 8063float sdf_ellipse(vec2 p, vec2 r) { 8064 float k0 = length(p / r); 8065 float k1 = length(p / (r * r)); 8066 return k0 * (k0 - 1.0) / k1; 8067 8068 // V1 8069 // float k1 = length(p/r); 8070 // return (k1-1.0)*min(r.x,r.y); 8071 8072 // V3 8073 // float k1 = length(p/r); 8074 // return length(p)*(1.0-1.0/k1); 8075} 8076 8077float sdf_rounded_box(vec2 p, vec2 b, float r) { 8078 vec2 q = abs(p) - b + r; 8079 return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r; 8080} 8081 8082// sdf_rounded_box is only valid for 0 <= r <= min(b.x, b.y); larger r inverts 8083// the field so the interior reads as outside and the rect disappears. Clamp 8084// to max corner radius (pill / CSS-style when r exceeds the short side). 8085float effective_round_rect_radius(vec2 b, float r) { 8086 return min(max(r, 0.0), min(b.x, b.y)); 8087} 8088 8089vec4 over(vec4 below, vec4 above) { 8090 vec4 result; 8091 float alpha = above.a + below.a * (1.0 - above.a); 8092 result.rgb = 8093 (above.rgb * above.a + below.rgb * below.a * (1.0 - above.a)) / alpha; 8094 result.a = alpha; 8095 return result; 8096} 8097 8098float antialias(float distance) { 8099 return clamp(distance / -fwidth(distance), 0.0, 1.0); 8100} 8101 8102vec4 mix_border_inside(vec4 border, vec4 inside, float distance) { 8103 // Blend the border on top of the background and then linearly interpolate 8104 // between the two as we slide inside the background. 8105 return mix(border, inside, clamp(1.0 - distance, 0.0, 1.0) * antialias(distance)); 8106} 8107 8108float sigmoid(float t) { 8109 return 1.0 / (1.0 + exp(-t)); 8110} 8111 8112float make_shadow(vec2 pos, vec2 halfSize, float cornerRd, float blurRd, float distMul, float shape) { 8113 float distance; 8114 if (shape < 0.5) { 8115 distance = sdf_circle(pos, halfSize.x); 8116 } else if (shape < 1.5) { 8117 distance = sdf_ellipse(pos, halfSize); 8118 } else if (shape < 2.5) { 8119 distance = sdf_rounded_box(pos, halfSize, effective_round_rect_radius(halfSize, cornerRd + blurRd)); 8120 } 8121 float dist = sigmoid(distMul * distance / blurRd); 8122 return clamp(dist, 0.0, 1.0); 8123} 8124 8125void main() { 8126 float strokeWidth; 8127 vec4 fillColor; 8128 vec4 strokeColor; 8129 float opacity; 8130 float fillOpacity; 8131 float strokeOpacity; 8132 float shapeSizeAttenuation; 8133 float cornerRadius; 8134 vec4 innerShadowColor; 8135 vec4 innerShadow; 8136 float strokeAlignment; 8137 8138 #ifdef USE_INSTANCES 8139 fillColor = v_FillColor; 8140 strokeColor = v_StrokeColor; 8141 strokeWidth = v_StrokeWidth; 8142 opacity = v_Opacity.x; 8143 fillOpacity = v_Opacity.y; 8144 strokeOpacity = v_Opacity.z; 8145 shapeSizeAttenuation = v_Opacity.w; 8146 cornerRadius = v_CornerRadius; 8147 strokeAlignment = v_StrokeAlignment; 8148 innerShadowColor = v_InnerShadowColor; 8149 innerShadow = v_InnerShadow; 8150 #else 8151 fillColor = u_FillColor; 8152 strokeColor = u_StrokeColor; 8153 strokeWidth = u_ZIndexStrokeWidth.y; 8154 opacity = u_Opacity.x; 8155 fillOpacity = u_Opacity.y; 8156 strokeOpacity = u_Opacity.z; 8157 shapeSizeAttenuation = u_Opacity.w; 8158 cornerRadius = u_ZIndexStrokeWidth.z; 8159 strokeAlignment = u_ZIndexStrokeWidth.w; 8160 innerShadowColor = u_InnerShadowColor; 8161 innerShadow = u_InnerShadow; 8162 #endif 8163 8164 #ifdef USE_FILLIMAGE 8165 fillColor = texture(SAMPLER_2D(u_Texture), v_Uv); 8166 #ifndef USE_INSTANCES 8167 if (u_FilterExtras.w > 0.5) { 8168 fillColor = vec4(0.0); 8169 } else { 8170 float _layerAlphaMul = 8171 (dot(u_FillColor.rgb, vec3(1.0)) < 0.001 && u_FillColor.a < 0.001) 8172 ? 1.0 8173 : u_FillColor.a; 8174 fillColor.a *= _layerAlphaMul; 8175 } 8176 #endif 8177 #endif 8178 8179 float compressed = shapeSizeAttenuation; 8180 float sizeAttenuation = floor(compressed * SHIFT_RIGHT23); 8181 compressed -= sizeAttenuation * SHIFT_LEFT23; 8182 float strokeAttenuation = floor(compressed * SHIFT_RIGHT22); 8183 compressed -= strokeAttenuation * SHIFT_LEFT22; 8184 float shape = compressed; 8185 8186 if (strokeAttenuation > 0.5 && sizeAttenuation < 0.5) { 8187 strokeWidth = strokeWidth / u_ZoomScale; 8188 } 8189 8190 float distance; 8191#ifdef USE_FILLIMAGE_BAKED_STROKE 8192 vec2 sdfHalfSize = u_Size.xy; 8193#endif 8194 // 'circle', 'ellipse', 'rect' 8195 if (shape < 0.5) { 8196#ifdef USE_FILLIMAGE_BAKED_STROKE 8197 distance = sdf_circle(v_FragCoord, sdfHalfSize.x); 8198#else 8199 distance = sdf_circle(v_FragCoord, v_Radius.x); 8200#endif 8201 } else if (shape < 1.5) { 8202#ifdef USE_FILLIMAGE_BAKED_STROKE 8203 distance = sdf_ellipse(v_FragCoord, sdfHalfSize); 8204#else 8205 distance = sdf_ellipse(v_FragCoord, v_Radius); 8206#endif 8207 } else if (shape < 2.5) { 8208#ifdef USE_FILLIMAGE_BAKED_STROKE
8209 distance = sdf_rounded_box(v_FragCoord, sdfHalfSize, effective_round_rect_radius(sdfHalfSize, cornerRadius)); 8210#else 8211 distance = sdf_rounded_box(v_FragCoord, v_Radius, effective_round_rect_radius(v_Radius, cornerRadius)); 8212#endif 8213 // TODO: Fast path when the quad is not rounded and doesn't have any border. 8214 } 8215 8216 // based on the target alpha compositing mode. 8217 fillColor.a *= fillOpacity; 8218 strokeColor.a *= strokeOpacity; 8219 8220 vec4 color = fillColor; 8221 float d1; 8222 float d2; 8223 if (strokeWidth > 0.0) { 8224 if (strokeAlignment < 0.5) { 8225 d1 = distance + strokeWidth; 8226 d2 = distance + strokeWidth / 2.0; 8227 color = mix_border_inside(over(fillColor, strokeColor), fillColor, d1); 8228 color = mix_border_inside(strokeColor, color, d2); 8229 } else if (strokeAlignment < 1.5) { 8230 d1 = distance + strokeWidth; 8231 d2 = distance; 8232 color = mix_border_inside(over(fillColor, strokeColor), fillColor, d1); 8233 color = mix_border_inside(strokeColor, color, d2); 8234 } else if (strokeAlignment < 2.5) { 8235 d2 = distance + strokeWidth; 8236 color = mix_border_inside(strokeColor, color, d2); 8237 } 8238 } 8239 outputColor = color; 8240 8241 float innerShadowBlurRadius = innerShadow.z / 2.0; 8242 if (innerShadowBlurRadius > 0.0 8243#if !defined(USE_INSTANCES) 8244 && u_FilterExtras.z < 0.5 8245#endif 8246 ) { 8247 vec2 shadowOffset = -innerShadow.xy; 8248 float blurRadius = innerShadow.z; 8249 float distMul = -1.0; 8250 float lowerShadow = make_shadow(v_FragCoord + shadowOffset, v_Radius, cornerRadius, blurRadius, distMul, shape); 8251 8252 vec3 lowerShadowColor = innerShadowColor.rgb * innerShadowColor.a; 8253 outputColor = over(vec4(color.xyz, 1.0), vec4(lowerShadowColor, 1.0 - lowerShadow)); 8254 outputColor = over(outputColor, vec4(color.xyz, clamp(distance, 0.0, 1.0))); 8255 } 8256 8257 float antialiasedBlur = -fwidth(length(v_FragCoord)); 8258 float opacity_t = clamp(distance / antialiasedBlur, 0.0, 1.0); 8259#ifdef USE_FILLIMAGE_BAKED_STROKE 8260 float distForAlpha = distance - u_FilterExtras.x; 8261 outputColor.a *= clamp(1.0 - distForAlpha, 0.0, 1.0) * opacity * opacity_t; 8262#else 8263 outputColor.a *= clamp(1.0 - distance, 0.0, 1.0) * opacity * opacity_t; 8264#endif 8265 8266 ${nv} 8267 8268#ifdef USE_STENCIL 8269 // Stencil pass: discard by geometry (SDF distance), not alpha. Include the same 8270 // anti-alias band as the normal pass (fwidth(distance)) so the stencil boundary 8271 // matches the visible shape and avoids edge holes. 8272 float outerBoundary = (strokeAlignment < 1.5) ? 0.0 : strokeWidth; 8273 if (distance > outerBoundary) 8274 discard; 8275#else 8276 if (outputColor.a < epsilon) 8277 discard; 8278#endif 8279 8280#ifdef USE_SOFT_CLIP_OUTSIDE 8281 outputColor *= 0.15; 8282#endif 8283} 8284`,pvt="50% 50%";function av(t){const e=t.trim().toLowerCase();if(e==="left"||e==="top")return 0;if(e==="right"||e==="bottom")return 1;if(e==="center")return .5;const r=/^(-?[\d.]+)%$/.exec(e);return r?Math.max(0,Math.min(1,parseFloat(r[1])/100)):null}function gvt(t){var e,r,i,s,o,n,a,l,c;const h=t.trim().split(/\s+/).filter(Boolean);if(h.length===0)return{x:.5,y:.5};const u=new Set(["left","right","center"]),d=new Set(["top","bottom","center"]),f=_=>{const w=_.toLowerCase();return u.has(w)&&!d.has(w)?"x":d.has(w)&&!u.has(w)?"y":"either"};if(h.length===1){const _=f(h[0]);return _==="x"?{x:(e=av(h[0]))!==null&&e!==void 0?e:.5,y:.5}:_==="y"?{x:.5,y:(r=av(h[0]))!==null&&r!==void 0?r:.5}:{x:(i=av(h[0]))!==null&&i!==void 0?i:.5,y:.5}}const g=h[0],p=h[1],m=f(g),v=f(p);let b=.5,y=.5;return m==="x"&&v==="y"?(b=(s=av(g))!==null&&s!==void 0?s:.5,y=(o=av(p))!==null&&o!==void 0?o:.5):m==="y"&&v==="x"?(y=(n=av(g))!==null&&n!==void 0?n:.5,b=(a=av(p))!==null&&a!==void 0?a:.5):(b=(l=av(g))!==null&&l!==void 0?l:.5,y=(c=av(p))!==null&&c!==void 0?c:.5),{x:b,y}}function yee(t,e,r,i,s){if(t<=0||e<=0||r<=0||i<=0)return{dw:r,dh:i};if(s==="fill")return{dw:r,dh:i};if(s==="none")return{dw:t,dh:e};if(s==="scale-down"){if(t<=r&&e<=i)return{dw:t,dh:e};const n=Math.min(r/t,i/e);return{dw:t*n,dh:e*n}}if(s==="contain"){const n=Math.min(r/t,i/e);return{dw:t*n,dh:e*n}}const o=Math.max(r/t,i/e);return{dw:t*o,dh:e*o}}NV=function(t,e,r,i,s="fill",o=pvt){const{dw:n,dh:a}=yee(t,e,r,i,s),{x:l,y:c}=gvt(o);return{dx:(r-n)*l,dy:(i-a)*c,dw:n,dh:a}};function lz(t,e,r,i,s,o,n){var a,l;const c=(a=n==null?void 0:n.objectFit)!==null&&a!==void 0?a:"fill",h=(l=n==null?void 0:n.objectPosition)!==null&&l!==void 0?l:pvt,{dx:u,dy:d,dw:f,dh:g}=NV(r,i,s,o,c,h);t.clearRect(0,0,s,o),t.drawImage(e,0,0,r,i,u,d,f,g)}function nJ(t){const e={},r=t.objectFit;typeof r=="string"&&r.length>0&&(e.objectFit=r);const i=t.objectPosition;return typeof i=="string"&&i.length>0&&(e.objectPosition=i),e}const vee=4096;function aJ(){if(typeof globalThis>"u")return 1;const t=globalThis.devicePixelRatio;return Number.isFinite(t)&&t>0?t:1}function lJ(t,e,r,i,s,o=vee,n="fill"){const a=Math.max(1,Math.floor(t)),l=Math.max(1,Math.floor(e)),c=Math.max(1,s);if(r<.5||i<.5)return{width:a,height:l};const h=Math.ceil(r*c),u=Math.ceil(i*c);let d=n==="fill"?Math.max(a,h):h,f=n==="fill"?Math.max(l,u):u;if(d>o||f>o){const g=Math.min(o/d,o/f,1);d=Math.max(1,Math.floor(d*g)),f=Math.max(1,Math.floor(f*g))}return{width:d,height:f}}var _ee=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};jtt=function(t,e,r){var i;const s=Cg(r.opacity);if(!t||!e)return s;const o=t.getNodeByEntity(e),n=o==null?void 0:o.fills;if(!Array.isArray(n)||n.length===0)return s;const a=(i=n.find(l=>Dd(l)&&l.type===r.type&&"value"in l&&"value"in r&&String(l.value)===String(r.value)))!==null&&i!==void 0?i:n.find(l=>Dd(l)&&l.type===r.type);return a&&"opacity"in a&&a.opacity!=null&&a.opacity!==""?Cg(a.opacity):s},hG=function(t,e,r){var i;const s=r.type==="image"?nJ(r):{};if(r.type!=="image"||!t||!e)return s;const o=t.getNodeByEntity(e),n=o==null?void 0:o.fills;if(!Array.isArray(n))return s;const a=(i=n.find(l=>l.type==="image"&&l.value===r.value))!==null&&i!==void 0?i:n.find(l=>l.type==="image");return a?Object.assign(Object.assign({},s),nJ(a)):s};const nB=new Map;wO=function(t){return nB.get(t)};function cJ(t,e){const r=nB.get(t);if(r&&r!==e&&"close"in r&&typeof r.close=="function")try{r.close()}catch{}nB.set(t,e)}const hJ=new Map,Q3=new Map;function bee(t,e,r,i){const s=Pr.get().createCanvas(e,r),o=s.getContext("2d");if(!o)return null;try{lz(o,t,t.width,t.height,e,r,i)}catch{return null}return s}function wee(t,e){if(e){let i=Q3.get(t);i||(i=new Set,Q3.set(t,i)),i.add(e)}if(hJ.has(t))return;const r=_ee(this,void 0,void 0,function*(){try{const i=yield Pr.get().createImage(t);nB.set(t,i);const s=Q3.get(t);if(Q3.delete(t),s)for(const o of s)try{o()}catch{}}catch{Q3.delete(t)}finally{hJ.delete(t)}});hJ.set(t,r)}uG=function(t,e,r,i,s){if(!t)return null;const o=Math.max(1,Math.ceil(e)),n=Math.max(1,Math.ceil(r)),a=nB.get(t);return a?bee(a,o,n,s):Aee(t,e,r,s)||(wee(t,i),null)};function uJ(t,e,r,i){const s=nB.get(t),o=s?Math.max(1,Math.floor(s.width)):1,n=s?Math.max(1,Math.floor(s.height)):1;return lJ(o,n,e,r,aJ(),void 0,i??"fill")}function Eee(t,e,r,i,s,o){const n=Pr.get().createCanvas(t,e),a=n.getContext("2d");return a&&(a.fillStyle=`rgba(${r},${i},${s},${o})`,a.fillRect(0,0,t,e)),n}function Aee(t,e,r,i){if(typeof Image>"u"||!t)return null;const s=Math.max(1,Math.ceil(e)),o=Math.max(1,Math.ceil(r)),n=new Image;
8284if(n.crossOrigin="anonymous",n.src=t,!n.complete||n.naturalWidth===0)return null;const a=Pr.get().createCanvas(s,o),l=a.getContext("2d");if(!l)return null;try{lz(l,n,n.naturalWidth,n.naturalHeight,s,o,i)}catch{return null}return a}function mvt(t,e){const r=Math.max(1,Math.ceil(t)),i=Math.max(1,Math.ceil(e)),{r:s,g:o,b:n,opacity:a}=Wo("none");return Eee(r,i,s,o,n,a)}hE=function(t,e){const r=Pr.get().createTexImageSource(e);t.setImageData([r])};var xi=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Ie=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},vy,Ic,tU,Aw,fS,aB,rl,lB,cB,Fg,pS,gS,Ng,mS,yS,lv;const xee={center:0,inner:1,outer:2};class vS extends dS{constructor(){super(...arguments),vy.set(this,void 0),Ic.set(this,void 0),tU.set(this,!1),Aw.set(this,null),fS.set(this,!1),aB.set(this,!1),rl.set(this,[]),lB.set(this,[]),cB.set(this,[]),Fg.set(this,null),pS.set(this,[]),gS.set(this,null),Ng.set(this,null),mS.set(this,[]),yS.set(this,null),lv.set(this,!1)}get extraShaderDefines(){const e=this.shapes[0];return!e||this.instanced?super.extraShaderDefines:nz(e)?`${super.extraShaderDefines}#define USE_FILLIMAGE_BAKED_STROKE 8285`:super.extraShaderDefines}static useDash(e){const{dasharray:r}=e.has(Gt)?e.read(Gt):{dasharray:[0,0]};return r[0]>0&&r[1]>0}
8285applyRasterFilterChainIfNeeded(e,r,i,s){const o=Hl(e);if(this.instanced||!o)return r;const n=G2(Iv(o));if(n.length===0)return r;xi(this,Aw,r,"f"),this.createPostProcessing(n,r,i,s);const{texture:a}=this.renderPostProcessingTextureSpace(i,s);return xi(this,fS,!0,"f"),a}disposeFillLayerResources(){var e,r;const i=Ie(this,lv,"f")&&!Ie(this,fS,"f")&&Ie(this,Ic,"f")!=null?Ie(this,Ic,"f"):null;xi(this,lv,!1,"f");for(const o of Ie(this,lB,"f"))o.destroy();xi(this,lB,[],"f");for(const o of Ie(this,cB,"f"))o.destroy();xi(this,cB,[],"f");const s=Ie(this,Ic,"f")!=null&&Ie(this,rl,"f").includes(Ie(this,Ic,"f"));for(const o of Ie(this,rl,"f"))(e=o.destroy)===null||e===void 0||e.call(o);xi(this,rl,[],"f"),(s||i)&&xi(this,Ic,null,"f"),(r=i==null?void 0:i.destroy)===null||r===void 0||r.call(i),this.disposeMultiFillDepthPassResources()}disposeFillImageResources(){var e,r;this.disposeFillLayerResources(),!Ie(this,fS,"f")&&!Ie(this,tU,"f")&&((e=Ie(this,Ic,"f"))===null||e===void 0||e.destroy()),(r=Ie(this,Aw,"f"))===null||r===void 0||r.destroy(),xi(this,Aw,null,"f"),xi(this,Ic,null,"f"),xi(this,fS,!1,"f"),xi(this,tU,!1,"f")}disposeMultiFillDepthPassResources(){var e,r;(e=Ie(this,gS,"f"))===null||e===void 0||e.destroy(),xi(this,gS,null,"f");for(const i of Ie(this,pS,"f"))i.destroy();xi(this,pS,[],"f"),(r=Ie(this,yS,"f"))===null||r===void 0||r.destroy(),xi(this,yS,null,"f");for(const i of Ie(this,mS,"f"))i.destroy();xi(this,mS,[],"f"),xi(this,Fg,null,"f"),xi(this,Ng,null,"f")}createFillImageTextureForLayer(e,r,i,s,o,n){var a,l;if(r.type==="image"){const p=hG(this.api,e,r),{width:m,height:v}=uJ(r.value,o,n,p.objectFit),b=uG(r.value,m,v,()=>nt(e,yi),p),y=b??mvt(m,v),_=this.device.createTexture({format:X.U8_RGBA_NORM,width:m,height:v,usage:vi.SAMPLED});hE(_,y);const w=wO(r.value),E=w?Math.max(1,w.width):1,A=w?Math.max(1,w.height):1;return Sbt({entity:e,url:r.value,targetW:m,targetH:v,sourceW:E,sourceH:A,rasterOptions:p}),this.applyRasterFilterChainIfNeeded(e,_,m,v)}if(r.type==="pattern"){const p=Math.max(1,Math.ceil(o)),m=Math.max(1,Math.ceil(n)),v=this.texturePool.getOrCreatePattern({pattern:{image:r.value,repetition:(a=r.repetition)!==null&&a!==void 0?a:"repeat",transform:(l=r.transform)!==null&&l!==void 0?l:""},width:p,height:m}),b=this.device.createTexture({format:X.U8_RGBA_NORM,width:p,height:m,usage:vi.SAMPLED});return b.setImageData([v]),this.applyRasterFilterChainIfNeeded(e,b,p,m)}if(r.type==="solid"){const p=Math.max(1,Math.ceil(o)),m=Math.max(1,Math.ceil(n)),{r:v,g:b,b:y,opacity:_}=Wo(r.value),w=Pr.get().createCanvas(p,m),E=w.getContext("2d");if(!E)throw new Error("Canvas 2D required for FillLayers solid raster");E.fillStyle=`rgba(${v},${b},${y},${_})`,E.fillRect(0,0,p,m);const A=this.device.createTexture({format:X.U8_RGBA_NORM,width:p,height:m,usage:vi.SAMPLED});return hE(A,w),this.applyRasterFilterChainIfNeeded(e,A,p,m)}const c=Math.max(1,Math.ceil(o)),h=Math.max(1,Math.ceil(n)),u=nm(r.value),d=u!==void 0&&u.length===1?u[0]:void 0;if(d&&Zy(d)){const p=this.renderMeshGradientTexture(d,c,h);return this.applyRasterFilterChainIfNeeded(e,p,c,h)}const f=this.texturePool.getOrCreateGradient({gradients:u??[],min:[i,s],width:c,height:h}),g=this.device.createTexture({format:X.U8_RGBA_NORM,width:c,height:h,usage:vi.SAMPLED});return g.setImageData([f]),this.applyRasterFilterChainIfNeeded(e,g,c,h)}validate(e){var r,i;if(!super.validate(e))return!1;if(this.shapes.length===0)return!0;const s=kh(this.shapes[0]),o=kh(e);if(s==null!=(o==null)||s!=null&&o!=null&&s!==o||vS.useDash(e)!==vS.useDash(this.shapes[0]))return!1;const n=Hl(this.shapes[0]),a=Hl(e);if(!!n!=!!a||n&&a&&n!==a)return!1;const l=this.shapes[0].has(Ce)?this.shapes[0].read(Ce).layers:null,c=e.has(Ce)?e.read(Ce).layers:null;if(l==null!=(c==null)||l&&c&&JSON.stringify(l)!==JSON.stringify(c))return!1;const h=this.api.getNodeByEntity(this.shapes[0]),u=this.api.getNodeByEntity(e);if(JSON.stringify((r=h==null?void 0:h.fills)!==null&&r!==void 0?r:null)!==JSON.stringify((i=u==null?void 0:u.fills)!==null&&i!==void 0?i:null))return!1;const d=p=>{var m;return(m=p==null?void 0:p.some(v=>v.type==="image"))!==null&&m!==void 0?m:!1};if(d(l)||d(c)||$0(e)&&this.instanced)return!1;const f=Ij(this.api,this.shapes[0]),g=Ij(this.api,e);return!((f??"normal")!==(g??"normal")||Aq(f)||Aq(g))}createGeometry(){this.indexBufferData=new Uint32Array([0,1,2,0,2,3]),this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=this.device.createBuffer({viewOrSize:this.indexBufferData,usage:Ee.INDEX,hint:rr.STATIC}),this.vertexBufferDatas[0]=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.vertexBuffers[0]&&this.vertexBuffers[0].destroy(),this.vertexBuffers[0]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[0],usage:Ee.VERTEX,hint:rr.STATIC}),this.instanced&&(this.vertexBuffers[1]&&(this.vertexBuffers[1].destroy(),this.vertexBuffers[2].destroy()),this.vertexBufferDatas[1]=new Float32Array(new Array(32*this.shapes.length).fill(0)),this.vertexBuffers[1]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[1],usage:Ee.VERTEX,hint:rr.DYNAMIC}),this.vertexBufferDatas[2]=new Float32Array(new Array(6*this.shapes.length).fill(0)),this.vertexBuffers[2]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[2],usage:Ee.VERTEX,hint:rr.DYNAMIC}
8285)),this.vertexBufferDescriptors=[{arrayStride:8,stepMode:Pi.VERTEX,attributes:[{shaderLocation:Dn.FRAG_COORD,offset:0,format:X.F32_RG}]}],this.instanced&&this.vertexBufferDescriptors.push({arrayStride:128,stepMode:Pi.INSTANCE,attributes:[{shaderLocation:Dn.POSITION,offset:0,format:X.F32_RGBA},{shaderLocation:Dn.SIZE,offset:16,format:X.F32_RGBA},{shaderLocation:Dn.FILL_COLOR,offset:32,format:X.F32_RGBA},{shaderLocation:Dn.STROKE_COLOR,offset:48,format:X.F32_RGBA},{shaderLocation:Dn.ZINDEX_STROKE_WIDTH,offset:64,format:X.F32_RGBA},{shaderLocation:Dn.OPACITY,offset:80,format:X.F32_RGBA},{shaderLocation:Dn.INNER_SHADOW_COLOR,offset:96,format:X.F32_RGBA},{shaderLocation:Dn.INNER_SHADOW,offset:112,format:X.F32_RGBA}]},{arrayStride:24,stepMode:Pi.INSTANCE,attributes:[{shaderLocation:Dn.ABCD,offset:0,format:X.F32_RGBA},{shaderLocation:Dn.TXTY,offset:16,format:X.F32_RG}]})}createMaterial(e,r){var i,s;this.createProgram(dvt,fvt,e),this.disposeFillImageResources(),!this.instanced&&!Ie(this,vy,"f")&&xi(this,vy,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*48,usage:Ee.UNIFORM,hint:rr.DYNAMIC}),"f"),this.pipeline=this.renderCache.createRenderPipeline({inputLayout:this.inputLayout,program:this.program,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:X.D24_S8,megaStateDescriptor:Object.assign({attachmentsState:[{channelWriteMask:oo.ALL,rgbBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.SRC_ALPHA,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA}}],blendConstant:Ra,cullMode:jl.NONE,depthWrite:!0,depthCompare:li.GREATER},this.stencilDescriptor)}),this.device.setResourceName(this.pipeline,"SDFPipeline");const o=!this.instanced&&!((i=this.shapes[0])===null||i===void 0)&&i.has(Ce)?$0(this.shapes[0]):null,n=o!=null&&o.length>1;n&&(xi(this,Fg,this.renderCache.createRenderPipeline({inputLayout:this.inputLayout,program:this.program,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:X.D24_S8,megaStateDescriptor:Object.assign({attachmentsState:[{channelWriteMask:oo.ALL,rgbBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.SRC_ALPHA,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA}}],blendConstant:Ra,cullMode:jl.NONE,depthWrite:!1,depthCompare:li.GREATER},this.stencilDescriptor)}),"f"),this.device.setResourceName(Ie(this,Fg,"f"),"SDFPipelineMultiFillMidPass"));const a={pipeline:this.pipeline,uniformBufferBindings:[{buffer:r}]};if(this.instanced||a.uniformBufferBindings.push({buffer:Ie(this,vy,"f")}),this.useFillImage){this.bindings&&this.bindings.destroy();const l=this.shapes[0];xi(this,fS,!1,"f"),xi(this,aB,!1,"f"),Hl(l)||this.destroyFullPostProcessingChain(),Ie(this,Aw,"f")&&(Ie(this,Aw,"f").destroy(),xi(this,Aw,null,"f"));const c=$0(l);if(c&&(aw(c)||LL(c))&&c){const{minX:h,minY:u,maxX:d,maxY:f}=lS(l),g=d-h,p=f-u;if(xi(this,rl,c.map(m=>this.createFillImageTextureForLayer(l,m,h,u,g,p)),"f"),LL(c)){const m=Math.max(1,...Ie(this,rl,"f").map(y=>y.width)),v=Math.max(1,...Ie(this,rl,"f").map(y=>y.height)),b=apt(this.device,this.renderCache,c,Ie(this,rl,"f"),m,v,()=>this.createSampler());for(const y of Ie(this,rl,"f"))(s=y.destroy)===null||s===void 0||s.call(y);xi(this,rl,[],"f"),xi(this,Ic,b,"f"),xi(this,lv,!0,"f")}else xi(this,Ic,Ie(this,rl,"f")[0],"f"),xi(this,lv,!1,"f")}else if(l.has(Ce)){const h=fj(l);if(h){const{minX:u,minY:d,maxX:f,maxY:g}=lS(l),p=f-u,m=g-d;xi(this,Ic,this.createFillImageTextureForLayer(l,h,u,d,p,m),"f")}}else if(l.has(yh))xi(this,Ic,l.read(yh).value,"f"),xi(this,tU,!0,"f");else if(!this.instanced&&nz(l)){const h=lS(l),u=l.read(Gt).width,d=ovt(h,u),f=d.maxX-d.minX,g=d.maxY-d.minY,p=Math.max(1,Math.ceil(f)),m=Math.max(1,Math.ceil(g)),v=lee(l,d,p,m),b=this.device.createTexture({format:X.U8_RGBA_NORM,width:p,height:m,usage:vi.SAMPLED});hE(b,v),xi(this,Ic,this.applyRasterFilterChainIfNeeded(l,b,p,m),"f"),xi(this,aB,!0,"f")}a.samplerBindings=[{texture:Ie(this,Ic,"f"),sampler:this.createSampler()}]}if(this.bindings=this.renderCache.createBindings(a),n&&Ie(this,Fg,"f")){const l={pipeline:Ie(this,Fg,"f"),uniformBufferBindings:a.uniformBufferBindings};a.samplerBindings&&(l.samplerBindings=a.samplerBindings),xi(this,gS,this.renderCache.createBindings(l),"f")}if(Ie(this,rl,"f").length>0&&a.samplerBindings){const l=this.createSampler();if(xi(this,lB,Ie(this,rl,"f").map(c=>this.renderCache.createBindings({pipeline:this.pipeline,uniformBufferBindings:a.uniformBufferBindings,samplerBindings:[{texture:c,sampler:l}]})),"f"),n&&Ie(this,Fg,"f")){const c=this.createSampler();xi(this,pS,Ie(this,rl,"f").map(h=>this.renderCache.createBindings({pipeline:Ie(this,Fg,"f"),uniformBufferBindings:a.uniformBufferBindings,samplerBindings:[{texture:h,sampler:c}]})),"f")}}if(this.parentClipMode==="soft"){const l=this.device.queryVendorInfo().platformString==="WebGPU"?`diagnostic(off,derivative_uniformity); 8286`:"",c=e+` 8287#define USE_SOFT_CLIP_OUTSIDE 8288`,h=this.renderCache.createProgram({vertex:{glsl:c+dvt},fragment:{glsl:c+fvt,postprocess:g=>l+g}}),u=[...this.vertexBufferDescriptors];this.useWireframe&&u.push(this.barycentricBufferDescriptor);const d=this.renderCache.createInputLayout({vertexBufferDescriptors:u,indexBufferFormat:X.U32_R,program:h});this.inputLayoutSoftClipOutside=d,this.pipelineSoftClipOutside=this.renderCache.createRenderPipeline({input
8288Layout:d,program:h,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:X.D24_S8,megaStateDescriptor:Object.assign({attachmentsState:[{channelWriteMask:oo.ALL,rgbBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.SRC_ALPHA,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA}}],blendConstant:Ra,cullMode:jl.NONE,depthWrite:!0,depthCompare:li.GREATER},this.stencilDescriptorForSoftOutside)}),this.device.setResourceName(this.pipelineSoftClipOutside,"SDFPipelineSoftClipOutside"),n&&(xi(this,Ng,this.renderCache.createRenderPipeline({inputLayout:d,program:h,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:X.D24_S8,megaStateDescriptor:Object.assign({attachmentsState:[{channelWriteMask:oo.ALL,rgbBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.SRC_ALPHA,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA}}],blendConstant:Ra,cullMode:jl.NONE,depthWrite:!1,depthCompare:li.GREATER},this.stencilDescriptorForSoftOutside)}),"f"),this.device.setResourceName(Ie(this,Ng,"f"),"SDFPipelineSoftClipOutsideMultiFillMidPass")),this.programSoftClipOutside=h;const f={pipeline:this.pipelineSoftClipOutside,uniformBufferBindings:[...a.uniformBufferBindings]};if(a.samplerBindings&&(f.samplerBindings=a.samplerBindings),this.bindingsSoftClipOutside=this.renderCache.createBindings(f),n&&Ie(this,Ng,"f")){const g={pipeline:Ie(this,Ng,"f"),uniformBufferBindings:[...a.uniformBufferBindings]};a.samplerBindings&&(g.samplerBindings=a.samplerBindings),xi(this,yS,this.renderCache.createBindings(g),"f")}if(Ie(this,rl,"f").length>0&&f.samplerBindings){const g=this.createSampler();if(xi(this,cB,Ie(this,rl,"f").map(p=>this.renderCache.createBindings({pipeline:this.pipelineSoftClipOutside,uniformBufferBindings:f.uniformBufferBindings,samplerBindings:[{texture:p,sampler:g}]})),"f"),n&&Ie(this,Ng,"f")){const p=this.createSampler();xi(this,mS,Ie(this,rl,"f").map(m=>this.renderCache.createBindings({pipeline:Ie(this,Ng,"f"),uniformBufferBindings:f.uniformBufferBindings,samplerBindings:[{texture:m,sampler:p}]})),"f")}}}}submitNodeLayerBlendComposite(e,r,i,s,o,n,a){hYt(e,this.device,this.renderCache,r,i,Ij(this.api,this.shapes[0]),n,a)}render(e,r,i){let s=Object.assign({},i);if(this.instanced){const n=[];this.shapes.forEach((a,l,c)=>{const[h]=this.generateBuffer(a,l,c.length);n.push(...h)}),this.vertexBufferDatas[1]=new Float32Array(n),this.vertexBuffers[1].setSubData(0,new Uint8Array(this.vertexBufferDatas[1].buffer)),this.vertexBufferDatas[2]=new Float32Array(this.shapes.map(a=>{const{matrix:l}=a.read(Ae);return[l.m00,l.m01,l.m02,l.m10,l.m11,l.m12]}).flat()),this.vertexBuffers[2].setSubData(0,new Uint8Array(this.vertexBufferDatas[2].buffer))}else{const n=this.shapes[0],a=$0(n);if(a&&!Ie(this,lv,"f")){const{matrix:f}=n.read(Ae),g=[f.m00,f.m01,f.m02,f.m10,f.m11,f.m12,f.m20,f.m21,f.m22],p=aw(a);this.useWireframe&&this.geometryDirty&&this.generateWireframe();for(let m=0;m<a.length;m++){const v=a.length>1&&m<a.length-1,b=v&&Ie(this,Fg,"f")?Ie(this,Fg,"f"):this.pipeline,[y,_]=this.generateBuffer(n,0,1,{kind:"fill-layer",layerIndex:m});Ie(this,vy,"f").setSubData(0,new Uint8Array(new Float32Array([...sh(ie.fromGLMat3(g)),...y]).buffer));const w=Object.assign({u_ModelMatrix:g},_);p&&(w.u_FillImage=Ie(this,rl,"f")[m]);const E=Object.assign(Object.assign({},w),i);s=E,this.program.setUniformsLegacy(E),e.setPipeline(b);const A=this.vertexBuffers.map(S=>({buffer:S}));this.useWireframe&&A.push({buffer:this.barycentricBuffer}),e.setVertexInput(this.inputLayout,A,{buffer:this.indexBuffer});const x=p?v&&Ie(this,pS,"f").length>0?Ie(this,pS,"f")[m]:Ie(this,lB,"f")[m]:v&&Ie(this,gS,"f")?Ie(this,gS,"f"):this.bindings;if(e.setBindings(x),(this.useStencil||this.parentClipMode)&&e.setStencilReference($f),e.drawIndexed(6,this.shapes.length),this.parentClipMode==="soft"&&this.pipelineSoftClipOutside&&this.bindingsSoftClipOutside&&this.programSoftClipOutside){const S=this.parentOutsideAlpha,T=v&&Ie(this,Ng,"f")?Ie(this,Ng,"f"):this.pipelineSoftClipOutside;this.programSoftClipOutside.setUniformsLegacy(Object.assign(Object.assign({},s),{u_AlphaScale:S}
8288)),e.setPipeline(T),e.setVertexInput(this.inputLayoutSoftClipOutside,A,{buffer:this.indexBuffer});const R=p?v&&Ie(this,mS,"f").length>0?Ie(this,mS,"f")[m]:Ie(this,cB,"f")[m]:v&&Ie(this,yS,"f")?Ie(this,yS,"f"):this.bindingsSoftClipOutside;e.setBindings(R),e.setStencilReference($f),e.drawIndexed(6,this.shapes.length)}}if((n.has(Gt)?n.read(Gt).width:0)>0&&!vS.useDash(n)&&kh(n)==null){const[m,v]=this.generateBuffer(n,0,1,{kind:"stroke-pass",skipFillImageSample:p});Ie(this,vy,"f").setSubData(0,new Uint8Array(new Float32Array([...sh(ie.fromGLMat3(g)),...m]).buffer));const b=Object.assign({u_ModelMatrix:g},v);p?b.u_FillImage=Ie(this,rl,"f")[0]:this.useFillImage&&(b.u_FillImage=Ie(this,Ic,"f"));const y=Object.assign(Object.assign({},b),i);s=y,this.program.setUniformsLegacy(y),e.setPipeline(this.pipeline);const _=this.vertexBuffers.map(w=>({buffer:w}));if(this.useWireframe&&_.push({buffer:this.barycentricBuffer}),e.setVertexInput(this.inputLayout,_,{buffer:this.indexBuffer}),e.setBindings(this.bindings),(this.useStencil||this.parentClipMode)&&e.setStencilReference($f),e.drawIndexed(6,this.shapes.length),this.parentClipMode==="soft"&&this.pipelineSoftClipOutside&&this.bindingsSoftClipOutside&&this.programSoftClipOutside){const w=this.parentOutsideAlpha;this.programSoftClipOutside.setUniformsLegacy(Object.assign(Object.assign({},s),{u_AlphaScale:w})),e.setPipeline(this.pipelineSoftClipOutside),e.setVertexInput(this.inputLayoutSoftClipOutside,_,{buffer:this.indexBuffer}),e.setBindings(this.bindingsSoftClipOutside),e.setStencilReference($f),e.drawIndexed(6,this.shapes.length)}}return}const{matrix:l}=this.shapes[0].read(Ae),[c,h]=this.generateBuffer(this.shapes[0],0,1),u=[l.m00,l.m01,l.m02,l.m10,l.m11,l.m12,l.m20,l.m21,l.m22];Ie(this,vy,"f").setSubData(0,new Uint8Array(new Float32Array([...sh(ie.fromGLMat3(u)),...c]).buffer));const d=Object.assign({u_ModelMatrix:u},h);this.useFillImage&&(d.u_FillImage=Ie(this,Ic,"f")),this.program.setUniformsLegacy(d),s=Object.assign(Object.assign({},d),i)}this.useWireframe&&this.geometryDirty&&this.generateWireframe(),this.program.setUniformsLegacy(s),e.setPipeline(this.pipeline);const o=this.vertexBuffers.map(n=>({buffer:n}));if(this.useWireframe&&o.push({buffer:this.barycentricBuffer}),e.setVertexInput(this.inputLayout,o,{buffer:this.indexBuffer}),e.setBindings(this.bindings),(this.useStencil||this.parentClipMode)&&e.setStencilReference($f),e.drawIndexed(6,this.shapes.length),this.parentClipMode==="soft"&&this.pipelineSoftClipOutside&&this.bindingsSoftClipOutside&&this.programSoftClipOutside){const n=this.parentOutsideAlpha;this.programSoftClipOutside.setUniformsLegacy(Object.assign(Object.assign({},s),{u_AlphaScale:n})),e.setPipeline(this.pipelineSoftClipOutside),e.setVertexInput(this.inputLayoutSoftClipOutside,o,{buffer:this.indexBuffer}),e.setBindings(this.bindingsSoftClipOutside),e.setStencilReference($f),e.drawIndexed(6,this.shapes.length)}}destroy(){var e;this.disposeFillImageResources(),this.destroyFullPostProcessingChain(),xi(this,aB,!1,"f"),super.destroy(),this.program&&((e=Ie(this,vy,"f"))===null||e===void 0||e.destroy(),xi(this,vy,null,"f"))}generateBuffer(e,r,i,s){const o=e.has(Ln)?e.read(Ln).value:0;let n=[0,0,0,0],a=[0,0,0,0],l=0,c=0;const h=(o+1/i*r)/Ew;if(e.has(et)){const{cx:Dt,cy:rt,r:At}=e.read(et);n=[Dt,rt,h,0],a=[At,At,0,0],l=0}else if(e.has(ae)){const{cx:Dt,cy:rt,rx:At,ry:Vt}=e.read(ae);n=[Dt,rt,h,0],a=[At,Vt,0,0],l=1}else if(e.has($t)){const{x:Dt,y:rt,width:At,height:Vt,cornerRadius:de}=e.read($t);n=[Dt+At/2,rt+Vt/2,h,0],a=[At/2,Vt/2,0,0],l=2,c=de}let u=Hx(e);const d=$0(e),f=Nh(e);if((s==null?void 0:s.kind)==="fill-layer"&&d){const Dt=d[s.layerIndex];u=Dt.type==="solid"?Dt.value:"#ffffff"}else if((s==null?void 0:s.kind)==="stroke-pass")u="transparent";else if(!s&&f.length===1&&e.has(Ce)){const Dt=f[0];u=Dt.type==="solid"?Dt.value:"#ffffff"}else!s&&Ie(this,lv,"f")&&e.has(Ce)&&(u="#ffffff");const{r:g,g:p,b:m,opacity:v}=Wo(u!=null&&u!==""?u:"transparent"),b=e.has(bo)?e.read(bo).opacity:1,y=H0(e),_=e.has(Gt)?e.read(Gt).width:0,w=e.has(Gt)?e.read(Gt).alignment:"center",{color:E,offsetX:A,offsetY:x,blurRadius:S}=e.has(ac)?e.read(ac):{color:null,offsetX:0,offsetY:0,blurRadius:0},{r:T,g:R,b:B,opacity:O}=Wo(y??"transparent"),{strokeColorAlphaMul:C,strokeUniformOpacityMul:F}=b2(e),{r:U,g:H,b:N,opacity:G}=Wo(E),Y=n,q=a;let L=g/255,J=p/255,tt=m/255,bt=v;if((s==null?void 0:s.kind)==="fill-layer"&&d){const Dt=d[s.layerIndex],rt=Cg(Dt.opacity);Dt.type==="gradient"?(L=1,J=1,tt=1,bt=rt):bt=v*rt}else if(!s&&f.length===1&&e.has(Ce)){const Dt=f[0],rt=Cg(Dt.opacity);Dt.type==="gradient"?(L=1,J=1,tt=1,bt=rt):bt=v*rt}else!s&&Ie(this,lv,"f")&&e.has(Ce)&&(L=1,J=1,tt=1,bt=1);const ct=[L,J,tt,bt],Xt=[T/255,R/255,B/255,O*C];let It=vS.useDash(e)?0:_;kh(e)!=null&&(It=0),(s==null?void 0:s.kind)==="fill-layer"&&(It=0);let zt=[0,0,0,0];if(Ie(this,aB,"f")&&kh(e)==null){It=0;const Dt=e.has(Gt)?e.read(Gt).width:0;zt=[Dt*.5,Dt,0,0]}(s==null?void 0:s.kind)==="fill-layer"?zt[2]=1:(s==null?void 0:s.kind)==="stroke-pass"&&s.skipFillImageSample&&(zt[3]=1);const Ht=[o/Ew,It,c,xee[w]],Lt=(e.has(Xc)?1:0)*8388608+(e.has(Qn)?1:0)*4194304+l,tr=[b,1,F,Lt],Gr=[U/255,H/255,N/255,G],re=[A,x,S,0],ci=[...Y,...q,...ct,...Xt,...Ht,...tr,...Gr,...re];return this.instanced||ci.push(...zt),[ci,{u_Position:Y,u_Size:q,u_FillColor:ct,u_StrokeColor:Xt,u_ZIndexStrokeWidth:Ht,u_Opacity:tr,u_InnerShadowColor:Gr,u_InnerShadow:re,u_FilterExtras:zt}]}}vy=new WeakMap,Ic=new WeakMap,tU=new WeakMap,Aw=new WeakMap,fS=new WeakMap,aB=new WeakMap,rl=new WeakMap,lB=new WeakMap,cB=new WeakMap,Fg=new WeakMap,pS=new WeakMap,gS=new WeakMap,Ng=new WeakMap,mS=new WeakMap,yS=new WeakMap,lv=new WeakMap;var ch;(function(t){t[t.BARYCENTRIC=0]="BARYCENTRIC",t[t.FRAG_COORD=1]="FRAG_COORD",t[t.ABCD=2]="ABCD",t[t.TXTY=3]="TXTY",t[t.POSITION_SIZE=4]="POSITION_SIZE",t[t.ZINDEX_STROKE_WIDTH=5]="ZINDEX_STROKE_WIDTH",t[t.DROP_SHADOW_COLOR=6]="DROP_SHADOW_COLOR",t[t.DROP_SHADOW=7]="DROP_SHADOW"})(ch||(ch={}));const See=` 8289layout(std140) uniform SceneUniforms { 8290 mat3 u_ProjectionMatrix; 8291 mat3 u_ViewMatrix; 8292 mat3 u_ViewProjectionInvMatrix;
8293 vec4 u_BackgroundColor; 8294 vec4 u_GridColor; 8295 float u_ZoomScale; 8296 float u_CheckboardStyle; 8297}; 8298 8299${iB} 8300layout(location = ${ch.FRAG_COORD}) in vec2 a_FragCoord; 8301 8302#ifdef USE_INSTANCES 8303 layout(location = ${ch.ABCD}) in vec4 a_Abcd; 8304 layout(location = ${ch.TXTY}) in vec2 a_Txty; 8305 layout(location = ${ch.POSITION_SIZE}) in vec4 a_PositionSize; 8306 layout(location = ${ch.ZINDEX_STROKE_WIDTH}) in vec4 a_ZIndexStrokeWidth; 8307 layout(location = ${ch.DROP_SHADOW_COLOR}) in vec4 a_DropShadowColor; 8308 layout(location = ${ch.DROP_SHADOW}) in vec4 a_DropShadow; 8309#else 8310 layout(std140) uniform ShapeUniforms { 8311 mat3 u_ModelMatrix; 8312 vec4 u_PositionSize; 8313 vec4 u_ZIndexStrokeWidth; 8314 vec4 u_DropShadowColor; 8315 vec4 u_DropShadow; 8316 }; 8317#endif 8318 8319out vec2 v_Origin; 8320#ifdef USE_INSTANCES 8321 out float v_CornerRadius; 8322 out vec4 v_DropShadowColor; 8323 out vec4 v_DropShadow; 8324#else 8325#endif 8326out vec2 v_Size; 8327out vec2 v_Point; 8328 8329void main() { 8330 ${rB} 8331 8332 mat3 model; 8333 vec2 origin; 8334 vec2 size; 8335 float zIndex; 8336 vec4 dropShadow; 8337 float sizeAttenuation; 8338 8339 #ifdef USE_INSTANCES 8340 model = mat3(a_Abcd.x, a_Abcd.y, 0, a_Abcd.z, a_Abcd.w, 0, a_Txty.x, a_Txty.y, 1); 8341 origin = a_PositionSize.xy; 8342 size = a_PositionSize.zw; 8343 zIndex = a_ZIndexStrokeWidth.x; 8344 dropShadow = a_DropShadow; 8345 sizeAttenuation = a_ZIndexStrokeWidth.w; 8346 v_CornerRadius = a_ZIndexStrokeWidth.z; 8347 v_DropShadowColor = a_DropShadowColor; 8348 v_DropShadow = dropShadow; 8349 #else 8350 model = u_ModelMatrix; 8351 origin = u_PositionSize.xy; 8352 size = u_PositionSize.zw; 8353 zIndex = u_ZIndexStrokeWidth.x; 8354 dropShadow = u_DropShadow; 8355 sizeAttenuation = u_ZIndexStrokeWidth.w; 8356 #endif 8357 8358 float scale = 1.0; 8359 if (sizeAttenuation > 0.5) { 8360 scale = 1.0 / u_ZoomScale; 8361 } 8362 8363 // Set the bounds of the shadow and adjust its size based on the shadow's 8364 // spread radius to achieve the spreading effect 8365 float margin = 3.0 * dropShadow.z; 8366 8367 vec2 center = origin + size / 2.0; 8368 vec2 sizeSign = sign(size); 8369 size = abs(size); 8370 8371 // Recalculate the origin since the size could be negative 8372 origin = center - size / 2.0 + dropShadow.xy * sizeSign; 8373 v_Size = size; 8374 v_Origin = origin; 8375 8376 origin -= margin; 8377 size += 2.0 * margin; 8378 8379 v_Point = center + a_FragCoord * (size / 2.0); 8380 8381 gl_Position = vec4((u_ProjectionMatrix 8382 * u_ViewMatrix 8383 * model 8384 * vec3(center + a_FragCoord * (size / 2.0) * scale, 1)).xy, zIndex, 1); 8385} 8386`,Tee=` 8387layout(std140) uniform SceneUniforms { 8388 mat3 u_ProjectionMatrix; 8389 mat3 u_ViewMatrix; 8390 mat3 u_ViewProjectionInvMatrix; 8391 vec4 u_BackgroundColor; 8392 vec4 u_GridColor; 8393 float u_ZoomScale; 8394 float u_CheckboardStyle; 8395}; 8396 8397#ifdef USE_INSTANCES 8398#else 8399 layout(std140) uniform ShapeUniforms { 8400 mat3 u_ModelMatrix; 8401 vec4 u_PositionSize; 8402 vec4 u_ZIndexStrokeWidth; 8403 vec4 u_DropShadowColor; 8404 vec4 u_DropShadow; 8405 }; 8406#endif 8407 8408out vec4 outputColor; 8409 8410${aS} 8411in vec2 v_Origin; 8412#ifdef USE_INSTANCES 8413 in float v_CornerRadius; 8414 in vec4 v_DropShadowColor; 8415 in vec4 v_DropShadow; 8416#else 8417#endif 8418in vec2 v_Size; 8419in vec2 v_Point; 8420 8421float epsilon = 0.000001; 8422float PI = 3.1415926; 8423 8424// A standard gaussian function, used for weighting samples 8425float gaussian(float x, float sigma) { 8426 return exp(-(x * x) / (2. * sigma * sigma)) / (sqrt(2. * PI) * sigma); 8427} 8428 8429// This approximates the error function, needed for the gaussian integral 8430vec2 erf(vec2 x) { 8431 vec2 s = sign(x), a = abs(x); 8432 x = 1.0 + (0.278393 + (0.230389 + 0.078108 * (a * a)) * a) * a; 8433 x *= x; 8434 return s - s / (x * x); 8435} 8436 8437// @see https://raphlinus.github.io/graphics/2020/04/21/blurred-rounded-rects.html 8438// vec2 erf7(vec2 x) { 8439// x = x * sqrt(2. * PI); 8440// vec2 xx = x * x; 8441// x = x + (0.24295 + (0.03395 + 0.0104 * xx) * xx) * (x * xx); 8442// return x / sqrt(1.0 + x * x); 8443// } 8444 8445float rect_shadow(vec2 pixel_position, vec2 origin, vec2 size, float sigma) { 8446 vec2 bottom_right = origin + size; 8447 vec2 x_distance = vec2(pixel_position.x - origin.x, pixel_position.x - bottom_right.x); 8448 vec2 y_distance = vec2(pixel_position.y - origin.y, pixel_position.y - bottom_right.y); 8449 vec2 integral_x = 0.5 + 0.5 * erf(x_distance * (sqrt(0.5) / sigma)); 8450 vec2 integral_y = 0.5 + 0.5 * erf(y_distance * (sqrt(0.5) / sigma)); 8451 return (integral_x.x - integral_x.y) * (integral_y.x - integral_y.y); 8452} 8453 8454float blur_along_x(float x, float y, float sigma, float corner, vec2 half_size) { 8455 float delta = min(half_size.y - corner - abs(y), 0.0); 8456 float curved = half_size.x - corner + sqrt(max(0., corner * corner - delta * delta)); 8457 vec2 integral = 0.5 + 0.5 * erf((x + vec2(-curved, curved)) * (sqrt(0.5) / sigma)); 8458 return integral.y - integral.x; 8459} 8460 8461void main() { 8462 float cornerRadius; 8463 vec4 dropShadow; 8464 vec4 dropShadowColor; 8465 8466 #ifdef USE_INSTANCES 8467 cornerRadius = v_CornerRadius; 8468 dropShadowColor = v_DropShadowColor; 8469 dropShadow = v_DropShadow; 8470 #else 8471 cornerRadius = u_ZIndexStrokeWidth.z; 8472 dropShadowColor = u_DropShadowColor; 8473 dropShadow = u_DropShadow; 8474 #endif 8475 8476 float blur_radius = dropShadow.z; 8477 if (blur_radius > 0.0) { 8478 float alpha = 0.; 8479 vec2 point = v_Point; 8480 8481 if (cornerRadius > 0.0) { 8482 vec2 half_size = v_Size / 2.0; 8483 vec2 center = v_Origin + half_size; 8484 vec2 center_to_point = point - center; 8485 8486 // The signal is only non-zero in a limited range, so don't waste samples 8487 float low = center_to_point.y - half_size.y; 8488 float high = center_to_point.y + half_size.y; 8489 float start = clamp(-3. * blur_radius, low, high); 8490 float end = clamp(3. * blur_radius, low, high); 8491 8492 // Accumulate samples (we can get away with surprisingly few samples) 8493 float step = (end - start) / 4.; 8494 float y = start + step * 0.5; 8495 8496 for (int i = 0; i < 4; i++) { 8497 alpha += blur_along_x(center_to_point.x, center_to_point.y - y, blur_radius, 8498 cornerRadius, half_size) * 8499 gaussian(y, blur_radius) * step; 8500 y += step; 8501 } 8502 } else { 8503 alpha = rect_shadow(point, v_Origin, v_Size, blur_radius); 8504 } 8505 8506 outputColor = dropShadowColor; 8507 outputColor.a = alpha; 8508 8509 ${nv} 8510 } else { 8511 discard; 8512 } 8513} 8514`;var cz=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Ree=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
8514return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},_S;class yvt extends dS{constructor(){super(...arguments),_S.set(this,void 0)}static check(e){return e.has($t)&&e.has(ro)&&e.read(ro).blurRadius>0}createGeometry(){this.indexBufferData=new Uint32Array([0,1,2,0,2,3]),this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=this.device.createBuffer({viewOrSize:this.indexBufferData,usage:Ee.INDEX,hint:rr.STATIC}),this.vertexBufferDatas[0]=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.vertexBuffers[0]&&this.vertexBuffers[0].destroy(),this.vertexBuffers[0]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[0],usage:Ee.VERTEX,hint:rr.STATIC}),this.instanced&&(this.vertexBuffers[1]&&(this.vertexBuffers[1].destroy(),this.vertexBuffers[2].destroy()),this.vertexBufferDatas[1]=new Float32Array(new Array(16*this.shapes.length).fill(0)),this.vertexBuffers[1]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[1],usage:Ee.VERTEX,hint:rr.DYNAMIC}),this.vertexBufferDatas[2]=new Float32Array(new Array(6*this.shapes.length).fill(0)),this.vertexBuffers[2]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[2],usage:Ee.VERTEX,hint:rr.DYNAMIC})),this.vertexBufferDescriptors=[{arrayStride:8,stepMode:Pi.VERTEX,attributes:[{shaderLocation:ch.FRAG_COORD,offset:0,format:X.F32_RG}]}],this.instanced&&this.vertexBufferDescriptors.push({arrayStride:64,stepMode:Pi.INSTANCE,attributes:[{shaderLocation:ch.POSITION_SIZE,offset:0,format:X.F32_RGBA},{shaderLocation:ch.ZINDEX_STROKE_WIDTH,offset:16,format:X.F32_RGBA},{shaderLocation:ch.DROP_SHADOW_COLOR,offset:32,format:X.F32_RGBA},{shaderLocation:ch.DROP_SHADOW,offset:48,format:X.F32_RGBA}]},{arrayStride:24,stepMode:Pi.INSTANCE,attributes:[{shaderLocation:ch.ABCD,offset:0,format:X.F32_RGBA},{shaderLocation:ch.TXTY,offset:16,format:X.F32_RG}]})}createMaterial(e,r){this.createProgram(See,Tee,e),!this.instanced&&!cz(this,_S,"f")&&Ree(this,_S,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*32,usage:Ee.UNIFORM,hint:rr.DYNAMIC}),"f"),this.inputLayout=this.renderCache.createInputLayout({vertexBufferDescriptors:this.vertexBufferDescriptors,indexBufferFormat:X.U32_R,program:this.program}),this.pipeline=this.renderCache.createRenderPipeline({inputLayout:this.inputLayout,program:this.program,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:X.D24_S8,megaStateDescriptor:Object.assign({attachmentsState:[{channelWriteMask:oo.ALL,rgbBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.SRC_ALPHA,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA}}],blendConstant:Ra,depthWrite:!1,depthCompare:li.GREATER},this.stencilDescriptor)}),this.instanced?this.bindings=this.renderCache.createBindings({pipeline:this.pipeline,uniformBufferBindings:[{buffer:r}]}):this.bindings=this.device.createBindings({pipeline:this.pipeline,uniformBufferBindings:[{buffer:r},{buffer:cz(this,_S,"f")}]})}render(e,r,i){if(this.instanced){const o=[];this.shapes.forEach(n=>{const[a]=this.generateBuffer(n);o.push(...a)}),this.vertexBufferDatas[1]=new Float32Array(o),this.vertexBuffers[1].setSubData(0,new Uint8Array(this.vertexBufferDatas[1].buffer)),this.vertexBufferDatas[2]=new Float32Array(this.shapes.map(n=>{const{matrix:a}=n.read(Ae);return[a.m00,a.m01,a.m02,a.m10,a.m11,a.m12]}).flat()),this.vertexBuffers[2].setSubData(0,new Uint8Array(this.vertexBufferDatas[2].buffer))}else{const{matrix:o}=this.shapes[0].read(Ae),n=[o.m00,o.m01,o.m02,o.m10,o.m11,o.m12,o.m20,o.m21,o.m22],[a,l]=this.generateBuffer(this.shapes[0]);cz(this,_S,"f").setSubData(0,new Uint8Array(new Float32Array([...sh(ie.fromGLMat3(n)),...a]).buffer));const c=Object.assign({u_ModelMatrix:n},l);this.program.setUniformsLegacy(c)}this.useWireframe&&this.geometryDirty&&this.generateWireframe(),this.program.setUniformsLegacy(i),e.setPipeline(this.pipeline);const s=this.vertexBuffers.map(o=>({buffer:o}));this.useWireframe&&s.push({buffer:this.barycentricBuffer}),e.setVertexInput(this.inputLayout,s,{buffer:this.indexBuffer}),e.setBindings(this.bindings),(this.useStencil||this.parentClipMode)&&e.setStencilReference($f),e.drawIndexed(6,this.shapes.length)}destroy(){var e;super.destroy(),this.program&&((e=cz(this,_S,"f"))===null||e===void 0||e.destroy())}
8514generateBuffer(e){const{x:r,y:i,width:s,height:o,cornerRadius:n}=e.read($t),a=e.has(Gt)?e.read(Gt).width:0,{color:l,offsetX:c,offsetY:h,blurRadius:u}=e.read(ro),{r:d,g:f,b:g,opacity:p}=Wo(l),m=0,v=e.has(Ln)?e.read(Ln).value:0,b=[r,i,s,o],y=[v/Ew,a,n,m?1:0],_=[d/255,f/255,g/255,p],w=[c,h,u,0];return[[...b,...y,..._,...w],{u_PositionSize:b,u_ZIndexStrokeWidth:y,u_DropShadowColor:_,u_DropShadow:w}]}}_S=new WeakMap;var hh;(function(t){t[t.BARYCENTRIC=0]="BARYCENTRIC",t[t.PREV=1]="PREV",t[t.POINTA=2]="POINTA",t[t.POINTB=3]="POINTB",t[t.NEXT=4]="NEXT",t[t.VERTEX_JOINT=5]="VERTEX_JOINT",t[t.VERTEX_NUM=6]="VERTEX_NUM",t[t.TRAVEL=7]="TRAVEL"})(hh||(hh={}));var yn;(function(t){t[t.NONE=0]="NONE",t[t.FILL=1]="FILL",t[t.JOINT_BEVEL=4]="JOINT_BEVEL",t[t.JOINT_MITER=8]="JOINT_MITER",t[t.JOINT_ROUND=12]="JOINT_ROUND",t[t.JOINT_CAP_BUTT=16]="JOINT_CAP_BUTT",t[t.JOINT_CAP_SQUARE=18]="JOINT_CAP_SQUARE",t[t.JOINT_CAP_ROUND=20]="JOINT_CAP_ROUND",t[t.FILL_EXPAND=24]="FILL_EXPAND",t[t.CAP_BUTT=32]="CAP_BUTT",t[t.CAP_SQUARE=64]="CAP_SQUARE",t[t.CAP_ROUND=96]="CAP_ROUND",t[t.CAP_BUTT2=128]="CAP_BUTT2"})(yn||(yn={}));const Cee=` 8515layout(std140) uniform SceneUniforms { 8516 mat3 u_ProjectionMatrix; 8517 mat3 u_ViewMatrix; 8518 mat3 u_ViewProjectionInvMatrix; 8519 vec4 u_BackgroundColor; 8520 vec4 u_GridColor; 8521 float u_ZoomScale; 8522 float u_CheckboardStyle; 8523 vec2 u_Viewport; 8524}; 8525 8526${iB} 8527layout(location = ${hh.PREV}) in vec2 a_Prev; 8528layout(location = ${hh.POINTA}) in vec2 a_PointA; 8529layout(location = ${hh.POINTB}) in vec2 a_PointB; 8530layout(location = ${hh.NEXT}) in vec2 a_Next; 8531layout(location = ${hh.VERTEX_JOINT}) in float a_VertexJoint; 8532layout(location = ${hh.VERTEX_NUM}) in float a_VertexNum; 8533layout(location = ${hh.TRAVEL}) in float a_Travel; 8534 8535layout(std140) uniform ShapeUniforms { 8536 mat3 u_ModelMatrix; 8537 vec4 u_StrokeColor; 8538 vec4 u_ZIndexStrokeWidth; 8539 vec4 u_Opacity; 8540 vec4 u_StrokeDash; 8541 vec4 u_StrokeUVRect; 8542}; 8543 8544const float FILL = ${yn.FILL}.0; 8545const float BEVEL = ${yn.JOINT_BEVEL}.0; 8546const float MITER = ${yn.JOINT_MITER}.0; 8547const float ROUND = ${yn.JOINT_ROUND}.0; 8548const float JOINT_CAP_BUTT = ${yn.JOINT_CAP_BUTT}.0; 8549const float JOINT_CAP_SQUARE = ${yn.JOINT_CAP_SQUARE}.0; 8550const float JOINT_CAP_ROUND = ${yn.JOINT_CAP_ROUND}.0; 8551const float FILL_EXPAND = ${yn.FILL_EXPAND}.0; 8552const float CAP_BUTT = 1.0; 8553const float CAP_SQUARE = 2.0; 8554const float CAP_ROUND = 3.0; 8555const float CAP_BUTT2 = 4.0; 8556 8557const float expand = 1.0; 8558const float dpr = 2.0; 8559 8560out vec4 v_Distance; 8561out vec4 v_Arc; 8562out float v_Type; 8563out float v_Travel; 8564out float v_ScalingFactor; 8565#ifdef USE_STROKE_GRADIENT 8566out vec2 v_StrokeUv; 8567#endif 8568#ifdef USE_INSTANCES 8569 out vec4 v_StrokeColor; 8570 out vec4 v_Opacity; 8571 out float v_StrokeAlignment; 8572#else 8573#endif 8574 8575vec2 doBisect( 8576 vec2 norm, float len, vec2 norm2, float len2, float dy, float inner 8577) { 8578 vec2 bisect = (norm + norm2) / 2.0; 8579 bisect /= dot(norm, bisect); 8580 if (inner > 0.5) { 8581 if (len < len2) { 8582 if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) { 8583 return dy * norm; 8584 } 8585 } else { 8586 if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) { 8587 return dy * norm; 8588 } 8589 } 8590 } 8591 return dy * bisect; 8592} 8593 8594mat3 inverseMat3(mat3 m) { 8595 float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2]; 8596 float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2]; 8597 float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2]; 8598 8599 float b01 = a22 * a11 - a12 * a21; 8600 float b11 = -a22 * a10 + a12 * a20; 8601 float b21 = a21 * a10 - a11 * a20; 8602 8603 float det = a00 * b01 + a01 * b11 + a02 * b21; 8604 if (abs(det) < 1e-12) { 8605 return mat3(1.0); 8606 } 8607 return mat3( 8608 b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11), 8609 b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10), 8610 b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10) 8611 ) / det; 8612} 8613 8614// vec2 clip2ScreenSpace(vec4 clip) { 8615// return u_Viewport * (0.5 * clip.xy / clip.w + 0.5); 8616// } 8617 8618void main() { 8619 ${rB} 8620 8621 mat3 model = u_ModelMatrix; 8622 vec4 strokeColor = u_StrokeColor; 8623 float zIndex = u_ZIndexStrokeWidth.x; 8624 float strokeWidth = u_ZIndexStrokeWidth.y; 8625 float strokeMiterlimit = u_ZIndexStrokeWidth.z; 8626 float strokeAlignment = u_ZIndexStrokeWidth.w; 8627 bool strokeAttenuation = u_Opacity.w > 0.5; 8628 8629 if (strokeAttenuation) { 8630 strokeWidth /= u_ZoomScale; 8631 } 8632 8633 vec2 pointA; 8634 vec2 pointB; 8635 // vec4 clip0 = vec4((u_ProjectionMatrix
8636 // * u_ViewMatrix 8637 // * model 8638 // * vec3(a_PointA, 1)).xy, zIndex, 1);; 8639 // vec4 clip1 = vec4((u_ProjectionMatrix 8640 // * u_ViewMatrix 8641 // * model 8642 // * vec3(a_PointB, 1)).xy, zIndex, 1);; 8643 8644 // if (sizeAttenuation) { 8645 // pointA = clip2ScreenSpace(clip0); 8646 // pointB = clip2ScreenSpace(clip1); 8647 // } else { 8648 pointA = (model * vec3(a_PointA, 1.0)).xy; 8649 pointB = (model * vec3(a_PointB, 1.0)).xy; 8650 // } 8651 8652 vec2 xBasis = pointB - pointA; 8653 float len = length(xBasis); 8654 vec2 forward = xBasis / len; 8655 vec2 norm = vec2(forward.y, -forward.x); 8656 8657 float type = a_VertexJoint; 8658 float vertexNum = a_VertexNum; 8659 8660 float capType = floor(type / 32.0); 8661 type -= capType * 32.0; 8662 v_Arc = vec4(0.0); 8663 strokeWidth *= 0.5; 8664 float strokeAlignmentFactor = 2.0 * strokeAlignment - 1.0; 8665 8666 vec2 pos; 8667 8668 if (capType == CAP_ROUND) { 8669 if (vertexNum < 3.5) { 8670 gl_Position = vec4(0.0, 0.0, 0.0, 1.0); 8671 return; 8672 } 8673 type = JOINT_CAP_ROUND; 8674 capType = 0.0; 8675 } 8676 8677 if (type >= BEVEL) { 8678 float dy = strokeWidth + expand; 8679 float inner = 0.0; 8680 if (vertexNum >= 1.5) { 8681 dy = -dy; 8682 inner = 1.0; 8683 } 8684 8685 vec2 base, next, xBasis2, bisect; 8686 float flag = 0.0; 8687 float sign2 = 1.0; 8688 if (vertexNum < 0.5 || vertexNum > 2.5 && vertexNum < 3.5) { 8689 // if (sizeAttenuation) { 8690 // next = clip2ScreenSpace(vec4((u_ProjectionMatrix 8691 // * u_ViewMatrix 8692 // * model 8693 // * vec3(a_Prev, 1)).xy, zIndex, 1)); 8694 // } else { 8695 next = (model * vec3(a_Prev, 1.0)).xy; 8696 // } 8697 8698 base = pointA; 8699 flag = type - floor(type / 2.0) * 2.0; 8700 sign2 = -1.0; 8701 } else { 8702 // if (sizeAttenuation) { 8703 // next = clip2ScreenSpace(vec4((u_ProjectionMatrix 8704 // * u_ViewMatrix 8705 // * model 8706 // * vec3(a_Next, 1)).xy, zIndex, 1)); 8707 // } else { 8708 next = (model * vec3(a_Next, 1.0)).xy; 8709 // } 8710 8711 base = pointB; 8712 if (type >= MITER && type < MITER + 3.5) { 8713 flag = step(MITER + 1.5, type); 8714 // check miter limit here? 8715 } 8716 } 8717 8718 xBasis2 = next - base; 8719 float len2 = length(xBasis2); 8720 vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2; 8721 float D = norm.x * norm2.y - norm.y * norm2.x; 8722 if (D < 0.0) { 8723 inner = 1.0 - inner; 8724 } 8725 norm2 *= sign2; 8726 8727 if (abs(strokeAlignmentFactor) > 0.01) { 8728 float shift = strokeWidth * strokeAlignmentFactor; 8729 pointA += norm * shift; 8730 pointB += norm * shift; 8731 if (abs(D) < 0.01) { 8732 base += norm * shift; 8733 } else { 8734 base += doBisect(norm, len, norm2, len2, shift, 0.0); 8735 } 8736 } 8737 8738 float collinear = step(0.0, dot(norm, norm2)); 8739 v_Type = 0.0; 8740 float dy2 = -1000.0; 8741 float dy3 = -1000.0; 8742 if (abs(D) < 0.01 && collinear < 0.5) { 8743 if (type >= ROUND && type < ROUND + 1.5) { 8744 type = JOINT_CAP_ROUND; 8745 } 8746 // TODO: BUTT here too 8747 } 8748 8749 if (vertexNum < 3.5) { 8750 if (abs(D) < 0.01) { 8751 pos = dy * norm; 8752 } else { 8753 if (flag < 0.5 && inner < 0.5) { 8754 pos = dy * norm; 8755 } else { 8756 pos = doBisect(norm, len, norm2, len2, dy, inner); 8757 } 8758 } 8759 if (capType >= CAP_BUTT && capType < CAP_ROUND) { 8760 float extra = step(CAP_SQUARE, capType) * strokeWidth; 8761 vec2 back = -forward; 8762 if (vertexNum < 0.5 || vertexNum > 2.5) { 8763 pos += back * (expand + extra); 8764 dy2 = expand; 8765 } else { 8766 dy2 = dot(pos + base - pointA, back) - extra; 8767 } 8768 } 8769 if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) { 8770 float extra = step(JOINT_CAP_SQUARE, type) * strokeWidth; 8771 if (vertexNum < 0.5 || vertexNum > 2.5) { 8772 dy3 = dot(pos + base - pointB, forward) - extra; 8773 } else { 8774 pos += forward * (expand + extra); 8775 dy3 = expand; 8776 if (capType >= CAP_BUTT) { 8777 dy2 -= expand + extra; 8778 } 8779 } 8780 } 8781 } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) { 8782 if (inner > 0.5) { 8783 dy = -dy; 8784 inner = 0.0; 8785 } 8786 vec2 d2 = abs(dy) * forward; 8787 if (vertexNum < 4.5) { 8788 dy = -dy; 8789 pos = dy * norm; 8790 } else if (vertexNum < 5.5) { 8791 pos = dy * norm; 8792 } else if (vertexNum < 6.5) { 8793 pos = dy * norm + d2; 8794 v_Arc.x = abs(dy); 8795 } else { 8796 dy = -dy; 8797 pos = dy * norm + d2; 8798 v_Arc.x = abs(dy); 8799 } 8800 dy2 = 0.0; 8801 v_Arc.y = dy; 8802 v_Arc.z = 0.0; 8803 v_Arc.w = strokeWidth; 8804 v_Type = 3.0; 8805 } else if (abs(D) < 0.01) { 8806 pos = dy * norm; 8807 } else { 8808 if (type >= ROUND && type < ROUND + 1.5) { 8809 if (inner > 0.5) { 8810 dy = -dy; 8811 inner = 0.0; 8812 } 8813 if (vertexNum < 4.5) { 8814 pos = doBisect(norm, len, norm2, len2, -dy, 1.0); 8815 } else if (vertexNum < 5.5) { 8816 pos = dy * norm; 8817 } else if (vertexNum > 7.5) { 8818 pos = dy * norm2; 8819 } else { 8820 pos = doBisect(norm, len, norm2, len2, dy, 0.0); 8821 float d2 = abs(dy); 8822 if (length(pos) > abs(dy) * 1.5) { 8823 if (vertexNum < 6.5) { 8824 pos.x = dy * norm.x - d2 * norm.y; 8825 pos.y = dy * norm.y + d2 * norm.x; 8826 } else { 8827 pos.x = dy * norm2.x + d2 * norm2.y; 8828 pos.y = dy * norm2.y - d2 * norm2.x; 8829 } 8830 } 8831 } 8832 vec2 norm3 = normalize(norm + norm2); 8833 8834 float sign = step(0.0, dy) * 2.0 - 1.0; 8835 v_Arc.x = sign * dot(pos, norm3); 8836 v_Arc.y = pos.x * norm3.y - pos.y * norm3.x; 8837 v_Arc.z = dot(norm, norm3) * strokeWidth; 8838 v_Arc.w = strokeWidth; 8839 8840 dy = -sign * dot(pos, norm); 8841 dy2 = -sign * dot(pos, norm2); 8842 dy3 = v_Arc.z - v_Arc.x; 8843 v_Type = 3.0; 8844 } else { 8845 float hit = 0.0; 8846 if (type >= BEVEL && type < BEVEL + 1.5) { 8847 if (dot(norm, norm2) > 0.0) { 8848 type = MITER; 8849 } 8850 } 8851 if (type >= MITER && type < MITER + 3.5) { 8852 if (inner > 0.5) { 8853 dy = -dy; 8854 inner = 0.0; 8855 } 8856 float sign = step(0.0, dy) * 2.0 - 1.0; 8857 pos = doBisect(norm, len, norm2, len2, dy, 0.0); 8858 if (length(pos) > abs(dy) * strokeMiterlimit) { 8859 type = BEVEL; 8860 } else { 8861 if (vertexNum < 4.5) { 8862 dy = -dy; 8863 pos = doBisect(norm, len, norm2, len2, dy, 1.0); 8864 } else if (vertexNum < 5.5) { 8865 pos = dy * norm; 8866 } else if (vertexNum > 6.5) { 8867 pos = dy * norm2; 8868 } 8869 v_Type = 1.0; 8870 dy = -sign * dot(pos, norm); 8871 dy2 = -sign * dot(pos, norm2); 8872 hit = 1.0; 8873 } 8874 } 8875 if (type >= BEVEL && type < BEVEL + 1.5) { 8876 if (inner > 0.5) { 8877 dy = -dy; 8878 inner = 0.0; 8879 } 8880 float d2 = abs(dy); 8881 vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x); 8882 vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x); 8883 if (vertexNum < 4.5) { 8884 pos = doBisect(norm, len, norm2, len2, -dy, 1.0); 8885 } else if (vertexNum < 5.5) { 8886 pos = dy * norm; 8887 } else if (vertexNum > 7.5) { 8888 pos = dy * norm2; 8889 } else { 8890 if (vertexNum < 6.5) { 8891 pos = pos3; 8892 } else { 8893 pos = pos4; 8894 } 8895 } 8896 vec2 norm3 = normalize(norm + norm2); 8897 float sign = step(0.0, dy) * 2.0 - 1.0; 8898 dy = -sign * dot(pos, norm); 8899 dy2 = -sign * dot(pos, norm2); 8900 dy3 = (-sign * dot(pos, norm3)) + strokeWidth; 8901 v_Type = 4.0; 8902 hit = 1.0; 8903 } 8904 if (hit < 0.5) { 8905 gl_Position = vec4(0.0, 0.0, 0.0, 1.0); 8906 return; 8907 } 8908 } 8909 } 8910 pos += base; 8911 v_Distance = vec4(dy, dy2, dy3, strokeWidth) * dpr; 8912 v_Arc *= dpr; 8913 v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x)); 8914 } 8915 8916 // v_ScalingFactor = sqrt(model[0][0] * model[0][0] + model[0][1] * model[0][1] + model[0][2] * model[0][2]); 8917 v_ScalingFactor = 1.0; 8918 8919#ifdef USE_STROKE_GRADIENT
8920 vec3 localH = inverseMat3(model) * vec3(pos, 1.0); 8921 v_StrokeUv = (localH.xy - u_StrokeUVRect.xy) * u_StrokeUVRect.zw; 8922#endif 8923 8924 // if (sizeAttenuation) { 8925 // vec4 clip = mix(clip0, clip1, 0.5); 8926 // gl_Position = vec4(clip.w * (2.0 * pos / u_Viewport - 1.0), clip.z, clip.w); 8927 // } else { 8928 gl_Position = vec4((u_ProjectionMatrix 8929 * u_ViewMatrix 8930 * vec3(pos, 1)).xy, zIndex, 1); 8931 // } 8932} 8933`,Mee=` 8934layout(std140) uniform SceneUniforms { 8935 mat3 u_ProjectionMatrix; 8936 mat3 u_ViewMatrix; 8937 mat3 u_ViewProjectionInvMatrix; 8938 vec4 u_BackgroundColor; 8939 vec4 u_GridColor; 8940 float u_ZoomScale; 8941 float u_CheckboardStyle; 8942 vec2 u_Viewport; 8943}; 8944 8945layout(std140) uniform ShapeUniforms { 8946 mat3 u_ModelMatrix; 8947 vec4 u_StrokeColor; 8948 vec4 u_ZIndexStrokeWidth; 8949 vec4 u_Opacity; 8950 vec4 u_StrokeDash; 8951 vec4 u_StrokeUVRect; 8952}; 8953 8954out vec4 outputColor; 8955 8956${aS} 8957in vec4 v_Distance; 8958in vec4 v_Arc; 8959in float v_Type; 8960in float v_Travel; 8961in float v_ScalingFactor; 8962#ifdef USE_STROKE_GRADIENT 8963in vec2 v_StrokeUv; 8964uniform sampler2D u_Texture; 8965#endif 8966 8967float epsilon = 0.000001; 8968 8969float antialias(float distance) { 8970 return clamp(distance / fwidth(distance), 0.0, 1.0); 8971} 8972 8973float pixelLine(float x) { 8974 return clamp(x + 0.5, 0.0, 1.0); 8975} 8976// float pixelLine(float x, float A, float B) { 8977// float y = abs(x), s = sign(x); 8978// if (y * 2.0 < A - B) { 8979// return 0.5 + s * y / A; 8980// } 8981// y -= (A - B) * 0.5; 8982// y = max(1.0 - y / B, 0.0); 8983// return (1.0 + s * (1.0 - y * y)) * 0.5; 8984// //return clamp(x + 0.5, 0.0, 1.0); 8985// } 8986 8987void main() { 8988#ifdef USE_STROKE_GRADIENT 8989 vec4 strokeColor = texture(SAMPLER_2D(u_Texture), v_StrokeUv); 8990#else 8991 vec4 strokeColor = u_StrokeColor; 8992#endif 8993 float opacity = u_Opacity.x; 8994 float strokeOpacity = u_Opacity.z; 8995 bool strokeAttenuation = u_Opacity.w > 0.5; 8996 float strokeAlignment = u_ZIndexStrokeWidth.w; 8997 float alpha = 1.0; 8998 8999 float d1 = v_Distance.x; 9000 float d2 = v_Distance.y; 9001 float d3 = v_Distance.z; 9002 float w = v_Distance.w; 9003 9004 if (v_Type < 0.5) { 9005 float left = max(d1 - 0.5, -w); 9006 float right = min(d1 + 0.5, w); 9007 float near = d2 - 0.5; 9008 float far = min(d2 + 0.5, 0.0); 9009 float top = d3 - 0.5; 9010 float bottom = min(d3 + 0.5, 0.0); 9011 alpha = max(antialias(right - left), 0.0) * max(bottom - top, 0.0) * max(far - near, 0.0); 9012 } else if (v_Type < 1.5) { 9013 float a1 = pixelLine(d1 - w); 9014 float a2 = pixelLine(d1 + w); 9015 float b1 = pixelLine(d2 - w); 9016 float b2 = pixelLine(d2 + w); 9017 9018 float left = max(d1 - 0.5, -w); 9019 float right = min(d1 + 0.5, w); 9020 9021 alpha = antialias(a2 * b2 - a1 * b1); 9022 } else if (v_Type < 2.5) { 9023 alpha *= max(min(d1 + 0.5, 1.0), 0.0); 9024 alpha *= max(min(d2 + 0.5, 1.0), 0.0); 9025 alpha *= max(min(d3 + 0.5, 1.0), 0.0); 9026 } else if (v_Type < 3.5) { 9027 float a1 = pixelLine(d1 - w); 9028 float a2 = pixelLine(d1 + w); 9029 float b1 = pixelLine(d2 - w); 9030 float b2 = pixelLine(d2 + w); 9031 float alpha_miter = a2 * b2 - a1 * b1; 9032 float alpha_bevel = pixelLine(d3); 9033 9034 float r = length(v_Arc.xy); 9035 float circle_hor = pixelLine(w + r) - pixelLine(-w + r); 9036 float circle_vert = min(w * 2.0, 1.0); 9037 float alpha_circle = circle_hor * circle_vert;
9038 alpha = min(alpha_miter, max(alpha_circle, alpha_bevel)); 9039 } else { 9040 float a1 = pixelLine(d1 - w); 9041 float a2 = pixelLine(d1 + w); 9042 float b1 = pixelLine(d2 - w); 9043 float b2 = pixelLine(d2 + w); 9044 alpha = antialias(a2 * b2 - a1 * b1); 9045 alpha *= pixelLine(d3); 9046 } 9047 9048 float u_Dash = u_StrokeDash.x; 9049 float u_Gap = u_StrokeDash.y; 9050 float u_DashOffset = u_StrokeDash.z; 9051 9052 float scalingFactor = v_ScalingFactor; 9053 float travelScalingFactor = 1.0; 9054 if (strokeAttenuation) { 9055 travelScalingFactor = u_ZoomScale; 9056 } 9057 9058 if (u_Dash + u_Gap > 1.0) { 9059 float P = u_Dash * scalingFactor + u_Gap * scalingFactor; 9060 float dashLen = u_Dash * scalingFactor; 9061 float dashCapMode = u_StrokeDash.w; 9062 9063 if (dashCapMode < 0.5) { 9064 float travel = mod(v_Travel * travelScalingFactor + u_Gap * scalingFactor * 0.5 + u_DashOffset, P) - (u_Gap * scalingFactor * 0.5); 9065 float left = max(travel - 0.5, -0.5); 9066 float right = min(travel + 0.5, u_Dash * v_ScalingFactor + 0.5); 9067 alpha *= antialias(max(0.0, right - left)); 9068 } else { 9069 float s = mod(v_Travel * travelScalingFactor + u_Gap * scalingFactor * 0.5 + u_DashOffset, P); 9070 float sw = u_ZIndexStrokeWidth.y; 9071 float capExt = sw * 0.5; 9072 float aa = 0.5; 9073 float L1 = dashLen + capExt; 9074 float L2 = P - capExt; 9075 float inLeft = 1.0 - smoothstep(L1 - aa, L1 + aa, s); 9076 float inRight = smoothstep(L2 - aa, L2 + aa, s); 9077 alpha *= clamp(inLeft + inRight, 0.0, 1.0); 9078 9079 // Round dash cap\uFF1A\u7528\u7EBF\u6BB5\u80F6\u56CA SDF\uFF08\u4E0E\u65B9\u5E3D\u540C\u4E00\u53EF\u89C1\u5F27\u957F\u533A\u95F4\uFF09\uFF0C\u907F\u514D\u4E24\u6BB5 min(\u5706,\u5706) \u5728\u5468\u671F\u5750\u6807\u4E0B\u9519\u4F4D\u3002 9080 if (dashCapMode > 1.5) { 9081 float k = w / max(sw, 1.0e-4); 9082 float R = w * 0.5; 9083 float Lk = dashLen * k; 9084 float xCell; 9085 if (s >= L2) { 9086 // \u8D77\u70B9\u524D\u95F4\u9699 + \u8D77\u70B9\u534A\u5706\uFF1As\u2208[L2,P) \u6620\u5C04\u5230 x\u2208[-R,0)\uFF08\u6CBF\u8DEF\u5F84\u6307\u5411 dash \u65B9\u5411\uFF09 9087 xCell = -R + (s - L2) * k; 9088 } else if (s <= L1) { 9089 // dash \u4E3B\u4F53 + \u7EC8\u70B9\u534A\u5706\uFF1Ax\u2208[0, Lk+R] 9090 xCell = s * k; 9091 } else { 9092 xCell = 1.0e9; 9093 } 9094 vec2 pa = vec2(xCell, d1); 9095 vec2 ba = vec2(max(Lk, 1.0e-6), 0.0); 9096 float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0); 9097 float distCap = length(pa - ba * h) - R; 9098 alpha *= antialias(-distCap); 9099 } 9100 } 9101 } 9102 9103 outputColor = strokeColor;
9104 outputColor.a *= alpha * opacity * strokeOpacity; 9105 9106 ${nv} 9107 9108 #ifndef USE_STENCIL 9109 if (outputColor.a < epsilon) { 9110 discard; 9111 } 9112 #endif 9113} 9114`;var Po=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},uh=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},hz,_y,hB,bS,uB,wS,kg,xw,dJ;const uz=1e-4,eU=64;function dz(t){if(t.has(fe)){const e=t.read(fe).geometryBounds,r=e.maxX-e.minX,i=e.maxY-e.minY;if(r>=.5&&i>=.5)return{minX:e.minX,minY:e.minY,maxX:e.maxX,maxY:e.maxY}}return t.has($t)?$t.getGeometryBounds(t.read($t)):t.has(ae)?ae.getGeometryBounds(t.read(ae)):t.has(et)?et.getGeometryBounds(t.read(et)):{minX:0,minY:0,maxX:1,maxY:1}}const Lg=2,vvt=3,Bee={inner:0,center:.5,outer:1};class Hf extends dS{constructor(){super(...arguments),hz.add(this),_y.set(this,null),hB.set(this,!1),bS.set(this,null),uB.set(this,void 0),wS.set(this,void 0),kg.set(this,void 0),xw.set(this,void 0),this.instanced=!1,this.pointsBuffer=[],this.travelBuffer=[]}static check(e){return e.has(Mt)||e.has(_t)||e.has(ke)||e.has(ue)&&e.hasSomeOf(et,ae,$t,_t,xt,Mt)||e.hasSomeOf($t,et,ae)&&e.has(Gt)&&(e.read(Gt).dasharray[0]>0&&e.read(Gt).dasharray[1]>0||kh(e)!=null&&e.read(Gt).width>0)||e.has(xt)&&e.has(Gt)&&_ft(e)||e.has(Yt)&&e.has(wa)&&uYt(e.read(wa))}validate(e){return!1}get useRasterFilterEngineTimeRefresh(){const e=this.shapes[0];if(!e||this.instanced||!(EX(e)||kh(e)!=null&&!(e.has(ue)&&(e.hasSomeOf(et,ae,xt)&&this.index===1||e.has($t)&&this.index===2))))return!1;const r=Hl(e);return!!(r&&U2(r))}get extraShaderDefines(){const e=this.shapes[0];return!this.instanced&&e&&EX(e)?`#define USE_STROKE_GRADIENT 9115`:kh(e)==null||e.has(ue)&&(e.hasSomeOf(et,ae,xt)&&this.index===1||e.has($t)&&this.index===2)?"":`#define USE_STROKE_GRADIENT 9116`}get instanceCount(){const e=this.shapes[0];return e.hasSomeOf(_t,xt,Yt,ke,Mt)||e.has(ue)&&e.hasSomeOf(et,ae,$t,_t,xt,Mt)?Math.max(0,Math.floor(this.pointsBuffer.length/vvt)-3):e.has($t)?6:e.hasSomeOf(et,ae)?eU+1:0}createGeometry(){const e=[],r=[],i=[];let s=0;this.shapes.forEach(o=>{const{pointsBuffer:n,travelBuffer:a}=Iee(o,o.has(ue)&&(o.hasSomeOf(et,ae,xt)&&this.index===2||o.has($t)&&this.index!==2||o.has(_t)||o.has(Mt)));r.push(...n),i.push(...a),e.push(0+s,1+s,2+s,0+s,2+s,3+s,4+s,5+s,6+s,4+s,6+s,7+s,4+s,7+s,8+s),s+=9}),this.indexBufferData=new Uint32Array(e),this.pointsBuffer=r,this.travelBuffer=i,Po(this,kg,"f")&&Po(this,kg,"f").destroy(),uh(this,kg,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*15*this.instanceCount*this.shapes.length,usage:Ee.VERTEX,hint:rr.DYNAMIC}),"f"),Po(this,uB,"f")&&Po(this,uB,"f").destroy(),uh(this,uB,this.device.createBuffer({viewOrSize:new Float32Array([0,1,2,3,4,5,6,7,8]),usage:Ee.VERTEX,hint:rr.STATIC}),"f"),Po(this,wS,"f")&&Po(this,wS,"f").destroy(),uh(this,wS,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*this.instanceCount,usage:Ee.VERTEX,hint:rr.STATIC}),"f"),Po(this,kg,"f").setSubData(0,new Uint8Array(new Float32Array(this.pointsBuffer).buffer)),Po(this,wS,"f").setSubData(0,new Uint8Array(new Float32Array(this.travelBuffer).buffer)),this.vertexBufferOffsets=[0,12,20,24,36,0,0],this.vertexBuffers=[Po(this,kg,"f"),Po(this,kg,"f"),Po(this,kg,"f"),Po(this,kg,"f"),Po(this,kg,"f"),Po(this,uB,"f"),Po(this,wS,"f")],this.vertexBufferDatas=[new Float32Array(this.pointsBuffer),new Float32Array(this.pointsBuffer),new Float32Array(this.pointsBuffer),new Float32Array(this.pointsBuffer),new Float32Array(this.pointsBuffer),new Float32Array([0,1,2,3,4,5,6,7,8]),new Float32Array(this.travelBuffer)],this.vertexBufferDescriptors=[{arrayStri
9116de:12,stepMode:Pi.INSTANCE,attributes:[{format:X.F32_RG,offset:0,shaderLocation:hh.PREV}]},{arrayStride:12,stepMode:Pi.INSTANCE,attributes:[{format:X.F32_RG,offset:0,shaderLocation:hh.POINTA}]},{arrayStride:12,stepMode:Pi.INSTANCE,attributes:[{format:X.F32_R,offset:0,shaderLocation:hh.VERTEX_JOINT}]},{arrayStride:12,stepMode:Pi.INSTANCE,attributes:[{format:X.F32_RG,offset:0,shaderLocation:hh.POINTB}]},{arrayStride:12,stepMode:Pi.INSTANCE,attributes:[{format:X.F32_RG,offset:0,shaderLocation:hh.NEXT}]},{arrayStride:4,stepMode:Pi.VERTEX,attributes:[{format:X.F32_R,offset:0,shaderLocation:hh.VERTEX_NUM}]},{arrayStride:4,stepMode:Pi.INSTANCE,attributes:[{format:X.F32_R,offset:0,shaderLocation:hh.TRAVEL}]}],this.indexBuffer||(this.indexBuffer=this.device.createBuffer({viewOrSize:this.indexBufferData,usage:Ee.INDEX,hint:rr.STATIC}))}createMaterial(e,r){var i,s,o,n,a;const l=e.includes("USE_STROKE_GRADIENT");(i=this.bindings)===null||i===void 0||i.destroy(),l||Po(this,hz,"m",dJ).call(this),this.createProgram(Cee,Mee,e),Po(this,xw,"f")||uh(this,xw,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*36,usage:Ee.UNIFORM,hint:rr.DYNAMIC}),"f"),this.inputLayout=this.renderCache.createInputLayout({vertexBufferDescriptors:this.vertexBufferDescriptors,indexBufferFormat:X.U32_R,program:this.program}),this.pipeline=this.renderCache.createRenderPipeline({inputLayout:this.inputLayout,program:this.program,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:X.D24_S8,megaStateDescriptor:Object.assign({attachmentsState:[{channelWriteMask:oo.ALL,rgbBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.SRC_ALPHA,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA}}],blendConstant:Ra,depthWrite:!1,depthCompare:li.GREATER},this.stencilDescriptor)});const c={pipeline:this.pipeline,uniformBufferBindings:[{buffer:r},{buffer:Po(this,xw,"f")}]};if(l){const h=this.shapes[0];if(this.destroyFullPostProcessingChain(),(s=Po(this,bS,"f"))===null||s===void 0||s.destroy(),uh(this,bS,null,"f"),(n=(o=Po(this,_y,"f"))===null||o===void 0?void 0:o.destroy)===null||n===void 0||n.call(o),uh(this,_y,null,"f"),uh(this,hB,!1,"f"),EX(h)){const u=nvt(h,()=>dz(h)),d=u.maxX-u.minX,f=u.maxY-u.minY,g=Math.max(1,Math.ceil(d)),p=Math.max(1,Math.ceil(f)),m=aee(h,u,g,p),v=this.device.createTexture({format:X.U8_RGBA_NORM,width:g,height:p,usage:vi.SAMPLED});v.setImageData([m]),uh(this,_y,this.applyRasterFilterChainIfNeeded(h,v,g,p),"f")}else{const u=dz(h),{minX:d,minY:f,maxX:g,maxY:p}=u,m=g-d,v=p-f,b=Math.max(1,Math.ceil(m)),y=Math.max(1,Math.ceil(v)),_=nm((a=kh(h))!==null&&a!==void 0?a:""),w=(_==null?void 0:_.length)===1?_[0]:void 0;if(w&&Zy(w)){const E=this.renderMeshGradientTexture(w,b,y);uh(this,_y,this.applyRasterFilterChainIfNeeded(h,E,b,y),"f")}else{const E=this.texturePool.getOrCreateGradient({gradients:_??[],min:[d,f],width:b,height:y}),A=this.device.createTexture({format:X.U8_RGBA_NORM,width:b,height:y,usage:vi.SAMPLED});A.setImageData([E]),uh(this,_y,this.applyRasterFilterChainIfNeeded(h,A,b,y),"f")}}c.samplerBindings=[{texture:Po(this,_y,"f"),sampler:this.createSampler()}]}this.bindings=this.renderCache.createBindings(c)}applyRasterFilterChainIfNeeded(e,r,i,s){const o=Hl(e);if(this.instanced||!o)return r;const n=G2(Iv(o));if(n.length===0)return r;uh(this,bS,r,"f"),this.createPostProcessing(n,r,i,s);const{texture:a}=this.renderPostProcessingTextureSpace(i,s);return uh(this,hB,!0,"f"),a}render(e,r,i){if(this.instanceCount<=0)return;const{matrix:s}=this.shapes[0].read(Ae),o=[s.m00,s.m01,s.m02,s.m10,s.m11,s.m12,s.m20,s.m21,s.m22],[n,a]=this.generateBuffer(this.shapes[0]);Po(this,xw,"f").setSubData(0,new Uint8Array(new Float32Array([...sh(ie.fromGLMat3(o)),...n]).buffer));const l=Object.assign({u_ModelMatrix:o},a);this.program.setUniformsLegacy(l),this.useWireframe&&this.geometryDirty&&this.generateWireframe(),this.program.setUniformsLegacy(i),e.setPipeline(this.pipeline);const c=this.vertexBuffers.map((h,u)=>({buffer:h,offset:this.vertexBufferOffsets[u]}));this.useWireframe&&c.push({buffer:this.barycentricBuffer,offset:0}),e.setVertexInput(this.inputLayout,c,{buffer:this.indexBuffer}),e.setBindings(this.bindings),(this.useStencil||this.parentClipMode)&&e.setStencilReference($f),e.drawIndexed(15,this.instanceCount)}destroy(){var e;Po(this,hz,"m",dJ).call(this),super.destroy(),this.program&&((e=Po(this,xw,"f"))===null||e===void 0||e.destroy(),uh(this,xw,null,"f"))}generateBuffer(e){const r=e.has(Ln)?e.read(Ln).value:0,i=Hx(e),{r:s,g:o,b:n,opacity:a}=Wo(i??"transparent"),l=H0(e),{width:c,alignment:h,miterlimit:u,dasharray:d,dashoffset:f,dashcap:g}=e.has(Gt)?e.read(Gt):{width:0,alignment:"center",miterlimit:10,dasharray:[],dashoffset:0,dashcap:"none"},{r:p,g:m,b:v,opacity:b}=Wo(l??"transparent");let y=c;if(e.has(ue)){const{fillWeight:O}=e.read(ue);O!==-1&&this.index===2&&(y=O)}const _=e.has(bo)?e.read(bo).opacity:1,{strokeColorAlphaMul:w,strokeUniformOpacityMul:E}=b2(e);let A=[p/255,m/255,v/255,b*w];const x=[(r+.1)/Ew,y,u,Bee[h]],S=[_,1,E,e.has(Qn)?1:0],T=[d&&d[0]||0,d&&d[1]||0,f||0,g==="square"?1:g==="round"?2:0],R=this.shapes[0];if(R.has(ue)&&(R.hasSomeOf(et,ae,xt)&&this.index===1||R.has($t)&&this.index===2))A=[s/255,o/255,n/255,a],S[2]=pj(R);else if(R.has(Yt)&&R.has(wa)){const{color:O,thickness:C,style:F}=R.read(wa),{fontMetrics:U}=R.read(Ji),H=Wo(O);A=[H.r/255,H.g/255,H.b/255,a],x[1]=C;const N=U.fontSize/14;F==="dotted"?(T[0]=N*1.5,T[1]=N):F==="dashed"&&(T[0]=N*4,T[1]=N*2),T[3]=0}let B=[0,0,0,0];if(EX(e)){const O=nvt(e,()=>
9116dz(e)),C=O.maxX-O.minX,F=O.maxY-O.minY;B=[O.minX,O.minY,C===0?0:1/C,F===0?0:1/F]}else if(kh(e)!=null&&!(e.has(ue)&&(e.hasSomeOf(et,ae,xt)&&this.index===1||e.has($t)&&this.index===2))){const{minX:O,minY:C,maxX:F,maxY:U}=dz(e),H=F-O,N=U-C;B=[O,C,H===0?0:1/H,N===0?0:1/N]}return[[...A,...x,...S,...T,...B],{u_StrokeColor:A,u_ZIndexStrokeWidth:x,u_Opacity:S,u_StrokeDash:T,u_StrokeUVRect:B}]}}_y=new WeakMap,hB=new WeakMap,bS=new WeakMap,uB=new WeakMap,wS=new WeakMap,kg=new WeakMap,xw=new WeakMap,hz=new WeakSet,dJ=function(){var t,e,r;this.destroyFullPostProcessingChain(),(t=Po(this,bS,"f"))===null||t===void 0||t.destroy(),uh(this,bS,null,"f"),Po(this,hB,"f")||(r=(e=Po(this,_y,"f"))===null||e===void 0?void 0:e.destroy)===null||r===void 0||r.call(e),uh(this,_y,null,"f"),uh(this,hB,!1,"f")};function _vt(t){let e;switch(t){case"bevel":e=yn.JOINT_BEVEL;break;case"round":e=yn.JOINT_ROUND;break;default:e=yn.JOINT_MITER;break}return e}function fz(t){let e;switch(t){case"square":e=yn.CAP_SQUARE;break;case"round":e=yn.CAP_ROUND;break;default:e=yn.CAP_BUTT;break}return e}function bvt(t,e,r,i,s){if(e==="none")return[];const o=r?[t[0],t[1]]:[t[t.length-2],t[t.length-1]],n=r?[t[2],t[3]]:[t[t.length-4],t[t.length-3]],a=[n[0]-o[0],n[1]-o[1]],l=Math.atan2(a[1],a[0]);let c=[];if(e==="line"){const h=i*s;c=sQ(o[0],o[1],h,l).flat()}else if(e==="triangle"){const h=i*s,u=o,d=[u[0]+h*Math.cos(l+Math.PI/6),u[1]+h*Math.sin(l+Math.PI/6)],f=[u[0]+h*Math.cos(l-Math.PI/6),u[1]+h*Math.sin(l-Math.PI/6)];c=[...d,...u,...f,...d]}else if(e==="diamond"){const h=i*s,u=Math.cos(l),d=Math.sin(l),f=o,g=[f[0]+u*h*.5,f[1]+d*h*.5],p=[f[0]+u*h,f[1]+d*h],m=h*.4,v=[g[0]-d*m,g[1]+u*m],b=[g[0]+d*m,g[1]-u*m];c=[...f,...v,...p,...b,...f]}return[NaN,NaN,...c,NaN,NaN]}function Oee(t,e,r,i,s){const o=bvt(t,e,!0,i,s),n=bvt(t,r,!1,i,s);return[...o,...n]}function Iee(t,e=!0){const{linecap:r,linejoin:i,width:s}=t.has(Gt)?t.read(Gt):{linecap:"butt",linejoin:"miter",width:1},{start:o,end:n,factor:a}=t.has(qo)?t.read(qo):{start:"none",end:"none",factor:3};let l=[],c,h;if(t.has(ue)&&t.has(iu)&&t.hasSomeOf(et,ae,$t,Mt,_t,xt)){const{strokePoints:b,fillPoints:y}=t.read(iu),_=e?b:y;l=_.map((w,E)=>[...w].concat(E!==_.length-1?[NaN,NaN]:[])).flat(2)}else if(t.has(_t))l=t.read(_t).points.reduce((b,y)=>(b.push(y[0],y[1]),b),[]);else if(t.has(Mt)){const{x1:b,y1:y,x2:_,y2:w}=t.read(Mt);l=[b,y,_,w]}else if(t.has(ke)){const{vertices:b,segments:y}=t.read(ke),_=ree(b,y);l=_.points,c=_.linejoin,h=_.linecap}else if(t.has(xt)){const b=t.read(wo).points;l=b.map((y,_)=>[...y].concat(_!==b.length-1?[NaN,NaN]:[])).flat(2),l.length===2&&l.push(l[0]+uz,l[1])}else if(t.has($t)){const{x:b,y,width:_,height:w}=t.read($t);l=[b,y,b+_,y,b+_,y+w,b,y+w,b,y,b+uz,y]}else if(t.has(et)){const{cx:b,cy:y,r:_}=t.read(et);for(let w=0;w<eU;w++){const E=w/eU*Math.PI*2;l.push(b+_*Math.cos(E),y+_*Math.sin(E))}l.push(b+_,y)}else if(t.has(ae)){const{cx:b,cy:y,rx:_,ry:w}=t.read(ae);for(let E=0;E<eU;E++){const A=E/eU*Math.PI*2;l.push(b+_*Math.cos(A),y+w*Math.sin(A))}l.push(b+_,y)}else if(t.has(Yt)&&t.has(wa)){const{anchorX:b,anchorY:y}=t.read(Yt),{line:_,style:w,thickness:E}=t.read(wa),{lineMetrics:A,height:x}=t.read(Ji);A.forEach((S,T)=>{const R=[];let B=0,O=0;const C=E;if(w==="wavy"){let U="M 0 0";for(;O+C*2<S.width;)U+=` Q ${O+C} ${B%2!=0?C:-C} ${O+C*2} 0`,O+=C*2,++B;const{subPaths:H}=a3(U),N=H.map(G=>G.getPoints().map(Y=>[Y[0],Y[1]]));R.push(...N.flat(2))}else R.push(0,0,S.width,0);let F=0;_==="underline"||_==="overline"?F=x:_==="line-through"&&(F=x/2),R.forEach((U,H)=>{H%2===0?R[H]+=b+S.x:R[H]+=y+S.y+F}),T!==A.length-1&&R.push(NaN,NaN),l.push(...R)})}if((t.has(Mt)||t.has(_t)||t.has(xt)||t.has(ke))&&l.push(...Oee(l,o,n,s,a)),c&&c.length<l.length/2){const b=l.length/2-c.length;c=[...c,...Array(b).fill(void 0)],h&&(h=[...h,...Array(b).fill(void 0)])}const u=_vt(i),d=fz(r),f=[];let g=0;for(let b=0;b<l.length;b+=Lg)(isNaN(l[b])||isNaN(l[b+1]))&&(f.push(l.slice(g,b)),g=b+2);f.push(l.slice(g));const p=[],m=[];let v=0;return f.forEach((b,y)=>{if(b.length<Lg*2)return;const _=[],w=[0];let E=(Math.round(0/Lg)+2)*vvt,A=0,x=!1;if(b.length>=6&&b[0]===b[b.length-2]&&b[1]===b[b.length-1]){const B=[b[2]-b[0],b[3]-b[1]];b.push(b[0]+uz*B[0],b[1]+uz*B[1]),x=!0}for(let B=0;B<b.length;B+=Lg){const O=v+B/Lg,C=(c==null?void 0:c[O])!==void 0?c[O]:void 0,F=(h==null?void 0:h[O])!==void 0?h[O]:void 0,U=C!==void 0?_vt(C):u,H=F!==void 0?fz(F):d,N=F!==void 0?fz(F):d;let G=N;N===yn.CAP_ROUND&&(G=yn.JOINT_CAP_ROUND),N===yn.CAP_BUTT&&(G=yn.JOINT_CAP_BUTT),N===yn.CAP_SQUARE&&(G=yn.JOINT_CAP_SQUARE),B>1&&(x&&B>=b.length-Lg||(A+=Math.sqrt(Math.pow(b[B]-b[B-Lg],2)+Math.pow(b[B+1]-b[B+1-Lg],2)),w.push(A))),_[E++]=b[B],_[E++]=b[B+1],_[E]=U,B==0?H!==yn.CAP_ROUND&&(_[E]+=H):(isNaN(b[B-2])||isNaN(b[B-1]))&&
9116(_[E]+=yn.CAP_BUTT),B+Lg*2>=b.length||isNaN(b[B+4])||isNaN(b[B+5])?_[E]+=G-U:(B+Lg>=b.length||isNaN(b[B+2])||isNaN(b[B+3]))&&(_[E]=0),E++}_[E++]=b[b.length-4],_[E++]=b[b.length-3],_[E++]=0,_[0]=b[0],_[1]=b[1],_[2]=0,_[3]=b[2],_[4]=b[3];const S=v,T=(h==null?void 0:h[S])!==void 0?h[S]:void 0,R=T!==void 0?fz(T):d;_[5]=R===yn.CAP_ROUND?R:0,p.push(..._),m.push(...w),v+=b.length/Lg,y<f.length-1&&(v+=1)}),{pointsBuffer:p,travelBuffer:m}}var pz;(function(t){t[t.BARYCENTRIC=0]="BARYCENTRIC",t[t.POSITION=1]="POSITION"})(pz||(pz={}));const Dee=` 9117layout(std140) uniform SceneUniforms { 9118 mat3 u_ProjectionMatrix; 9119 mat3 u_ViewMatrix; 9120 mat3 u_ViewProjectionInvMatrix; 9121 vec4 u_BackgroundColor; 9122 vec4 u_GridColor; 9123 float u_ZoomScale; 9124 float u_CheckboardStyle; 9125}; 9126 9127${iB} 9128layout(location = ${pz.POSITION}) in vec2 a_Position; 9129 9130layout(std140) uniform ShapeUniforms { 9131 mat3 u_ModelMatrix; 9132 vec4 u_FillColor; 9133 vec4 u_StrokeColor; 9134 vec4 u_ZIndexStrokeWidth; 9135 vec4 u_Opacity; 9136 vec4 u_FillUVRect; 9137}; 9138 9139#ifdef USE_FILLIMAGE 9140out vec2 v_Uv; 9141#endif 9142 9143void main() { 9144 ${rB} 9145 9146 mat3 model; 9147 vec4 fillColor; 9148 vec4 strokeColor; 9149 float zIndex; 9150 float strokeWidth; 9151 float strokeAlignment; 9152 float sizeAttenuation; 9153 model = u_ModelMatrix; 9154 fillColor = u_FillColor; 9155 strokeColor = u_StrokeColor; 9156 zIndex = u_ZIndexStrokeWidth.x; 9157 strokeWidth = u_ZIndexStrokeWidth.y; 9158 strokeAlignment = u_ZIndexStrokeWidth.w; 9159 sizeAttenuation = u_Opacity.w; 9160 9161 float scale = 1.0; 9162 if (sizeAttenuation > 0.5) { 9163 scale = 1.0 / u_ZoomScale; 9164 } 9165 9166 #ifdef USE_FILLIMAGE 9167 v_Uv = (a_Position - u_FillUVRect.xy) * u_FillUVRect.zw; 9168 #endif 9169 9170 gl_Position = vec4((u_ProjectionMatrix 9171 * u_ViewMatrix 9172 * model 9173 * vec3(a_Position * scale, 1)).xy, zIndex, 1); 9174} 9175`,Pee=` 9176layout(std140) uniform SceneUniforms { 9177 mat3 u_ProjectionMatrix; 9178 mat3 u_ViewMatrix; 9179 mat3 u_ViewProjectionInvMatrix; 9180 vec4 u_BackgroundColor; 9181 vec4 u_GridColor; 9182 float u_ZoomScale; 9183 float u_CheckboardStyle; 9184}; 9185 9186layout(std140) uniform ShapeUniforms { 9187 mat3 u_ModelMatrix; 9188 vec4 u_FillColor; 9189 vec4 u_StrokeColor; 9190 vec4 u_ZIndexStrokeWidth; 9191 vec4 u_Opacity; 9192 vec4 u_FillUVRect; 9193}; 9194 9195${aS} 9196 9197out vec4 outputColor; 9198 9199#ifdef USE_FILLIMAGE 9200in vec2 v_Uv; 9201uniform sampler2D u_Texture; 9202#endif 9203 9204float epsilon = 0.000001; 9205 9206void main() { 9207 float strokeWidth; 9208 vec4 fillColor; 9209 vec4 strokeColor; 9210 float opacity; 9211 float fillOpacity; 9212 float strokeOpacity; 9213 float cornerRadius; 9214 float strokeAlignment; 9215 9216 fillColor = u_FillColor; 9217 strokeColor = u_StrokeColor; 9218 strokeWidth = u_ZIndexStrokeWidth.y; 9219 opacity = u_Opacity.x; 9220 fillOpacity = u_Opacity.y; 9221 strokeOpacity = u_Opacity.z; 9222 cornerRadius = u_ZIndexStrokeWidth.z; 9223 strokeAlignment = u_ZIndexStrokeWidth.w; 9224 9225 #ifdef USE_FILLIMAGE 9226 fillColor = texture(SAMPLER_2D(u_Texture), v_Uv); 9227 float _layerAlphaMul = 9228 (dot(u_FillColor.rgb, vec3(1.0)) < 0.001 && u_FillColor.a < 0.001) 9229 ? 1.0 9230 : u_FillColor.a; 9231 fillColor.a *= _layerAlphaMul; 9232 #endif 9233 9234 // based on the target alpha compositing mode. 9235 fillColor.a *= fillOpacity; 9236 strokeColor.a *= strokeOpacity; 9237 9238 outputColor = fillColor; 9239 outputColor.a *= opacity; 9240 9241 ${nv} 9242 9243 #ifndef USE_STENCIL 9244 if (outputColor.a < epsilon) 9245 discard; 9246 #endif 9247} 9248`;var Fo=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Hr=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Sw,Xh,Tw,ES,dh,dB,Ug,AS,xS,by;const Fee={center:0,inner:1,outer:2};class SS extends dS{constructor(){super(...arguments),Sw.set(this,void 0),Xh.set(this,void 0),Tw.set(this,null),ES.set(this,!1),dh.set(this,[]),dB.set(this,[]),Ug.set(this,null),AS.set(this,[]),xS.set(this,null),by.set(this,!1),this.points=[],this.instanced=!1}static useDash(e){const{dasharray:r=[]}=e.has(Gt)?e.read(Gt):{dasharray:[]};return r[0]>0&&r[1]>0}
9248applyRasterFilterChainIfNeeded(e,r,i,s){var o;const n=Hl(e);if(this.instanced||!n)return r;const a=G2(Iv(n));if(a.length===0)return r;Fo(this,Tw,r,"f");const l=BV(),c=this.getPostChain(),h=(o=c==null?void 0:c.isReadyForSize(i,s))!==null&&o!==void 0?o:!1;(!l||!h||!(c!=null&&c.syncEffects(a)))&&this.createPostProcessing(a,r,i,s);const{texture:u}=this.renderPostProcessingTextureSpace(i,s);return Fo(this,ES,!0,"f"),u}disposeMeshFillLayerResources(){var e,r,i;const s=Hr(this,by,"f")&&!Hr(this,ES,"f")&&Hr(this,Xh,"f")!=null?Hr(this,Xh,"f"):null;Fo(this,by,!1,"f");for(const n of Hr(this,dB,"f"))n.destroy();Fo(this,dB,[],"f"),(e=Hr(this,xS,"f"))===null||e===void 0||e.destroy(),Fo(this,xS,null,"f");for(const n of Hr(this,AS,"f"))n.destroy();Fo(this,AS,[],"f"),Fo(this,Ug,null,"f");const o=Hr(this,Xh,"f")!=null&&Hr(this,dh,"f").includes(Hr(this,Xh,"f"));for(const n of Hr(this,dh,"f"))(r=n.destroy)===null||r===void 0||r.call(n);Fo(this,dh,[],"f"),o&&Fo(this,Xh,null,"f"),(i=s==null?void 0:s.destroy)===null||i===void 0||i.call(s)}createMeshFillLayerTexture(e,r,i,s,o,n){var a,l;if(r.type==="image"){const p=hG(this.api,e,r),{width:m,height:v}=uJ(r.value,o,n,p.objectFit),b=uG(r.value,m,v,()=>nt(e,yi),p),y=b??mvt(m,v),_=this.device.createTexture({format:X.U8_RGBA_NORM,width:m,height:v,usage:vi.SAMPLED});hE(_,y);const w=wO(r.value),E=w?Math.max(1,w.width):1,A=w?Math.max(1,w.height):1;return Sbt({entity:e,url:r.value,targetW:m,targetH:v,sourceW:E,sourceH:A,rasterOptions:p}),this.applyRasterFilterChainIfNeeded(e,_,m,v)}if(r.type==="pattern"){const p=Math.max(1,Math.ceil(o)),m=Math.max(1,Math.ceil(n)),v=this.texturePool.getOrCreatePattern({pattern:{image:r.value,repetition:(a=r.repetition)!==null&&a!==void 0?a:"repeat",transform:(l=r.transform)!==null&&l!==void 0?l:""},width:p,height:m}),b=this.device.createTexture({format:X.U8_RGBA_NORM,width:p,height:m,usage:vi.SAMPLED});return b.setImageData([v]),this.applyRasterFilterChainIfNeeded(e,b,p,m)}if(r.type==="solid"){const p=Math.max(1,Math.ceil(o)),m=Math.max(1,Math.ceil(n)),{r:v,g:b,b:y,opacity:_}=Wo(r.value),w=Pr.get().createCanvas(p,m),E=w.getContext("2d");if(!E)throw new Error("Canvas 2D required for FillLayers solid raster");E.fillStyle=`rgba(${v},${b},${y},${_})`,E.fillRect(0,0,p,m);const A=this.device.createTexture({format:X.U8_RGBA_NORM,width:p,height:m,usage:vi.SAMPLED});return hE(A,w),this.applyRasterFilterChainIfNeeded(e,A,p,m)}const c=Math.max(1,Math.ceil(o)),h=Math.max(1,Math.ceil(n)),u=nm(r.value),d=u!==void 0&&u.length===1?u[0]:void 0;if(d&&Zy(d)){const p=this.renderMeshGradientTexture(d,c,h);return this.applyRasterFilterChainIfNeeded(e,p,c,h)}const f=this.texturePool.getOrCreateGradient({gradients:u??[],min:[i,s],width:c,height:h}),g=this.device.createTexture({format:X.U8_RGBA_NORM,width:c,height:h,usage:vi.SAMPLED});return g.setImageData([f]),this.applyRasterFilterChainIfNeeded(e,g,c,h)}validate(e){var r,i;if(!super.validate(e))return!1;if(this.shapes.length===0)return!0;const s=this.shapes[0].has(ue)&&this.shapes[0].read(ue).fillStyle==="watercolor",o=e.has(ue)&&e.read(ue).fillStyle==="watercolor";if(s!==o||this.shapes[0].has(xt)&&e.has(xt)&&this.shapes[0].read(xt).d!==e.read(xt).d)return!1;const n=this.shapes[0].has(ke)?this.shapes[0].read(ke):null,a=e.has(ke)?e.read(ke):null;if(n===null!=(a===null))return!1;if(n&&a){const v=b=>JSON.stringify({vertices:b.vertices,segments:b.segments,regions:b.regions});if(v(n)!==v(a))return!1}const l=this.shapes[0].has(yh),c=e.has(yh);if(l!==c)return!1;const h=Hl(this.shapes[0]),u=Hl(e);if(!!h!=!!u||h&&u&&h!==u)return!1;const d=this.shapes[0].has(Ce)?this.shapes[0].read(Ce).layers:null,f=e.has(Ce)?e.read(Ce).layers:null;if(d==null!=(f==null)||d&&f&&JSON.stringify(d)!==JSON.stringify(f))return!1;const g=this.api.getNodeByEntity(this.shapes[0]),p=this.api.getNodeByEntity(e);if(JSON.stringify((r=g==null?void 0:g.fills)!==null&&r!==void 0?r:null)!==JSON.stringify((i=p==null?void 0:p.fills)!==null&&i!==void 0?i:null))return!1;const m=v=>{var b;return(b=v==null?void 0:v.some(y=>y.type==="image"))!==null&&b!==void 0?b:!1};return!(m(d)||m(f))}createGeometry(){var e,r;const i=this.shapes[0];let s,o,n;if(i.has(ue)&&i.has(iu)&&i.hasSomeOf(et,ae,$t,xt))s=i.read(iu).fillPathPoints,o=im.EARCUT;else if(i.has(xt))s=i.read(wo).points,o=i.read(xt).tessellationMethod;else if(i.has(ke)){const{vertices:a,segments:l,regions:c}=i.read(ke);n=KV(a,l,c)}if(n!==void 0)this.points=n.points,this.indexBufferData=new Uint32Array(n.indices);else if(s!==void 0&&o!==void 0){const a=s.flat(2);if(a.length>0){if(o===im.EARCUT){let l=[],c=[];const h=[];let u=0,d=Cq(s[0]);
9248s.forEach(f=>{Cq(f)!==d?l.push(c.length):(d=Cq(f),l.length>0&&(h.push(...rT(c.flat(),l).map(g=>g+u)),u+=c.length,l=[],c=[])),c.push(...f)}),c.length&&h.push(...rT(c.flat(),l).map(f=>f+u)),this.indexBufferData=new Uint32Array(h),this.points=a}else if(o===im.LIBTESS){const l=kq(s,i.read(xt).fillRule);this.indexBufferData=new Uint32Array(new Array(l.length/2).fill(void 0).map((c,h)=>h)),this.points=l}}else this.points=[],this.indexBufferData=new Uint32Array([])}else this.points=[],this.indexBufferData=new Uint32Array([]);this.vertexBuffers[0]&&this.vertexBuffers[0].destroy(),this.vertexBufferDatas[0]=new Float32Array((e=this.points)!==null&&e!==void 0?e:[]),this.vertexBuffers[0]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[0],usage:Ee.VERTEX,hint:rr.STATIC}),this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=this.device.createBuffer({viewOrSize:(r=this.indexBufferData)!==null&&r!==void 0?r:new Uint32Array([]),usage:Ee.INDEX,hint:rr.STATIC}),this.vertexBufferDescriptors=[{arrayStride:8,stepMode:Pi.VERTEX,attributes:[{shaderLocation:pz.POSITION,offset:0,format:X.F32_RG}]}]}createMaterial(e,r){var i,s;this.createProgram(Dee,Pee,e),this.disposeMeshFillLayerResources(),Hr(this,Sw,"f")||Fo(this,Sw,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*40,usage:Ee.UNIFORM,hint:rr.DYNAMIC}),"f"),this.pipeline=this.renderCache.createRenderPipeline({inputLayout:this.inputLayout,program:this.program,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:X.D24_S8,topology:Ia.TRIANGLES,megaStateDescriptor:Object.assign({attachmentsState:[{channelWriteMask:oo.ALL,rgbBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.SRC_ALPHA,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA}}],blendConstant:Ra,depthWrite:!this.isWatercolorRoughMesh(),depthCompare:li.GREATER},this.stencilDescriptor)}),this.device.setResourceName(this.pipeline,"MeshPipeline");const o=!this.instanced&&!((i=this.shapes[0])===null||i===void 0)&&i.has(Ce)?$0(this.shapes[0]):null,n=o!=null&&o.length>1;n&&(Fo(this,Ug,this.renderCache.createRenderPipeline({inputLayout:this.inputLayout,program:this.program,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:X.D24_S8,topology:Ia.TRIANGLES,megaStateDescriptor:Object.assign({attachmentsState:[{channelWriteMask:oo.ALL,rgbBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.SRC_ALPHA,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA}}],blendConstant:Ra,depthWrite:!1,depthCompare:li.GREATER},this.stencilDescriptor)}),"f"),this.device.setResourceName(Hr(this,Ug,"f"),"MeshPipelineMultiFillMidPass"));const a={pipeline:this.pipeline,uniformBufferBindings:[{buffer:r},{buffer:Hr(this,Sw,"f")}]};if(this.useFillImage){this.bindings&&this.bindings.destroy();const l=this.shapes[0];Fo(this,ES,!1,"f"),Hl(l)||this.destroyFullPostProcessingChain(),Hr(this,Tw,"f")&&(Hr(this,Tw,"f").destroy(),Fo(this,Tw,null,"f"));const c=$0(l);if(c&&(aw(c)||LL(c))&&c){const{minX:h,minY:u,maxX:d,maxY:f}=lS(l),g=d-h,p=f-u;if(Fo(this,dh,c.map(m=>this.createMeshFillLayerTexture(l,m,h,u,g,p)),"f"),LL(c)){const m=Math.max(1,...Hr(this,dh,"f").map(y=>y.width)),v=Math.max(1,...Hr(this,dh,"f").map(y=>y.height)),b=apt(this.device,this.renderCache,c,Hr(this,dh,"f"),m,v,()=>this.createSampler());for(const y of Hr(this,dh,"f"))(s=y.destroy)===null||s===void 0||s.call(y);Fo(this,dh,[],"f"),Fo(this,Xh,b,"f"),Fo(this,by,!0,"f")}else Fo(this,Xh,Hr(this,dh,"f")[0],"f"),Fo(this,by,!1,"f")}else if(l.has(Ce)){const h=fj(l);if(h){const{minX:u,minY:d,maxX:f,maxY:g}=lS(l),p=f-u,m=g-d;Fo(this,Xh,this.createMeshFillLayerTexture(l,h,u,d,p,m),"f")}}else l.has(yh)&&Fo(this,Xh,l.read(yh).value,"f");a.samplerBindings=[{texture:Hr(this,Xh,"f"),sampler:this.createSampler()}]}if(this.bindings=this.renderCache.createBindings(a),n&&Hr(this,Ug,"f")){const l={pipeline:Hr(this,Ug,"f"),uniformBufferBindings:a.uniformBufferBindings};a.samplerBindings&&(l.samplerBindings=a.samplerBindings),Fo(this,xS,this.renderCache.createBindings(l),"f")}if(Hr(this,dh,"f").length>0&&a.samplerBindings){const l=this.createSampler();if(Fo(this,dB,Hr(this,dh,"f").map(c=>this.renderCache.createBindings({pipeline:this.pipeline,uniformBufferBindings:a.uniformBufferBindings,samplerBindings:[{texture:c,sampler:l}]})),"f"),n&&Hr(this,Ug,"f")){const c=this.createSampler();Fo(this,AS,Hr(this,dh,"f").map(h=>this.renderCache.createBindings({pipeline:Hr(this,Ug,"f"),uniformBufferBindings:a.uniformBufferBindings,samplerBindings:[{texture:h,sampler:c}]})),"f")}}}isWatercolorRoughMesh(){var e;return!!(!((e=this.shapes[0])===null||e===void 0)&&e.has(ue))&&this.shapes[0].read(ue).fillStyle==="watercolor"}render(e,r,i){const s=this.shapes[0].has(ue)?this.shapes[0].read(ue).fillStyle:null;if(this.points.length===0||s!==null&&s!=="solid"&&s!=="watercolor")return;const o=this.shapes[0],n=$0(o);if(n&&!Hr(this,by,"f")){this.useWireframe&&this.geometryDirty&&this.generateWireframe();const{matrix:f}=o.read(Ae),g=[f.m00,f.m01,f.m02,f.m10,f.m11,f.m12,f.m20,f.m21,f.m22],p=aw(n);for(let m=0;m<n.length;m++){const v=n.length>1&&m<n.length-1,b=v&&Hr(this,Ug,"f")?Hr(this,Ug,"f"):this.pipeline,[y,_]=this.generateBuffer(o,{kind:"fill-layer",layerIndex:m});Hr(this,Sw,"f").setSubData(0,new Uint8Array(new Float32Array([...sh(ie.fromGLMat3(g)),...y]).buffer));const w=Object.assign({u_ModelMatrix:g},_);p&&(w.u_FillImage=Hr(this,dh,"f")[m]);const E=Object.assign(Object.assign({},w),i);
9248this.program.setUniformsLegacy(E),e.setPipeline(b);const A=this.vertexBuffers.map(S=>({buffer:S}));this.useWireframe&&A.push({buffer:this.barycentricBuffer}),e.setVertexInput(this.inputLayout,A,{buffer:this.indexBuffer});const x=p?v&&Hr(this,AS,"f").length>0?Hr(this,AS,"f")[m]:Hr(this,dB,"f")[m]:v&&Hr(this,xS,"f")?Hr(this,xS,"f"):this.bindings;e.setBindings(x),(this.useStencil||this.parentClipMode)&&e.setStencilReference($f),e.drawIndexed(this.indexBufferData.length,this.shapes.length)}return}const{matrix:a}=this.shapes[0].read(Ae),[l,c]=this.generateBuffer(this.shapes[0]),h=[a.m00,a.m01,a.m02,a.m10,a.m11,a.m12,a.m20,a.m21,a.m22];Hr(this,Sw,"f").setSubData(0,new Uint8Array(new Float32Array([...sh(ie.fromGLMat3(h)),...l]).buffer));const u=Object.assign({u_ModelMatrix:h},c);this.useFillImage&&(u.u_FillImage=Hr(this,Xh,"f")),this.program.setUniformsLegacy(u),this.useWireframe&&this.geometryDirty&&this.generateWireframe(),this.program.setUniformsLegacy(i),e.setPipeline(this.pipeline);const d=this.vertexBuffers.map(f=>({buffer:f}));this.useWireframe&&d.push({buffer:this.barycentricBuffer}),e.setVertexInput(this.inputLayout,d,{buffer:this.indexBuffer}),e.setBindings(this.bindings),(this.useStencil||this.parentClipMode)&&e.setStencilReference($f),e.drawIndexed(this.indexBufferData.length,this.shapes.length)}destroy(){var e,r,i,s;this.disposeMeshFillLayerResources(),this.destroyFullPostProcessingChain(),(e=Hr(this,Tw,"f"))===null||e===void 0||e.destroy(),Fo(this,Tw,null,"f"),Hr(this,ES,"f")||(i=(r=Hr(this,Xh,"f"))===null||r===void 0?void 0:r.destroy)===null||i===void 0||i.call(r),Fo(this,Xh,null,"f"),Fo(this,ES,!1,"f"),super.destroy(),this.program&&((s=Hr(this,Sw,"f"))===null||s===void 0||s.destroy())}generateBuffer(e,r){const i=e.has(Ln)?e.read(Ln).value:0;let s=Hx(e);const o=$0(e),n=Nh(e);if((r==null?void 0:r.kind)==="fill-layer"&&o){const N=o[r.layerIndex];s=N.type==="solid"?N.value:"#ffffff"}else if(!r&&n.length===1&&e.has(Ce)){const N=n[0];s=N.type==="solid"?N.value:"#ffffff"}else!r&&Hr(this,by,"f")&&e.has(Ce)&&(s="#ffffff");const{r:a,g:l,b:c,opacity:h}=Wo(s!=null&&s!==""?s:"transparent"),u=e.has(bo)?e.read(bo).opacity:1,d=H0(e),f=e.has(Gt)?e.read(Gt).width:0,g=e.has(Gt)?e.read(Gt).alignment:"center",{r:p,g:m,b:v,opacity:b}=Wo(d??"transparent"),{strokeColorAlphaMul:y,strokeUniformOpacityMul:_}=b2(e);let w=0,E=0,A=0,x=0;if(n.some(N=>N.type==="pattern")||o!=null&&aw(o)||e.has(Ce)&&(aw(n)||Hr(this,by,"f"))){const{minX:N,minY:G,maxX:Y,maxY:q}=lS(e),L=Y-N,J=q-G;w=N,E=G,A=L===0?0:1/L,x=J===0?0:1/J}else if(this.useFillImage){const{minX:N,minY:G,maxX:Y,maxY:q}=lS(e),L=Y-N,J=q-G;w=N,E=G,A=L===0?0:1/L,x=J===0?0:1/J}else w=0,E=0,A=0,x=0;let S=a/255,T=l/255,R=c/255,B=h;if((r==null?void 0:r.kind)==="fill-layer"&&o){const N=o[r.layerIndex],G=Cg(N.opacity);N.type==="gradient"?(S=1,T=1,R=1,B=G):B=h*G}else if(!r&&n.length===1&&e.has(Ce)){const N=n[0],G=Cg(N.opacity);N.type==="gradient"?(S=1,T=1,R=1,B=G):B=h*G}else!r&&Hr(this,by,"f")&&e.has(Ce)&&(S=1,T=1,R=1,B=1);const O=[S,T,R,B],C=[p/255,m/255,v/255,b*y],F=[i/Ew,SS.useDash(e)?0:f,0,Fee[g]],U=[u,1,_,0],H=[w,E,A,x];return this.isWatercolorRoughMesh()&&(U[1]*=.05),[[...O,...C,...F,...U,...H],{u_FillColor:O,u_StrokeColor:C,u_ZIndexStrokeWidth:F,u_Opacity:U,u_FillUVRect:H}]}}Sw=new WeakMap,Xh=new WeakMap,Tw=new WeakMap,ES=new WeakMap,dh=new WeakMap,dB=new WeakMap,Ug=new WeakMap,AS=new WeakMap,xS=new WeakMap,by=new WeakMap;const Nee=` 9249 vec3 mod289(vec3 x) { 9250 return x - floor(x * (1.0 / 289.0)) * 289.0; 9251 } 9252 9253 vec2 mod289(vec2 x) { 9254 return x - floor(x * (1.0 / 289.0)) * 289.0; 9255 } 9256 9257 vec3 permute(vec3 x) { 9258 return mod289(((x*34.0)+1.0)*x); 9259 } 9260 9261 float snoise(vec2 v) 9262 { 9263 const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0 9264 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) 9265 -0.577350269189626, // -1.0 + 2.0 * C.x 9266 0.024390243902439); // 1.0 / 41.0 9267 // First corner 9268 vec2 i = floor(v + dot(v, C.yy) ); 9269 vec2 x0 = v - i + dot(i, C.xx); 9270 9271 // Other corners 9272 vec2 i1; 9273 //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 9274 //i1.y = 1.0 - i1.x; 9275 i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); 9276 // x0 = x0 - 0.0 + 0.0 * C.xx ; 9277 // x1 = x0 - i1 + 1.0 * C.xx ; 9278 // x2 = x0 - 1.0 + 2.0 * C.xx ; 9279 vec4 x12 = x0.xyxy + C.xxzz; 9280 x12.xy -= i1; 9281 9282 // Permutations 9283 i = mod289(i); // Avoid truncation effects in permutation 9284 vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) 9285 + i.x + vec3(0.0, i1.x, 1.0 )); 9286 9287 vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); 9288 m = m*m ; 9289 m = m*m ; 9290 9291 // Gradients: 41 points uniformly over a line, mapped onto a diamond. 9292 // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) 9293 9294 vec3 x = 2.0 * fract(p * C.www) - 1.0; 9295 vec3 h = abs(x) - 0.5; 9296 vec3 ox = floor(x + 0.5); 9297 vec3 a0 = x - ox; 9298 9299 // Normalise gradients implicitly by scaling m 9300 // Approximation of: m *= inversesqrt( a0*a0 + h*h ); 9301 m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); 9302 9303 // Compute final noise value at P 9304 vec3 g; 9305 g.x = a0.x * x0.x + h.x * x0.y; 9306 g.yz = a0.yz * x12.xz + h.yz * x12.yw; 9307 return 130.0 * dot(m, g); 9308 }`,kee=` 9309 float aastep(float threshold, float value) { 9310 float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757; 9311 return smoothstep(threshold - afwidth, threshold + afwidth, value); 9312 } 9313`,Lee=` 9314 ${kee} 9315 ${Nee} 9316 float absorb(float sdf, vec2 uv, float scale, float falloff) { 9317 float distort = sdf + snoise(uv * scale) * falloff; 9318 return aastep(0.5, distort); 9319 } 9320`,Uee=` 9321 ${Lee} 9322 9323 // float ink(float sdf, vec2 uv) { 9324 // float alpha = 0.0; 9325 // alpha += absorb(sdf, uv, 1000.0, 0.1) * 0.3; 9326 // alpha += absorb(sdf, uv, 50.0, 0.2) * 0.3; 9327 // alpha += absorb(sdf, uv, 500.0, 0.2) * 0.3; 9328 // return alpha; 9329 // } 9330 9331 // float ink(float sdf, vec2 uv) { 9332 // float alpha = 0.0; 9333 // alpha += absorb(sdf, uv, 80.0, 0.02) * 0.1; 9334 // alpha += absorb(sdf, uv, 50.0, 0.02) * 0.1; 9335 // alpha += absorb(sdf, uv, 500.0, 0.05) * 0.2; 9336 // alpha += absorb(sdf, uv, 1000.0, 0.05) * 0.2; 9337 // alpha += absorb(sdf, uv, 3000.0, 0.1) * 0.2; 9338 // alpha += absorb(sdf, uv, 1000.0, 0.3) * 0.15; 9339 // return alpha; 9340 // } 9341 9342 float ink(float sdf, vec2 uv) { 9343 float alpha = 0.0;
9344 alpha += absorb(sdf, uv, 600.0, 0.1) * 0.2; 9345 alpha += absorb(sdf, uv, 300.0, 0.1) * 0.2; 9346 alpha += absorb(sdf, uv, 20.0, 0.05) * 0.2; 9347 alpha += absorb(sdf, uv, 400.0, 0.05) * 0.2; 9348 alpha += absorb(sdf, uv, 100.0, 0.2) * 0.2; 9349 return alpha; 9350 } 9351`;var fB;(function(t){t[t.BARYCENTRIC=0]="BARYCENTRIC",t[t.POSITION=1]="POSITION",t[t.UV_OFFSET=2]="UV_OFFSET"})(fB||(fB={}));const wvt=` 9352layout(std140) uniform SceneUniforms { 9353 mat3 u_ProjectionMatrix; 9354 mat3 u_ViewMatrix; 9355 mat3 u_ViewProjectionInvMatrix; 9356 vec4 u_BackgroundColor; 9357 vec4 u_GridColor; 9358 float u_ZoomScale; 9359 float u_CheckboardStyle; 9360}; 9361 9362layout(std140) uniform ShapeUniforms { 9363 mat3 u_ModelMatrix; 9364 vec4 u_FillColor; 9365 vec4 u_StrokeColor; 9366 vec4 u_ZIndexStrokeWidth; 9367 vec4 u_Opacity; 9368 vec4 u_DropShadowColor; 9369 vec4 u_DropShadow; 9370 vec2 u_AtlasSize; 9371 vec4 u_FillUVRect; 9372}; 9373 9374${iB} 9375layout(location = ${fB.POSITION}) in vec3 a_Position; 9376layout(location = ${fB.UV_OFFSET}) in vec4 a_UvOffset; 9377 9378out vec2 v_Uv; 9379#ifdef USE_FILLIMAGE 9380out vec2 v_FillUv; 9381#endif 9382 9383void main() { 9384 ${rB} 9385 9386 #ifdef USE_INSTANCES 9387 float zIndex = a_Position.z; 9388 #else 9389 float zIndex = u_ZIndexStrokeWidth.x; 9390 #endif 9391 9392 float strokeWidth = u_ZIndexStrokeWidth.y; 9393 float fontSize = u_ZIndexStrokeWidth.z; 9394 float sizeAttenuation = u_Opacity.w; 9395 9396 float scale = 1.0; 9397 if (sizeAttenuation > 0.5) { 9398 scale = 1.0 / u_ZoomScale; 9399 } 9400 9401 v_Uv = a_UvOffset.xy / u_AtlasSize; 9402 vec2 offset = a_UvOffset.zw; 9403 9404 vec2 localPos = a_Position.xy + offset * scale; 9405#ifdef USE_FILLIMAGE 9406 // Render-to-texture uses framebuffer/texture row order vs. our top-down local UVs; flip V 9407 // so filtered RGBA matches on-screen SDF orientation (same issue as mesh FillImage from GPU RT). 9408 v_FillUv = (localPos - u_FillUVRect.xy) * u_FillUVRect.zw; 9409 v_FillUv.y = 1.0 - v_FillUv.y; 9410#endif 9411 9412 gl_Position = vec4((u_ProjectionMatrix 9413 * u_ViewMatrix 9414 * u_ModelMatrix 9415 * vec3(localPos, 1)).xy, zIndex, 1); 9416} 9417`,Evt=` 9418layout(std140) uniform SceneUniforms { 9419 mat3 u_ProjectionMatrix; 9420 mat3 u_ViewMatrix; 9421 mat3 u_ViewProjectionInvMatrix; 9422 vec4 u_BackgroundColor; 9423 vec4 u_GridColor; 9424 float u_ZoomScale; 9425 float u_CheckboardStyle; 9426}; 9427 9428layout(std140) uniform ShapeUniforms { 9429 mat3 u_ModelMatrix; 9430 vec4 u_FillColor; 9431 vec4 u_StrokeColor; 9432 vec4 u_ZIndexStrokeWidth; 9433 vec4 u_Opacity; 9434 vec4 u_DropShadowColor; 9435 vec4 u_DropShadow; 9436 vec2 u_AtlasSize; 9437 vec4 u_FillUVRect; 9438}; 9439 9440out vec4 outputColor; 9441 9442${aS} 9443in vec2 v_Uv; 9444#ifdef USE_FILLIMAGE 9445in vec2 v_FillUv; 9446#endif 9447uniform sampler2D u_Texture; 9448 9449float epsilon = 0.000001; 9450 9451float median(float r, float g, float b) { 9452 return max(min(r, g), min(max(r, g), b)); 9453} 9454 9455#define SDF_PX 8.0 9456 9457void main() { 9458#ifdef USE_FILLIMAGE 9459 outputColor = texture(SAMPLER_2D(u_Texture), v_FillUv); 9460 outputColor.a *= u_Opacity.x; 9461 ${nv} 9462 if (outputColor.a < epsilon) 9463 discard; 9464#else 9465 float strokeWidth = u_ZIndexStrokeWidth.y; 9466 vec4 fillColor = u_FillColor; 9467 vec4 strokeColor = u_StrokeColor; 9468 float opacity = u_Opacity.x; 9469 float fillOpacity = u_Opacity.y; 9470 float strokeOpacity = u_Opacity.z; 9471 float shapeSizeAttenuation = u_Opacity.w; 9472 vec4 dropShadow = u_DropShadow; 9473 vec4 dropShadowColor = u_DropShadowColor; 9474 float shadowDist; 9475 float shadowBlurRadius = u_DropShadow.z; 9476 9477 #ifdef USE_SDF_NONE 9478 outputColor = texture(SAMPLER_2D(u_Texture), v_Uv); 9479 #else 9480 float dist; 9481 lowp float buff; 9482 vec2 shadowOffset = u_DropShadow.xy / u_AtlasSize; 9483 9484 #ifdef USE_SDF 9485 #ifdef USE_EMOJI 9486 fillColor = texture(SAMPLER_2D(u_Texture), v_Uv); 9487 #endif 9488 dist = texture(SAMPLER_2D(u_Texture), v_Uv).a; 9489 buff = (256.0 - 64.0) / 256.0; 9490 9491 #ifdef USE_SHADOW 9492 shadowDist = texture(SAMPLER_2D(u_Texture), v_Uv - shadowOffset).a; 9493 #endif 9494 #endif 9495 9496 #ifdef USE_MSDF 9497 vec3 s = texture(SAMPLER_2D(u_Texture), v_Uv).rgb; 9498 dist = median(s.r, s.g, s.b); 9499 buff = 0.5; 9500 9501 #ifdef USE_SHADOW 9502 vec3 shadowSample = texture(SAMPLER_2D(u_Texture), v_Uv - shadowOffset).rgb; 9503 shadowDist = median(shadowSample.r, shadowSample.g, shadowSample.b); 9504 #endif 9505 #endif 9506 9507 float fontSize = u_ZIndexStrokeWidth.z; 9508 fillColor.a *= fillOpacity; 9509 strokeColor.a *= strokeOpacity; 9510 9511 highp float gamma_scaled = fwidth(dist); 9512 if (strokeWidth > 0.0 && strokeColor.a > 0.0) { 9513 float fillAlpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); 9514 float strokeThreshold = buff - strokeWidth / fontSize; 9515 float strokeAlpha = smoothstep(strokeThreshold - gamma_scaled, strokeThreshold + gamma_scaled, dist); 9516 9517 vec4 finalColor = mix(strokeColor, fillColor, fillAlpha); 9518 outputColor = finalColor; 9519 opacity *= strokeAlpha; 9520 } else { 9521 highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); 9522 opacity *= alpha; 9523 outputColor = fillColor; 9524 } 9525 #endif 9526 9527 outputColor.a *= opacity; 9528 9529 #ifdef USE_SHADOW 9530 // gamma_scaled = fwidth(shadowDist) * 128.0 / shadowBlurRadius; 9531 gamma_scaled = shadowBlurRadius / 128.0; 9532 highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, shadowDist); 9533 dropShadowColor.a *= alpha; 9534 outputColor = mix(dropShadowColor, outputColor, outputColor.a); 9535 #endif 9536 9537 ${nv} 9538 9539 if (outputColor.a < epsilon) 9540 discard; 9541#endif 9542} 9543`,Avt=` 9544layout(std140) uniform SceneUniforms { 9545 mat3 u_ProjectionMatrix; 9546 mat3 u_ViewMatrix; 9547 mat3 u_ViewProjectionInvMatrix;
9548 vec4 u_BackgroundColor; 9549 vec4 u_GridColor; 9550 float u_ZoomScale; 9551 float u_CheckboardStyle; 9552}; 9553 9554layout(std140) uniform ShapeUniforms { 9555 mat3 u_ModelMatrix; 9556 vec4 u_FillColor; 9557 vec4 u_StrokeColor; 9558 vec4 u_ZIndexStrokeWidth; 9559 vec4 u_Opacity; 9560 vec4 u_DropShadowColor; 9561 vec4 u_DropShadow; 9562 vec2 u_AtlasSize; 9563 vec4 u_FillUVRect; 9564}; 9565 9566out vec4 outputColor; 9567 9568${aS} 9569in vec2 v_Uv; 9570#ifdef USE_FILLIMAGE 9571in vec2 v_FillUv; 9572#endif 9573uniform sampler2D u_Texture; 9574 9575float epsilon = 0.000001; 9576 9577float median(float r, float g, float b) { 9578 return max(min(r, g), min(max(r, g), b)); 9579} 9580 9581${Uee} 9582 9583#define SDF_PX 8.0 9584 9585void main() { 9586#ifdef USE_FILLIMAGE 9587 outputColor = texture(SAMPLER_2D(u_Texture), v_FillUv); 9588 outputColor.a *= u_Opacity.x; 9589 ${nv} 9590 if (outputColor.a < epsilon) 9591 discard; 9592#else 9593 float strokeWidth = u_ZIndexStrokeWidth.y; 9594 vec4 fillColor = u_FillColor; 9595 vec4 strokeColor = u_StrokeColor; 9596 float opacity = u_Opacity.x; 9597 float fillOpacity = u_Opacity.y; 9598 float strokeOpacity = u_Opacity.z; 9599 float shapeSizeAttenuation = u_Opacity.w; 9600 vec4 dropShadow = u_DropShadow; 9601 vec4 dropShadowColor = u_DropShadowColor; 9602 float shadowDist; 9603 float shadowBlurRadius = u_DropShadow.z; 9604 9605 #ifdef USE_SDF_NONE 9606 outputColor = texture(SAMPLER_2D(u_Texture), v_Uv); 9607 #else 9608 float dist; 9609 lowp float buff; 9610 vec2 shadowOffset = u_DropShadow.xy / u_AtlasSize; 9611 9612 #ifdef USE_SDF 9613 #ifdef USE_EMOJI 9614 fillColor = texture(SAMPLER_2D(u_Texture), v_Uv); 9615 #endif 9616 dist = texture(SAMPLER_2D(u_Texture), v_Uv).a; 9617 buff = (256.0 - 64.0) / 256.0; 9618 9619 #ifdef USE_SHADOW 9620 shadowDist = texture(SAMPLER_2D(u_Texture), v_Uv - shadowOffset).a; 9621 #endif 9622 #endif 9623 9624 #ifdef USE_MSDF 9625 vec3 s = texture(SAMPLER_2D(u_Texture), v_Uv).rgb; 9626 dist = median(s.r, s.g, s.b); 9627 buff = 0.5; 9628 9629 #ifdef USE_SHADOW 9630 vec3 shadowSample = texture(SAMPLER_2D(u_Texture), v_Uv - shadowOffset).rgb; 9631 shadowDist = median(shadowSample.r, shadowSample.g, shadowSample.b); 9632 #endif 9633 #endif 9634 9635 float fontSize = u_ZIndexStrokeWidth.z; 9636 9637 highp float gamma_scaled; 9638 highp float alpha = ink(dist - 0.2, v_Uv); 9639 9640 opacity *= alpha; 9641 9642 outputColor = fillColor; 9643 #endif 9644 9645 outputColor.a *= opacity; 9646 9647 #ifdef USE_SHADOW 9648 // gamma_scaled = fwidth(shadowDist) * 128.0 / shadowBlurRadius; 9649 gamma_scaled = shadowBlurRadius / 128.0; 9650 alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, shadowDist); 9651 dropShadowColor.a *= alpha; 9652 outputColor = mix(dropShadowColor, outputColor, outputColor.a); 9653 #endif 9654 9655 ${nv} 9656 9657 if (outputColor.a < epsilon) 9658 discard; 9659#endif 9660} 9661`;var oi=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Fl=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},TS,cv,Gg,Wg,RS,pB,CS,gB,rU,hv,Rw,fJ,xvt,pJ;function Gee(t){var e;if(!(t!=null&&t.length))return null;for(const r of t)if(Zy(r)){const i=(e=r.colors[0])!==null&&e!==void 0?e:r.backgroundColor;if(i)return i}else if("steps"in r&&r.steps.length>0)return r.steps[0].color;return null}function Svt(t){if(!t.has(Ce))return"black";for(const e of Nh(t)){if(e.type==="solid")return e.value;if(e.type==="gradient"){const r=Gee(nm(e.value));if(r)return r}}return"black"}function Wee(t,e,r){const i=e*4,s=Math.floor(r/2),o=new Uint8Array(i);for(let n=0;n<s;n++){const a=n*i,l=(r-1-n)*i;o.set(t.subarray(a,a+i)),t.copyWithin(a,l,l+i),t.set(o,l)}}function jee(t){const e=t.width,r=t.height;let i;if(typeof document<"u"){const o=document.createElement("canvas");o.width=e,o.height=r,i=o}else i=new OffscreenCanvas(e,r);const s=i.getContext("2d");return s.translate(0,r),s.scale(1,-1),s.drawImage(t,0,0),i}class Xee extends dS{constructor(){super(...arguments),TS.add(this),cv.set(this,new i9t),Gg.set(this,void 0),Wg.set(this,null),RS.set(this,null),pB.set(this,!1),CS.set(this,null),gB.set(this,null),rU.set(this,null),hv.set(this,null),Rw.set(this,null)}validate(e){return super.validate(e)?this.shapes.length===0?!0:this.hash(this.shapes[0])===this.hash(e):!1}hash(e){var r,i;const{bitmapFont:s,physical:o}=e.read(Yt),n=(r=H0(e))!==null&&r!==void 0?r:"none",a=e.has(Ji)?e.read(Ji):"",l=e.has(ro)?e.read(ro).blurRadius:0,c=(i=Hl(e))!==null&&i!==void 0?i:"",h=e.has(Ce)?Nh(e).map(u=>`${u.type}:${String(u.value)}:${Cg(u.opacity)}`).join("|"):"";return`${a}-${s==null?void 0:s.fontFamily}-${o}-${l}-${n}-${h}-${c}`}get useRasterFilterEngineTimeRefresh(){const e=this.shapes[0];if(!e||!this.useFillImage)return!1;const r=Hl(e);return!!(r&&U2(r))}get useFillImage(){const e=this.shapes[0];if(!(e!=null&&e.has(Ce)))return super.useFillImage;const r=fj(e),i=r==null?void 0:r.blendMode;return(r==null?void 0:r.type)==="solid"&&(i==null||i==="normal")&&!e.has(yh)&&!iv(Hl(e))&&!nz(e)?!1:super.useFillImage}get useBitmapFont(){return!!this.shapes[0].read(Yt).bitmapFont}createGeometry(){const{fontFamily:e,fontWeight:r,fontStyle:i,bitmapFont:s,esdt:o,fontSize:n}=this.shapes[0].read(Yt),{font:a,fontMetrics:l}=this.shapes[0].read(Ji),c=Svt(this.shapes[0]),h=[],u=[],d=[];let f=0,g;if(this.useBitmapFont)g=l.fontSize/s.baseMeasurementFontSize;else{g=Number(n)/(Ppt/Fd);const p=this.shapes.map(m=>m.read(Ji).bidiChars).join("");oi(this,cv,"f").generateAtlas(a,e,r.toString(),i,p,this.device,o,c)}
9661this.shapes.forEach(p=>{const m=p.read(Ji),{letterSpacing:v,bitmapFont:b}=p.read(Yt),{font:y,lines:_,lineHeight:w}=m,{indicesOffset:E,indexBuffer:A,charUVOffsetBuffer:x,charPositionsBuffer:S}=this.buildTextBuffers({object:p,lines:_,fontStack:y,lineHeight:w,letterSpacing:v,indicesOffset:f,bitmapFont:b,fontScale:g});f=E,d.push(...x),u.push(...S),h.push(...A)}),this.indexBufferData=new Uint32Array(h),this.vertexBuffers[0]&&this.vertexBuffers[0].destroy(),this.vertexBufferDatas[0]=new Float32Array(u),this.vertexBuffers[0]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[0],usage:Ee.VERTEX,hint:rr.STATIC}),this.vertexBuffers[1]&&this.vertexBuffers[1].destroy(),this.vertexBufferDatas[1]=new Float32Array(d),this.vertexBuffers[1]=this.device.createBuffer({viewOrSize:this.vertexBufferDatas[1],usage:Ee.VERTEX,hint:rr.STATIC}),this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=this.device.createBuffer({viewOrSize:this.indexBufferData,usage:Ee.INDEX,hint:rr.STATIC}),this.vertexBufferDescriptors=[{arrayStride:12,stepMode:Pi.VERTEX,attributes:[{shaderLocation:fB.POSITION,offset:0,format:X.F32_RGB}]},{arrayStride:16,stepMode:Pi.VERTEX,attributes:[{shaderLocation:fB.UV_OFFSET,offset:0,format:X.F32_RGBA}]}]}createMaterial(e,r){var i,s;const o=this.shapes[0],{content:n,physical:a}=o.read(Yt),{blurRadius:l}=o.has(ro)?o.read(ro):{blurRadius:0};let c;if(this.useBitmapFont){const{bitmapFont:m}=o.read(Yt);m.createTexture(this.device),c=m.pages[0].texture;const{distanceField:v}=m;v.type==="msdf"?e+=`#define USE_MSDF 9662`:v.type==="sdf"?e+=`#define USE_SDF 9663`:e+=`#define USE_SDF_NONE 9664`}else e+=`#define USE_SDF 9665`,r$t(n)&&(e+=`#define USE_EMOJI 9666`),c=oi(this,cv,"f").getAtlasTexture();l>0&&(e+=`#define USE_SHADOW 9667`),this.device.setResourceName(c,"SDFText Texture");const h=e.includes("USE_FILLIMAGE");this.destroyFullPostProcessingChain(),oi(this,TS,"m",fJ).call(this),h||((i=oi(this,hv,"f"))===null||i===void 0||i.destroy(),Fl(this,hv,null,"f"));const u=e.replace(`#define USE_FILLIMAGE 9668`,"").replace(`#define USE_WIREFRAME 9669`,"").replace(`#define USE_STENCIL 9670`,""),d=this.device.queryVendorInfo().platformString==="WebGPU"?`diagnostic(off,derivative_uniformity); 9671`:"";if(h){let m=!1,v;if(o.has(Ce)){const b=fj(o);(b==null?void 0:b.type)==="gradient"&&(v=nm(b.value))}if(v&&v.length>0&&!this.useBitmapFont){let b;if(o.has(fe)){const w=o.read(fe).renderBounds;b={minX:w.minX,minY:w.minY,maxX:w.maxX,maxY:w.maxY}}else{nt(o,Ji),Object.assign(o.write(Ji),om(o.read(Yt)));const w=o.read(Yt),E=o.read(Ji),A=o.has(Gt)?o.read(Gt):void 0,x=o.has(ro)?o.read(ro):void 0,S=Yt.getRenderBounds(w,E,A,x);b={minX:S.minX,minY:S.minY,maxX:S.maxX,maxY:S.maxY}}const y=b.maxX-b.minX,_=b.maxY-b.minY;if(y>1e-6&&_>1e-6){const{width:w,height:E}=lJ(1,1,y,_,aJ()),A=v.filter(Zy),x=v.filter(R=>!Zy(R)),S=pj(o);let T=null;if(A.length===0&&x.length>0)T=hee(o,b,w,E,x,S),m=!0;else if(A.length>0){const R=A[0],B=this.renderMeshGradientTexture(R,w,E),O=this.readTextureRgba8Sync(B,w,E);if(B.destroy(),Wee(O,w,E),S<.999||S>1.001)for(let H=3;H<O.length;H+=4)O[H]=Math.round(O[H]*S);let C;if(typeof document<"u"){const H=document.createElement("canvas");H.width=w,H.height=E,C=H}else C=new OffscreenCanvas(w,E);const F=C.getContext("2d"),U=new ImageData(new Uint8ClampedArray(O.buffer,O.byteOffset,O.byteLength),w,E);F.putImageData(U,0,0),x.length>0&&(F.globalCompositeOperation="source-atop",Y3(F,b,w,E),avt(F,x,b),F.setTransform(1,0,0,1,0,0),F.globalCompositeOperation="source-over"),nee(C,o,b,w,E),T=C,m=!0}if(m&&T){const R=this.device.createTexture({format:X.U8_RGBA_NORM,width:w,height:E,usage:vi.SAMPLED}),B=jee(T);R.setImageData([B]),Fl(this,RS,R,"f");const O=oi(this,TS,"m",pJ).call(this,o,R,w,E);Fl(this,pB,O!==R,"f"),Fl(this,Wg,O,"f")}}}if(!m){const b=o.read(fe).renderBounds,y=b.maxX-b.minX,_=b.maxY-b.minY,{width:w,height:E}=lJ(1,1,y,_,aJ());Fl(this,CS,this.renderCache.createProgram({vertex:{glsl:u+wvt},fragment:{glsl:u+(a?Avt:Evt),postprocess:G=>d+G}}),"f"),Fl(this,rU,this.renderCache.createInputLayout({vertexBufferDescriptors:this.vertexBufferDescriptors,indexBufferFormat:X.U32_R,program:oi(this,CS,"f")}
9671),"f"),Fl(this,gB,this.renderCache.createRenderPipeline({inputLayout:oi(this,rU,"f"),program:oi(this,CS,"f"),colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:X.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:oo.ALL,rgbBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.SRC_ALPHA,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA}}],blendConstant:Ra,depthWrite:!0,depthCompare:li.GREATER,stencilWrite:!1,stencilFront:{compare:li.ALWAYS,passOp:Oi.KEEP,failOp:Oi.KEEP,depthFailOp:Oi.KEEP},stencilBack:{compare:li.ALWAYS,passOp:Oi.KEEP,failOp:Oi.KEEP,depthFailOp:Oi.KEEP}}}),"f"),this.device.setResourceName(oi(this,gB,"f"),"SDFTextBakePipeline"),oi(this,Rw,"f")||Fl(this,Rw,this.device.createBuffer({viewOrSize:48*Float32Array.BYTES_PER_ELEMENT,usage:Ee.UNIFORM,hint:rr.DYNAMIC}),"f"),oi(this,TS,"m",xvt).call(this,y,_,w,E),oi(this,Gg,"f")||Fl(this,Gg,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*60,usage:Ee.UNIFORM,hint:rr.DYNAMIC}),"f");const A=Bt();Yc(A),bi(A,A,[-b.minX,-b.minY]);const x=ie.fromGLMat3(A),S=this.useBitmapFont?o.read(Yt).bitmapFont.pages[0]:oi(this,cv,"f").getAtlas().image,[T,R]=this.generateBuffer(o,S);oi(this,Gg,"f").setSubData(0,new Uint8Array(new Float32Array([...sh(x),...T]).buffer)),oi(this,CS,"f").setUniformsLegacy(Object.assign({u_ModelMatrix:ie.toGLMat3(x)},R));const B=this.renderCache.createSampler({addressModeU:ho.CLAMP_TO_EDGE,addressModeV:ho.CLAMP_TO_EDGE,minFilter:hs.POINT,magFilter:hs.BILINEAR,mipmapFilter:Ro.LINEAR,lodMinClamp:0,lodMaxClamp:0});(s=oi(this,hv,"f"))===null||s===void 0||s.destroy(),Fl(this,hv,this.renderCache.createBindings({pipeline:oi(this,gB,"f"),uniformBufferBindings:[{buffer:oi(this,Rw,"f")},{buffer:oi(this,Gg,"f")}],samplerBindings:[{texture:c,sampler:B}]}),"f");const O=this.device.createTexture({format:X.U8_RGBA_NORM,width:w,height:E,usage:vi.RENDER_TARGET|vi.SAMPLED}),C=this.device.createTexture({format:X.D24_S8,width:w,height:E,usage:vi.RENDER_TARGET}),F=this.device.createRenderTargetFromTexture(O),U=this.device.createRenderTargetFromTexture(C),H=this.device.createRenderPass({colorAttachment:[F],colorClearColor:[Ra],colorResolveTo:[null],colorStore:[!0],depthStencilAttachment:U,depthClearValue:0});H.setViewport(0,0,w,E),H.setPipeline(oi(this,gB,"f")),H.setBindings(oi(this,hv,"f")),H.setVertexInput(oi(this,rU,"f"),this.vertexBuffers.map(G=>({buffer:G})),{buffer:this.indexBuffer}),H.drawIndexed(this.indexBufferData.length),this.device.submitPass(H),U.destroy(),C.destroy(),Fl(this,RS,O,"f");const N=oi(this,TS,"m",pJ).call(this,o,O,w,E);Fl(this,pB,N!==O,"f"),Fl(this,Wg,N,"f")}}this.createProgram(wvt,a?Avt:Evt,e),oi(this,Gg,"f")||Fl(this,Gg,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*60,usage:Ee.UNIFORM,hint:rr.DYNAMIC}),"f"),this.pipeline=this.renderCache.createRenderPipeline({inputLayout:this.inputLayout,program:this.program,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:X.D24_S8,megaStateDescriptor:{attachmentsState:[{channelWriteMask:oo.ALL,rgbBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.SRC_ALPHA,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA}}],blendConstant:Ra,depthWrite:!0,depthCompare:li.GREATER,stencilWrite:!1,stencilFront:{compare:li.ALWAYS,passOp:Oi.KEEP,failOp:Oi.KEEP,depthFailOp:Oi.KEEP},stencilBack:{compare:li.ALWAYS,passOp:Oi.KEEP,failOp:Oi.KEEP,depthFailOp:Oi.KEEP}}}),this.device.setResourceName(this.pipeline,"SDFTextPipeline");const f=this.renderCache.createSampler({addressModeU:ho.CLAMP_TO_EDGE,addressModeV:ho.CLAMP_TO_EDGE,minFilter:hs.POINT,magFilter:hs.BILINEAR,mipmapFilter:Ro.LINEAR,lodMinClamp:0,lodMaxClamp:0}),g=h&&oi(this,Wg,"f")?oi(this,Wg,"f"):c,p={pipeline:this.pipeline,uniformBufferBindings:[{buffer:r},{buffer:oi(this,Gg,"f")}],samplerBindings:[{texture:g,sampler:f}]};this.bindings=this.renderCache.createBindings(p)}render(e,r,i){const{matrix:s}=this.shapes[0].read(Ae),o=[s.m00,s.m01,s.m02,s.m10,s.m11,s.m12,s.m20,s.m21,s.m22],[n,a]=this.generateBuffer(this.shapes[0],this.useBitmapFont?this.shapes[0].read(Yt).bitmapFont.pages[0]:oi(this,cv,"f").getAtlas().image);oi(this,Gg,"f").setSubData(0,new Uint8Array(new Float32Array([...sh(ie.fromGLMat3(o)),...n]).buffer)),this.program.setUniformsLegacy(Object.assign({u_ModelMatrix:o},a)),this.useFillImage&&oi(this,Wg,"f")&&this.program.setUniformsLegacy({u_Texture:oi(this,Wg,"f")}),this.useWireframe&&this.geometryDirty&&this.generateWireframe(),this.program.setUniformsLegacy(i),e.setP
9671ipeline(this.pipeline);const l=this.vertexBuffers.map(c=>({buffer:c}));this.useWireframe&&l.push({buffer:this.barycentricBuffer}),e.setVertexInput(this.inputLayout,l,{buffer:this.indexBuffer}),e.setBindings(this.bindings),(this.useStencil||this.parentClipMode)&&e.setStencilReference($f),e.drawIndexed(this.indexBufferData.length)}destroy(){var e,r,i;this.destroyFullPostProcessingChain(),(e=oi(this,hv,"f"))===null||e===void 0||e.destroy(),Fl(this,hv,null,"f"),oi(this,TS,"m",fJ).call(this),(r=oi(this,Rw,"f"))===null||r===void 0||r.destroy(),Fl(this,Rw,null,"f"),super.destroy(),this.program&&((i=oi(this,Gg,"f"))===null||i===void 0||i.destroy()),oi(this,cv,"f").destroy()}generateBuffer(e,r){const i=e.has(Xc)?1:0,s=(e.has(Ln)?e.read(Ln).value:0)/Ew,o=Svt(e),{r:n,g:a,b:l,opacity:c}=Wo(o&&o!=="none"?o:"transparent"),h=e.has(bo)?e.read(bo).opacity:1,u=H0(e),d=e.has(Gt)?e.read(Gt).width:0,{r:f,g,b:p,opacity:m}=Wo(u??"transparent"),{strokeColorAlphaMul:v,strokeUniformOpacityMul:b}=b2(e),{color:y,offsetX:_,offsetY:w,blurRadius:E}=e.has(ro)?e.read(ro):{color:null,offsetX:0,offsetY:0,blurRadius:0},{r:A,g:x,b:S,opacity:T}=Wo(y),{width:R,height:B}=r,{fontSize:O}=e.read(Ji).fontMetrics,C=[n/255,a/255,l/255,c],F=[f/255,g/255,p/255,m*v],U=[s,d,O,0],H=[h,1,b,i],N=[A/255,x/255,S/255,T],G=[_,w,E,0],Y=[R,B];let q;if(e.has(fe)){const L=e.read(fe).renderBounds,J=L.maxX-L.minX,tt=L.maxY-L.minY;q=[L.minX,L.minY,J>0?1/J:0,tt>0?1/tt:0]}else q=[0,0,1,1];return[[...C,...F,...U,...H,...N,...G,...Y,0,0,...q],{u_FillColor:C,u_StrokeColor:F,u_ZIndexStrokeWidth:U,u_Opacity:H,u_DropShadowColor:N,u_DropShadow:G,u_AtlasSize:Y,u_FillUVRect:q}]}buildTextBuffers({object:e,lines:r,fontStack:i,lineHeight:s,letterSpacing:o,indicesOffset:n,bitmapFont:a,fontScale:l}){const{textAlign:c,bitmapFontKerning:h}=e.read(Yt),u=e.read(Ji),d=e.has(Ln)?e.read(Ln).value:0;let f=0,g=0;c==="left"||c==="start"?f=0:c==="right"||c==="end"?f=u.width:c==="center"&&(f=u.width/2);const{fontBoundingBoxAscent:p=0}=u.fontMetrics;g=p;const m=[],v=[],b=[];let y=n;const _=oi(this,cv,"f").layout(r,i,s,c,o,a,l,h,0,(s-u.fontMetrics.fontSize)/2);let w;return a?w={[i]:Object.keys(a.chars).reduce((E,A)=>{const{xAdvance:x,xOffset:S,yOffset:T,rect:R}=a.chars[A];return E[A]={rect:R,metrics:{width:x,height:a.lineHeight,left:S,top:-T,advance:x}},E},{})}:w=oi(this,cv,"f").getAtlas().positions,s9t(_,w,this.useBitmapFont).forEach((E,A,x)=>{m.push(E.tex.x,E.tex.y,E.tl.x,E.tl.y),m.push(E.tex.x+E.tex.w,E.tex.y,E.tr.x,E.tr.y),m.push(E.tex.x+E.tex.w,E.tex.y+E.tex.h,E.br.x,E.br.y),m.push(E.tex.x,E.tex.y+E.tex.h,E.bl.x,E.bl.y);const S=(d+1/x.length*A)/Ew;v.push(f,g,S,f,g,S,f,g,S,f,g,S),b.push(0+y,2+y,1+y),b.push(2+y,0+y,3+y),y+=4}),{indexBuffer:b,charUVOffsetBuffer:m,charPositionsBuffer:v,indicesOffset:y}}}cv=new WeakMap,Gg=new WeakMap,Wg=new WeakMap,RS=new WeakMap,pB=new WeakMap,CS=new WeakMap,gB=new WeakMap,rU=new WeakMap,hv=new WeakMap,Rw=new WeakMap,TS=new WeakSet,fJ=function(){oi(this,RS,"f")&&(oi(this,RS,"f").destroy(),Fl(this,RS,null,"f")),!oi(this,pB,"f")&&oi(this,Wg,"f")&&oi(this,Wg,"f").destroy(),Fl(this,Wg,null,"f"),Fl(this,pB,!1,"f")},xvt=function(t,e,r,i){var s,o;const n=ld(Bt(),t,e),a=Yc(Bt()),l=us(Bt(),n,a),c=(s=_i(Bt(),l))!==null&&s!==void 0?s:Yc(Bt()),h=new Float32Array([...sh(ie.fromGLMat3(n)),...sh(ie.fromGLMat3(a)),...sh(ie.fromGLMat3(c)),0,0,0,0,0,0,0,0,this.sceneZoomScale,0,r,i]);oi(this,Rw,"f").setSubData(0,new Uint8Array(h.buffer)),(o=oi(this,CS,"f"))===null||o===void 0||o.setUniformsLegacy({u_ProjectionMatrix:n,u_ViewMatrix:a,u_ViewProjectionInvMatrix:c,u_BackgroundColor:[0,0,0,0],u_GridColor:[0,0,0,0],u_ZoomScale:this.sceneZoomScale,u_CheckboardStyle:0,u_Viewport:[r,i]})},pJ=function(t,e,r,i){const s=Hl(t);if(!s)return e;const o=G2(Iv(s));if(o.length===0)return e;this.createPostProcessing(o,e,r,i);const{texture:n}=this.renderPostProcessingTextureSpace(r,i);return n};const zee=` 9672 float random (in vec2 st) { 9673 return fract(sin(dot(st.xy, 9674 vec2(12.9898,78.233)))* 9675 43758.5453123); 9676 } 9677`,Vee=` 9678 ${zee} 9679 9680 // Based on Morgan McGuire @morgan3d 9681 // https://www.shadertoy.com/view/4dS3Wd 9682 float noise (in vec2 st) { 9683 vec2 i = floor(st); 9684 vec2 f = fract(st); 9685 9686 // Four corners in 2D of a tile 9687 float a = random(i); 9688 float b = random(i + vec2(1.0, 0.0)); 9689 float c = random(i + vec2(0.0, 1.0)); 9690 float d = random(i + vec2(1.0, 1.0)); 9691 9692 vec2 u = f * f * (3.0 - 2.0 * f); 9693 9694 return mix(a, b, u.x) + 9695 (c - a)* u.y * (1.0 - u.x) + 9696 (d - b) * u.x * u.y; 9697 } 9698 9699 #define OCTAVES 6 9700 float fbm (in vec2 st) { 9701 // Initial values 9702 float value = 0.0; 9703 float amplitude = .5; 9704 float frequency = 0.; 9705 // 9706 // Loop of octaves 9707 for (int i = 0; i < OCTAVES; i++) { 9708 value += amplitude * noise(st); 9709 st *= 2.; 9710 amplitude *= .5; 9711 } 9712 return value; 9713 } 9714`;var Cw;(function(t){t[t.BARYCENTRIC=0]="BARYCENTRIC",t[t.POINTA=1]="POINTA",t[t.POINTB=2]="POINTB",t[t.VERTEX_NUM=3]="VERTEX_NUM"})(Cw||(Cw={}));const Yee=` 9715 layout(std140) uniform SceneUniforms { 9716 mat3 u_ProjectionMatrix; 9717 mat3 u_ViewMatrix; 9718 mat3 u_ViewProjectionInvMatrix;
9719 vec4 u_BackgroundColor; 9720 vec4 u_GridColor; 9721 float u_ZoomScale; 9722 float u_CheckboardStyle; 9723 }; 9724 9725 ${iB} 9726 layout(location = ${Cw.POINTA}) in vec4 a_PointA; 9727 layout(location = ${Cw.POINTB}) in vec4 a_PointB; 9728 layout(location = ${Cw.VERTEX_NUM}) in float a_VertexNum; 9729 9730 layout(std140) uniform ShapeUniforms { 9731 mat3 u_ModelMatrix; 9732 vec4 u_StrokeColor; 9733 vec4 u_ZIndexStrokeWidth; 9734 vec4 u_Opacity; 9735 vec4 u_Stamp; 9736 }; 9737 9738 out vec2 p0; 9739 out float r0; 9740 out float l0; 9741 out vec2 p1; 9742 out float r1; 9743 out float l1; 9744 out vec2 p; 9745 9746 void main() { 9747 ${rB} 9748 9749 mat3 model; 9750 vec4 fillColor; 9751 vec4 strokeColor; 9752 float zIndex; 9753 float strokeWidth; 9754 9755 model = u_ModelMatrix; 9756 strokeColor = u_StrokeColor; 9757 zIndex = u_ZIndexStrokeWidth.x; 9758 strokeWidth = u_ZIndexStrokeWidth.y; 9759 9760 p0 = a_PointA.xy; 9761 r0 = a_PointA.z; 9762 l0 = a_PointA.w; 9763 p1 = a_PointB.xy; 9764 r1 = a_PointB.z; 9765 l1 = a_PointB.w; 9766 9767 vec2 tangentDirection = normalize(p1 - p0); 9768 vec2 normalDirection = vec2(-tangentDirection.y, tangentDirection.x); 9769 float cosTheta = (r0 - r1)/distance(p0, p1); 9770 if(abs(cosTheta) >= 1.0) return; 9771 9772 vec2 tangent = normalize(p1 - p0); 9773 vec2 normal = vec2(-tangent.y, tangent.x); 9774 9775 float vertexNum = a_VertexNum; 9776 9777 vec2 position; 9778 vec2 offsetSign; 9779 float r; 9780 if (vertexNum < 0.5) { 9781 position = p0; 9782 r = r0; 9783 offsetSign = vec2(-1.0, -1.0); 9784 } else if (vertexNum < 1.5) { 9785 position = p0; 9786 r = r0; 9787 offsetSign = vec2(-1.0, 1.0); 9788 } else if (vertexNum < 2.5) { 9789 position = p1; 9790 r = r1; 9791 offsetSign = vec2(1.0, 1.0); 9792 } else if (vertexNum < 3.5) { 9793 position = p1; 9794 r = r1; 9795 offsetSign = vec2(1.0, -1.0); 9796 } 9797 9798 // Apply the half angle formula from cos(theta) to tan(theta/2) 9799 float tanHalfTheta = sqrt((1.0+cosTheta) / (1.0-cosTheta)); 9800 float cotHalfTheta = 1.0 / tanHalfTheta; 9801 float normalTanValue = vec4(tanHalfTheta, tanHalfTheta, cotHalfTheta, cotHalfTheta)[gl_VertexID]; 9802 // Corner case: The small circle is very close to the big one, casuing large offset in the normal direction, discard the edge 9803 if(normalTanValue > 10.0 || normalTanValue < 0.1) return; 9804 9805 vec2 trapzoidVertexPosition = position + 9806 offsetSign.x * r * tangentDirection + 9807 offsetSign.y * r * normalDirection * normalTanValue; 9808 p = trapzoidVertexPosition; 9809 9810 gl_Position = vec4((u_ProjectionMatrix 9811 * u_ViewMatrix 9812 * model 9813 * vec3(trapzoidVertexPosition, 1)).xy, zIndex, 1); 9814 } 9815 `,$ee=` 9816 layout(std140) uniform SceneUniforms { 9817 mat3 u_ProjectionMatrix; 9818 mat3 u_ViewMatrix; 9819 mat3 u_ViewProjectionInvMatrix; 9820 vec4 u_BackgroundColor; 9821 vec4 u_GridColor; 9822 float u_ZoomScale; 9823 float u_CheckboardStyle; 9824 }; 9825 9826 layout(std140) uniform ShapeUniforms { 9827 mat3 u_ModelMatrix; 9828 vec4 u_StrokeColor; 9829 vec4 u_ZIndexStrokeWidth; 9830 vec4 u_Opacity; 9831 vec4 u_Stamp; 9832 }; 9833 9834 ${aS} 9835 9836 in vec2 p0; 9837 in float r0; 9838 in float l0; 9839 in vec2 p1; 9840 in float r1; 9841 in float l1; 9842 in vec2 p; 9843 9844 #ifdef USE_FILLIMAGE 9845 uniform sampler2D u_Texture; 9846 #endif 9847 9848 out vec4 outputColor; 9849 9850 float epsilon = 0.000001; 9851 9852 const int EquiDistance = 0, RatioDistance = 1; 9853 9854 float x2n(float x){ 9855 float stampInterval = u_Stamp.x; 9856 int stampMode = int(u_Stamp.w); 9857 if(stampMode == EquiDistance) return x / stampInterval; 9858 if(stampMode == RatioDistance){ 9859 float L = distance(p0, p1); 9860 if(r0 == r1) return x/(stampInterval*r0); 9861 else return -L / stampInterval / (r0 - r1) * log(1.0 - (1.0 - r1/r0)/L * x); 9862 } 9863 return 0.0; 9864 } 9865 9866 float n2x(float n){ 9867 float stampInterval = u_Stamp.x; 9868 int stampMode = int(u_Stamp.w); 9869 if(stampMode == EquiDistance) return n * stampInterval; 9870 if(stampMode == RatioDistance){ 9871 float L = distance(p0, p1); 9872 if(r0 == r1) return n * stampInterval * r0; 9873 else return L * (1.0-exp(-(r0-r1)*n*stampInterval/L)) / (1.0-r1/r0); 9874 } 9875 return 0.0; 9876 } 9877 9878 mat2 rotate(float angle){ 9879 return mat2(cos(angle), -sin(angle), sin(angle), cos(angle)); 9880 } 9881 9882 ${Vee} 9883 9884 void main() { 9885 float strokeWidth; 9886 vec4 strokeColor; 9887 float opacity; 9888 float strokeOpacity; 9889 float brushType; 9890 9891 strokeColor = u_StrokeColor; 9892 strokeWidth = u_ZIndexStrokeWidth.y; 9893 brushType = u_ZIndexStrokeWidth.z; 9894 opacity = u_Opacity.x; 9895 strokeOpacity = u_Opacity.z; 9896 9897 vec2 tangent = normalize(p1 - p0); 9898 vec2 normal = vec2(-tangent.y, tangent.x); 9899 9900 // The local coordinate orgin at p0, x axis along the tangent direct. 9901 float len = distance(p1, p0); 9902 vec2 pLocal = vec2(dot(p-p0, tangent), dot(p-p0, normal)); 9903 vec2 p0Local = vec2(0, 0); 9904 vec2 p1Local = vec2(len, 0); 9905 9906 float cosTheta = (r0 - r1)/len; 9907 float d0 = distance(p, p0); 9908 float d0cos = pLocal.x / d0; 9909 float d1 = distance(p, p1); 9910 float d1cos = (pLocal.x - len) / d1; 9911
9912 // Remove corners 9913 if(d0cos < cosTheta && d0 > r0) discard; 9914 if(d1cos > cosTheta && d1 > r1) discard; 9915 9916 vec4 color = strokeColor; 9917 9918 if (brushType < 0.5) { 9919 // Vanilla brush 9920 if(d0 < r0 && d1 < r1) discard; 9921 float A = (d0 < r0 || d1 < r1) ? 1.0 - sqrt(1.0 - color.a) : color.a; 9922 outputColor = vec4(color.rgb, A); 9923 return; 9924 } else if (brushType < 1.5) { 9925 // Stamp brush 9926 // The method here is not published yet, it should be explained in a 10min video. 9927 // The footprint is a disk instead of a square. 9928 // We set a quadratic polynomial to calculate the effect range, the range on polyline edge footprint can touch the current pixel. 9929 // Two roots of the quadratic polynomial are the effectRangeFront and effectRangeBack. 9930 // Formulas from SIGGRAPH 2022 Talk - A Fast & Robust Solution for Cubic & Higher-Order Polynomials 9931 // The quadratic equation 9932 float a, b, c, delta; 9933 a = 1.0 - pow(cosTheta, 2.0); 9934 b = 2.0 * (r0 * cosTheta - pLocal.x); 9935 c = pow(pLocal.x, 2.0) + pow(pLocal.y, 2.0) - pow(r0, 2.0); 9936 delta = pow(b, 2.0) - 4.0*a*c; 9937 if(delta <= 0.0) discard; // This should never happen. 9938 9939 // Solve the quadratic equation 9940 // Need to learn how to solve a quadratic equation? Check this talk by Cem Yuksel: 9941 // https://www.youtube.com/watch?v=ok0EZ0fBCMA 9942 float tempMathBlock = b + sign(b) * sqrt(delta); 9943 float x1 = -2.0 * c / tempMathBlock; 9944 float x2 = -tempMathBlock / (2.0*a); 9945 float effectRangeFront = x1 <= x2 ? x1 : x2; 9946 float effectRangeBack = x1 > x2 ? x1 : x2; 9947 9948 float stampInterval = u_Stamp.x; 9949 float noiseFactor = u_Stamp.y; 9950 float rotationFactor = u_Stamp.z; 9951 9952 // With the distance to the polyline's first vertex, we can compute a "stamp index" value. 9953 // which indicate the number of stamps from the first vertex to current point. 9954 // We stamp on polyline every time the stamp index comes to an integer. 9955 float index0 = l0/stampInterval; // The stamp index of vertex0. 9956 float startIndex, endIndex; 9957 if (effectRangeFront <= 0.0){ 9958 startIndex = ceil(index0); 9959 } 9960 else{ 9961 startIndex = ceil(index0 + x2n(effectRangeFront)); 9962 } 9963 float index1 = l1/stampInterval; 9964 float backIndex = x2n(effectRangeBack) + index0; 9965 endIndex = index1 < backIndex ? index1 : backIndex; 9966 if(startIndex > endIndex) discard; 9967 9968 // The main loop to sample and blend color from the footprint, from startIndex to endIndex 9969 int MAX_i = 128; float currIndex = startIndex; 9970 float A = 0.0; 9971 for(int i = 0; i < MAX_i; i++){ 9972 float currStampLocalX = n2x(currIndex - index0); 9973 // Apply roation and sample the footprint. 9974 vec2 pToCurrStamp = pLocal - vec2(currStampLocalX, 0.0); 9975 float currStampRadius = r0 - cosTheta * currStampLocalX; 9976 float angle = rotationFactor*radians(360.0*fract(sin(currIndex)*1.0)); 9977 pToCurrStamp *= rotate(angle); 9978 vec2 textureCoordinate = (pToCurrStamp/currStampRadius + 1.0)/2.0; 9979 9980 float opacity = 1.0; 9981 #ifdef USE_FILLIMAGE 9982 opacity = texture(SAMPLER_2D(u_Texture), textureCoordinate).a; 9983 #endif 9984 // Blend opacity. 9985 float opacityNoise = noiseFactor*fbm(textureCoordinate*50.0); 9986 opacity = clamp(opacity - opacityNoise, 0.0, 1.0) * color.a; 9987 A = A * (1.0-opacity) + opacity; 9988 9989 currIndex += 1.0; 9990 if(currIndex > endIndex) break; 9991 } 9992 if(A < 1e-4) discard; 9993 outputColor = vec4(color.rgb, A); 9994 } 9995 9996 ${nv} 9997 } 9998 `;var zh=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},gz=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
9998return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},MS,mB,Mw,yB;const Hee={vanilla:0,stamp:1};class Kee extends dS{constructor(){super(...arguments),MS.set(this,void 0),mB.set(this,void 0),Mw.set(this,void 0),yB.set(this,void 0),this.instanced=!1,this.pointsBuffer=[]}get instanceCount(){const e=this.shapes[0],{points:r}=e.read(ai);return r.length}validate(e){return!0}createGeometry(){const e=[0,1,2,0,2,3],r=[];let i=0,s=0;this.shapes.forEach(o=>{const{points:n}=o.read(ai);n.forEach((a,l)=>{l>0&&(s+=Sa(n[l-1].x,n[l-1].y,a.x,a.y)),r.push(a.x,a.y,a.radius,s)}),e.push(0+i,1+i,2+i,0+i,2+i,3+i),i+=4}),this.indexBufferData=new Uint32Array(e),this.pointsBuffer=r,zh(this,Mw,"f")&&zh(this,Mw,"f").destroy(),gz(this,Mw,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*6*this.instanceCount*this.shapes.length,usage:Ee.VERTEX,hint:rr.DYNAMIC}),"f"),zh(this,mB,"f")&&zh(this,mB,"f").destroy(),gz(this,mB,this.device.createBuffer({viewOrSize:new Float32Array([0,1,2,3]),usage:Ee.VERTEX,hint:rr.STATIC}),"f"),zh(this,Mw,"f").setSubData(0,new Uint8Array(new Float32Array(this.pointsBuffer).buffer)),this.vertexBufferOffsets=[0,16,0],this.vertexBuffers=[zh(this,Mw,"f"),zh(this,Mw,"f"),zh(this,mB,"f")],this.vertexBufferDatas=[new Float32Array(this.pointsBuffer),new Float32Array(this.pointsBuffer),new Float32Array([0,1,2,3])],this.vertexBufferDescriptors=[{arrayStride:16,stepMode:Pi.INSTANCE,attributes:[{format:X.F32_RGBA,offset:0,shaderLocation:Cw.POINTA}]},{arrayStride:16,stepMode:Pi.INSTANCE,attributes:[{format:X.F32_RGBA,offset:0,shaderLocation:Cw.POINTB}]},{arrayStride:4,stepMode:Pi.VERTEX,attributes:[{format:X.F32_R,offset:0,shaderLocation:Cw.VERTEX_NUM}]}],this.indexBuffer||(this.indexBuffer=this.device.createBuffer({viewOrSize:this.indexBufferData,usage:Ee.INDEX,hint:rr.STATIC}))}createMaterial(e,r){const i=this.shapes[0],{points:s}=i.read(ai);if(s.length===0)return;this.createProgram(Yee,$ee,e),zh(this,MS,"f")||gz(this,MS,this.device.createBuffer({viewOrSize:Float32Array.BYTES_PER_ELEMENT*32,usage:Ee.UNIFORM,hint:rr.DYNAMIC}),"f"),this.pipeline=this.renderCache.createRenderPipeline({inputLayout:this.inputLayout,program:this.program,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:X.D24_S8,topology:Ia.TRIANGLES,megaStateDescriptor:Object.assign({attachmentsState:[{channelWriteMask:oo.ALL,rgbBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.SRC_ALPHA,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA}}],blendConstant:Ra,depthWrite:!0,depthCompare:li.GREATER},this.stencilDescriptor)}),this.device.setResourceName(this.pipeline,"BrushPipeline");const o={pipeline:this.pipeline,uniformBufferBindings:[{buffer:r},{buffer:zh(this,MS,"f")}]};if(this.useFillImage){this.bindings&&this.bindings.destroy();const n=this.shapes[0];if(n.has(Ce)){const l=Nh(n).find(c=>c.type==="image");if(l){const c=wO(l.value);if(c){const h=this.device.createTexture({format:X.U8_RGBA_NORM,width:c.width,height:c.height,usage:vi.SAMPLED});h.setImageData([c]),gz(this,yB,h,"f")}}}const a=this.renderCache.createSampler({addressModeU:ho.CLAMP_TO_EDGE,addressModeV:ho.CLAMP_TO_EDGE,minFilter:hs.POINT,magFilter:hs.BILINEAR,mipmapFilter:Ro.LINEAR,lodMinClamp:0,lodMaxClamp:0});o.samplerBindings=[{texture:zh(this,yB,"f"),sampler:a}]}this.bindings=this.renderCache.createBindings(o)}render(e,r,i){const s=this.shapes[0],{points:o}=s.read(ai);if(o.length===0)return;const{matrix:n}=this.shapes[0].read(Ae),[a,l]=this.generateBuffer(s),c=[n.m00,n.m01,n.m02,n.m10,n.m11,n.m12,n.m20,n.m21,n.m22];zh(this,MS,"f").setSubData(0,new Uint8Array(new Float32Array([...sh(ie.fromGLMat3(c)),...a]).buffer));const h=Object.assign({u_ModelMatrix:c},l);this.useFillImage&&(h.u_FillImage=zh(this,yB,"f")),this.program.setUniformsLegacy(h),this.useWireframe&&this.geometryDirty&&this.generateWireframe(),this.program.setUniformsLegacy(i),e.setPipeline(this.pipeline);const u=this.vertexBuffers.map((d,f)=>({buffer:d,offset:this.vertexBufferOffsets[f]}));this.useWireframe&&u.push({buffer:this.barycentricBuffer,offset:0}),e.setVertexInput(this.inputLayout,u,{buffer:this.indexBuffer}),e.setBindings(this.bindings),(this.useStencil||this.parentClipMode)&&e.setStencilReference($f),e.drawIndexed(6,this.instanceCount)}destroy(){var e,r;super.destroy(),this.program&&((e=zh(this,MS,"f"))===null||e===void 0||e.destroy(),(r=zh(this,yB,"f"))===null||r===void 0||r.destroy())}generateBuffer(e){const{type:r,stampInterval:i,stampMode:s,stampNoiseFactor:o,stampRotationFactor:n}=e.read(ai),a=Hee[r],l=e.has(Ln)?e.read(Ln).value:0,c=e.has(bo)?e.read(bo).opacity:1,h=H0(e),u=e.has(Gt)?e.read(Gt).width:0,{r:d,g:f,b:g,opacity:p}=Wo(h??"transparent"),{strokeColorAlphaMul:m,strokeUniformOpacityMul:v}=b2(e),b=[d/255,f/255,g/255,p*m],y=[l/Ew,u,a,0],_=[c,0,v,0],w=[i,o,n,s===jw.EQUI_DISTANCE?0:1];return[[...b,...y,..._,...w],{u_StrokeColor:b,u_ZIndexStrokeWidth:y,u_Opacity:_,u_Stamp:w}]}}MS=new WeakMap,mB=new WeakMap,Mw=new WeakMap,yB=new WeakMap,vO=function(t,e){const r=typeof t=="string"?t:(t==null?void 0:t.has(Gs))&&t.read(Gs).value,i=typeof e=="string"?e:(e==null?void 0:e.has(Gs))&&e.read(Gs).value;return r<i?-1:r>i?1:0};class mz extends We{constructor(){super(),this.renderables=this.query(e=>e.current.with(Zi).with(Gs).read),this.fractionalIndexes=this.query(e=>e.addedChangedOrRemoved.with(Gs).trackWrites),this.query(e=>e.with(Ln).write)}execute(){if(this.fractionalIndexes.addedChangedOrRemoved.length>0){let e=1;[...this.renderables.current].sort((r,i)=>
9998{if(r.has(Gs)&&i.has(Gs)){const s=r.read(Gs).value,o=i.read(Gs).value;return s<o?-1:s>o?1:0}}).forEach(r=>{r.has(Ln)||r.add(Ln),Object.assign(r.write(Ln),{value:e++})})}}}var Ks=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},vB=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},yz,Ql,_B,BS,bB,iU,wB,gJ;function qee(t){if(Ngt(t))return[];const e=[];return t.has(et)||t.has(ae)?t.has(ue)?e.push(SS,Hf,Hf):e.push(vS,Hf):t.has($t)?t.has(ue)?e.push(yvt,SS,Hf,Hf):e.push(yvt,vS,Hf):t.has(Mt)||t.has(_t)?e.push(Hf):t.has(xt)?t.has(ue)?e.push(SS,Hf,Hf):e.push(SS,Hf):t.has(Yt)?e.push(Hf,Xee):t.has(ai)?e.push(Kee):t.has(ke)&&e.push(SS,Hf),e}class Tvt{constructor(e,r,i,s,o){yz.add(this),this.device=e,this.swapChain=r,this.renderCache=i,this.texturePool=s,this.api=o,Ql.set(this,[]),_B.set(this,new Set),BS.set(this,new WeakMap),bB.set(this,new WeakMap),iU.set(this,Object.create(null)),wB.set(this,[])}collectDrawcallCtors(e){return qee(e).map(r=>{if(!r.check||r.check&&r.check(e))return r}).filter(r=>!!r)}createDrawcalls(e,r=!1){return this.collectDrawcallCtors(e).map((i,s)=>{const o=new i(this.device,this.swapChain,this.renderCache,this.texturePool,r,s,this.api);return Ks(this,_B,"f").add(o),o.add(e),o})}getOrCreateNonBatchableDrawcalls(e){let r=Ks(this,BS,"f").get(e);const i=this.collectDrawcallCtors(e);if(r)if(r.length!==i.length||r.some((s,o)=>s.constructor!==i[o]))this.remove(e),r=void 0;else return r;return r=this.createDrawcalls(e),Ks(this,BS,"f").set(e,r),r}getOrCreateBatchableDrawcalls(e){let r=Ks(this,bB,"f").get(e);const i=this.collectDrawcallCtors(e);if(r)if(r.length!==i.length||r.some((s,o)=>s.constructor!==i[o]))this.remove(e),r=void 0;else return r;if(!r){const s=e.has(et)?e.has(ue)?"rough-circle":"circle":e.has(ae)?e.has(ue)?"rough-ellipse":"ellipse":e.has($t)?e.has(ue)?"rough-rect":"rect":e.has(_t)?e.has(ue)?"rough-polyline":"polyline":e.has(Mt)?e.has(ue)?"rough-line":"line":e.has(xt)?e.has(ue)?"rough-path":"path":e.has(Yt)?"text":e.has(ke)?"vector-network":e.has(ai)?"brush":void 0;let o=Ks(this,iU,"f")[s];o||(o=[]);const n=this.collectDrawcallCtors(e);r=o.find(a=>a.length===n.length&&a.every(l=>l.validate(e))),r||(r=this.createDrawcalls(e,!0)||[],o.push(r),Ks(this,iU,"f")[s]=o),r.forEach(a=>{a.add(e)}),Ks(this,bB,"f").set(e,r)}return r}add(e,r){Ngt(e)||(r||(e.read(Zi).batchable?r=this.getOrCreateBatchableDrawcalls(e):r=this.getOrCreateNonBatchableDrawcalls(e)),r.length&&Ks(this,Ql,"f").indexOf(r[0])===-1&&Ks(this,Ql,"f").push(...r))}remove(e,r=!0){var i;e.read(Zi).batchable?(this.getOrCreateBatchableDrawcalls(e).forEach(s=>{s.remove(e)}),Ks(this,bB,"f").delete(e)):((i=Ks(this,BS,"f").get(e))===null||i===void 0||i.forEach(s=>{r&&(s.destroy(),Ks(this,_B,"f").delete(s)),Ks(this,Ql,"f").includes(s)&&Ks(this,Ql,"f").splice(Ks(this,Ql,"f").indexOf(s),1)}),r&&Ks(this,BS,"f").delete(e))}hideUIs(){[...Ks(this,Ql,"f")].forEach(e=>{e.shapes.some(r=>r.has(Ii))&&(Ks(this,Ql,"f").splice(Ks(this,Ql,"f").indexOf(e),1),Ks(this,wB,"f").push(e))})}showUIs(){Ks(this,wB,"f").forEach(e=>{Ks(this,Ql,"f").push(e)}),vB(this,wB,[],"f")}destroy(){Ks(this,_B,"f").forEach(e=>{e.destroyed||e.destroy()}),Ks(this,_B,"f").clear(),vB(this,BS,new WeakMap,"f"),vB(this,bB,new WeakMap,"f"),vB(this,iU,Object.create(null),"f"),vB(this,wB,[],"f"),this.clear()}clear(){vB(this,Ql,[],"f")}sort(){Ks(this,Ql,"f").sort((e,r)=>{const i=e.shapes[0],s=r.shapes[0];return vO(i,s)})}buildFlushSegments(){const e=[];let r=[];for(const i of Ks(this,Ql,"f"))i.needsNodeLayerBlend()?(r.length>0&&(e.push({type:"normal",drawcalls:[...r]}),r=[]),e.push({type:"layerBlend",drawcall:i})):r.push(i);return r.length>0&&e.push({type:"normal",drawcalls:r}),e}flushDrawcalls(e,r,i,s,o){o.forEach(n=>
9998{n.submit(e,r,i,s)})}scheduleFlush(e,r,i,s,o,n,a,l,c,h){var u;c&&this.sort(),Ks(this,yz,"m",gJ).call(this);const d=this.buildFlushSegments();if(!d.some(v=>v.type==="layerBlend")){e.pushPass(v=>{v.setDebugName(h),v.attachRenderTargetID(In.Color0,r),v.attachRenderTargetID(In.DepthStencil,i),v.exec(b=>{l(b),this.flushDrawcalls(b,s,o,e,Ks(this,Ql,"f"))})});return}((u=d[0])===null||u===void 0?void 0:u.type)==="layerBlend"&&d.unshift({type:"normal",drawcalls:[]});let f=!0;const g={backbufferWidth:n,backbufferHeight:a,antialiasingMode:V3.None},p=iz(Ra),m=zte;for(const v of d)if(v.type==="normal")e.pushPass(b=>{b.setDebugName(f?h:`${h} (cont)`),b.attachRenderTargetID(In.Color0,r),b.attachRenderTargetID(In.DepthStencil,i),b.exec(y=>{f&&(l(y),f=!1),this.flushDrawcalls(y,s,o,e,v.drawcalls)})});else{const b=e.createRenderTargetID(Hte(g,p),"Node Layer Blend Src"),y=e.createRenderTargetID(sz(In.DepthStencil,g,m),"Node Layer Blend Src Depth");e.pushPass(E=>{E.setDebugName("Node Layer Blend Src"),E.attachRenderTargetID(In.Color0,b),E.attachRenderTargetID(In.DepthStencil,y),E.exec(A=>{v.drawcall.renderNodeLayerBlendSrcInPass(A,s,o)})});const _=e.resolveRenderTarget(b),w=e.resolveRenderTarget(r);e.pushPass(E=>{E.setDebugName("Node Layer Blend"),E.attachRenderTargetID(In.Color0,r),E.attachRenderTargetID(In.DepthStencil,i),E.attachResolveTexture(w),E.attachResolveTexture(_),E.exec((A,x)=>{const S=x.getResolveTextureForID(w),T=x.getResolveTextureForID(_);v.drawcall.submitNodeLayerBlendComposite(A,S,T,s,o,n,a)})})}}flush(e,r,i,s){Ks(this,yz,"m",gJ).call(this),Ks(this,Ql,"f").forEach(o=>{o.submit(e,r,i,s)})}stats(){return{drawcallCount:Ks(this,Ql,"f").length}}}Ql=new WeakMap,_B=new WeakMap,BS=new WeakMap,bB=new WeakMap,iU=new WeakMap,wB=new WeakMap,yz=new WeakSet,gJ=function(){const t=[],e=[],r=[],i=[];Ks(this,Ql,"f").forEach(s=>{s.shapes.forEach(o=>{o.has(Sn)&&(r.push(o),t.push(s)),o.has(yi)&&(i.push(o),e.push(s))})}),t.forEach(s=>s.geometryDirty=!0),e.forEach(s=>s.materialDirty=!0),r.forEach(s=>
9998Zr(s,Sn)),i.forEach(s=>Zr(s,yi))};var Zee={trailer:59};function Rvt(t=256){let e=0,r=new Uint8Array(t);return{get buffer(){return r.buffer},reset(){e=0},bytesView(){return r.subarray(0,e)},bytes(){return r.slice(0,e)},writeByte(s){i(e+1),r[e]=s,e++},writeBytes(s,o=0,n=s.length){i(e+n);for(let a=0;a<n;a++)r[e++]=s[a+o]},writeBytesView(s,o=0,n=s.byteLength){i(e+n),r.set(s.subarray(o,o+n),e),e+=n}};function i(s){var o=r.length;if(o>=s)return;var n=1024*1024;s=Math.max(s,o*(o<n?2:1.125)>>>0),o!=0&&(s=Math.max(s,256));let a=r;r=new Uint8Array(s),e>0&&r.set(a.subarray(0,e),0)}}var mJ=12,Cvt=5003,Jee=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];function Qee(t,e,r,i,s=Rvt(512),o=new Uint8Array(256),n=new Int32Array(Cvt),a=new Int32Array(Cvt)){let l=n.length,c=Math.max(2,i);o.fill(0),a.fill(0),n.fill(-1);let h=0,u=0,d=c+1,f=d,g=!1,p=f,m=(1<<p)-1,v=1<<d-1,b=v+1,y=v+2,_=0,w=r[0],E=0;for(let S=l;S<65536;S*=2)++E;E=8-E,s.writeByte(c),x(v);let A=r.length;for(let S=1;S<A;S++)t:{let T=r[S],R=(T<<mJ)+w,B=T<<E^w;if(n[B]===R){w=a[B];break t}let O=B===0?1:l-B;for(;n[B]>=0;)if(B-=O,B<0&&(B+=l),n[B]===R){w=a[B];break t}x(w),w=T,y<1<<mJ?(a[B]=y++,n[B]=R):(n.fill(-1),y=v+2,g=!0,x(v))}return x(w),x(b),s.writeByte(0),s.bytesView();function x(S){for(h&=Jee[u],u>0?h|=S<<u:h=S,u+=p;u>=8;)o[_++]=h&255,_>=254&&(s.writeByte(_),s.writeBytesView(o,0,_),_=0),h>>=8,u-=8;if((y>m||g)&&(g?(p=f,m=(1<<p)-1,g=!1):(++p,m=p===mJ?1<<p:(1<<p)-1)),S==b){for(;u>0;)o[_++]=h&255,_>=254&&(s.writeByte(_),s.writeBytesView(o,0,_),_=0),h>>=8,u-=8;_>0&&(s.writeByte(_),s.writeBytesView(o,0,_),_=0)}}}var tre=Qee;function Mvt(t,e,r){return t<<8&63488|e<<2&992|r>>3}function Bvt(t,e,r,i){return t>>4|e&240|(r&240)<<4|(i&240)<<8}function Ovt(t,e,r){return t>>4<<8|e&240|r>>4}function vz(t,e,r){return t<e?e:t>r?r:t}function _z(t){return t*t}function Ivt(t,e,r){var i=0,s=1e100;let o=t[e],n=o.cnt;o.ac;let a=o.rc,l=o.gc,c=o.bc;for(var h=o.fw;h!=0;h=t[h].fw){let d=t[h],f=d.cnt,g=n*f/(n+f);if(!(g>=s)){var u=0;u+=g*_z(d.rc-a),!(u>=s)&&(u+=g*_z(d.gc-l),!(u>=s)&&(u+=g*_z(d.bc-c),!(u>=s)&&(s=u,i=h)))}}o.err=s,o.nn=i}function yJ(){return{ac:0,rc:0,gc:0,bc:0,cnt:0,nn:0,fw:0,bk:0,tm:0,mtm:0,err:0}}function ere(t,e){let r=e==="rgb444"?4096:65536,i=new Array(r),s=t.length;if(e==="rgba4444")for(let o=0;o<s;++o){let n=t[o],a=n>>24&255,l=n>>16&255,c=n>>8&255,h=n&255,u=Bvt(h,c,l,a),d=u in i?i[u]:i[u]=yJ();d.rc+=h,d.gc+=c,d.bc+=l,d.ac+=a,d.cnt++}else if(e==="rgb444")for(let o=0;o<s;++o){let n=t[o],a=n>>16&255,l=n>>8&255,c=n&255,h=Ovt(c,l,a),u=h in i?i[h]:i[h]=yJ();u.rc+=c,u.gc+=l,u.bc+=a,u.cnt++}else for(let o=0;o<s;++o){let n=t[o],a=n>>16&255,l=n>>8&255,c=n&255,h=Mvt(c,l,a),u=h in i?i[h]:i[h]=yJ();u.rc+=c,u.gc+=l,u.bc+=a,u.cnt++}return i}function rre(t,e,r={}){let{format:i="rgb565",clearAlpha:s=!0,clearAlphaColor:o=0,clearAlphaThreshold:n=0,oneBitAlpha:a=!1}=r;if(!t||!t.buffer)throw new Error("quantize() expected RGBA Uint8Array data");if(!(t instanceof Uint8Array)&&!(t instanceof Uint8ClampedArray))throw new Error("quantize() expected RGBA Uint8Array data");let l=new Uint32Array(t.buffer),c=r.useSqrt!==!1,h=i==="rgba4444",u=ere(l,i),d=u.length,f=d-1,g=new Uint32Array(d+1);for(var p=0,m=0;m<d;++m){let C=u[m];if(C!=null){var v=1/C.cnt;h&&(C.ac*=v),C.rc*=v,C.gc*=v,C.bc*=v,u[p++]=C}}_z(e)/p<.022&&(c=!1);for(var m=0;m<p-1;++m)u[m].fw=m+1,u[m+1].bk=m,c&&(u[m].cnt=Math.sqrt(u[m].cnt));c&&(u[m].cnt=Math.sqrt(u[m].cnt));var b,y,_;for(m=0;m<p;++m){Ivt(u,m);var w=u[m].err;for(y=++g[0];y>1&&(_=y>>1,!(u[b=g[_]].err<=w));y=_)g[y]=b;g[y]=m}var E=p-e;for(m=0;m<E;){for(var A;;){var x=g[1];if(A=u[x],A.tm>=A.mtm&&u[A.nn].mtm<=A.tm)break;A.mtm==f?x=g[1]=g[g[0]--]:(Ivt(u,x),A.tm=m);var w=u[x].err;for(y=1;(_=y+y)<=g[0]&&(_<g[0]&&u[g[_]].err>u[g[_+1]].err&&_++,!(w<=u[b=g[_]].err));y=_)g[y]=b;g[y]=x}var S=u[A.nn],T=A.cnt,R=S.cnt,v=1/(T+R);h&&(A.ac=v*(T*A.ac+R*S.ac)),A.rc=v*(T*A.rc+R*S.rc),A.gc=v*(T*A.gc+R*S.gc),A.bc=v*(T*A.bc+R*S.bc),A.cnt+=S.cnt,A.mtm=++m,u[S.bk].fw=S.fw,u[S.fw].bk=S.bk,S.mtm=f}let B=[];var O=0;for(m=0;;++O){let C=vz(Math.round(u[m].rc),0,255),F=vz(Math.round(u[m].gc),0,255),U=vz(Math.round(u[m].bc),0,255),H=255;h&&(H=vz(Math.round(u[m].ac),0,255),a&&(H=H<=(typeof a=="number"?a:127)?0:255),s&&H<=n&&(C=F=U=o,H=0));let N=h?[C,F,U,H]:[C,F,U];if(ire(B,N)||B.push(N),(m=u[m].fw)==0)break}return B}function ire(t,e){for(let r=0;r<t.length;r++){let i=t[r],s=i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2],o=i.length>=4&&e.length>=4?i[3]===e[3]:!0;if(s&&o)return!0}return!1}function sre(t,e,r="rgb565"){if(!t||!t.buffer)throw new Error("quantize() expected RGBA Uint8Array data");if(!(t instanceof Uint8Array)&&!(t instanceof Uint8ClampedArray))throw new Error("quantize() expected RGBA Uint8Array data");if(e.length>
9998256)throw new Error("applyPalette() only works with 256 colors or less");let i=new Uint32Array(t.buffer),s=i.length,o=r==="rgb444"?4096:65536,n=new Uint8Array(s),a=new Array(o);if(r==="rgba4444")for(let l=0;l<s;l++){let c=i[l],h=c>>24&255,u=c>>16&255,d=c>>8&255,f=c&255,g=Bvt(f,d,u,h),p=g in a?a[g]:a[g]=ore(f,d,u,h,e);n[l]=p}else{let l=r==="rgb444"?Ovt:Mvt;for(let c=0;c<s;c++){let h=i[c],u=h>>16&255,d=h>>8&255,f=h&255,g=l(f,d,u),p=g in a?a[g]:a[g]=nre(f,d,u,e);n[c]=p}}return n}function ore(t,e,r,i,s){let o=0,n=1e100;for(let a=0;a<s.length;a++){let l=s[a],c=l[3],h=OS(c-i);if(h>n)continue;let u=l[0];if(h+=OS(u-t),h>n)continue;let d=l[1];if(h+=OS(d-e),h>n)continue;let f=l[2];h+=OS(f-r),!(h>n)&&(n=h,o=a)}return o}function nre(t,e,r,i){let s=0,o=1e100;for(let n=0;n<i.length;n++){let a=i[n],l=a[0],c=OS(l-t);if(c>o)continue;let h=a[1];if(c+=OS(h-e),c>o)continue;let u=a[2];c+=OS(u-r),!(c>o)&&(o=c,s=n)}return s}function OS(t){return t*t}function are(t={}){let{initialCapacity:e=4096,auto:r=!0}=t,i=Rvt(e),s=5003,o=new Uint8Array(256),n=new Int32Array(s),a=new Int32Array(s),l=!1;return{reset(){i.reset(),l=!1},finish(){i.writeByte(Zee.trailer)},bytes(){return i.bytes()},bytesView(){return i.bytesView()},get buffer(){return i.buffer},get stream(){return i},writeHeader:c,writeFrame(h,u,d,f={}){let{transparent:g=!1,transparentIndex:p=0,delay:m=0,palette:v=null,repeat:b=0,colorDepth:y=8,dispose:_=-1}=f,w=!1;if(r?l||(w=!0,c(),l=!0):w=!!f.first,u=Math.max(0,Math.floor(u)),d=Math.max(0,Math.floor(d)),w){if(!v)throw new Error("First frame must include a { palette } option");cre(i,u,d,v,y),Dvt(i,v),b>=0&&hre(i,b)}let E=Math.round(m/10);lre(i,_,E,g,p);let A=!!v&&!w;ure(i,u,d,A?v:null),A&&Dvt(i,v),dre(i,h,u,d,y,o,n,a)}};function c(){Pvt(i,"GIF89a")}}function lre(t,e,r,i,s){t.writeByte(33),t.writeByte(249),t.writeByte(4),s<0&&(s=0,i=!1);var o,n;i?(o=1,n=2):(o=0,n=0),e>=0&&(n=e&7),n<<=2,t.writeByte(0|n|0|o),Bw(t,r),t.writeByte(s||0),t.writeByte(0)}function cre(t,e,r,i,s=8){let o=1,n=0,a=vJ(i.length)-1,l=o<<7|s-1<<4|n<<3|a;Bw(t,e),Bw(t,r),t.writeBytes([l,0,0])}function hre(t,e){t.writeByte(33),t.writeByte(255),t.writeByte(11),Pvt(t,"NETSCAP
9998E2.0"),t.writeByte(3),t.writeByte(1),Bw(t,e),t.writeByte(0)}function Dvt(t,e){let r=1<<vJ(e.length);for(let i=0;i<r;i++){let s=[0,0,0];i<e.length&&(s=e[i]),t.writeByte(s[0]),t.writeByte(s[1]),t.writeByte(s[2])}}function ure(t,e,r,i){if(t.writeByte(44),Bw(t,0),Bw(t,0),Bw(t,e),Bw(t,r),i){let s=0,o=0,n=vJ(i.length)-1;t.writeByte(128|s|o|0|n)}else t.writeByte(0)}function dre(t,e,r,i,s=8,o,n,a){tre(r,i,e,s,t,o,n,a)}function Bw(t,e){t.writeByte(e&255),t.writeByte(e>>8&255)}function Pvt(t,e){for(var r=0;r<e.length;r++)t.writeByte(e.charCodeAt(r))}function vJ(t){return Math.max(Math.ceil(Math.log2(t)),1)}var bz=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};const _J={high:256,medium:128,low:64};function fre(t){return t==null?_J.high:_J[t]??_J.high}function Fvt(){if(typeof MediaRecorder>"u")return null;const t=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];for(const e of t)if(MediaRecorder.isTypeSupported(e))return e;return null}function Nvt(){return new Promise(t=>requestAnimationFrame(()=>t()))}function pre(t,e,r,i=.92){return gre(t,e,r,i)}function gre(t,e,r,i){return bz(this,void 0,void 0,function*(){const s=Fvt();if(!s)throw new Error("WebM encoding is not supported");const o=[];r(0),yield Nvt();let n=t();const a=n.width,l=n.height;if(a<1||l<1)return new Blob([],{type:"video/webm"});const c=document.createElement("canvas");c.width=a,c.height=l;const h=c.getContext("2d",{willReadFrequently:!0});if(!h)return new Blob([],{type:"video/webm"});const u=g=>new Promise((p,m)=>{const v=new Image;v.onload=()=>{h.clearRect(0,0,a,l),h.drawImage(v,0,0,a,l),p()},v.onerror=()=>m(new Error("WebM: frame PNG decode failed")),v.src=g});yield u(n.toDataURL("image/png",i));const d=c.captureStream(0),f=d.getVideoTracks()[0];return new Promise((g,p)=>{const m=new MediaRecorder(d,{mimeType:s,videoBitsPerSecond:8e6});m.ondataavailable=v=>{v.data&&v.data.size>0&&o.push(v.data)},m.onerror=()=>p(new Error("MediaRecorder error")),m.onstop=()=>{var v;const b=(v=s.split(";")[0])!==null&&v!==void 0?v:"video/webm";g(new Blob(o,{type:b}))},bz(this,void 0,void 0,function*(){try{if(!f.requestFrame)throw new Error("Canvas capture track has no requestFrame()");m.start(100),f.requestFrame();for(let v=1;v<e;v++){if(r(v),yield Nvt(),n=t(),n.width!==a||n.height!==l){p(new Error("WebM: export size changed between frames"));return}yield u(n.toDataURL("image/png",i)),f.requestFrame()}yield new Promise(v=>setTimeout(v,0)),m.stop()}catch(v){p(v)}})})})}function mre(t,e,r,i){return bz(this,void 0,void 0,function*(){const s=new Image;return yield new Promise((o,n)=>{s.onload=()=>o(),s.onerror=()=>n(new Error("GIF frame: failed to decode PNG data URL")),s.src=t}),i.clearRect(0,0,e,r),i.drawImage(s,0,0,e,r),i.getImageData(0,0,e,r)})}function yre(t,e,r,i){return bz(this,arguments,void 0,function*(s,o,n,a,l=.92,c=256){const h=Math.max(2,Math.min(256,Math.floor(c))),u=Math.max(1,Math.round(1e3/Math.max(1,n)));let d=0,f=0,g=null;const p=are();for(let m=0;m<o;m++){a(m);const v=s();if(m===0){if(d=v.width,f=v.height,d<1||f<1)return new Blob;const E=document.createElement("canvas");if(E.width=d,E.height=f,g=E.getContext("2d",{willReadFrequently:!0}),!g)return new Blob}else if(v.width!==d||v.height!==f){if(d=v.width,f=v.height,d<1||f<1)return new Blob;g.canvas.width=d,g.canvas.height=f}const b=v.toDataURL("image/png",l),y=yield mre(b,d,f,g),_=rre(y.data,h),w=sre(y.data,_);p.writeFrame(w,d,f,{palette:_,delay:u})}return p.finish(),new Blob([new Uint8Array(p.bytes())],{type:"image/gif"})})}let wz=null;function vre(t){wz=t}function bJ(){return wz}function _re(t){wz===t&&(wz=null)}var bre=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
9998a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},kvt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};function wre(t){return t.has(et)||t.has(ae)||t.has($t)||t.has(Mt)||t.has(_t)||t.has(xt)||t.has(Yt)||t.has(ai)||t.has(ke)}function Ere(t){const e=[],r=i=>{if(wre(i)&&e.push(i),i.has(ze))for(const s of i.read(ze).children)r(s)};return r(t),e}function Are(t){return t.has(Zi)&&(t.has(et)||t.has(ae)||t.has($t)||t.has(Mt)||t.has(_t)||t.has(xt)||t.has(Yt)||t.has(ai)||t.has(ke)||t.has(_e))}sG=class extends We{constructor(){super(),this.setupDevice=this.attach(G3),this.canvases=this.query(t=>t.current.with(wt).read),this.gpuReadyCanvases=this.query(t=>t.added.current.with(wt,cs).read),this.cameras=this.query(t=>t.addedOrChanged.with(Pe).trackWrites),this.renderables=this.query(t=>t.added.and.changed.and.removed.with(Zi).withAny(et,ae,$t,Mt,_t,xt,Yt,ai,ke,_e).trackWrites),this.lines=this.query(t=>t.added.and.removed.with(Mt)),this.polylines=this.query(t=>t.added.and.removed.with(_t)),this.paths=this.query(t=>t.added.and.removed.with(xt)),this.vectorNetworks=this.query(t=>t.added.and.removed.with(ke)),this.toBeDeleted=this.query(t=>t.addedOrChanged.with(Tn).trackWrites),this.culleds=this.query(t=>t.addedOrChanged.and.removed.with(jc).trackWrites),this.grids=this.query(t=>t.addedChangedOrRemoved.with(rd).trackWrites),this.themes=this.query(t=>t.addedChangedOrRemoved.with(ul).trackWrites),this.rasterScreenshotRequests=this.query(t=>t.addedChangedOrRemoved.with(Ca).trackWrites),this.rasterAnimationExportRequests=this.query(t=>t.addedChangedOrRemoved.with(Ga).trackWrites),this.fillLayers=this.query(t=>t.addedChangedOrRemoved.with(Ce).trackWrites),this.strokeLayers=this.query(t=>t.addedChangedOrRemoved.with(Fs).trackWrites),this.fillTextures=this.query(t=>t.addedChangedOrRemoved.with(yh).trackWrites),this.strokes=this.query(t=>t.addedChangedOrRemoved.with(Gt).trackWrites),this.rectsStrokeGradientBounds=this.query(t=>t.addedChangedOrRemoved.with($t).trackWrites),this.ellipsesStrokeGradientBounds=this.query(t=>t.addedChangedOrRemoved.with(ae).trackWrites),this.circlesStrokeGradientBounds=this.query(t=>t.addedChangedOrRemoved.with(et).trackWrites),this.opacities=this.query(t=>t.addedChangedOrRemoved.with(bo).trackWrites),this.innerShadows=this.query(t=>t.addedChangedOrRemoved.with(ac).trackWrites),this.dropShadows=this.query(t=>t.addedChangedOrRemoved.with(ro).trackWrites),this.wireframes=this.query(t=>t.addedChangedOrRemoved.with(jy).trackWrites),this.roughs=this.query(t=>t.addedChangedOrRemoved.with(ue).trackWrites),this.fractionalIndexes=this.query(t=>t.addedChangedOrRemoved.with(Gs).trackWrites),this.textDecorations=this.query(t=>t.addedChangedOrRemoved.with(wa).trackWrites),this.sizeAttenuations=this.query(t=>t.addedChangedOrRemoved.with(Xc).trackWrites),this.strokeAttenuations=this.query(t=>t.addedChangedOrRemoved.with(Qn).trackWrites),this.markers=this.query(t=>t.addedChangedOrRemoved.with(qo).trackWrites),this.filters=this.query(t=>t.addedChangedOrRemoved.with(La).trackWrites),this.nodeLayerBlendModes=this.query(t=>t.addedChangedOrRemoved.with(zy).trackWrites),this.filtersCurrent=this.query(t=>t.current.with(La).read),this.fillTextureLiveCurrent=this.query(t=>t.current.with(JU).read),this.clipModes=this.query(t=>t.addedChangedOrRemoved.with(Gc).trackWrites),this.meshes3DChanged=this.query(t=>t.addedOrChanged.and.current.with(Ns,Ni,ki).trackWrites),this.extrude3DChanged=this.query(t=>t.addedOrChanged.and.removed.with(Lo).trackWrites),this.cameras3DChanged=this.query(t=>t.addedOrChanged.and.current.with(Bi).trackWrites),this.renderers=new Map,this.partialRasterRenderers=new Map,this.pendingRenderables=new WeakMap,this.query(t=>t.using(js,Lo).read.and.current.with(ul,rd,cs,jt,Bi,Pe,ze,be,et,ae,$t,Mt,_t,xt,wo,fe,Ae,bo,Gt,ac,ro,jy,Ln,ue,iu,Yt,Ji,Ce,yh,Gs,Xc,Qn,wa,Ii,Ls,qo,tu,Gc,mh,Hn,sm,Ns,Ni,ar,Kn).read.and.using(Ca,Ga,Vy,vh,Sn,yi,Ji,ki).write)}collectRainUrlsForRasterExport(t,e){const r=new Set,i=e.length>0?e:t.getNodes();for(const s of i){const o="filter"in s&&typeof s.filter=="string"?s.filter:void 0;for(const n of vZ(o))r.add(n)}return[...r]}rasterExportHasRainFx(t,e){const r=i=>i!=null&&i.trim()?Iv(i).some(s=>s.type==="rain"&&YV(s)):!1;if(e.length>0){for(const i of e)if("filter"in i&&typeof i.filter=="string"&&r(i.filter))return!0;return!1}return r(t.getAppState().filter)}runRasterScreenshotExport(t,e){return kvt(this,void 0,void 0,function*(){var r,i;if(!t.has(Ca))return;const s=t.read(Ca),{api:o}=t.read(wt),n=this.collectRainUrlsForRasterExport(o,s.nodes);if(n.length>0)try{yield Promise.all([_Z(n),Lte(n)])}catch(u){console.warn("rain: preload drop textures before export failed",u)}const a=Math.max(0,(r=s.rainWarmupSec)!==null&&r!==void 0?r:0),l=(i=s.rainCaptureTimeSec)!==null&&i!==void 0?i:0,c=l>0&&Number.isFinite(l)?l:a,h=a>0&&this.rasterExportHasRainFx(o,s.nodes);h&&ZZ({kind:"png",warmupSec:a,captureTimeSec:c>0?c:a});try{this.renderCamera(t,e,!0,Object.assign({}
9998,h?{postEffectTimeSec:c>0?c:a}:{}))}finally{h&&rz(),s.nodes.length>0&&this.releasePartialRasterRenderer(t)}})}*setScreenshotTrigger(t,e,r){nt(t,vh);const i=t.write(vh);Object.assign(i,{dataURL:e,canvas:t,download:r}),yield,Zr(t,vh),Zr(t,Ca)}getOrCreatePartialRasterRenderer(t,e,r){let i=this.partialRasterRenderers.get(t);return i||(i=this.createRenderer(e,r),this.partialRasterRenderers.set(t,i),i.dispose=t.read(cs).scope.add(i.dispose)),i}releasePartialRasterRenderer(t){const e=this.partialRasterRenderers.get(t);e&&(e.dispose(),this.partialRasterRenderers.delete(t))}createRenderer(t,e){const{device:r,swapChain:i,renderCache:s,texturePool:o,scope:n}=t,a={uniformBuffer:r.createBuffer({viewOrSize:68*Float32Array.BYTES_PER_ELEMENT,usage:Ee.UNIFORM,hint:rr.DYNAMIC}),uniformLegacyObject:null,gridRenderer:new Wte,filters:{},batchManager:new Tvt(r,i,s,o,e),dispose:()=>{}};return a.dispose=n.add(()=>{a.gridRenderer.destroy(),Object.values(a.filters).forEach(l=>l.destroy()),a.batchManager.destroy(),a.uniformBuffer.destroy(),this.renderers.forEach((l,c)=>{l===a&&(this.renderers.delete(c),this.pendingRenderables.delete(c))}),this.partialRasterRenderers.forEach((l,c)=>{l===a&&this.partialRasterRenderers.delete(c)})}),a}renderCamera(t,e,r=!1,i){var s,o;if(!t.has(cs))return;(i==null?void 0:i.postEffectTimeSec)!=null&&wX(i.postEffectTimeSec);let n,a=t.read(cs);const{api:l}=t.read(wt),{filter:c}=l.getAppState(),h=t.has(Ca)?t.read(Ca):null,u=h||(i!=null&&i.rasterForExport?{type:"image/png",encoderOptions:.92,grid:i.rasterForExport.grid,download:!1,nodes:i.rasterForExport.nodes,scale:i.rasterForExport.scale}:null),{type:d,encoderOptions:f,grid:g,download:p,nodes:m,scale:v=1}=u??{type:"image/png",encoderOptions:1,grid:!1,nodes:[],scale:1},b=!u||g,y=m.length>0,_=0;let w=null;if(y){const C=l.getBounds(m),F=C.maxX-C.minX+2*_,U=C.maxY-C.minY+2*_;if(C.minX<=C.maxX&&C.minY<=C.maxY&&F>0&&U>0){const H=Math.max(.25,Math.min(8,Number.isFinite(v)?v:1)),N=Math.max(1,Math.ceil(F*H)),G=Math.max(1,Math.ceil(U*H));this.setupDevice.resizeOffscreen(N,G);const Y=Bt();bi(Y,Y,[-(C.minX-_),-(C.minY-_)]);const q=ld(Bt(),F,U),L=us(Bt(),q,Y),J=_i(Bt(),L);w={projectionMatrix:ie.fromGLMat3(q),viewMatrix:ie.fromGLMat3(Y),viewProjectionMatrixInv:J?ie.fromGLMat3(J):ie.IDENTITY,zoom:1}}}if(y){if(a=this.setupDevice.getOffscreenGPUResource(),!a)return;n=this.getOrCreatePartialRasterRenderer(t,a,l)}else this.renderers.get(e)||this.renderers.set(e,this.createRenderer(a,l)),n=this.renderers.get(e);const{swapChain:E,device:A,renderCache:x,renderGraph:S}=a,{uniformBuffer:T,gridRenderer:R,batchManager:B,filters:O}=n;try{u&&B.hideUIs();const{width:C,height:F}=E.getCanvas();if(C<=0||F<=0)return;const U=E.getOnscreenTexture(),[H,N]=this.updateUniform(t,e,b,E,w);n.uniformLegacyObject=N,T.setSubData(0,new Uint8Array(H.buffer));const G={backbufferWidth:C,backbufferHeight:F,antialiasingMode:V3.None},Y=bJ();Y==null||Y.prepareForComposite(t);const q=(s=Y==null?void 0:Y.shouldComposite(t))!==null&&s!==void 0?s:!1,L=sz(In.Color0,G,q&&(o=Y.getColorClearDescriptor(t))!==null&&o!==void 0?o:iz(QU)),J=sz(In.DepthStencil,G,Xte),tt=S.newGraphBuilder(),bt=tt.createRenderTargetID(L,"Main Color"),ct=tt.createRenderTargetID(J,"Main Depth"),Xt=q?"Main Render Pass (3D + 2D)":"Main Render Pass";if(y){const{api:It}=t.read(wt),zt=new Set;m.forEach(Ht=>{const Lt=Ht.parentId&&It.getNodeById(Ht.parentId),tr=Lt&&It.getEntity(Lt);Lt&&!m.includes(Lt)&&Lt.clipMode&&!zt.has(tr)&&(zt.add(tr),B.add(tr));const Gr=It.getEntity(Ht),re=Ere(Gr),ci=re.length>0?re:[Gr];for(const Dt of ci)B.add(Dt)})}else this.pendingRenderables.has(e)&&(this.pendingRenderables.get(e).forEach(({type:It,entity:zt})=>{const Ht=zt.has(Tn),Lt=zt.has(jc);It==="remove"||Lt||Ht?B.remove(zt,Ht||!Lt):B.add(zt)}),this.pendingRenderables.delete(e));if(B.scheduleFlush(tt,bt,ct,T,N,C,F,It=>{R.render(A,It,T,N),q&&Y.drawMeshes(It,t,C,F)},r,Xt),Iv(c).forEach(It=>{tt.pushPass(zt=>{zt.setDebugName(It.type.toUpperCase());const Ht=tt.resolveRenderTarget(bt);zt.attachRenderTargetID(In.Color0,bt),zt.attachResolveTexture(Ht),zt.exec((Lt,tr)=>{O[It.type]||(O[It.type]=Jmt(A,E,x)),O[It.type].render(Lt,tr.getResolveTextureForID(Ht),It)})})}),tt.resolveRenderTargetToExternalTexture(bt,U),S.execute(),h){const It=E.getCanvas().toDataURL(d,f);this.setScreenshotTrigger(t,It,p)}}finally{u&&B.showUIs(),y&&h&&this.releasePartialRasterRenderer(t)}}runRasterAnimationExport(t,e,r){return kvt(this,void 0,void 0,function*(){const{durationSec:i,fps:s,timeStart:o,rainWarmupSec:n,download:a}=r;let{format:l}=r;const c=Math.max(1,Math.min(450,Math.ceil(Math.max(0,i)*Math.max(1,s)))),h=1/Math.max(1,s),u={kind:"animation",timeStart:o,invFps:h,frameIndex:0,rainWarmupSec:Math.max(0,n),warmupApplied:!1};ZZ(u);const d=p=>
9998{u.frameIndex=p,this.renderCamera(t,e,!0,{postEffectTimeSec:u.rainWarmupSec+o+p*h,rasterForExport:{grid:r.grid,nodes:r.nodes,scale:r.scale}})};if(!t.has(cs)){rz();return}l==="webm"&&!Fvt()&&(l="gif");const f=r.nodes.length>0,g=()=>f?this.setupDevice.getOffscreenGPUResource().swapChain.getCanvas():t.read(cs).swapChain.getCanvas();try{let p;l==="webm"?p=yield pre(g,c,d):p=yield yre(g,c,s,d,.92,fre(r.gifQuality)),nt(t,Vy,{canvas:t,download:a,blob:p,fileName:`infinite-canvas-animation.${l==="webm"?"webm":"gif"}`})}catch(p){console.error("Raster animation export failed",p)}finally{rz(),r.nodes.length>0&&this.releasePartialRasterRenderer(t)}})}anyFilterUsesEngineTimePost(){for(const t of this.filtersCurrent.current){const{value:e}=t.read(La);if(U2(e))return!0}return!1}queueSceneRenderable(t,e){Are(e)&&(this.pendingRenderables.has(t)||this.pendingRenderables.set(t,[]),this.pendingRenderables.get(t).push({type:"add",entity:e}),nt(e,Sn),nt(e,yi))}queueAllSceneRenderablesUnderCamera(t){if(!t.has(ze))return;const e=r=>{if(this.queueSceneRenderable(t,r),r.has(ze))for(const i of r.read(ze).children)e(i)};for(const r of t.read(ze).children)e(r)}execute(){var t;this.gpuReadyCanvases.added.forEach(o=>{for(const n of o.read(wt).cameras)this.queueAllSceneRenderablesUnderCamera(n)}),new Set([...this.renderables.added,...this.renderables.changed,...this.polylines.added,...this.lines.added,...this.paths.added,...this.vectorNetworks.added,...this.culleds.removed]).forEach(o=>{const n=En(o);this.renderables.added.includes(o)&&(nt(o,Sn),nt(o,yi)),this.renderables.changed.includes(o)&&((o.has(Mt)||o.has(_t)||o.has(xt)||o.has(Yt)||o.has(ue)||o.has(ai))&&nt(o,Sn),o.has(Yt)&&nt(o,yi)),(GXt(o)!=null||kh(o)!=null)&&nt(o,yi),this.pendingRenderables.has(n)||this.pendingRenderables.set(n,[]),this.pendingRenderables.get(n).push({type:"add",entity:o})}),new Set([...this.toBeDeleted.addedOrChanged,...this.renderables.removed,...this.polylines.removed,...this.lines.removed,...this.paths.removed,...this.vectorNetworks.removed,...this.culleds.addedOrChanged]).forEach(o=>{const n=En(o);this.pendingRenderables.has(n)||this.pendingRenderables.set(n,[]),this.pendingRenderables.get(n).push({type:"remove",entity:o})}),[...this.strokes.addedChangedOrRemoved,...this.markers.addedChangedOrRemoved].forEach(o=>{if((o.has(_t)||o.has(xt)||o.has(Mt)||o.has(ae)||o.has($t)||o.has(et))&&nt(o,Sn),o.has(Zi)&&!o.has(ue)&&(o.has(ae)||o.has($t)||o.has(et))){const n=En(o);this.pendingRenderables.has(n)||this.pendingRenderables.set(n,[]),this.pendingRenderables.get(n).push({type:"add",entity:o})}}),new Set([...this.strokeLayers.addedChangedOrRemoved,...this.rectsStrokeGradientBounds.addedChangedOrRemoved,...this.ellipsesStrokeGradientBounds.addedChangedOrRemoved,...this.circlesStrokeGradientBounds.addedChangedOrRemoved]).forEach(o=>{if(o.has(Zi)&&!o.has(ue)&&(o.has(ae)||o.has($t)||o.has(et))){const n=En(o);this.pendingRenderables.has(n)||this.pendingRenderables.set(n,[]),this.pendingRenderables.get(n).push({type:"add",entity:o}),nt(o,yi)}kh(o)!=null&&nt(o,Sn)}),this.filters.addedChangedOrRemoved.forEach(o=>{o.has(Yt)&&nt(o,yi)}),new Set([...this.extrude3DChanged.addedOrChanged,...this.extrude3DChanged.removed]).forEach(o=>{if(!o.has(Zi))return;const n=En(o);this.pendingRenderables.has(n)||this.pendingRenderables.set(n,[]);const a=this.pendingRenderables.get(n);a.push({type:"remove",entity:o}),o.has(Lo)||a.push({type:"add",entity:o})});const e=this.anyFilterUsesEngineTimePost(),r=this.fillTextureLiveCurrent.current.length>0,i=bJ(),s=this.meshes3DChanged.addedOrChanged.length>0||this.cameras3DChanged.addedOrChanged.length>0||this.extrude3DChanged.addedOrChanged.length>0||((t=i==null?void 0:i.has3DContent())!==null&&t!==void 0?t:!1);this.canvases.current.forEach(o=>{var n;if(this.rasterScreenshotRequests.addedChangedOrRemoved.includes(o)&&o.has(Ca)){const{cameras:c}=o.read(wt),h=c[0];h&&this.runRasterScreenshotExport(o,h);return}if(this.rasterAnimationExportRequests.addedChangedOrRemoved.includes(o)&&o.has(Ga)){const c=o.read(Ga),h={download:c.download,format:c.format,durationSec:c.durationSec,fps:c.fps,grid:c.grid,nodes:c.nodes,scale:c.scale,timeStart:c.timeStart,rainWarmupSec:(n=c.rainWarmupSec)!==null&&n!==void 0?n:0,gifQuality:c.gifQuality};Zr(o,Ga);const{cameras:u}=o.read(wt),d=u[0];d&&this.runRasterAnimationExport(o,d,h);return}let a=this.grids.addedChangedOrRemoved.includes(o)||this.themes.addedChangedOrRemoved.includes(o)||e||r||s;const{cameras:l}=o.read(wt);l.forEach(c=>{if(!a&&this.pendingRenderables.get(c)&&(a=!!this.pendingRenderables.get(c).length),!a&&this.cameras.addedOrChanged.includes(c)&&(a=!0),this.fillLayers.addedChangedOrRemoved.length>0)for(const h of this.fillLayers.addedChangedOrRemoved)h.has(Zi)&&nt(h,yi);!a&&(this.fillLayers.addedChangedOrRemoved.length||this.strokeLayers.addedChangedOrRemoved.length||this.fillTextures.addedChangedOrRemoved.length||this.strokes.addedChangedOrRemoved.length||this.opacities.addedChangedOrRemoved.length||this.innerShadows.addedChangedOrRemoved.length||this.dropShadows.addedChangedOrRemoved.length||this.wireframes.addedChangedOrRemoved.length||this.roughs.addedChangedOrRemoved.length||this.fractionalIndexes.addedChangedOrRemoved.length||this.textDecorations.addedChangedOrRemoved.length||this.sizeAttenuations.addedChangedOrRemoved.length||this.strokeAttenuations.addedChangedOrRemoved.length||this.markers.addedChangedOrRemoved.length||this.filters.addedChangedOrRemoved.length||this.nodeLayerBlendM
9998odes.addedChangedOrRemoved.length||this.clipModes.addedChangedOrRemoved.length)&&(a=!0),a&&this.renderCamera(o,c,!0)})})}finalize(){this.renderers.forEach(t=>t.dispose()),this.partialRasterRenderers.forEach(t=>t.dispose()),this.renderers.clear(),this.partialRasterRenderers.clear()}updateUniform(t,e,r,i,s){const{mode:o,colors:n}=t.read(ul),{checkboardStyle:a}=t.read(rd),l=e.read(Pe),{width:c,height:h}=i.getCanvas(),u=n[o].background,d=n[o].grid,{r:f,g,b:p,opacity:m}=Wo(u),{r:v,g:b,b:y,opacity:_}=Wo(d),{projectionMatrix:w,viewMatrix:E,viewProjectionMatrixInv:A,zoom:x}=s??l,S=w,T=E,R=A,B=[f/255,g/255,p/255,m],O=[v/255,b/255,y/255,_],C=x,F=r?[wh.NONE,wh.GRID,wh.DOTS].indexOf(a):0,U=[c,h],H=new Float32Array([...sh(S),...sh(T),...sh(R),...B,...O,C,F,...U]),N={u_ProjectionMatrix:ie.toGLMat3(S),u_ViewMatrix:ie.toGLMat3(T),u_ViewProjectionInvMatrix:ie.toGLMat3(R),u_BackgroundColor:B,u_GridColor:O,u_ZoomScale:C,u_CheckboardStyle:F,u_Viewport:U};return[H,N]}},bre([bO],sG.prototype,"setScreenshotTrigger",null);function sU(t){let e=t;const r=new Set;for(;e&&!r.has(e);){if(r.add(e),e.has(js))return e.read(js).canvas;if(e.has(jt)){const i=e.read(jt).canvas;if(i)return i}if(e.has(be))e=e.read(be).parent;else break}}function xre(t,e,r){if(t.has(js)){const i=t.read(js).canvas;return nr(i)&&i===e}return r===1}function IS(t,e,r){for(const i of t)if(nr(i)){if(i.has(js)){const s=i.read(js).canvas;if(nr(s)&&s===e)return i;continue}if(r===1)return i}}function EB(t,e){return t.find(r=>r.has(jt)&&r.read(jt).canvas===e)}function Ow(t,e,r){return t.filter(i=>xre(i,e,r))}const Sre=` 9999#define MAX_3D_LIGHTS 8 10000 10001layout(std140) uniform SceneUniforms3D { 10002 mat4 u_ProjectionMatrix3D; 10003 mat4 u_ViewMatrix3D; 10004 mat4 u_CanvasViewProjection3D; 10005 // z=1: linked perspective; xyw = camera eye (canvas space) for lighting 10006 vec4 u_SceneParams; 10007 vec4 u_AmbientLight; 10008 vec4 u_LightCount; 10009 vec4 u_LightPositions[MAX_3D_LIGHTS]; 10010 vec4 u_LightDirections[MAX_3D_LIGHTS]; 10011 vec4 u_LightColors[MAX_3D_LIGHTS]; 10012 vec4 u_LightParams3D[MAX_3D_LIGHTS]; 10013}; 10014 10015layout(std140) uniform ModelUniforms3D { 10016 mat4 u_ModelMatrix3D; 10017 mat4 u_NormalMatrix3D; 10018 vec4 u_BaseColor; 10019 vec4 u_LightParams; // x: ambient, y: diffuse, z: specular, w: shininess 10020 vec4 u_LightDirection; // deprecated: kept for uniform-buffer layout compatibility 10021 // xy: Transform3D.translation (perspective anchor on canvas) 10022 vec4 u_CanvasAnchor; 10023 // x: map, y: specularMap, z: bumpMap, w: bumpScale 10024 vec4 u_MaterialFlags; 10025 // x: metallic, y: roughness (PBR metallic-roughness workflow) 10026 vec4 u_PbrParams; 10027}; 10028 10029layout(location = 0) in vec3 a_Position3D; 10030layout(location = 1) in vec3 a_Normal3D; 10031layout(location = 2) in vec2 a_Uv3D; 10032 10033out vec3 v_Normal; 10034out vec3 v_FragPos; 10035out vec2 v_Uv; 10036 10037void main() { 10038 vec4 worldPos = u_ModelMatrix3D * vec4(a_Position3D, 1.0); 10039 v_FragPos = worldPos.xyz; 10040 v_Normal = (u_NormalMatrix3D * vec4(a_Normal3D, 0.0)).xyz; 10041 v_Uv = a_Uv3D; 10042 10043 if (u_SceneParams.z > 0.5) { 10044 // 2D VP: pan / zoom / Y-flip; perspective scales offsets from placement anchor. 10045 vec4 clip2d = u_CanvasViewProjection3D * vec4(worldPos.xy, 0.0, 1.0); 10046 vec4 anchor2d = u_CanvasViewProjection3D * 10047 vec4(u_CanvasAnchor.xy, 0.0, 1.0); 10048 vec4 viewPos = u_ViewMatrix3D * worldPos; 10049 vec4 clipP = u_ProjectionMatrix3D * viewPos; 10050 vec4 viewRef = u_ViewMatrix3D * 10051 vec4(worldPos.x, worldPos.y, u_CanvasAnchor.z, 1.0); 10052 float clipPwRef = (u_ProjectionMatrix3D * viewRef).w; 10053 float pw = clipP.w; 10054 if (abs(pw) < 1e-6) { 10055 pw = pw >= 0.0 ? 1e-6 : -1e-6; 10056 } 10057 // Canvas z+ points into the screen; nearer faces have larger pw. 10058 float scale = pw / clipPwRef; 10059 gl_Position.xy = anchor2d.xy + (clip2d.xy - anchor2d.xy) * scale; 10060 gl_Position.z = clipP.z * clip2d.w / pw; 10061 gl_Position.w = clip2d.w; 10062 } else { 10063 gl_Position = u_ProjectionMatrix3D * u_ViewMatrix3D * worldPos; 10064 } 10065} 10066`,Tre=` 10067#define MAX_3D_LIGHTS 8 10068#define LIGHT_TYPE_DIRECTIONAL 1 10069#define LIGHT_TYPE_POINT 2 10070#define LIGHT_TYPE_SPOT 3 10071 10072// Order must match vert (WebGPU assigns UBO bindings by declaration order per stage). 10073layout(std140) uniform SceneUniforms3D { 10074 mat4 u_ProjectionMatrix3D; 10075 mat4 u_ViewMatrix3D; 10076 mat4 u_CanvasViewProjection3D; 10077 vec4 u_SceneParams; 10078 vec4 u_AmbientLight; 10079 vec4 u_LightCount; 10080 vec4 u_LightPositions[MAX_3D_LIGHTS]; 10081 vec4 u_LightDirections[MAX_3D_LIGHTS]; 10082 vec4 u_LightColors[MAX_3D_LIGHTS]; 10083 vec4 u_LightParams3D[MAX_3D_LIGHTS]; 10084}; 10085 10086layout(std140) uniform ModelUniforms3D { 10087 mat4 u_ModelMatrix3D; 10088 mat4 u_NormalMatrix3D; 10089 vec4 u_BaseColor; 10090 vec4 u_LightParams; // x: ambient, y: diffuse, z: specular, w: shininess 10091 vec4 u_LightDirection; // deprecated: kept for uniform-buffer layout compatibility 10092 // xy: Transform3D.translation (perspective anchor on canvas) 10093 vec4 u_CanvasAnchor; 10094 // x: map, y: specularMap, z: bumpMap, w: bumpScale 10095 vec4 u_MaterialFlags; 10096 // x: metallic, y: roughness (PBR metallic-roughness workflow) 10097 vec4 u_PbrParams; 10098}; 10099 10100uniform sampler2D u_Map; 10101uniform sampler2D u_SpecularMap; 10102uniform sampler2D u_BumpMap; 10103 10104in vec3 v_Normal; 10105in vec3 v_FragPos; 10106in vec2 v_Uv; 10107 10108out vec4 outputColor; 10109 10110#define PI 3.141592653589793 10111 10112float distanceAttenuation(float distanceToLight, float range) { 10113 if (range <= 0.0) { 10114 return 1.0; 10115 } 10116 float factor = clamp(1.0 - distanceToLight / range, 0.0, 1.0); 10117 return factor * factor; 10118} 10119 10120// GGX / Trowbridge-Reitz normal distribution function. 10121float distributionGGX(float NdotH, float roughness) { 10122 float a = roughness * roughness; 10123 float a2 = a * a; 10124 float NdotH2 = NdotH * NdotH; 10125 float denom = NdotH2 * (a2 - 1.0) + 1.0; 10126 denom = PI * denom * denom; 10127 return a2 / max(denom, 1e-6); 10128} 10129 10130// Schlick-GGX geometry term (single direction) with direct-lighting k. 10131float geometrySchlickGGX(float NdotX, float roughness) { 10132 float r = roughness + 1.0; 10133 float k = (r * r) / 8.0; 10134 return NdotX / (NdotX * (1.0 - k) + k); 10135} 10136 10137// Smith geometry term combining view and light occlusion. 10138float geometrySmith(float NdotV, float NdotL, float roughness) { 10139 return geometrySchlickGGX(NdotV, roughness) * 10140 geometrySchlickGGX(NdotL, roughness); 10141} 10142 10143// Schlick Fresnel approximation. 10144vec3 fresnelSchlick(float cosTheta, vec3 F0) { 10145 return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0); 10146} 10147 10148// Cook-Torrance microfacet BRDF for a single analytic light. 10149vec3 shadeLight( 10150 int index, 10151 vec3 normal, 10152 vec3 viewDir, 10153 vec3 albedo, 10154 vec3 F0, 10155 float metallic, 10156 float roughness, 10157 float specularScale 10158) { 10159 vec4 params = u_LightParams3D[index]; 10160 int lightType = int(params.x); 10161 float intensity = params.y; 10162 float range = params.z; 10163 float cosInner = params.w; 10164 float cosOuter = u_LightDirections[index].w; 10165 vec3 lightColor = u_LightColors[index].rgb * intensity; 10166 vec3 lightDir = vec3(0.0, 0.0, 1.0); 10167 float attenuation = 1.0; 10168 10169 if (lightType == LIGHT_TYPE_DIRECTIONAL) { 10170 lightDir = normalize(-u_LightDirections[index].xyz); 10171 } else { 10172 vec3 toLight = u_LightPositions[index].xyz - v_FragPos; 10173 float distanceToLight = length(toLight); 10174 if (distanceToLight > 1e-6) { 10175 lightDir = toLight / distanceToLight; 10176 } 10177 attenuation *= distanceAttenuation(distanceToLight, range); 10178 10179 if (lightType == LIGHT_TYPE_SPOT) { 10180 vec3 spotDirection = normalize(u_LightDirections[index].xyz); 10181 float spotCos = dot(-lightDir, spotDirection);
10182 float cone = smoothstep(cosOuter, cosInner, spotCos); 10183 attenuation *= cone; 10184 } 10185 } 10186 10187 vec3 halfDir = normalize(lightDir + viewDir); 10188 float NdotL = max(dot(normal, lightDir), 0.0); 10189 float NdotV = max(dot(normal, viewDir), 0.0); 10190 float NdotH = max(dot(normal, halfDir), 0.0); 10191 float HdotV = max(dot(halfDir, viewDir), 0.0); 10192 10193 vec3 radiance = lightColor * attenuation; 10194 10195 float NDF = distributionGGX(NdotH, roughness); 10196 float G = geometrySmith(NdotV, NdotL, roughness); 10197 vec3 F = fresnelSchlick(HdotV, F0); 10198 10199 vec3 numerator = NDF * G * F * specularScale; 10200 float denom = 4.0 * NdotV * NdotL + 1e-4; 10201 vec3 specular = numerator / denom; 10202 10203 // Energy conservation: metals have no diffuse contribution. 10204 vec3 kD = (vec3(1.0) - F) * (1.0 - metallic); 10205 10206 return (kD * albedo / PI + specular) * radiance * NdotL; 10207} 10208 10209vec3 perturbNormalFromBumpMap(vec3 normal, vec2 uv, float bumpScale) { 10210 vec3 dp1 = dFdx(v_FragPos); 10211 vec3 dp2 = dFdy(v_FragPos); 10212 vec2 duv1 = dFdx(uv); 10213 vec2 duv2 = dFdy(uv); 10214 vec3 dp2perp = cross(dp2, normal); 10215 vec3 dp1perp = cross(normal, dp1); 10216 vec3 tangent = dp1perp * duv2.x + dp2perp * duv1.x; 10217 vec3 bitangent = dp1perp * duv2.y + dp2perp * duv1.y; 10218 float maxLen = max(dot(tangent, tangent), dot(bitangent, bitangent)); 10219 float invmax = inversesqrt(maxLen); 10220 tangent *= invmax; 10221 bitangent *= invmax; 10222 float height = texture(SAMPLER_2D(u_BumpMap), uv).r; 10223 float heightDx = texture(SAMPLER_2D(u_BumpMap), uv + duv1).r - height; 10224 float heightDy = texture(SAMPLER_2D(u_BumpMap), uv + duv2).r - height; 10225 return normalize( 10226 tangent * (-heightDx * bumpScale) + 10227 bitangent * (-heightDy * bumpScale) + 10228 normal 10229 ); 10230} 10231 10232void main() { 10233 vec3 normal = normalize(v_Normal); 10234 if (u_MaterialFlags.z > 0.5) { 10235 normal = perturbNormalFromBumpMap(normal, v_Uv, u_MaterialFlags.w); 10236 } 10237 vec3 viewDir; 10238 if (u_SceneParams.z > 0.5) { 10239 viewDir = normalize( 10240 vec3(u_SceneParams.x, u_SceneParams.y, u_SceneParams.w) - v_FragPos 10241 ); 10242 } else { 10243 viewDir = normalize(-v_FragPos); 10244 } 10245 10246 vec4 baseColor = u_BaseColor; 10247 if (u_MaterialFlags.x > 0.5) { 10248 baseColor *= texture(SAMPLER_2D(u_Map), v_Uv); 10249 } 10250 vec3 albedo = baseColor.rgb; 10251 10252 float metallic = clamp(u_PbrParams.x, 0.0, 1.0); 10253 // Clamp roughness to a small minimum (0.04): at roughness 0 the GGX lobe 10254 // collapses to a delta, producing fireflies / division instabilities in the 10255 // analytic specular term, so we keep a tiny floor as is common in PBR shaders. 10256 float roughness = clamp(u_PbrParams.y, 0.04, 1.0); 10257 10258 // Optional specular map modulates the microfacet specular response. 10259 float specularScale = 1.0; 10260 if (u_MaterialFlags.y > 0.5) { 10261 specularScale = dot( 10262 texture(SAMPLER_2D(u_SpecularMap), v_Uv).rgb, 10263 vec3(0.299, 0.587, 0.114) 10264 ); 10265 } 10266 10267 // Dielectrics reflect ~4% at normal incidence; metals tint reflectance with 10268 // the base color. 10269 vec3 F0 = mix(vec3(0.04), albedo, metallic); 10270 10271 vec3 Lo = vec3(0.0); 10272 for (int i = 0; i < MAX_3D_LIGHTS; i++) { 10273 if (i >= int(u_LightCount.x)) { 10274 break; 10275 } 10276 Lo += shadeLight( 10277 i, 10278 normal, 10279 viewDir, 10280 albedo, 10281 F0, 10282 metallic, 10283 roughness, 10284 specularScale 10285 ); 10286 } 10287 10288 // Ambient term (legacy ambient field acts as an ambient strength). 10289 vec3 ambient = u_AmbientLight.rgb * u_LightParams.x * albedo; 10290 10291 vec3 result = ambient + Lo; 10292 outputColor = vec4(result, baseColor.a); 10293} 10294`;let Ez=null;function Rre(t){Ez=t}function Cre(){return Ez}function Mre(t){Ez===t&&(Ez=null)}const AB=8,Lvt=188,Uvt=56;class Gvt extends We{constructor(){super(),this.setupDevice=this.attach(G3),this.canvases=this.query(e=>e.current.with(wt).read),this.cameras3D=this.query(e=>e.current.with(Bi).read),this.cameras2D=this.query(e=>e.current.with(jt,Pe).read),this.meshes3D=this.query(e=>e.current.with(Ns,Ni,ki).read),this.lights3D=this.query(e=>e.current.with(Kn).read),this.meshes3DDirty=this.query(e=>e.addedOrChanged.and.removed.with(Ns,Ni,ki).trackWrites),this.extrudeSources=this.query(e=>e.current.with(Lo).read),this.deviceStates=new WeakMap,this.trackedDevices=new Set,vre(this),this.query(e=>e.using(js).read.and.current.with(cs,wt,jt,Bi,Pe,Lo,Kn,Ns,Ni,ki).read)}
10294resolveRenderCameraEntity(e){const r=this.canvases.current.length||1,i=IS(this.cameras3D.current,e,r);if(i)return i;const s=this.cameras3D.current;if(s.length===0)return;const o=this.collectMeshEntities(e);if(this.extrudeSources.current.some(n=>{const a=n.read(Lo).meshEntity;return a&&nr(a)&&o.includes(a)})){const n=s.find(a=>a.read(Bi).linked);if(n)return n}return s[0]}collectMeshEntities(e){const r=this.canvases.current.length||1,i=[],s=new Set,o=n=>{s.has(n)||!nr(n)||!n.has(Ns)||!n.has(Ni)||!n.has(ki)||!Ow([n],e,r).length||(s.add(n),i.push(n))};for(const n of this.meshes3D.current)o(n);for(const n of this.extrudeSources.current){const a=n.read(Lo).meshEntity;a&&o(a)}return i}has3DContent(e){return e?!!IS(this.cameras3D.current,e,this.canvases.current.length||1)&&this.collectMeshEntities(e).length>0:this.canvases.current.some(r=>this.has3DContent(r))}prepareForComposite(e){!this.has3DContent(e)||!e.has(cs)||this.initPipeline(e)}shouldComposite(e){if(!this.has3DContent(e)||!e.has(cs))return!1;const{device:r}=e.read(cs);return this.deviceStates.has(r)}drawMeshes(e,r,i,s){if(i<=0||s<=0)return;const o=this.initPipeline(r);if(!o||!this.shouldComposite(r))return;const{device:n}=r.read(cs),a=this.resolveRenderCameraEntity(r);if(!a)return;const l=a.read(Bi),c=this.canvases.current.length||1,h=l.linked?EB(this.cameras2D.current,r):void 0,{width:u,height:d}=r.read(wt),f=l.linked&&u>0&&d>0?u/d:i/s;this.updateSceneUniforms(o,l,f,h,r,c),e.setViewport(0,0,i,s),e.setPipeline(o.pipeline);for(const p of this.collectMeshEntities(r)){const m=this.meshes3DDirty.addedOrChanged.includes(p),v=this.getOrCreateMeshGPU(p,n,o,m);if(!v)continue;const b=p.read(Ni),{texture:y,ready:_}=this.resolveMaterialTexture(o,n,b.map),{texture:w,ready:E}=this.resolveMaterialTexture(o,n,b.specularMap),{texture:A,ready:x}=this.resolveMaterialTexture(o,n,b.bumpMap),S=this.updateModelUniforms(p,v.modelUniformBuffer,{mapReady:_,specularMapReady:E,bumpMapReady:x});o.program.setUniformsLegacy(Object.assign(Object.assign({},o.sceneLegacyUniforms),S));const T=n.createBindings({pipeline:o.pipeline,uniformBufferBindings:[{buffer:o.sceneUniformBuffer},{buffer:v.modelUniformBuffer}],samplerBindings:[{texture:y,sampler:o.sampler},{texture:w,sampler:o.sampler},{texture:A,sampler:o.sampler}]});e.setBindings(T),e.setVertexInput(o.inputLayout,[{buffer:v.vertexBuffer},{buffer:v.normalBuffer},{buffer:v.uvBuffer}],v.indexBuffer?{buffer:v.indexBuffer}:null),v.indexBuffer?e.drawIndexed(v.indexCount):e.draw(v.vertexCount),T.destroy()}const g=Cre();g&&g.hasGizmoContent(r)&&g.drawGizmos(e,r,i,s)}getColorClearDescriptor(e){if(!this.shouldComposite(e))return;const r=this.resolveRenderCameraEntity(e),i=r==null?void 0:r.read(Bi);return i!=null&&i.clearColor?iz(QU):void 0}initPipeline(e){if(!e.has(cs))return null;const{device:r,renderCache:i}=e.read(cs);return this.ensureDeviceState(r,i)}ensureDeviceState(e,r){const i=this.deviceStates.get(e);if(i)return i;const s=r.createProgram({vertex:{glsl:Sre,entryPoint:"main"},fragment:{glsl:Tre,entryPoint:"main"}}),o=r.createInputLayout({vertexBufferDescriptors:[{arrayStride:12,stepMode:Pi.VERTEX,attributes:[{format:X.F32_RGB,offset:0,shaderLocation:0}]},{arrayStride:12,stepMode:Pi.VERTEX,attributes:[{format:X.F32_RGB,offset:0,shaderLocation:1}]},{arrayStride:8,stepMode:Pi.VERTEX,attributes:[{format:X.F32_RG,offset:0,shaderLocation:2}]}],indexBufferFormat:X.U32_R,program:s}),n=r.createRenderPipeline({inputLayout:o,program:s,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:X.D24_S8,topology:Ia.TRIANGLES,megaStateDescriptor:_j({attachmentsState:[{channelWriteMask:oo.ALL,rgbBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ZERO},alphaBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ZERO}}],blendConstant:Ra,depthWrite:!0,depthCompare:li.GREATER,cullMode:jl.BACK})}),a=e.createBuffer({viewOrSize:Lvt*4,usage:Ee.UNIFORM,hint:rr.DYNAMIC}),l=e.createTexture({format:X.U8_RGBA_NORM,width:1,height:1,usage:vi.SAMPLED});l.setImageData([new Uint8Array([255,255,255,255])]);const c=r.createSampler({addressModeU:ho.REPEAT,addressModeV:ho.CLAMP_TO_EDGE,minFilter:hs.BILINEAR,magFilter:hs.BILINEAR,mipmapFilter:Ro.LINEAR,lodMinClamp:0,lodMaxClamp:0}),h={program:s,pipeline:n,inputLayout:o,sceneUniformBuffer:a,sceneLegacyUniforms:{},sceneParams:[0,0,0,0],canvasViewProjection:Ai.IDENTITY,meshGPUCache:new Map,whiteTexture:l,sampler:c,textureCache:new Map};return this.deviceStates.set(e,h),this.trackedDevices.add(e),h}dropDeviceState(e){var r;const i=this.deviceStates.get(e);if(i){for(const s of i.meshGPUCache.values())try{s.vertexBuffer.destroy(),s.normalBuffer.destroy(),s.uvBuffer.destroy(),(r=s.indexBuffer)===null||r===void 0||r.destroy(),s.modelUniformBuffer.destroy()}catch{}try{i.sceneUniformBuffer.destroy(),i.whiteTexture.destroy();for(const s of i.textureCache.values())s.texture.destroy();i.textureCache.clear()}catch{}this.deviceStates.delete(e),this.trackedDevices.delete(e)}}resolveDeviceForMesh(e){if(e.has(js)){const r=e.read(js).canvas;if(nr(r)&&r.has(cs))return r.read(cs).device}return null}getActiveDevices(){const e=new Set;
10294for(const r of this.canvases.current)r.has(cs)&&e.add(r.read(cs).device);return e}getOrCreateMeshGPU(e,r,i,s=!1){var o,n;const a=e.read(Ns);if(a.positions.length===0||((o=this.resolveDeviceForMesh(e))!==null&&o!==void 0?o:r)!==r)return null;let l=i.meshGPUCache.get(e);if(l&&!s)return l;l&&(l.vertexBuffer.destroy(),l.normalBuffer.destroy(),l.uvBuffer.destroy(),(n=l.indexBuffer)===null||n===void 0||n.destroy(),l.modelUniformBuffer.destroy());const c=r.createBuffer({viewOrSize:a.positions,usage:Ee.VERTEX,hint:rr.STATIC}),h=r.createBuffer({viewOrSize:a.normals,usage:Ee.VERTEX,hint:rr.STATIC}),u=a.uvs&&a.uvs.length===a.vertexCount*2?a.uvs:new Float32Array(a.vertexCount*2),d=r.createBuffer({viewOrSize:u,usage:Ee.VERTEX,hint:rr.STATIC});let f=null,g=0;a.indices&&a.indices.length>0&&(f=r.createBuffer({viewOrSize:a.indices,usage:Ee.INDEX,hint:rr.STATIC}),g=a.indices.length);const p=r.createBuffer({viewOrSize:Uvt*4,usage:Ee.UNIFORM,hint:rr.DYNAMIC});return l={vertexBuffer:c,normalBuffer:h,uvBuffer:d,indexBuffer:f,indexCount:g,vertexCount:a.vertexCount,modelUniformBuffer:p},i.meshGPUCache.set(e,l),l}updateSceneUniforms(e,r,i,s,o,n){let a,l;if(r.linked&&s&&r.projection==="orthographic"){const u=s.read(Pe).viewProjectionMatrix,d=r.far>0?-2/r.far:0;a=CU(u,d),l=Ai.IDENTITY,e.canvasViewProjection=Ai.IDENTITY,e.sceneParams=[0,0,0,0]}else if(r.linked&&s&&r.projection==="perspective"){const u=s.read(Pe),d=s.read(jt),f=d.canvas?d.canvas.read(wt).height:0,g=MQ(f,u.zoom,r.fovy),p=new Ai(1,0,0,0,0,1,0,0,0,0,1,0,0,0,-g,1);l=Ai.multiply(CQ(u.viewMatrix),p),a=Ai.perspective(r.fovy,i,r.near,r.far),e.canvasViewProjection=CU(u.viewProjectionMatrix,0),e.sceneParams=[u.x,u.y,1,g]}else{if(e.canvasViewProjection=Ai.IDENTITY,e.sceneParams=[0,0,0,0],r.projection==="orthographic"){const u=Math.abs(r.eye[2]-r.center[2]),d=u*i;a=Ai.ortho(-d,d,-u,u,r.near,r.far)}else a=Ai.perspective(r.fovy,i,r.near,r.far);l=Ai.lookAt(r.eye,r.center,r.up)}const c=this.packLightUniforms(o,n),h=new Float32Array(Lvt);h.set(a.toFloat32Array(),0),h.set(l.toFloat32Array(),16),h.set(e.canvasViewProjection.toFloat32Array(),32),h.set(e.sceneParams,48),h.set(c.ambient,52),h.set([c.count,0,0,0],56),h.set(c.positions,60),h.set(c.directions,92),h.set(c.colors,124),h.set(c.params,156),e.sceneUniformBuffer.setSubData(0,new Uint8Array(h.buffer)),e.sceneLegacyUniforms={u_ProjectionMatrix3D:Ai.toGLMat4(a),u_ViewMatrix3D:Ai.toGLMat4(l),u_CanvasViewProjection3D:Ai.toGLMat4(e.canvasViewProjection),u_SceneParams:e.sceneParams,u_AmbientLight:c.ambient,u_LightCount:[c.count,0,0,0],u_LightPositions:c.positions,u_LightDirections:c.directions,u_LightColors:c.colors,u_LightParams3D:c.params}}packLightUniforms(e,r){const i=Ow(this.lights3D.current,e,r),s=[0,0,0,1],o=new Float32Array(AB*4),n=new Float32Array(AB*4),a=new Float32Array(AB*4),l=new Float32Array(AB*4);let c=0;const h=d=>
10294{s[0]+=d.color[0]*d.intensity,s[1]+=d.color[1]*d.intensity,s[2]+=d.color[2]*d.intensity},u=d=>{if(c>=AB)return;const f=c*4,g=Nwt[d.type],p=Math.max(0,d.innerConeAngle),m=Math.max(p,d.outerConeAngle);o.set([...d.position,0],f),n.set([...d.direction,d.type==="spot"?Math.cos(m):0],f),a.set([...d.color,0],f),l.set([g,d.intensity,d.range,d.type==="spot"?Math.cos(p):0],f),c++};if(i.length===0)h(new Kn({type:"ambient"})),u(new Kn({type:"directional"}));else{let d=!1;for(const f of i){const g=f.read(Kn);g.type==="ambient"?h(g):(g.type==="directional"&&(d=!0),u(g))}!d&&c<AB&&u(new Kn({type:"directional",intensity:.75}))}return{ambient:s,count:c,positions:o,directions:n,colors:a,params:l}}resolveMaterialTexture(e,r,i){if(!i)return{texture:e.whiteTexture,ready:!1};const s=e.textureCache.get(i);if(s)return{texture:s.status==="ready"?s.texture:e.whiteTexture,ready:s.status==="ready"};const o=r.createTexture({format:X.U8_RGBA_NORM,width:1,height:1,usage:vi.SAMPLED});o.setImageData([new Uint8Array([255,255,255,255])]);const n={texture:o,status:"loading"};return e.textureCache.set(i,n),nj(i).then(a=>{if(e.textureCache.get(i)!==n)return;const l=r.createTexture({format:X.U8_RGBA_NORM,width:a.width,height:a.height,usage:vi.SAMPLED,pixelStore:{unpackFlipY:!0}});l.setImageData([a]),n.texture.destroy(),n.texture=l,n.status="ready"}).catch(a=>{console.warn("[MeshPipeline3D] failed to load material map",i,a),n.status="error"}),{texture:e.whiteTexture,ready:!1}}updateModelUniforms(e,r,i={mapReady:!1,specularMapReady:!1,bumpMapReady:!1}){const s=e.read(ki),o=e.read(Ni),n=cc();O$(n,n,s.translation),YO(n,n,s.rotation[0]),$O(n,n,s.rotation[1]),HO(n,n,s.rotation[2]),I$(n,n,s.scale);const a=cc();M4(a,n),M$(a,a);const l={u_ModelMatrix3D:n,u_NormalMatrix3D:a,u_BaseColor:o.baseColor,u_LightParams:[o.ambient,o.diffuse,o.specular,o.shininess],u_LightDirection:[-.5,-.7,-.5,0]},c=i.mapReady?1:0,h=i.specularMapReady?1:0,u=i.bumpMapReady?1:0,d=new Float32Array(Uvt);return d.set(Array.from(n),0),d.set(Array.from(a),16),d.set(o.baseColor,32),d.set([o.ambient,o.diffuse,o.specular,o.shininess],36),d.set([-.5,-.7,-.5,0],40),d.set([s.translation[0],s.translation[1],s.translation[2],0],44),d.set([c,h,u,o.bumpScale],48),d.set([o.metallic,o.roughness,0,0],52),r.setSubData(0,new Uint8Array(d.buffer)),Object.assign(Object.assign({},l),{u_CanvasAnchor:[s.translation[0],s.translation[1],s.translation[2],0],u_MaterialFlags:[c,h,u,o.bumpScale],u_PbrParams:[o.metallic,o.roughness,0,0]})}execute(){var e;for(const i of this.meshes3DDirty.removed)for(const s of this.trackedDevices){const o=this.deviceStates.get(s),n=o==null?void 0:o.meshGPUCache.get(i);n&&(n.vertexBuffer.destroy(),n.normalBuffer.destroy(),n.uvBuffer.destroy(),(e=n.indexBuffer)===null||e===void 0||e.destroy(),n.modelUniformBuffer.destroy(),o.meshGPUCache.delete(i))}const r=this.getActiveDevices();for(const i of[...this.trackedDevices])r.has(i)||this.dropDeviceState(i);if(this.has3DContent())for(const i of this.canvases.current)this.prepareForComposite(i)}finalize(){_re(this);for(const e of[...this.trackedDevices])this.dropDeviceState(e)}}class Az extends We{constructor(){super(),this.cameras2D=this.query(e=>e.current.with(jt,Pe).read),this.cameras3D=this.query(e=>e.current.with(Bi).write),this.canvases=this.query(e=>e.current.with(wt).read),this.query(e=>e.using(jt,wt,Pe,js,be).read.and.using(Bi).write)}execute(){var e,r;for(const i of this.cameras3D.current){const s=i.read(Bi);if(!s.linked)continue;const o=(e=i.has(js)?i.read(js).canvas:sU(i))!==null&&e!==void 0?e:(r=this.cameras2D.current[0])===null||r===void 0?void 0:r.read(jt).canvas;if(!o)continue;const n=EB(this.cameras2D.current,o);if(!n)continue;const a=n.read(jt);if(!a.canvas)continue;const{width:l,height:c}=a.canvas.read(wt);if(l<=0||c<=0)continue;const h=n.read(Pe),{x:u,y:d,zoom:f}=h,g=c/2,p=g/f,m=i.write(Bi);if(m.baseDistance=g,s.projection==="orthographic"){const[,v]=RQ(u,d);m.eye=[u,v,p],m.center=[u,v,0]}else m.eye=[u,d,p],m.center=[u,d,0]}}}const wJ=Lgt();class xz extends We{constructor(){super(),this.commands=new nE(this),this.sources=this.query(e=>e.addedOrChanged.with(Lo).trackWrites),this.pendingMeshes=this.query(e=>e.current.with(Lo,fe).read),this.cameras3D=this.query(e=>
10294e.current.with(Bi).read),this.canvases=this.query(e=>e.current.with(wt).read),this.query(e=>e.using(fe,wt,Bi,js,be).read.and.using(Lo,Gd).write)}execute(){const e=[],r=new Set,i=s=>{if(r.has(s)||!s.has(fe))return;const o=s.read(Lo);o.meshEntity&&nr(o.meshEntity)||(r.add(s),e.push({source:s,mesh:this.queueSpawnMesh(s)}))};for(const s of this.sources.addedOrChanged)i(s);for(const s of this.pendingMeshes.current)i(s);if(e.length>0){this.commands.execute();for(const{source:s,mesh:o}of e){const n=s.write(Lo),a=n.meshEntity;a&&nr(a)&&a!==o&&a.add(Tn),n.meshEntity=o.hold()}}if(e.length>0){const s=new Set;for(const{source:o}of e){const n=sU(o);if(!n)continue;const a=this.canvases.current.length||1;IS(this.cameras3D.current,n,a)||s.add(n)}for(const o of s)this.commands.spawn(new Bi({linked:!0,projection:"orthographic",clearColor:!1}),new js({canvas:o}));s.size>0&&this.commands.execute()}}queueSpawnMesh(e){const r=sU(e),i=[new Ns({positions:wJ.positions,normals:wJ.normals,indices:wJ.indices}),new Ni({baseColor:[.25,.55,.95,1],ambient:.15,diffuse:.75,specular:.4,shininess:48}),new ki,new Gd({source:e,unifiedSpace:!0})];return r?this.commands.spawn(...i,new js({canvas:r})).id():this.commands.spawn(...i).id()}}function Bre(t,e,r){var i,s,o;const n=Vgt(e),a=e.read(je),l=a.geometry,c=a.z,h=[...a.rotation3d],u=a.scale3d,d=[...a.baseColor],f=a.ambient,g=a.diffuse,p=a.specular,m=a.shininess,v=a.metallic,b=a.roughness,y=(i=a.map)!==null&&i!==void 0?i:null,_=(s=a.specularMap)!==null&&s!==void 0?s:null,w=(o=a.bumpMap)!==null&&o!==void 0?o:null,E=a.bumpScale,A=yw(l),x=M9t(l);Kj(A)||zgt(e);const S=n?{translation:[n[0],n[1],c],rotation:h,scale:sZ(u)}:{translation:[0,0,c],rotation:h,scale:sZ(u)};return t.spawn(new Ns(x),new Ni({baseColor:d,ambient:f,diffuse:g,specular:p,shininess:m,metallic:v,roughness:b,map:y,specularMap:_,bumpMap:w,bumpScale:E}),new ki(S),new fh({source:e.hold()}),new js({canvas:r})).id()}function Ore(t,e,r){var i,s,o;const n=r??{};t.spawn(new Bi({linked:(i=n.linked)!==null&&i!==void 0?i:!0,projection:(s=n.projection)!==null&&s!==void 0?s:"perspective",clearColor:(o=n.clearColor)!==null&&o!==void 0?o:!1}),new js({canvas:e}))}class Sz extends We{constructor(){super(),this.commands=new nE(this),this.sources=this.query(e=>e.addedOrChanged.with(je).trackWrites),this.pendingMeshes=this.query(e=>e.current.with(je).read),this.cameras3D=this.query(e=>e.current.with(Bi).read),this.canvases=this.query(e=>e.current.with(wt).read),this.query(e=>e.using(fe,wt,jt,be,Gs,Kn,mh,_e,$t).read.and.using(js,Ns,Ni,je,fh,ki,Bi,ks,ar).write)}execute(){const e=[],r=new Set,i=s=>{if(r.has(s))return;const o=s.read(je).meshEntity;if(o&&nr(o))return;r.add(s);const n=this.resolveCanvasForSource(s);n&&e.push({source:s,mesh:this.queueSpawnMesh(s,n)})};for(const s of this.sources.addedOrChanged){const o=s.read(je).meshEntity;if(o&&nr(o)){Xgt(s,o),eX(s,o),GX(s);const n=this.resolveCanvasForSource(s);n&&oZ(s,o,n);continue}i(s)}for(const s of this.pendingMeshes.current)i(s);if(e.length>0){this.commands.execute();for(const{source:s,mesh:o}of e){const n=s.write(je),a=n.meshEntity;a&&nr(a)&&a!==o&&a.add(Tn),n.meshEntity=o.hold(),eX(s,o),GX(s);const l=this.resolveCanvasForSource(s);l&&oZ(s,o,l)}}for(const{source:s}of e)this.ensureCameraForSource(s);e.length>0&&this.commands.execute()}ensureCameraForSource(e){var r;const i=this.resolveCanvasForSource(e);if(!i)return;const s=this.canvases.current.length||1;if(IS(this.cameras3D.current,i,s))return;const o=(r=e.read(je).camera3d)!==null&&r!==void 0?r:{};Ore(this.commands,i,o)}queueSpawnMesh(e,r){return Bre(this.commands,e,r)}resolveCanvasForSource(e){if(e.has(js)){const r=e.read(js).canvas;if(nr(r))return r}return sU(e)}}class Tz extends We{constructor(){super(),this.sources=this.query(e=>e.current.with(je).read),this.query(e=>e.using(fh,wt,js).read.and.using(Ns,Ni,je).write)}execute(){for(const e of this.sources.current)GX(e)}}class Rz extends We{constructor(){super(),this.sources=this.query(e=>e.current.with(Lo,fe).read),this.targets=this.query(e=>e.current.with(Gd).read),this.query(e=>e.using(Lo,Gd,fe,Ce,Ni,ki,Tn).read.write)}execute(){this.cleanupOrphanMeshes();for(const e of this.sources.current){const r=e.read(Lo),i=r.meshEntity;if(!i||!nr(i))continue;const s=e.read(fe).geometryWorldBounds,o=s.maxX-s.minX,n=s.maxY-s.minY;if(o<=0||n<=0)continue;const a=(s.minX+s.maxX)/2,l=(s.minY+s.maxY)/2,c=r.depth,h=e.read(fe).transformOBB.rotation,u=i.read(Gd).unifiedSpace,d=i.write(ki);d.translation=u?[a,l,-c/2]:RQ(a,l,-c/2),d.rotation=[0,0,h],d.scale=[o,n,c],i.write(Ni).baseColor=b9t(e)}}cleanupOrphanMeshes(){for(const e of this.targets.current){const{source:r}=e.read(Gd);nr(r)&&r.has(Lo)||e.add(Tn)}}}class Cz extends We{constructor(){super(),this.sources=this.query(e=>e.current.with(je).read),this.targets=this.query(e=>e.current.with(fh).read),this.query(e=>e.using(fe,_e,$t,Ni,ki,ks).read.and.using(je,fh,Tn,ar).read.write)}execute(){this.cleanupOrphanMeshes();for(const e of this.sources.current){const r=e.read(je).meshEntity;if(!r||!nr(r))continue;r.has(ar)&&r.read(ar).dragging?O9t(e,r):eX(e,r);const i=sU(e);
vendor: 28,084 bytes, line 10294
10294i&&oZ(e,r,i)}}cleanupOrphanMeshes(){for(const e of this.targets.current){if(!nr(e))continue;const{source:r}=e.read(fh);nr(r)&&r.has(je)&&r.read(je).meshEntity===e||e.add(Tn)}}}class Ire extends We{execute(){var e;const r=typeof globalThis<"u"&&typeof((e=globalThis.performance)===null||e===void 0?void 0:e.now)=="function"?globalThis.performance:null;wX(r?r.now()/1e3:0)}}function Dre(t,e,r){return Math.max(e,Math.min(t,r))}const vn={toVector(t,e){return t===void 0&&(t=e),Array.isArray(t)?t:[t,t]},add(t,e){return[t[0]+e[0],t[1]+e[1]]},sub(t,e){return[t[0]-e[0],t[1]-e[1]]},addTo(t,e){t[0]+=e[0],t[1]+=e[1]},subTo(t,e){t[0]-=e[0],t[1]-=e[1]}};function Wvt(t,e,r){return e===0||Math.abs(e)===1/0?Math.pow(t,r*5):t*e*r/(e+r*t)}function jvt(t,e,r,i=.15){return i===0?Dre(t,e,r):t<e?-Wvt(e-t,r-e,i)+e:t>r?+Wvt(t-r,r-e,i)+r:t}function Pre(t,[e,r],[i,s]){const[[o,n],[a,l]]=t;return[jvt(e,o,n,i),jvt(r,a,l,s)]}function Fre(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var i=r.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Nre(t){var e=Fre(t,"string");return typeof e=="symbol"?e:String(e)}function il(t,e,r){return e=Nre(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Xvt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,i)}return r}function Yn(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Xvt(Object(r),!0).forEach(function(i){il(t,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Xvt(Object(r)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(r,i))})}return t}const zvt={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function Vvt(t){return t?t[0].toUpperCase()+t.slice(1):""}const kre=["enter","leave"];function Lre(t=!1,e){return t&&!kre.includes(e)}function Ure(t,e="",r=!1){const i=zvt[t],s=i&&i[e]||e;return"on"+Vvt(t)+Vvt(s)+(Lre(r,s)?"Capture":"")}const Gre=["gotpointercapture","lostpointercapture"];function Wre(t){let e=t.substring(2).toLowerCase();const r=!!~e.indexOf("passive");r&&(e=e.replace("passive",""));const i=Gre.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(i);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:r}}function jre(t,e=""){const r=zvt[t],i=r&&r[e]||e;return t+i}function Mz(t){return"touches"in t}function Yvt(t){return Mz(t)?"touch":"pointerType"in t?t.pointerType:"mouse"}function Xre(t){return Array.from(t.touches).filter(e=>{var r,i;return e.target===t.currentTarget||((r=t.currentTarget)===null||r===void 0||(i=r.contains)===null||i===void 0?void 0:i.call(r,e.target))})}function zre(t){return t.type==="touchend"||t.type==="touchcancel"?t.changedTouches:t.targetTouches}function $vt(t){return Mz(t)?zre(t)[0]:t}function EJ(t,e){try{const r=e.clientX-t.clientX,i=e.clientY-t.clientY,s=(e.clientX+t.clientX)/2,o=(e.clientY+t.clientY)/2,n=Math.hypot(r,i);return{angle:-(Math.atan2(r,i)*180)/Math.PI,distance:n,origin:[s,o]}}catch{}return null}function Vre(t){return Xre(t).map(e=>e.identifier)}function Hvt(t,e){const[r,i]=Array.from(t.touches).filter(s=>e.includes(s.identifier));return EJ(r,i)}function AJ(t){const e=$vt(t);return Mz(t)?e.identifier:e.pointerId}function xB(t){const e=$vt(t);return[e.clientX,e.clientY]}const Kvt=40,qvt=800;function Zvt(t){let{deltaX:e,deltaY:r,deltaMode:i}=t;return i===1?(e*=Kvt,r*=Kvt):i===2&&(e*=qvt,r*=qvt),[e,r]}function Yre(t){var e,r;const{scrollX:i,scrollY:s,scrollLeft:o,scrollTop:n}=t.currentTarget;return[(e=i??o)!==null&&e!==void 0?e:0,(r=s??n)!==null&&r!==void 0?r:0]}function $re(t){const e={};if("buttons"in t&&(e.buttons=t.buttons),"shiftKey"in t){const{shiftKey:r,altKey:i,metaKey:s,ctrlKey:o}=t;Object.assign(e,{shiftKey:r,altKey:i,metaKey:s,ctrlKey:o})}return e}function Bz(t,...e){return typeof t=="function"?t(...e):t}function Hre(){}function Kre(...t){return t.length===0?Hre:t.length===1?t[0]:function(){let e;for(const r of t)e=r.apply(this,arguments)||e;return e}}function Jvt(t,e){return Object.assign({},e,t||{})}const qre=32;class Qvt{constructor(e,r,i){this.ctrl=e,this.args=r,this.key=i,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:r,ingKey:i,args:s}=this;r[i]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=s,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const r=this.state,i=this.config;r._active||(this.reset(),this.computeInitial(),r._active=!0,r.target=e.target,r.currentTarget=e.currentTarget,r.lastOffset=i.from?Bz(i.from,r):r.offset,r.offset=r.lastOffset,r.startTime=r.timeStamp=e.timeStamp)}computeValues(e){const r=this.state;r._values=e,r.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:r,config:i,shared:s}=this;r.args=this.args;let o=0;if(e&&(r.event=e,i.preventDefault&&e.cancelable&&r.event.preventDefault(),r.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,$re(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,o=e.timeStamp-r.timeStamp,r.timeStamp=e.timeStamp,r.elapsedTime=r.timeStamp-r.startTime),r._active){const E=r._delta.map(Math.abs);vn.addTo(r._distance,E)}this.axisIntent&&this.axisIntent(e);const[n,a]=r._movement,[l,c]=i.threshold,{_step:h,values:u}=r;if(i.hasCustomTransform?(h[0]===!1&&(h[0]=Math.abs(n)>=l&&u[0]),h[1]===!1&&(h[1]=Math.abs(a)>=c&&u[1])):(h[0]===!1&&(h[0]=Math.abs(n)>=l&&Math.sign(n)*l),h[1]===!1&&(h[1]=Math.abs(a)>=c&&Math.sign(a)*c)),r.intentional=h[0]!==!1||h[1]!==!1,!r.intentional)return;const d=[0,0];if(i.hasCustomTransform){const[E,A]=u;d[0]=h[0]!==!1?E-h[0]:0,d[1]=h[1]!==!1?A-h[1]:0}else d[0]=h[0]!==!1?n-h[0]:0,d[1]=h[1]!==!1?a-h[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(d);const f=r.offset,g=r._active&&!r._blocked||r.active;g&&(r.first=r._active&&!r.active,r.last=!r._active&&r.active,r.active=s[this.ingKey]=r._active,e&&(r.first&&("bounds"in i&&(r._bounds=Bz(i.bounds,r)),this.setup&&this.setup()),r.movement=d,this.computeOffset()));const[p,m]=r.offset,[[v,b],[y,_]]=r._bounds;r.overflow=[p<v?-1:p>b?1:0,m<y?-1:m>_?1:0],r._movementBound[0]=r.overflow[0]?r._movementBound[0]===!1?r._movement[0]:r._movementBound[0]:!1,r._movementBound[1]=r.overflow[1]?r._movementBound[1]===!1?r._movement[1]:r._movementBound[1]:!1;const w=r._active?i.rubberband||[0,0]:[0,0];if(r.offset=Pre(r._bounds,r.offset,w),r.delta=vn.sub(r.offset,f),this.computeMovement(),g&&(!r.last||o>qre)){r.delta=vn.sub(r.offset,f);const E=r.delta.map(Math.abs);vn.addTo(r.distance,E),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&o>0&&(r.velocity=[E[0]/o,E[1]/o],r.timeDelta=o)}}emit(){const e=this.state,r=this.shared,i=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!i.triggerAllEvents)return;const s=this.handler(Yn(Yn(Yn({},r),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Zre([t,e],r){const i=Math.abs(t),s=Math.abs(e);if(i>s&&i>r)return"x";if(s>i&&s>r)return"y"}class oU extends Qvt{constructor(...e){super(...e),il(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=vn.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=vn.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const r=this.state,i=this.config;if(!r.axis&&e){const s=typeof i.axisThreshold=="object"?i.axisThreshold[Yvt(e)]:i.axisThreshold;r.axis=Zre(r._movement,s)}r._blocked=(i.lockDirection||!!i.axis)&&!r.axis||!!i.axis&&i.axis!==r.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const Jre=t=>t,t_t=.15,e_t={enabled(t=!0){return t},eventOptions(t,e,r){return Yn(Yn({},r.shared.eventOptions),t)},preventDefault(t=!1){return t},triggerAllEvents(t=!1){return t},rubberband(t=0){switch(t){case!0:return[t_t,t_t];case!1:return[0,0];default:return vn.toVector(t)}},from(t){if(typeof t=="function")return t;if(t!=null)return vn.toVector(t)},transform(t,e,r){const i=t||r.shared.transform;return this.hasCustomTransform=!!i,i||Jre},threshold(t){return vn.toVector(t,0)}},Qre=0,DS=Yn(Yn({},e_t),{},{axis(t,e,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(t=Qre){return t},bounds(t={}){if(typeof t=="function")return o=>DS.bounds(t(o));if("current"in t)return()=>t.current;if(typeof HTMLElement=="function"&&t instanceof HTMLElement)return t;const{left:e=-1/0,right:r=1/0,top:i=-1/0,bottom:s=1/0}=t;return[[e,r],[i,s]]}}),r_t={ArrowRight:(t,e=1)=>[t*e,0],ArrowLeft:(t,e=1)=>[-1*t*e,0],ArrowUp:(t,e=1)=>[0,-1*t*e],ArrowDown:(t,e=1)=>[0,t*e]};class tie extends oU{constructor(...e){super(...e),il(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const r=e._bounds.getBoundingClientRect(),i=e.currentTarget.getBoundingClientRect(),s={left:r.left-i.left+e.offset[0],right:r.right-i.right+e.offset[0],top:r.top-i.top+e.offset[1],bottom:r.bottom-i.bottom+e.offset[1]};e._bounds=DS.bounds(s)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const r=this.config,i=this.state;if(e.buttons!=null&&(Array.isArray(r.pointerButtons)?!r.pointerButtons.includes(e.buttons):r.pointerButtons!==-1&&r.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);r.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&i._pointerActive)&&(this.start(e),this.setupPointer(e),i._pointerId=AJ(e),i._pointerActive=!0,this.computeValues(xB(e)),this.computeInitial(),r.preventScrollAxis&&Yvt(e)!=="mouse"?(i._active=!1,this.setupScrollPrevention(e)):r.delay>0?(this.setupDelayTrigger(e),r.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const r=this.state;r._active=!0,r._preventScroll=!0,r._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const r=this.state,i=this.config;if(!r._pointerActive)return;const s=AJ(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;const o=xB(e);if(document.pointerLockElement===e.target?r._delta=[e.movementX,e.movementY]:(r._delta=vn.sub(o,r._values),this.computeValues(o)),vn.addTo(r._movement,r._delta),this.compute(e),r._delayed&&r.intentional){this.timeoutStore.remove("dragDelay"),r.active=!1,this.startPointerDrag(e);return}if(i.preventScrollAxis&&!r._preventScroll)if(r.axis)if(r.axis===i.preventScrollAxis||i.preventScrollAxis==="xy"){r._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{}const r=this.state,i=this.config;if(!r._active||!r._pointerActive)return;const s=AJ(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[o,n]=r._distance;if(r.tap=o<=i.tapsThreshold&&n<=i.tapsThreshold,r.tap&&i.filterTaps)r._force=!0;else{const[a,l]=r._delta,[c,h]=r._movement,[u,d]=i.swipe.velocity,[f,g]=i.swipe.distance,p=i.swipe.duration;if(r.elapsedTime<p){const m=Math.abs(a/r.timeDelta),v=Math.abs(l/r.timeDelta);m>u&&Math.abs(c)>f&&(r.swipe[0]=Math.sign(a)),v>d&&Math.abs(h)>g&&(r.swipe[1]=Math.sign(l))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const r=this.config,i=r.device;r.pointerLock&&e.currentTarget.requestPointerLock(),r.pointerCapture||(this.eventStore.add(this.sharedConfig.window,i,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,i,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,i,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,eie(e);const r=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",r),this.eventStore.add(this.sharedConfig.window,"touch","cancel",r),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const r=r_t[e.key];if(r){const i=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),i._delta=r(this.config.keyboardDisplacement,s),i._keyboardActive=!0,vn.addTo(i._movement,i._delta),this.compute(e),this.emit()}}keyUp(e){e.key in r_t&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const r=this.config.device;e(r,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(r,"change",this.pointerMove.bind(this)),e(r,"end",this.pointerUp.bind(this)),e(r,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function eie(t){"persist"in t&&typeof t.persist=="function"&&t.persist()}const nU=typeof window<"u"&&window.document&&window.document.createElement;function i_t(){return nU&&"ontouchstart"in window}function rie(){return i_t()||nU&&window.navigator.maxTouchPoints>1}function iie(){return nU&&"onpointerdown"in window}function sie(){return nU&&"exitPointerLock"in window.document}function oie(){try{return"constructor"in GestureEvent}catch{return!1}}const Kf={isBrowser:nU,gesture:oie(),touch:i_t(),touchscreen:rie(),pointer:iie(),pointerLock:sie()},nie=250,aie=180,lie=.5,cie=50,hie=250,uie=10,s_t={mouse:0,touch:0,pen:8},die=Yn(Yn({},DS),{},{device(t,e,{pointer:{touch:r=!1,lock:i=!1,mouse:s=!1}={}}){return this.pointerLock=i&&Kf.pointerLock,Kf.touch&&r?"touch":this.pointerLock?"mouse":Kf.pointer&&!s?"pointer":Kf.touch?"touch":"mouse"},preventScrollAxis(t,e,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&t?nie:void 0,!(!Kf.touchscreen||r===!1))return t||(r!==void 0?"y":void 0)},pointerCapture(t,e,{pointer:{capture:r=!0,buttons:i=1,keys:s=!0}={}}){return this.pointerButtons=i,this.keys=s,!this.pointerLock&&this.device==="pointer"&&r},threshold(t,e,{filterTaps:r=!1,tapsThreshold:i=3,axis:s=void 0}){const o=vn.toVector(t,r?i:s?1:0);return this.filterTaps=r,this.tapsThreshold=i,o},swipe({velocity:t=lie,distance:e=cie,duration:r=hie}={}){return{velocity:this.transform(vn.toVector(t)),distance:this.transform(vn.toVector(e)),duration:r}},delay(t=0){switch(t){case!0:return aie;case!1:return 0;default:return t}},axisThreshold(t){return t?Yn(Yn({},s_t),t):s_t},keyboardDisplacement(t=uie){return t}});function o_t(t){const[e,r]=t.overflow,[i,s]=t._delta,[o,n]=t._direction;(e<0&&i>0&&o<0||e>0&&i<0&&o>0)&&(t._movement[0]=t._movementBound[0]),(r<0&&s>0&&n<0||r>0&&s<0&&n>0)&&(t._movement[1]=t._movementBound[1])}const fie=30,pie=100;class gie extends Qvt{constructor(...e){super(...e),il(this,"ingKey","pinching"),il(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const e=this.state;e._touchIds=[],e.canceled=!1,e.cancel=this.cancel.bind(this),e.turns=0}computeOffset(){const{type:e,movement:r,lastOffset:i}=this.state;e==="wheel"?this.state.offset=vn.add(r,i):this.state.offset=[(1+r[0])*i[0],r[1]+i[1]]}computeMovement(){const{offset:e,lastOffset:r}=this.state;this.state.movement=[e[0]/r[0],e[1]-r[1]]}axisIntent(){const e=this.state,[r,i]=e._movement;if(!e.axis){const s=Math.abs(r)*fie-Math.abs(i);s<0?e.axis="angle":s>0&&(e.axis="scale")}}restrictToAxis(e){this.config.lockDirection&&(this.state.axis==="scale"?e[1]=0:this.state.axis==="angle"&&(e[0]=0))}cancel(){const e=this.state;e.canceled||setTimeout(()=>{e.canceled=!0,e._active=!1,this.compute(),this.emit()},0)}touchStart(e){this.ctrl.setEventIds(e);const r=this.state,i=this.ctrl.touchIds;if(r._active&&r._touchIds.every(o=>i.has(o))||i.size<2)return;this.start(e),r._touchIds=Array.from(i).slice(0,2);const s=Hvt(e,r._touchIds);s&&this.pinchStart(e,s)}pointerStart(e){if(e.buttons!=null&&e.buttons%2!==1)return;this.ctrl.setEventIds(e),e.target.setPointerCapture(e.pointerId);const r=this.state,i=r._pointerEvents,s=this.ctrl.pointerIds;if(r._active&&Array.from(i.keys()).every(n=>s.has(n))||(i.size<2&&i.set(e.pointerId,e),r._pointerEvents.size<2))return;this.start(e);const o=EJ(...Array.from(i.values()));o&&this.pinchStart(e,o)}pinchStart(e,r){const i=this.state;i.origin=r.origin,this.computeValues([r.distance,r.angle]),this.computeInitial(),this.compute(e),this.emit()}touchMove(e){if(!this.state._active)return;const r=Hvt(e,this.state._touchIds);r&&this.pinchMove(e,r)}pointerMove(e){const r=this.state._pointerEvents;if(r.has(e.pointerId)&&r.set(e.pointerId,e),!this.state._active)return;const i=EJ(...Array.from(r.values()));i&&this.pinchMove(e,i)}pinchMove(e,r){const i=this.state,s=i._values[1],o=r.angle-s;let n=0;Math.abs(o)>270&&(n+=Math.sign(o)),this.computeValues([r.distance,r.angle-360*n]),i.origin=r.origin,i.turns=n,i._movement=[i._values[0]/i._initial[0]-1,i._values[1]-i._initial[1]],this.compute(e),this.emit()}touchEnd(e){this.ctrl.setEventIds(e),this.state._active&&this.state._touchIds.some(r=>!this.ctrl.touchIds.has(r))&&(this.state._active=!1,this.compute(e),this.emit())}pointerEnd(e){const r=this.state;this.ctrl.setEventIds(e);try{e.target.releasePointerCapture(e.pointerId)}catch{}r._pointerEvents.has(e.pointerId)&&r._pointerEvents.delete(e.pointerId),r._active&&r._pointerEvents.size<2&&(r._active=!1,this.compute(e),this.emit())}gestureStart(e){e.cancelable&&e.preventDefault();const r=this.state;r._active||(this.start(e),this.computeValues([e.scale,e.rotation]),r.origin=[e.clientX,e.clientY],this.compute(e),this.emit())}gestureMove(e){if(e.cancelable&&e.preventDefault(),!this.state._active)return;const r=this.state;this.computeValues([e.scale,e.rotation]),r.origin=[e.clientX,e.clientY];const i=r._movement;r._movement=[e.scale-1,e.rotation],r._delta=vn.sub(r._movement,i),this.compute(e),this.emit()}gestureEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}wheel(e){const r=this.config.modifierKey;r&&(Array.isArray(r)?!r.find(i=>e[i]):!e[r])||(this.state._active?this.wheelChange(e):this.wheelStart(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(e){this.start(e),this.wheelChange(e)}wheelChange(e){"uv"in e||e.cancelable&&e.preventDefault();const r=this.state;r._delta=[-Zvt(e)[1]/pie*r.offset[0],0],vn.addTo(r._movement,r._delta),o_t(r),this.state.origin=[e.clientX,e.clientY],this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){const r=this.config.device;r&&(e(r,"start",this[r+"Start"].bind(this)),e(r,"change",this[r+"Move"].bind(this)),e(r,"end",this[r+"End"].bind(this)),e(r,"cancel",this[r+"End"].bind(this)),e("lostPointerCapture","",this[r+"End"].bind(this))),this.config.pinchOnWheel&&e("wheel","",this.wheel.bind(this),{passive:!1})}}const mie=Yn(Yn({},e_t),{},{device(t,e,{shared:r,pointer:{touch:i=!1}={}}){if(r.target&&!Kf.touch&&Kf.gesture)return"gesture";if(Kf.touch&&i)return"touch";if(Kf.touchscreen){if(Kf.pointer)return"pointer";if(Kf.touch)return"touch"}},bounds(t,e,{scaleBounds:r={},angleBounds:i={}}){const s=n=>{const a=Jvt(Bz(r,n),{min:-1/0,max:1/0});return[a.min,a.max]},o=n=>{const a=Jvt(Bz(i,n),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof r!="function"&&typeof i!="function"?[s(),o()]:n=>[s(n),o(n)]},threshold(t,e,r){return this.lockDirection=r.axis==="lock",vn.toVector(t,this.lockDirection?[.1,3]:0)},modifierKey(t){return t===void 0?"ctrlKey":t},pinchOnWheel(t=!0){return t}});class yie extends oU{constructor(...e){super(...e),il(this,"ingKey","moving")}move(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.state._active?this.moveChange(e):this.moveStart(e),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(e){this.start(e),this.computeValues(xB(e)),this.compute(e),this.computeInitial(),this.emit()}moveChange(e){if(!this.state._active)return;const r=xB(e),i=this.state;i._delta=vn.sub(r,i._values),vn.addTo(i._movement,i._delta),this.computeValues(r),this.compute(e),this.emit()}moveEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}bind(e){e("pointer","change",this.move.bind(this)),e("pointer","leave",this.moveEnd.bind(this))}}const vie=Yn(Yn({},DS),{},{mouseOnly:(t=!0)=>t});class _ie extends oU{constructor(...e){super(...e),il(this,"ingKey","scrolling")}scroll(e){this.state._active||this.start(e),this.scrollChange(e),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(e){e.cancelable&&e.preventDefault();const r=this.state,i=Yre(e);r._delta=vn.sub(i,r._values),vn.addTo(r._movement,r._delta),this.computeValues(i),this.compute(e),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("scroll","",this.scroll.bind(this))}}const bie=DS;class wie extends oU{constructor(...e){super(...e),il(this,"ingKey","wheeling")}wheel(e){this.state._active||this.start(e),this.wheelChange(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(e){const r=this.state;r._delta=Zvt(e),vn.addTo(r._movement,r._delta),o_t(r),this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("wheel","",this.wheel.bind(this))}}const Eie=DS;class Aie extends oU{constructor(...e){super(...e),il(this,"ingKey","hovering")}enter(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.start(e),this.computeValues(xB(e)),this.compute(e),this.emit())}leave(e){if(this.config.mouseOnly&&e.pointerType!=="mouse")return;const r=this.state;if(!r._active)return;r._active=!1;const i=xB(e);r._movement=r._delta=vn.sub(i,r._values),this.computeValues(i),this.compute(e),r.delta=r.movement,this.emit()}bind(e){e("pointer","enter",this.enter.bind(this)),e("pointer","leave",this.leave.bind(this))}}const xie=Yn(Yn({},DS),{},{mouseOnly:(t=!0)=>t}),xJ=new Map,SJ=new Map;function Sie(t){xJ.set(t.key,t.engine),SJ.set(t.key,t.resolver)}const Tie={key:"drag",engine:tie,resolver:die},Rie={key:"hover",engine:Aie,resolver:xie},Cie={key:"move",engine:yie,resolver:vie},Mie={key:"pinch",engine:gie,resolver:mie},Bie={key:"scroll",engine:_ie,resolver:bie},Oie={key:"wheel",engine:wie,resolver:Eie};function Iie(t,e){if(t==null)return{};var r={},i=Object.keys(t),s,o;for(o=0;o<i.length;o++)s=i[o],!(e.indexOf(s)>=0)&&(r[s]=t[s]);return r}function Die(t,e){if(t==null)return{};var r=Iie(t,e),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(s=0;s<o.length;s++)i=o[s],!(e.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(t,i)&&(r[i]=t[i])}return r}const Pie={target(t){if(t)return()=>"current"in t?t.current:t},enabled(t=!0){return t},window(t=Kf.isBrowser?window:void 0){return t},eventOptions({passive:t=!0,capture:e=!1}={}){return{passive:t,capture:e}},transform(t){return t}},Fie=["target","eventOptions","window","enabled","transform"];function Oz(t={},e){const r={};for(const[i,s]of Object.entries(e))switch(typeof s){case"function":r[i]=s.call(r,t[i],i,t);break;case"object":r[i]=Oz(t[i],s);break;case"boolean":s&&(r[i]=t[i]);break}return r}function Nie(t,e,r={}){const i=t,{target:s,eventOptions:o,window:n,enabled:a,transform:l}=i,c=Die(i,Fie);if(r.shared=Oz({target:s,eventOptions:o,window:n,enabled:a,transform:l},Pie),e){const h=SJ.get(e);r[e]=Oz(Yn({shared:r.shared},c),h)}else for(const h in c){const u=SJ.get(h);u&&(r[h]=Oz(Yn({shared:r.shared},c[h]),u))}return r}class n_t{constructor(e,r){il(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=r}add(e,r,i,s,o){const n=this._listeners,a=jre(r,i),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},c=Yn(Yn({},l),o);e.addEventListener(a,s,c);const h=()=>{e.removeEventListener(a,s,c),n.delete(h)};return n.add(h),h}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class kie{constructor(){il(this,"_timeouts",new Map)}add(e,r,i=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(r,i,...s))}remove(e){const r=this._timeouts.get(e);r&&window.clearTimeout(r)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class Lie{constructor(e){il(this,"gestures",new Set),il(this,"_targetEventStore",new n_t(this)),il(this,"gestureEventStores",{}),il(this,"gestureTimeoutStores",{}),il(this,"handlers",{}),il(this,"config",{}),il(this,"pointerIds",new Set),il(this,"touchIds",new Set),il(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),Uie(this,e)}setEventIds(e){if(Mz(e))return this.touchIds=new Set(Vre(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,r){this.handlers=e,this.nativeHandlers=r}applyConfig(e,r){this.config=Nie(e,r,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const r=this.config.shared,i={};let s;if(!(r.target&&(s=r.target(),!s))){if(r.enabled){for(const n of this.gestures){const a=this.config[n],l=a_t(i,a.eventOptions,!!s);if(a.enabled){const c=xJ.get(n);new c(this,e,n).bind(l)}}const o=a_t(i,r.eventOptions,!!s);for(const n in this.nativeHandlers)o(n,"",a=>this.nativeHandlers[n](Yn(Yn({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const o in i)i[o]=Kre(...i[o]);if(!s)return i;for(const o in i){const{device:n,capture:a,passive:l}=Wre(o);this._targetEventStore.add(s,n,"",i[o],{capture:a,passive:l})}}}}function SB(t,e){t.gestures.add(e),t.gestureEventStores[e]=new n_t(t,e),t.gestureTimeoutStores[e]=new kie}function Uie(t,e){e.drag&&SB(t,"drag"),e.wheel&&SB(t,"wheel"),e.scroll&&SB(t,"
10294scroll"),e.move&&SB(t,"move"),e.pinch&&SB(t,"pinch"),e.hover&&SB(t,"hover")}const a_t=(t,e,r)=>(i,s,o,n={},a=!1)=>{var l,c;const h=(l=n.capture)!==null&&l!==void 0?l:e.capture,u=(c=n.passive)!==null&&c!==void 0?c:e.passive;let d=a?i:Ure(i,s,h);r&&u&&(d+="Passive"),t[d]=t[d]||[],t[d].push(o)},Gie=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function Wie(t){const e={},r={},i=new Set;for(let s in t)Gie.test(s)?(i.add(RegExp.lastMatch),r[s]=t[s]):e[s]=t[s];return[r,e,i]}function TB(t,e,r,i,s,o){if(!t.has(r)||!xJ.has(i))return;const n=r+"Start",a=r+"End",l=c=>{let h;return c.first&&n in e&&e[n](c),r in e&&(h=e[r](c)),c.last&&a in e&&e[a](c),h};s[i]=l,o[i]=o[i]||{}}function jie(t,e){const[r,i,s]=Wie(t),o={};return TB(s,r,"onDrag","drag",o,e),TB(s,r,"onWheel","wheel",o,e),TB(s,r,"onScroll","scroll",o,e),TB(s,r,"onPinch","pinch",o,e),TB(s,r,"onMove","move",o,e),TB(s,r,"onHover","hover",o,e),{handlers:o,config:e,nativeHandlers:i}}function Xie(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var i=r.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function zie(t){var e=Xie(t,"string");return typeof e=="symbol"?e:String(e)}function Vie(t,e,r){return e=zie(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l_t(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,i)}return r}function Iz(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?l_t(Object(r),!0).forEach(function(i){Vie(t,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):l_t(Object(r)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(r,i))})}return t}class Yie{constructor(e,r,i,s,o){this._target=e,this._gestureKey=s,this._ctrl=ne
10294w Lie(r),this._ctrl.applyHandlers(r,o),this._ctrl.applyConfig(Iz(Iz({},i),{},{target:e}),s),this._ctrl.effect()}destroy(){this._ctrl.clean()}setConfig(e){this._ctrl.clean(),this._ctrl.applyConfig(Iz(Iz({},e),{},{target:this._target}),this._gestureKey),this._ctrl.effect()}}function $ie(t){return t.forEach(Sie),function(e,r,i){const{handlers:s,nativeHandlers:o,config:n}=jie(r,i||{});return new Yie(e,s,n,void 0,o)}}const Hie=function(t,e,r){return $ie([Tie,Mie,Bie,Oie,Cie,Rie])(t,e,r||{})};var Kie=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},aU=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},PS;const qie=300;function TJ(t){t.cancelable&&t.preventDefault()}fO=class extends We{*setInputTrigger(t,e){const r=t.write(le);if(e in r){Object.assign(r,{[e]:!0}),yield;{const i=t.hold().write(le);Object.assign(i,{[e]:!1})}yield}}constructor(){super(),this.canvases=this.query(t=>t.added.and.removed.with(wt)),this.pointerIds=new Map,PS.set(this,new Map),this.query(t=>t.using(le,_o).write)}execute(){this.canvases.added.forEach(t=>{nt(t,le),nt(t,_o),this.bindEventListeners(t)}),this.canvases.removed.forEach(t=>{var e;this.accessRecentlyDeletedData();const r=t.read(wt),{element:i}=r;(e=aU(this,PS,"f").get(i))===null||e===void 0||e.forEach(s=>s()),aU(this,PS,"f").delete(i),this.pointerIds.delete(t.__id)})}finalize(){aU(this,PS,"f").forEach(t=>t.forEach(e=>e())),aU(this,PS,"f").clear(),this.pointerIds.clear()}bindEventListeners(t){const{element:e,api:r}=t.read(wt),i=Pr.get().getWindow(),s=!!i.PointerEvent,o="ontouchstart"in i,n=t.hold();this.pointerIds.set(t.__id,new Set);const a=this.pointerIds.get(t.__id);let l=null,c=!1,h=null,u=null;const d=C=>{if(!("touches"in C))return null;const F=C.touches;return F.length<2?null:{x:(F[0].clientX+F[1].clientX)/2,y:(F[0].clientY+F[1].clientY)/2}},f=C=>{C.ctrlKey&&(n.write(le).ctrlKey=!0),C.shiftKey&&(n.write(le).shiftKey=!0),C.metaKey&&(n.write(le).metaKey=!0),C.altKey&&(n.write(le).altKey=!0)},g=C=>{if(C.pointerType==="touch"&&c||C.pointerType==="touch"&&h!==null&&C.pointerId!==h)return;const F=r.client2Viewport({x:C.clientX,y:C.clientY});Object.assign(n.write(le),{pointerClient:[C.clientX,C.clientY],pointerViewport:[F.x,F.y],pointerType:C.pointerType==="touch"||C.pointerType==="pen"?C.pointerType:"mouse",pressure:C.pressure,pointerInside:F.x>=0&&F.y>=0&&F.x<=t.read(wt).width&&F.y<=t.read(wt).height}),f(C)},p=C=>{if(C.pointerType==="touch"&&c){a.delete(C.pointerId),C.pointerId===h&&(h=null),a.size<2&&(c=!1);return}Number.isFinite(C.clientX)&&Number.isFinite(C.clientY)&&g(C),this.setInputTrigger(n,"pointerUpTrigger"),a.delete(C.pointerId),C.pointerType==="touch"&&C.pointerId===h&&(h=null)},m=C=>{var F;Zo&&r.getCanvasElement().focus({preventScroll:!0});const U=[0,1,2];if(C.pointerType==="mouse"&&!U.includes(C.button))return;if(a.add(C.pointerId),a.size>1||C.button===2){C.pointerType==="touch"&&(!c&&h!==null&&(this.setInputTrigger(n,"pointerUpTrigger"),n.write(le).pointerCancelled=!0),c=!0,h=null);return}const H=performance.now(),N=n.read(le).lastPointerDownTime;if(H-N<qie&&this.setInputTrigger(n,"doubleClickTrigger"),this.setInputTrigger(n,"pointerDownTrigger"),Object.assign(n.write(le),{pointerInside:!0,pointerCancelled:!1,pointerButton:(F=C.button)!==null&&F!==void 0?F:0,pointerType:C.pointerType==="touch"||C.pointerType==="pen"?C.pointerType:"mouse"}),a.size===1){C.pointerType==="touch"&&(h=C.pointerId);const G=r.client2Viewport({x:C.clientX,y:C.clientY});Object.assign(n.write(le),{pointerClient:[C.clientX,C.clientY],pointerViewport:[G.x,G.y],pointerDownViewport:[G.x,G.y],lastPointerDownTime:H,pressure:C.pressure})}f(C)},v=C=>{n.write(le).pointerCancelled=!0,n.write(le).pointerInside=!1,a.delete(C.pointerId),C.pointerId===h&&(h=null),C.pointerType==="touch"&&a.size<2&&(c=!1)},b=()=>{n.write(le).pointerInside=!1,a.size>0&&(n.write(le).pointerCancelled=!0)},y=C=>{TJ(C),n.write(le).wheelTrigger=!0,n.write(le).deltaX=C.deltaX,n.write(le).deltaY=C.deltaY,f(C);const F=r.client2Viewport({x:C.clientX,y:C.clientY});Object.assign(n.write(le),{pointerClient:[C.clientX,C.clientY],pointerViewport:[F.x,F.y]})},_=Pr.get().getWindow(),w=new Hie(e,{onDrag:({event:C,last:F})=>{if(F){u=null;return}const U=d(C);if(!U){u!==null&&(u=null);return}TJ(C);const{x:H,y:N}=U;if(u===null){u={x:H,y:N},h!==null&&(this.setInputTrigger(n,"pointerUpTrigger"),n.write(le).pointerCancelled=!0,h=null),c=!0;return}const G=r.client2Viewport(u),Y=r.client2Viewport({x:H,y:N}),q=Y.x-G.x,L=Y.y-G.y;if(u={x:H,y:N},q===0&&L===0)return;const J=n.write(le);J.touchPanDeltaX+=q,J.touchPanDeltaY+=L;const tt=r.client2Viewport({x:H,y:N});J.pointerClient=[Math.round(H),Math.round(N)],J.pointerViewport=[tt.x,tt.y]},onPinch:({event:C,first:F,last:U,da:H,origin:N})=>{if(!Number.isFinite(H[0])){l=null;return}TJ(C);const G=H[0];if(F||l===null){h!==null&&(this.setInputTrigger(n,"pointerUpTrigger"),n.write(le).pointerCancelled=!0,h=null),c=!0,l=G;return}const Y=G-l;l=G;const q={x:N[0],y:N[1]},L=r.client2Viewport({x:q.x,y:q.y}),J=n.write(le);J.wheelTrigger=!0,J.ctrlKey=!0,J.deltaX=0,J.deltaY=-Y,J.pointerClient=[q.x,q.y],J.pointerViewport=[L.x,L.y],U&&(l=null,c=!1)}},{window:_,pinch:{preventDefault:!0,eventOptions:{passive:!1}},drag:{preventDefault:!0,eventOptions:{passive:!1}},eventOptions:{capture:!0,passive:!1}}),E=C=>{C.key==="Control"&&(n.write(le).ctrlKey=!0),C.key==="Shift"&&(n.write(le).shiftKey=!0),C.key==="Meta"&&(n.write(le).metaKey=!0),C.key==="Alt"&&(n.write(le).altKey=!0),n.write(le).key=C.key,n.write(le).keyShiftKey=C.shiftKey,n.write(le).event=C},A=C=>{C.key==="Control"&&(n.write(le).ctrlKey=!1),C.key==="Shift"&&(n.write(le).shiftKey=!1),C.key==="Meta"&&(n.write(le).metaKey=!1),C.key==="Alt"&&(n.write(le).altKey=!1),n.write(le).event=C},x=C=>{C.addEventListener("pointermove",g,!0),C.addEventListener("pointerdown",m,!0),C.addEventListener("pointerup",p,!0),C.addEventListener("pointercancel",v,!0),C.addEventListener("pointerleave",b,!0)},S=C=>{C.addEventListener("touchstart",m,!0),C.addEventListener("touchend",p,!0),C.addEventListener("touchmove",g,!0),C.addEventListener("touchcancel",v,!0)},T=C=>{C.addEventListener("mousemove",g,!0),C.addEventListener("mousedown",m,!0),C.addEventListener("mouseup",p,!0),C.addEventListener("mouseleave",b,!0)},R=C=>{C.removeEventListener("pointermove",g,!0),C.removeEventListener("pointerdown",m,!0),C.removeEventListener("pointerup",p,!0),C.removeEventListener("pointercancel",v,!0),C.removeEventListener("pointerleave",b,!0)},B=C=>{C.removeEventListener("touchstart",m,!0),C.removeEventListener("touchend",p,!0),C.removeEventListener("touchmove",g,!0),C.removeEventListener("touchcancel",v,!0)},O=C=>{C.removeEventListener("mousemove",g,!0),C.removeEventListener("mousedown",m,!0),C.removeEventListener("mouseup",p,!0),C.removeEventListener("mouseleave",b,!0)};"addEventListener"in i&&(s?x(e):(T(e),o&&S(e)),e.addEventListener("wheel",y,{capture:!0,passive:!1}),i.addEventListener("keydown",E,!0),i.addEventListener("keyup",A,!0),aU(this,PS,"f").set(e,[()=>{s?R(e):(O(e),o&&B(e)),w.destroy(),e.removeEventListener("wheel",y,!0),i.removeEventListener("keydown",E,!0),i.removeEventListener("keyup",A,!0)}]))}},PS=new WeakMap,Kie([bO],fO.prototype,"setInputTrigger",null);class RJ extends We{constructor(){super(),this.cameras=this.query(e=>e.current.with(jt).read),this.query(e=>e.using(wt,xa,le).write)}
10294execute(){this.cameras.current.forEach(e=>{if(!e.has(jt))return;const{canvas:r}=e.read(jt);if(!r)return;const i=r.write(le),{inputPoints:s}=r.read(wt);s.forEach(o=>{const n=o.write(xa);n.prevPoint=i.pointerViewport}),Object.assign(i,{wheelTrigger:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1,key:void 0,touchPanDeltaX:0,touchPanDeltaY:0})})}}const Zie=.02,Jie=4,Qie=100;dO=class extends We{constructor(){super(),this.cameras=this.query(t=>t.current.with(jt).read),this.zoomByClientPoint=(t,e,r,i)=>{const{zoom:s}=t.read(Pe),{cameraZoomFactor:o}=e.getAppState(),n=Math.max(Zie,Math.min(Jie,s*Math.pow(2,i*-o)));e.gotoLandmark(e.createLandmark({viewportX:r.x,viewportY:r.y,zoom:n}),{duration:0})},this.query(t=>t.using(wt,Pe).read.update.and.using(le,_o,so,_e,xa).write.and.using(le).read)}execute(){this.cameras.current.forEach(t=>{const e=t.read(jt);if(nt(t,so),!e.canvas||!t.has(Pe))return;const r=e.canvas.hold(),{api:i,inputPoints:s}=r.read(wt),o=i.getAppState().penbarSelected,n=t.write(so),a=r.write(le),l=r.write(_o),{pointerViewport:c}=a,h=t.read(_e),u=t.read(Pe),d=ie.toGLMat3(u.viewProjectionMatrixInv),f=h.translation.x,g=h.translation.y,p=h.rotation;if(o===vt.TEXT&&(l.value="text"),a.pointerDownTrigger){this.createEntity(xa,{prevPoint:a.pointerDownViewport,canvas:r});{const[m,v]=a.pointerDownViewport;n.pointerDownViewportX=m,n.pointerDownViewportY=v;const{x:b,y}=i.viewport2Canvas({x:m,y:v});n.pointerDownCanvasX=b,n.pointerDownCanvasY=y}o===vt.HAND&&(l.value="grabbing",n.rotate=a.shiftKey,fp(n.startInvertViewProjectionMatrix,d),n.startCameraX=f,n.startCameraY=g,n.startCameraRotation=p,Qt(n.startPos,this.getClipSpaceMousePosition(t),n.startInvertViewProjectionMatrix),n.startMousePos=c)}if(s.length>1&&s.forEach(m=>{m.delete()}),s.forEach(m=>{const v=m.write(xa),{prevPoint:[b,y]}=v,[_,w]=c;b===_&&y===w||o===vt.HAND&&(l.value="grabbing",n.rotate?this.rotateCamera(t):this.moveCamera(t))}),a.pointerUpTrigger){Object.assign(n,{pointerDownViewportX:void 0,pointerDownViewportY:void 0,pointerDownCanvasX:void 0,pointerDownCanvasY:void 0});for(const m of r.read(wt).inputPoints)m.delete();o===vt.HAND&&(l.value="grab",n.rotate=!1)}if(a.wheelTrigger)if(a.metaKey||a.ctrlKey)this.zoomByClientPoint(t,i,{x:c[0],y:c[1]},a.deltaY);else{const{x:m,y:v,zoom:b}=t.read(Pe),y=t.write(_e);Object.assign(y,{translation:{x:m+a.deltaX/b,y:v+a.deltaY/b},rotation:p})}if(a.touchPanDeltaX!==0||a.touchPanDeltaY!==0){const{x:m,y:v,zoom:b}=t.read(Pe),y=t.write(_e);Object.assign(y,{translation:{x:m+a.touchPanDeltaX/b,y:v+a.touchPanDeltaY/b},rotation:p})}})}moveCamera(t){const{startInvertViewProjectionMatrix:e,startPos:r,startCameraX:i,startCameraY:s,startCameraRotation:o}=t.read(so),n=Qt(it(),this.getClipSpaceMousePosition(t),e),a=t.write(_e);Object.assign(a,{translation:{x:i+r[0]-n[0],y:s+r[1]-n[1]},rotation:o})}rotateCamera(t){const{startPos:e,startCameraX:r,startCameraY:i,startCameraRotation:s,startMousePos:o}=t.read(so),n=t.write(_e),a=(t.read(jt).canvas.read(le).pointerViewport[0]-o[0])/Qie,l=Bt();bi(l,l,[e[0],e[1]]),Mo(l,l,a),bi(l,l,[-e[0],-e[1]]);const c=CJ(r,i,s,1/n.scale.x);us(l,l,c),Object.assign(n,{translation:{x:l[6],y:l[7]},rotation:s+a})}getClipSpaceMousePosition(t){const e=t.read(jt),r=e.canvas.read(wt),i=e.canvas.read(le),{element:s,devicePixelRatio:o}=r,n=s.getBoundingClientRect(),a=i.pointerViewport[0]-n.left,l=i.pointerViewport[1]-n.top,c=a/(s.clientWidth||r.width/o),h=l/(s.clientHeight||r.height/o),u=c*2-1,d=h*-2+1;return[u,d]}};function CJ(t,e,r,i){const s=1/i,o=Bt();return Yc(o),bi(o,o,[t,e]),Mo(o,o,r),xh(o,o,[s,s]),o}rp=class extends We{constructor(){super(),this.cameras=this.query(t=>t.current.addedOrChanged.with(jt,_e).trackWrites),this.canvases=this.query(t=>t.changed.with(wt).trackWrites),this.missingComputedCamera=this.query(t=>t.current.with(jt,_e).without(Pe).read),this.query(t=>t.using(Pe).write.and.using(wt,Gs,fe).read)}execute(){this.missingComputedCamera.current.forEach(t=>{const e=t.read(jt);if(!e.canvas)return;const{width:r,height:i}=e.canvas.read(wt);this.projection(t,r,i),this.updateMatrix(t),this.updateComputedCamera(t)}),this.cameras.addedOrChanged.forEach(t=>{const e=t.read(jt);if(!e.canvas)return;const{width:r,height:i}=e.canvas.read(wt);this.projection(t,r,i),this.updateMatrix(t),this.updateComputedCamera(t)}
10294),this.canvases.changed.forEach(t=>{const{cameras:e,width:r,height:i}=t.read(wt);e.forEach(s=>{this.projection(s,r,i),this.updateComputedCamera(s)})})}updateComputedCamera(t){const{translation:e,rotation:r,scale:i}=t.read(_e);Object.assign(t.write(Pe),{x:e.x,y:e.y,rotation:r,zoom:1/i.x})}projection(t,e,r){nt(t,Pe);const i=ld(Bt(),e,r);t.write(Pe).projectionMatrix=ie.fromGLMat3(i),this.updateViewProjectionMatrix(t)}updateMatrix(t){const{translation:e,rotation:r,scale:i}=t.read(_e),s=Bt();Yc(s),bi(s,s,[e.x,e.y]),Mo(s,s,r),xh(s,s,[i.x,i.y]),_i(s,s),t.write(Pe).viewMatrix=ie.fromGLMat3(s),this.updateViewProjectionMatrix(t)}updateViewProjectionMatrix(t){const{projectionMatrix:e,viewMatrix:r}=t.write(Pe),i=us(Bt(),ie.toGLMat3(e),ie.toGLMat3(r)),s=_i(Bt(),i);s&&Object.assign(t.write(Pe),{viewProjectionMatrix:ie.fromGLMat3(i),viewProjectionMatrixInv:ie.fromGLMat3(s)})}};class c_t extends We{constructor(){super(),this.paths=this.query(e=>e.addedOrChanged.with(xt).trackWrites),this.polylines=this.query(e=>e.addedOrChanged.with(_t).trackWrites),this.query(e=>e.current.with(wo).write),this.query(e=>e.using(Gt).read)}execute(){this.paths.addedOrChanged.forEach(e=>{_h(e)}),this.polylines.addedOrChanged.forEach(e=>{_h(e)})}}_h=function(t){if(t.has(xt)){const{d:e}=t.read(xt),{subPaths:r}=a3(e),i=r.map(s=>s.getPoints().map(o=>[o[0],o[1]]));nt(t,wo),t.write(wo).points=i}else if(t.has(_t)){const{points:e}=t.read(_t),{alignment:r,width:i}=t.read(Gt);nt(t,wo),t.write(wo).shiftedPoints=MJ(e,r,i)}};function MJ(t,e,r){return e==="center"?t:BJ(t,e==="inner",r)}function BJ(t,e,r){const i=[];return t.forEach(([s,o],n)=>{const a=Be(s,o),l=n===0?a:Be(t[n-1][0],t[n-1][1]),c=n===t.length-1?a:Be(t[n+1][0],t[n+1][1]),h=ru(it(),a,l),u=rm(h),d=it();$y(d,h,Be(u,u));const f=Be(d[1],-d[0]),g=ru(it(),c,a),p=rm(g),m=it();$y(m,g,Be(p,p));const v=Be(m[1],-m[0]),b=f[0]*v[1]-f[1]*v[0],y=2*(e?0:1)-1,_=r/2*y;u===0?Aa(a,a,Ea(v,v,_)):p===0||Math.abs(b)<.01?Aa(a,a,Ea(f,f,_)):Aa(a,a,jjt(f,v,_)),i.push([a[0],a[1]])}),i}function OJ(t){return Number.isFinite(t.minX)&&Number.isFinite(t.minY)&&Number.isFinite(t.maxX)&&Number.isFinite(t.maxY)&&t.minX<=t.maxX&&t.minY<=t.maxY}function h_t(t,e){const r=new Qe(1/0,1/0,-1/0,-1/0);if(!t.has(ze))return r;for(const i of t.read(ze).children){if(!i.has(fe))continue;const s=i.read(fe)[e];OJ(s)&&(r.minX=Math.min(r.minX,s.minX),r.minY=Math.min(r.minY,s.minY),r.maxX=Math.max(r.maxX,s.maxX),r.maxY=Math.max(r.maxY,s.maxY))}return r}function u_t(t,e){const r=new Qe;return r.addFrame(t.minX,t.minY,t.maxX,t.maxY,e),r}lE=class extends We{constructor(){super(),this.renderables=this.query(t=>t.addedOrChanged.with(Zi,Ae).withAny(_e,et,ae,$t,Mt,_t,xt,Yt,ai,ke,Js,Hn).trackWrites),this.missingBounds=this.query(t=>t.current.with(Zi,Ae).without(fe).withAny(_e,et,ae,$t,Mt,_t,xt,Yt,ai,ke,Js,Hn).read),this.query(t=>t.current.with(fe).write),this.query(t=>t.using(wt,et,ae,$t,Mt,_t,xt,wo,Yt,ai,Ji,Gt,ro,qo,ko,To,ze,be).read)}execute(){const t=new Set;this.missingBounds.current.forEach(e=>{Iw(e);let r=e;for(;r!=null&&r.has(be);){const i=r.read(be).parent;if(!i)break;i.has(Js)&&t.add(i),r=i}}),this.renderables.addedOrChanged.forEach(e=>{Iw(e);let r=e;for(;r!=null&&r.has(be);){const i=r.read(be).parent;if(!i)break;i.has(Js)&&t.add(i),r=i}}),t.forEach(e=>{Iw(e)})}};function Iw(t){nt(t,fe);const e=t.has(Gt)?t.read(Gt):void 0,r=t.has(ro)?t.read(ro):void 0;let i,s;if(t.has(et))i=et.getGeometryBounds(t.read(et)),s=et.getRenderBounds(t.read(et),e);else if(t.has(ae))i=ae.getGeometryBounds(t.read(ae)),s=ae.getRenderBounds(t.read(ae),e);else if(t.has($t))i=$t.getGeometryBounds(t.read($t)),s=$t.getRenderBounds(t.read($t),e,r);else if(t.has(Mt)){i=Mt.getGeometryBounds(t.read(Mt));const n=e==null?void 0:PB(t,e);s=Mt.getRenderBounds(t.read(Mt),n,t.has(qo)?t.read(qo):void 0)}else if(t.has(_t)){i=_t.getGeometryBounds(Object.assign(Object.assign({},t.read(_t)),{points:t.read(wo).shiftedPoints}));const n=e==null?void 0:PB(t,e);s=_t.getRenderBounds(t.read(_t),n,t.has(qo)?t.read(qo):void 0)}else if(t.has(ai))i=ai.getGeometryBounds(t.read(ai)),s=ai.getRenderBounds(t.read(ai));else if(t.has(xt)){i=xt.getGeometryBounds(t.read(xt),t.read(wo));const n=e==null?void 0:PB(t,e);s=xt.getRenderBounds(t.read(xt),t.read(wo),n,t.has(qo)?t.read(qo):void 0)}else if(t.has(Yt))i=Yt.getGeometryBounds(t.read(Yt),t.read(Ji)),s=Yt.getRenderBounds(t.read(Yt),t.read(Ji),e,r);else if(t.has(ke))i=ke.getGeometryBounds(t.read(ke)),s=ke.getRenderBounds(t.read(ke),e);else if(t.has(ko))i=ko.getGeometryBounds(t.read(ko)),s=i;else if(t.has(To))i=To.getGeometryBounds(t.read(To)),s=i;
10294else if(t.has(Js))if(t.has(ze)&&t.read(ze).children.forEach(n=>{Iw(n)}),t.has(Hn)&&(()=>{const n=t.read(Hn);return n.layoutWidth>0&&n.layoutHeight>0})()){const n=t.read(Hn);i=new Qe(0,0,n.layoutWidth,n.layoutHeight),s=new Qe(0,0,n.layoutWidth,n.layoutHeight)}else{const n=h_t(t,"geometryWorldBounds"),a=h_t(t,"renderWorldBounds"),l=new Qe(1/0,1/0,-1/0,-1/0),c=Bt(),h=_i(c,ie.toGLMat3(t.read(Ae).matrix))?ie.fromGLMat3(c):null;OJ(n)?i=h?u_t(n,h):n:i=l,OJ(a)?s=h?u_t(a,h):a:s=l}const o=t.has(Zi)?t.read(Zi).hitArea:null;if(o&&(o instanceof et?s=et.getRenderBounds(o):o instanceof $t&&(s=$t.getRenderBounds(o))),i&&(t.write(fe).geometryBounds=i),s&&(t.write(fe).renderBounds=s),i&&s){const n=t.read(Ae).matrix,{translation:a,rotation:l,scale:c}=Q8(ie.toGLMat3(n)),{geometryBounds:h,renderBounds:u}=t.read(fe),d=new Qe;d.addBounds(h,n);const f=new Qe;f.addBounds(u,n);const g=new Yu({x:a[0],y:a[1],width:h.maxX-h.minX,height:h.maxY-h.minY,rotation:l,scaleX:c[0],scaleY:c[1]});let p=g.x,m=g.y;if(t.has(_t)||t.has(xt)||t.has(Mt)){const b=h.minX,y=h.minY,{m00:_,m01:w,m10:E,m11:A,m20:x,m21:S}=n;p=_*b+E*y+x,m=w*b+A*y+S}const v=t.has(Js)?new Yu({x:d.minX,y:d.minY,width:d.maxX-d.minX,height:d.maxY-d.minY,rotation:0,scaleX:1,scaleY:1}):new Yu({x:p,y:m,width:g.width,height:g.height,rotation:g.rotation,scaleX:g.scaleX,scaleY:g.scaleY});Object.assign(t.write(fe),{renderWorldBounds:f,geometryWorldBounds:d,transformOBB:g,selectionOBB:v})}t.has(ze)&&!t.has(Js)&&t.read(ze).children.forEach(n=>{Iw(n)})}class Dz extends We{constructor(){super(),this.visibility=this.query(e=>e.addedOrChanged.with(he).trackWrites),this.query(e=>e.using(Pn).write.and.using(ze,be).read)}execute(){this.visibility.addedOrChanged.forEach(e=>{const{value:r}=e.read(he);e.has(Pn)||e.add(Pn);const i=e.write(Pn);if(r==="inherited"){const o=e.has(be)&&e.read(be).parent;o&&o.has(Pn)?i.visible=o.read(Pn).visible:i.visible=!0}else r==="hidden"?i.visible=!1:r==="visible"&&(i.visible=!0);const s=i.visible;Ov(e).forEach(o=>{o.has(he)&&o.read(he).value==="inherited"&&(o.has(Pn)?o.write(Pn).visible=s:o.add(Pn,{visible:s}))})})}}var IJ=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},lU;cG=class extends We{constructor(){super(),this.bounds=this.query(t=>t.addedOrChanged.and.removed.with(fe).trackWrites),this.cameras=this.query(t=>t.current.and.added.and.addedOrChanged.with(Pe).trackWrites),this.visibilities=this.query(t=>t.addedChangedOrRemoved.with(Pn).trackWrites),lU.set(this,new WeakMap),this.query(t=>t.using(jt,wt,be,ze,Zi).read.and.using(jc,dl).write)}remove(t){const e=En(t);e!==t&&e.read(dl).value.remove({minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,entity:t},(r,i)=>r.entity===i.entity)}execute(){const t=new WeakMap;this.cameras.current.forEach(i=>{t.set(i,new Set)}),this.cameras.added.forEach(i=>{i.add(dl,{value:new TE})}),this.cameras.addedOrChanged.forEach(i=>{const{api:s}=i.read(jt).canvas.read(wt),{minX:o,minY:n,maxX:a,maxY:l}=s.getViewportBounds(),c=this.getOrCreateViewport(i);c.minX=o,c.minY=n,c.maxX=a,c.maxY=l,Ov(i).forEach(h=>{var u;(u=t.get(i))===null||u===void 0||u.add(h)})}),this.visibilities.addedChangedOrRemoved.forEach(i=>{const s=En(i);t.has(s)&&t.get(s).add(i)});const e=new Map,r=new Map;this.bounds.addedOrChanged.forEach(i=>{var s;const o=En(i);if(o===i||!o.has(jt)){o.has(dl)&&o.read(dl).value.remove({minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,entity:i},(n,a)=>n.entity===a.entity);return}e.has(o)||e.set(o,new Set),(s=e.get(o))===null||s===void 0||s.add(i)}),this.bounds.removed.forEach(i=>{const s=En(i);if(s===i||!s.has(jt)){s.has(dl)&&s.read(dl).value.remove({minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,entity:i},(o,n)=>o.entity===n.entity);return}r.has(s)||r.set(s,new Set),r.get(s).add(i)}),[r,e].forEach(i=>{i.forEach((s,o)=>{const n=o.read(dl).value;
10294s.forEach(a=>{var l;(l=t.get(o))===null||l===void 0||l.add(a),n.remove({minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,entity:a},(c,h)=>c.entity===h.entity)})})}),e.forEach((i,s)=>{const o=s.read(dl).value,n=[];i.forEach(a=>{const{renderWorldBounds:l}=a.read(fe),c={minX:l.minX,minY:l.minY,maxX:l.maxX,maxY:l.maxY,entity:a};n.push(c)}),o.load(n)}),this.cameras.current.forEach(i=>{var s,o;if(((s=t.get(i))===null||s===void 0?void 0:s.size)===0)return;const n=i.read(dl).value,a=this.getOrCreateViewport(i),l=n.search(a).map(c=>c.entity);(o=t.get(i))===null||o===void 0||o.forEach(c=>{if(!c.has(Pn))return;const{visible:h}=c.read(Pn);c.has(Zi)&&(h&&l.includes(c)?c.has(jc)&&c.remove(jc):(!h||!l.includes(c))&&(c.has(jc)||c.add(jc)))})})}getOrCreateViewport(t){let e=IJ(this,lU,"f").get(t);return e||(IJ(this,lU,"f").set(t,new Qe),e=IJ(this,lU,"f").get(t)),e}},lU=new WeakMap;class d_t extends We{constructor(){super(),this.cursors=this.query(e=>e.addedOrChanged.with(_o).trackWrites),this.query(e=>e.using(wt).read)}execute(){this.cursors.addedOrChanged.forEach(e=>{const r=e.read(_o),{element:i}=e.read(wt);Zo&&i instanceof HTMLCanvasElement&&i.style.cursor!==r.value&&(i.style.cursor=r.value)})}}var tse=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},f_t=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};class cU extends We{*setScreenshotTrigger(e,r,i,s){nt(e,vh);const o=e.write(vh);Object.assign(o,{dataURL:r,canvas:e,svg:i,download:s}),yield,Zr(e,vh),Zr(e,Vg)}constructor(){super(),this.vectorScreenshotRequests=this.query(e=>e.added.with(Vg)),this.query(e=>e.using(wt,ul,rd,jt,Ii,ba,ze,be,et,ae,$t,_t,Mt,xt,Yt,Gt,bo,_e,Ce,ro,ac,he,Gs,fe,Pe,Ji,wa,qo,Mv,La,Xc,Qn,tu,Gc,mh).read.and.using(vh,Vg).write)}execute(){this.vectorScreenshotRequests.added.forEach(e=>f_t(this,void 0,void 0,function*(){const{canvas:r,grid:i,download:s,nodes:o}=e.read(Vg),{api:n}=r.read(wt),a=yield n.renderToSVG(o,{grid:i}),l=Pr.get().getXMLSerializer();this.setScreenshotTrigger(r,zbt(a),l.serializeToString(a),s)}))}}tse([bO],cU.prototype,"setScreenshotTrigger",null);function p_t(t,e){return f_t(this,arguments,void 0,function*(r,i,s=0,o){var n;const a=(n=o==null?void 0:o.designVariablesExport)!==null&&n!==void 0?n:"resolved",l=new Set;i.forEach(v=>{const b=r.getParent(v),y=r.getNodeByEntity(b);y&&y.clipMode&&!l.has(y)&&l.add(y)});const c=new Set([...i]);i=Array.from(c);const h=we("svg"),u=r.getBounds(i),d=u.maxX-u.minX,f=u.maxY-u.minY;h.setAttribute("width",`${ti(d)}`),h.setAttribute("height",`${ti(f)}`),h.setAttribute("viewBox",`${ti(u.minX-s)} ${ti(u.minY-s)} ${ti(d+s*2)} ${ti(f+s*2)}`),i=[...l,...i];const g=tq(i,r.getAppState().variables,a,r.getAppState().themeMode),p=r.readLayoutFromECS(g.nodes),m=rft(p,r.getNodes());if(g.cssRootStyle){const v=we("defs"),b=Pr.get().getDocument().createElementNS("http://www.w3.org/2000/svg","style");b.textContent=g.cssRootStyle,v.appendChild(b),h.insertBefore(v,h.firstChild)}return(yield Vz(m)).forEach(v=>{h.appendChild(v)}),h})}function g_t(t,e){const r=we("defs");t.appendChild(r);const i=we("pattern");i.setAttribute("id","small-grid"),i.setAttribute("width","10"),i.setAttribute("height","10"),i.setAttribute("patternUnits","userSpaceOnUse");const s=we("path");s.setAttribute("d","M 10 0 L 0 0 0 10"),s.setAttribute("fill","none"),s.setAttribute("stroke",e),s.setAttribute("stroke-width","1"),i.appendChild(s);const o=we("pattern");o.setAttribute("id","grid"),o.setAttribute("width","100"),o.setAttribute("height","100"),o.setAttribute("patternUnits","userSpaceOnUse");const n=we("rect");n.setAttribute("width","100"),n.setAttribute("height","100"),n.setAttribute("fill","url(#small-grid)"),o.appendChild(n);const a=we("path");a.setAttribute("d","M 100 0 L 0 0 0 100"),a.setAttribute("fill","none"),a.setAttribute("stroke",e),a.setAttribute("stroke-width","2"),o.appendChild(a),r.appendChild(i),r.appendChild(o);const l=we("rect");l.setAttribute("width","100%"),l.setAttribute("height","100%"),l.setAttribute("fill","url(#grid)"),t.appendChild(l)}function m_t(t,e){const r=we("defs");t.appendChild(r);const i=we("circle");i.setAttribute("id","dot-tl"),i.setAttribute("cx","0"),i.setAttribute("cy","0"),i.setAttribute("r","2"),i.setAttribute("fill",e);
10294const s=i.cloneNode(),o=i.cloneNode(),n=i.cloneNode();s.setAttribute("id","dot-tr"),s.setAttribute("cx","20"),o.setAttribute("id","dot-bl"),o.setAttribute("cy","20"),n.setAttribute("id","dot-br"),n.setAttribute("cx","20"),n.setAttribute("cy","20"),r.appendChild(i),r.appendChild(s),r.appendChild(o),r.appendChild(n);const a=we("pattern");a.setAttribute("id","dots-grid"),a.setAttribute("width","20"),a.setAttribute("height","20"),a.setAttribute("patternUnits","userSpaceOnUse");const l=we("use");l.setAttribute("xlink:href","#dot-bl");const c=we("use");c.setAttribute("xlink:href","#dot-br");const h=we("use");h.setAttribute("xlink:href","#dot-tl");const u=we("use");u.setAttribute("xlink:href","#dot-tr"),a.appendChild(l),a.appendChild(c),a.appendChild(h),a.appendChild(u),r.appendChild(a);const d=we("rect");d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.setAttribute("fill","url(#dots-grid)"),t.appendChild(d)}var uv=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};class ar{constructor(e){var r,i,s,o,n,a,l,c,h;e&&Object.assign(this,e),(r=this.mode)!==null&&r!==void 0||(this.mode="transform"),(i=this.activeAxis)!==null&&i!==void 0||(this.activeAxis="none"),(s=this.activePartKind)!==null&&s!==void 0||(this.activePartKind=null),(o=this.dragging)!==null&&o!==void 0||(this.dragging=!1),(n=this.dragHitStart)!==null&&n!==void 0||(this.dragHitStart=null),(a=this.dragAngleStart)!==null&&a!==void 0||(this.dragAngleStart=null),(l=this.initialTranslation)!==null&&l!==void 0||(this.initialTranslation=null),(c=this.initialRotation)!==null&&c!==void 0||(this.initialRotation=null),(h=this.initialScale)!==null&&h!==void 0||(this.initialScale=null)}}uv([P.object],ar.prototype,"mode",void 0),uv([P.object],ar.prototype,"activeAxis",void 0),uv([P.object],ar.prototype,"activePartKind",void 0),uv([P.boolean],ar.prototype,"dragging",void 0),uv([P.object],ar.prototype,"dragHitStart",void 0),uv([P.float32],ar.prototype,"dragAngleStart",void 0),uv([P.object],ar.prototype,"initialTranslation",void 0),uv([P.object],ar.prototype,"initialRotation",void 0),uv([P.object],ar.prototype,"initialScale",void 0);function y_t(t,e,r){if(t.linked&&r&&t.projection==="orthographic"){const o=r.read(Pe).viewProjectionMatrix,n=t.far>0?-2/t.far:0;return{mode:"linkedOrthographic",projMatrix:CU(o,n),viewMatrix:Ai.IDENTITY,canvasViewProjection:Ai.IDENTITY,sceneParams:[0,0,0,0]}}if(t.linked&&r&&t.projection==="perspective"){const o=r.read(Pe),n=r.read(jt),a=n.canvas?n.canvas.read(wt).height:0,l=MQ(a,o.zoom,t.fovy),c=new Ai(1,0,0,0,0,1,0,0,0,0,1,0,0,0,-l,1);return{mode:"linkedPerspective",viewMatrix:Ai.multiply(CQ(o.viewMatrix),c),projMatrix:Ai.perspective(t.fovy,e,t.near,t.far),canvasViewProjection:CU(o.viewProjectionMatrix,0),sceneParams:[o.x,o.y,1,l]}}let i,s;if(t.projection==="orthographic"){const o=Math.abs(t.eye[2]-t.center[2]),n=o*e;i=Ai.ortho(-n,n,-o,o,t.near,t.far)}else i=Ai.perspective(t.fovy,e,t.near,t.far);return s=Ai.lookAt(t.eye,t.center,t.up),{mode:"standard",projMatrix:i,viewMatrix:s,canvasViewProjection:Ai.IDENTITY,sceneParams:[0,0,0,0]}}function v_t(t){return t.mode==="linkedPerspective"?{mode:"linkedPerspective",projMatrix:t.projMatrix.toFloat32Array(),viewMatrix:t.viewMatrix.toFloat32Array(),canvasViewProjection:t.canvasViewProjection.toFloat32Array()}:t.mode==="linkedOrthographic"?{mode:"orthographic2d",projMatrix:t.projMatrix.toFloat32Array(),viewMatrix:Ai.IDENTITY.toFloat32Array()}:{mode:"standard",projMatrix:t.projMatrix.toFloat32Array(),viewMatrix:t.viewMatrix.toFloat32Array()}}function ese(t){const e=new Float32Array(52);return e.set(t.projMatrix.toFloat32Array(),0),e.set(t.viewMatrix.toFloat32Array(),16),e.set(t.canvasViewProjection.toFloat32Array(),32),e.set(t.sceneParams,48),e}function __t(t,e,r,i,s){const o=2*t/r-1,n=1-2*e/i,a=NT(o,n,-1,1),l=NT(o,n,1,1),c=s,h=f0();jv(h,a,c),Math.abs(h[3])>1e-10&&(h[0]/=h[3],h[1]/=h[3],h[2]/=h[3]);const u=f0();jv(u,l,c),Math.abs(u[3])>1e-10&&(u[0]/=u[3],u[1]/=u[3],u[2]/=u[3]);const d=[h[0],h[1],h[2]],f=Xa();return KO(f,[u[0],u[1],u[2]],d),qO(f,f),{origin:d,direction:[f[0],f[1],f[2]]}}function rse(t,e){const r=e,i=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0],o=Xa();for(let n=0;n<t.length;n+=3)d0(o,t[n],t[n+1],t[n+2]),sf(o,o,r),o[0]<i[0]&&(i[0]=o[0]),o[1]<i[1]&&(i[1]=o[1]),o[2]<i[2]&&(i[2]=o[2]),o[0]>s[0]&&(s[0]=o[0]),o[1]>s[1]&&(s[1]=o[1]),o[2]>s[2]&&(s[2]=o[2]);return{min:i,max:s}}function ise(t,e){let r=-1/0,i=1/0;for(let s=0;s<3;s++){const o=1/t.direction[s];let n=(e.min[s]-t.origin[s])*o,a=(e.max[s]-t.origin[s])*o;if(o<0){const l=n;n=a,a=l}if(r=Math.max(r,n),i=Math.min(i,a),i<r)return!1}return i>=0}function sse(t,e,r,i){const s=Xa(),o=Xa();
10294KO(s,r,e),KO(o,i,e);const n=Xa();Jst(n,t.direction,o);const a=FT(s,n);if(a>-1e-7&&a<1e-7)return-1;const l=1/a,c=Xa();KO(c,t.origin,e);const h=l*FT(c,n);if(h<0||h>1)return-1;const u=Xa();Jst(u,c,s);const d=l*FT(t.direction,u);if(d<0||h+d>1)return-1;const f=l*FT(o,u);return f>1e-7?f:-1}function ose(t,e,r,i){const s=i,o=rse(e,i);if(!ise(t,o))return null;let n=1/0,a=-1;const l=Xa(),c=Xa(),h=Xa(),u=r?r.length/3:e.length/9;for(let f=0;f<u;f++){let g,p,m;r?(g=r[f*3]*3,p=r[f*3+1]*3,m=r[f*3+2]*3):(g=f*9,p=f*9+3,m=f*9+6),d0(l,e[g],e[g+1],e[g+2]),sf(l,l,s),d0(c,e[p],e[p+1],e[p+2]),sf(c,c,s),d0(h,e[m],e[m+1],e[m+2]),sf(h,h,s);const v=sse(t,l,c,h);v>=0&&v<n&&(n=v,a=f)}if(a<0)return null;const d=[t.origin[0]+t.direction[0]*n,t.origin[1]+t.direction[1]*n,t.origin[2]+t.direction[2]*n];return{t:n,point:d,triangleIndex:a}}function nse(t,e,r){const i=cc();return O$(i,i,t),YO(i,i,e[0]),$O(i,i,e[1]),HO(i,i,e[2]),I$(i,i,r),i}function RB(t,e,r,i,s,o){const n=r,a=i,l=s,c=f0();jv(c,NT(t[0],t[1],0,1),n);const h=f0();jv(h,NT(e[0],e[1],0,1),n);const u=f0();jv(u,NT(t[0],t[1],t[2],1),a);const d=f0();jv(d,u,l);const f=f0();jv(f,NT(t[0],t[1],e[2],1),a);const g=f0();jv(g,f,l);let p=d[3];Math.abs(p)<1e-6&&(p=p>=0?1e-6:-1e-6);const m=p/g[3];let v=h[0]+(c[0]-h[0])*m,b=h[1]+(c[1]-h[1])*m;const y=d[2]*c[3]/p,_=c[3];if(o){const w=t[2]-e[2];v+=o[0]*w*_,b+=o[1]*w*_}return{clip:[v,b,y,_],pickDepth:d[3]/g[3]}}function DJ(t,e,r){const i=t[3],s=Math.abs(i)>1e-10?t[0]/i:t[0],o=Math.abs(i)>1e-10?t[1]/i:t[1];return[(s+1)*e/2,(1-o)*r/2]}function ase(t,e,r,i,s,o,n,a){const l=(o-a)*(r-n)+(n-s)*(i-a);if(Math.abs(l)<1e-10)return{inside:!1,u:0,v:0,w:0};const c=((o-a)*(t-n)+(n-s)*(e-a))/l,h=((a-i)*(t-n)+(r-n)*(e-a))/l,u=1-c-h;return{inside:c>=0&&h>=0&&u>=0,u:c,v:h,w:u}}function lse(t,e,r,i,s,o,n,a,l,c){const h=n,u=Xa(),d=Xa(),f=Xa(),g=[0,0,0],p=[0,0,0],m=[0,0,0];let v=-1/0,b=-1,y=null;const _=o?o.length/3:s.length/9;for(let w=0;w<_;w++){let E,A,x;o?(E=o[w*3]*3,A=o[w*3+1]*3,x=o[w*3+2]*3):(E=w*9,A=w*9+3,x=w*9+6),d0(u,s[E],s[E+1],s[E+2]),sf(u,u,h),d0(d,s[A],s[A+1],s[A+2]),sf(d,d,h),d0(f,s[x],s[x+1],s[x+2]),sf(f,f,h),g[0]=u[0],g[1]=u[1],g[2]=u[2],p[0]=d[0],p[1]=d[1],p[2]=d[2],m[0]=f[0],m[1]=f[1],m[2]=f[2];const S=RB(g,a,l.canvasViewProjection,l.viewMatrix,l.projMatrix,c),T=RB(p,a,l.canvasViewProjection,l.viewMatrix,l.projMatrix,c),R=RB(m,a,l.canvasViewProjection,l.viewMatrix,l.projMatrix,c),B=DJ(S.clip,r,i),O=DJ(T.clip,r,i),C=DJ(R.clip,r,i),F=ase(t,e,B[0],B[1],O[0],O[1],C[0],C[1]);if(!F.inside)continue;const U=F.u*S.pickDepth+F.v*T.pickDepth+F.w*R.pickDepth;U>v&&(v=U,b=w,y=[F.u*g[0]+F.v*p[0]+F.w*m[0],F.u*g[1]+F.v*p[1]+F.w*m[1],F.u*g[2]+F.v*p[2]+F.w*m[2]])}return b<0||!y?null:{t:-v,point:y,triangleIndex:b}}function b_t(t,e,r,i,s,o,n,a,l,c){if(l.mode==="linkedPerspective")return lse(t,e,r,i,s,o,n,a,l,c);const h=w_t(l.projMatrix,l.viewMatrix),u=__t(t,e,r,i,h);return ose(u,s,o,n)}function w_t(t,e){const r=cc();B$(r,t,e);const i=cc();return M4(i,r),i}const cse=[.5,-.55];function PJ(t){const e=t[3];return Math.abs(e)<1e-10?[t[0],t[1]]:[t[0]/e,t[1]/e]}function E_t(t,e){const r=t[0]-e[0],i=t[1]-e[1];return Math.hypot(r,i)}function hse(t){const e=Math.hypot(t[0],t[1]);return e<1e-10?[1,0]:[t[0]/e,t[1]/e]}function A_t(t,e,r){if(e<1e-8)return[0,0];const{canvasViewProjection:i,viewMatrix:s,projMatrix:o}=r,n=RB(t,t,i,s,o),a=RB([t[0]+e,t[1],t[2]],t,i,s,o),l=RB([t[0],t[1],t[2]+e],t,i,s,o),c=PJ(n.clip),h=E_t(c,PJ(a.clip));if(E_t(c,PJ(l.clip))>=h*.35)return[0,0];const u=Math.max(h,1e-4),d=hse(cse);return[d[0]*u/e,d[1]*u/e]}function use(t,e,r,i){const s=[],o=[],n=[];for(let a=0;a<=i;a++){const l=a/i*Math.PI*2,c=Math.cos(l),h=Math.sin(l);s.push(c*e,0,h*e),o.push(c,0,h),s.push(c*e,r,h*e),o.push(c,0,h)}for(let a=0;a<i;a++){const l=a*2,c=l+1,h=l+2,u=l+3;n.push(l,c,u,l,u,h)}return FJ({positions:s,normals:o,indices:n},t)}function dse(t,e,r,i,s){const o=[],n=[],a=[];o.push(0,i+r,0),n.push(0,1,0);const l=e/r;for(let h=0;h<=s;h++){const u=h/s*Math.PI*2,d=Math.cos(u),f=Math.sin(u);o.push(d*e,i,f*e);const g=d,p=l,m=f,v=Math.sqrt(g*g+p*p+m*m);n.push(g/v,p/v,m/v)}for(let h=1;h<=s;h++)a.push(0,h,h+1);const c=o.length/3;o.push(0,i,0),n.push(0,-1,0);for(let h=0;h<=s;h++){const u=h/s*Math.PI*2,d=Math.cos(u),f=Math.sin(u);o.push(d*e,i,f*e),n.push(0,-1,0)}for(let h=1;h<=s;h++)a.push(c,c+h+1,c+h);return FJ({positions:o,normals:n,indices:a},t)}function FJ(t,e){if(e==="y")return t;const{positions:r,normals:i,indices:s}=t,o=[],n=[];for(let a=0;a<r.length;a+=3){const[l,c,h]=[r[a],r[a+1],r[a+2]],[u,d,f]=[i[a],i[a+1],i[a+2]];e==="x"?(o.push(c,-l,h),n.push(d,-u,f)):(o.push(l,-h,c),n.push(u,-f,d))}return{positions:o,normals:n,indices:s}}function fse(t,e,r){const i=[],s=[],o=r,n=e;return t==="xy"?(i.push(o,o,0,o+n,o,0,o+n,o+n,0,o,o+n,0),s.push(0,0,1,0,0,1,0,0,1,0,0,1)):t==="xz"?(i.push(o,0,o,o+n,0,o,o+n,0,o+n,o,0,o+n),s.push(0,1,0,0,1,0,0,1,0,0,1,0)):(i.push(0,o,o,0,o+n,o,0,o+n,o+n,0,o,o+n),s.push(1,0,0,1,0,0,1,0,0,1,0,0)),{positions:i,normals:s,indices:[0,1,2,0,2,3]}}function x_t(){return[...pse(),...gse()]}function pse(t=.7,e=.02,r=.2,i=.06,s=.15,o=.25,n=12){const a=[],l=[{axis:"x",color:[1,.15,.15,1]},{axis:"y",color:[.15,1,.15,1]},{axis:"z",color:[.2,.45,1,1]}];for(const{axis:h,color:u}
10294of l){const d=use(h,e,t,n),f=dse(h,i,r,t,n),g=[...d.positions,...f.positions],p=[...d.normals,...f.normals],m=d.positions.length/3,v=[...d.indices,...f.indices.map(b=>b+m)];a.push({positions:new Float32Array(g),normals:new Float32Array(p),indices:new Uint32Array(v),color:u,axis:h,kind:"translate"})}const c=[{plane:"xy",color:[.2,.45,1,.35]},{plane:"xz",color:[.15,1,.15,.35]},{plane:"yz",color:[1,.15,.15,.35]}];for(const{plane:h,color:u}of c){const d=fse(h,s,o);a.push({positions:new Float32Array(d.positions),normals:new Float32Array(d.normals),indices:new Uint32Array(d.indices),color:u,axis:h,kind:"translate"})}return a}const S_t=.9,NJ=.85;function gse(t=NJ,e=.05,r=48){return[{axis:"x",color:[1,.15,.15,1]},{axis:"y",color:[.15,1,.15,1]},{axis:"z",color:[.2,.45,1,1]}].map(({axis:i,color:s})=>{const o=mse(i,t,e,r);return{positions:new Float32Array(o.positions),normals:new Float32Array(o.normals),indices:new Uint32Array(o.indices),color:s,axis:i,kind:"rotate"}})}function mse(t,e,r,i){const s=[],o=[],n=[],a=Math.max(e-r,e*.7);for(let l=0;l<i;l++){const c=l/i*Math.PI*2,h=(l+1)/i*Math.PI*2,u=Math.cos(c),d=Math.sin(c),f=Math.cos(h),g=Math.sin(h),p=[u*e,0,d*e],m=[f*e,0,g*e],v=[u*a,0,d*a],b=[f*a,0,g*a],y=s.length/3;for(const _ of[p,m,b,v])s.push(_[0],_[1],_[2]),o.push(0,1,0);n.push(y,y+1,y+2,y,y+2,y+3)}return t==="y"?{positions:s,normals:o,indices:n}:FJ({positions:s,normals:o,indices:n},t)}function T_t(t,e,r,i,s=150,o=!1){let n;if(o)n=Math.abs(t[2]-e[2]),n<1e-4&&(n=1e-4);else{const a=t[0]-e[0],l=t[1]-e[1],c=t[2]-e[2];n=Math.sqrt(a*a+l*l+c*c)}return 2*n*Math.tan(r/2)/i*s}const yse=x_t();function vse(){return yse}function R_t(t){return t==="x"||t==="y"||t==="z"}function C_t(t,e){return t==="translate"&&e==="z"}function M_t(t,e,r,i){const s=cc();return O$(s,s,t),i==="rotate"&&(YO(s,s,e[0]),$O(s,s,e[1]),HO(s,s,e[2])),I$(s,s,[r,r,r]),s}function B_t(t,e){const r=cc();YO(r,r,t[0]),$O(r,r,t[1]),HO(r,r,t[2]);const i=e==="x"?Wv(1,0,0):e==="y"?Wv(0,1,0):Wv(0,0,1),s=Xa();return sf(s,i,r),qO(s,s),[s[0],s[1],s[2]]}function O_t(t,e,r,i){const s=cc();YO(s,s,i[0]),$O(s,s,i[1]),HO(s,s,i[2]);const o=r==="x"?Wv(0,1,0):Wv(1,0,0),n=r==="x"||r==="y"?Wv(0,0,1):Wv(0,1,0),a=Xa(),l=Xa();sf(a,o,s),sf(l,n,s),qO(a,a),qO(l,l);const c=Wv(t[0]-e[0],t[1]-e[1],t[2]-e[2]);return Math.atan2(FT(c,l),FT(c,a))}function _se(t){let e=t;for(;e>Math.PI;)e-=2*Math.PI;for(;e<-Math.PI;)e+=2*Math.PI;return e}function Pz(t,e,r){const i=t.direction[0]*r[0]+t.direction[1]*r[1]+t.direction[2]*r[2];if(Math.abs(i)<1e-8)return null;const s=[e[0]-t.origin[0],e[1]-t.origin[1],e[2]-t.origin[2]],o=(s[0]*r[0]+s[1]*r[1]+s[2]*r[2])/i;return o<0?null:[t.origin[0]+t.direction[0]*o,t.origin[1]+t.direction[1]*o,t.origin[2]+t.direction[2]*o]}function I_t(t,e,r,i,s,o){const n=t.linked&&i>0&&s>0?i/s:e/r;return v_t(y_t(t,n,o))}function kJ(t,e,r,i,s,o,n,a){if(r<=0||i<=0)return{kind:"none"};for(const h of a){if(!h.has(ki)||!h.has(ar))continue;const u=h.read(ki),d=bse(t,e,r,i,s,o,u.translation,u.rotation);if(d)return{kind:"gizmo",entity:h,axis:d.axis,partKind:d.partKind}}let l=null,c=null;for(const h of n){const u=h.read(Ns),d=h.read(ki),f=nse(d.translation,d.rotation,d.scale),g=[d.translation[0],d.translation[1],d.translation[2]],p=b_t(t,e,r,i,u.positions,u.indices,f,g,o);p&&(!l||p.t<l.t)&&(l=p,c=h)}return c&&l?{kind:"mesh",entity:c,hit:l}:{kind:"none"}}function bse(t,e,r,i,s,o,n,a){const l=T_t(s.eye,n,s.fovy,i,150,s.linked),c=[n[0],n[1],n[2]],h=o.mode==="linkedPerspective"?A_t(c,l*Math.max(S_t,NJ*2),o):void 0;let u=null;for(const d of vse()){const f=M_t(n,a,l,d.kind),g=C_t(d.kind,d.axis)?h:void 0,p=b_t(t,e,r,i,d.positions,d.indices,f,c,o,g);p&&(!u||p.t<u.t)&&(u={axis:d.axis,partKind:d.kind,t:p.t})}return u?{axis:u.axis,partKind:u.partKind}:null}const wy=(t,e,r)=>[t[0]+(e[0]-t[0])*r,t[1]+(e[1]-t[1])*r],D_t=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1]);function P_t(t,e,r){var i,s,o,n;const a=t[r?e.end:e.start],l=t[r?e.start:e.end],c=r?e.tangentEnd:e.tangentStart,h=r?e.tangentStart:e.tangentEnd,u=[a.x,a.y],d=[l.x,l.y];return!(c!=null&&c.x)&&!(c!=null&&c.y)&&!(h!=null&&h.x)&&!(h!=null&&h.y)?[u,wy(u,d,1/3),wy(u,d,2/3),d]:[u,[a.x+((i=c==null?void 0:c.x)!==null&&i!==void 0?i:0),a.y+((s=c==null?void 0:c.y)!==null&&s!==void 0?s:0)],[l.x+((o=h==null?void 0:h.x)!==null&&o!==void 0?o:0),l.y+((n=h==null?void 0:h.y)!==null&&n!==void 0?n:0)],d]}function F_t(t,e){const r=wy(t[0],t[1],e),i=wy(t[1],t[2],e),s=wy(t[2],t[3],e),o=wy(r,i,e),n=wy(i,s,e),a=wy(o,n,e);return[[t[0],r,o,a],[a,n,s,t[3]]]}function N_t(t,e,r,i){const s=F_t(t,i);return Math.max(...e.map((o,n)=>D_t(o,s[0][n])),...r.map((o,n)=>D_t(o,s[1][n])))}function wse(t,e,r){let i=0,s=0,o=0;const n=[0,0],a=[0,0];for(let u=0;u<2;u++)for(let d=0;d<=16;d++){const f=d/16,g=F_t(u===0?t:e,f)[0][3],p=u===0?f*r:r+f*(1-r),m=Math.pow(1-p,3),v=3*Math.pow(1-p,2)*p,b=3*(1-p)*p*p,y=Math.pow(p,3);i+=v*v,s+=v*b,o+=b*b;for(let _=0;_<2;_++){const w=g[_]-m*t[0][_]-y*e[3][_];n[_]+=v*w,a[_]+=b*w}}const l=i*o-s*s,c=[0,0],h=[0,0];for(let u=0;u<2;u++)c[u]=(n[u]*o-a[u]*s)/l,h[u]=(a[u]*i-n[u]*s)/l;return[t[0],c,h,e[3]]}function Ese(t,e,r,i,s){const o=e.start===i?e.end:e.start,n=r.start===i?r.end:r.start;if(!t[o]||!t[n])return null;const a=_=>{var w,E,A,x;return!(!((w=_.tangentStart)===null||w===void 0)&&w.x)&&!(!((E=_.tangentStart)===null||E===void 0)&&E.y)&&!(!((A=_.tangentEnd)===null||A===void 0)&&A.x)&&!(!((x=_.tangentEnd)===null||x===void 0)&&x.y)};if(a(e)&&a(r))return{start:o,end:n};
10294const l=P_t(t,e,e.start===i),c=P_t(t,r,r.end===i),h=[...l,...c],u=Math.max(Math.max(...h.map(_=>_[0]))-Math.min(...h.map(_=>_[0])),Math.max(...h.map(_=>_[1]))-Math.min(...h.map(_=>_[1])),1e-6),d=s??u*.05;if(!(d>=0))return null;let f=l.map(_=>[..._]),g=c.map(_=>[..._]),p=.5;for(let _=1;_<=3;_++){f=f.slice(1).map((A,x)=>[A[0]-f[x][0],A[1]-f[x][1]]),g=g.slice(1).map((A,x)=>[A[0]-g[x][0],A[1]-g[x][1]]);const w=Math.pow(Math.hypot(...f[f.length-1]),1/_),E=Math.pow(Math.hypot(...g[0]),1/_);if(w>Math.pow(u,1/_)*1e-10&&E>Math.pow(u,1/_)*1e-10){p=w/(w+E);break}}const m=_=>({start:o,end:n,tangentStart:{x:_[1][0]-_[0][0],y:_[1][1]-_[0][1]},tangentEnd:{x:_[2][0]-_[3][0],y:_[2][1]-_[3][1]}}),v=[l[0],wy(l[0],l[1],1/p),wy(c[3],c[2],1/(1-p)),c[3]];if(N_t(v,l,c,p)<=Math.min(d,u*1e-7))return m(v);let b=null,y=1/0;for(const _ of[p,...Array.from({length:31},(w,E)=>(E+1)/32)]){const w=wse(l,c,_),E=N_t(w,l,c,_);E<y&&(b=w,y=E)}return b&&y<=d?m(b):null}const Hu=1e-6;function Fz(t,e,r,i){const s={x:e[0]-t[0],y:e[1]-t[1]},o={x:r[0]-i[0],y:r[1]-i[1]},n={};return(Math.abs(s.x)>Hu||Math.abs(s.y)>Hu)&&(n.tangentStart=s),(Math.abs(o.x)>Hu||Math.abs(o.y)>Hu)&&(n.tangentEnd=o),n}function k_t(t,e,r){return{c1:[t[0]+2/3*(e[0]-t[0]),t[1]+2/3*(e[1]-t[1])],c2:[r[0]+2/3*(e[0]-r[0]),r[1]+2/3*(e[1]-r[1])]}}function Ase(t,e){return Math.abs(t[0]-e[0])<Hu&&Math.abs(t[1]-e[1])<Hu}function xse(t,e="nonzero"){const r=[],i=[],s=[];if(!t)return{vertices:r,segments:i};const o=ep(t);let n=[0,0],a=-1,l=[0,0],c=-1,h=[],u=null,d=null;const f=v=>(r.push({x:v[0],y:v[1]}),r.length-1),g=(v,b,y)=>{i.push(Object.assign({start:v,end:b},y??{})),h.push(i.length-1)},p=v=>{v&&h.length>0&&s.push([...h]),h=[]};for(const v of o){const b=v[0],y=v.slice(1);switch(b){case"M":{p(!1),n=[y[0],y[1]],a=f(n),l=n,c=a,u=null,d=null;for(let _=2;_<y.length;_+=2){const w=[y[_],y[_+1]],E=f(w);g(a,E),n=w,a=E}break}case"L":{for(let _=0;_<y.length;_+=2){const w=[y[_],y[_+1]],E=f(w);g(a,E),n=w,a=E}u=null,d=null;break}case"H":{for(let _=0;_<y.length;_++){const w=[y[_],n[1]],E=f(w);g(a,E),n=w,a=E}u=null,d=null;break}case"V":{for(let _=0;_<y.length;_++){const w=[n[0],y[_]],E=f(w);g(a,E),n=w,a=E}u=null,d=null;break}case"C":{for(let _=0;_<y.length;_+=6){const w=[y[_],y[_+1]],E=[y[_+2],y[_+3]],A=[y[_+4],y[_+5]],x=f(A);g(a,x,Fz(n,w,E,A)),n=A,a=x,u=E}d=null;break}case"S":{for(let _=0;_<y.length;_+=4){const w=u?[2*n[0]-u[0],2*n[1]-u[1]]:[n[0],n[1]],E=[y[_],y[_+1]],A=[y[_+2],y[_+3]],x=f(A);g(a,x,Fz(n,w,E,A)),n=A,a=x,u=E}d=null;break}case"Q":{for(let _=0;_<y.length;_+=4){const w=[y[_],y[_+1]],E=[y[_+2],y[_+3]],{c1:A,c2:x}=k_t(n,w,E),S=f(E);g(a,S,Fz(n,A,x,E)),n=E,a=S,d=w}u=null;break}case"T":{for(let _=0;_<y.length;_+=2){const w=d?[2*n[0]-d[0],2*n[1]-d[1]]:[n[0],n[1]],E=[y[_],y[_+1]],{c1:A,c2:x}=k_t(n,w,E),S=f(E);g(a,S,Fz(n,A,x,E)),n=E,a=S,d=w}u=null;break}case"Z":case"z":{if(a!==c&&c>=0)if(Ase(n,l)){const _=i[i.length-1];_&&_.end===a?(_.end=c,a===r.length-1&&r.pop(),a=c):g(a,c)}else g(a,c);n=l,a=c,u=null,d=null,p(!0);break}}}p(!1);const m={vertices:r,segments:i};return s.length>0&&(m.regions=[{fillRule:e,loops:s}]),m}function Nz(t){const e=t.tangentStart,r=t.tangentEnd;return(!e||Math.abs(e.x)<Hu&&Math.abs(e.y)<Hu)&&(!r||Math.abs(r.x)<Hu&&Math.abs(r.y)<Hu)}_G=function(t,e,r){var i,s,o,n,a,l,c,h;const u=t[e.start],d=t[e.end];if(!u||!d)return null;if(Nz(e))return[u.x+(d.x-u.x)*r,u.y+(d.y-u.y)*r];const f=Be(u.x,u.y),g=Be(d.x,d.y),p=it(),m=it();Aa(p,f,Be((s=(i=e.tangentStart)===null||i===void 0?void 0:i.x)!==null&&s!==void 0?s:0,(n=(o=e.tangentStart)===null||o===void 0?void 0:o.y)!==null&&n!==void 0?n:0)),Aa(m,g,Be((l=(a=e.tangentEnd)===null||a===void 0?void 0:a.x)!==null&&l!==void 0?l:0,(h=(c=e.tangentEnd)===null||c===void 0?void 0:c.y)!==null&&h!==void 0?h:0));const v=new Rq(Ta(f),Ta(p),Ta(m),Ta(g)).getPoint(r);return[v[0],v[1]]};function L_t(t,e,r=.5){var i,s,o,n,a,l,c,h;const{vertices:u,segments:d}=t,f=d[e];if(!f||!u[f.start]||!u[f.end]||!Number.isFinite(r))return-1;const g=d.slice(),p=Math.min(1-Hu,Math.max(Hu,r));let m,v,b;if(Nz(f)){const w=u[f.start],E=u[f.end];m={x:w.x+(E.x-w.x)*p,y:w.y+(E.y-w.y)*p},v={start:f.start,end:-1},b={start:-1,end:f.end}}else{const w=u[f.start],E=u[f.end],A=[w.x,w.y],x=[E.x,E.y],S=[A[0]+((s=(i=f.tangentStart)===null||i===void 0?void 0:i.x)!==null&&s!==void 0?s:0),A[1]+((n=(o=f.tangentStart)===null||o===void 0?void 0:o.y)!==null&&n!==void 0?n:0)],T=[x[0]+((l=(a=f.tangentEnd)===null||a===void 0?void 0:a.x)!==null&&l!==void 0?l:0),x[1]+((h=(c=f.tangentEnd)===null||c===void 0?void 0:c.y)!==null&&h!==void 0?h:0)],R=(N,G)=>[N[0]+(G[0]-N[0])*p,N[1]+(G[1]-N[1])*p],B=R(A,S),O=R(S,T),C=R(T,x),F=R(B,O),U=R(O,C),H=R(F,U);
10294m={x:H[0],y:H[1]},v={start:f.start,end:-1,tangentStart:{x:B[0]-A[0],y:B[1]-A[1]},tangentEnd:{x:F[0]-H[0],y:F[1]-H[1]}},b={start:-1,end:f.end,tangentStart:{x:U[0]-H[0],y:U[1]-H[1]},tangentEnd:{x:C[0]-x[0],y:C[1]-x[1]}}}const y=u.length;u.push(m),v.end=y,b.start=y,d[e]=v;const _=d.length;return d.push(b),t.regions&&(t.regions=hU(t.regions,g,d,w=>w===e?[e,_]:[w])),y}function hU(t,e,r,i,s){return t.flatMap(o=>{const n=[];for(const a of o.loops){const l=gy(e,a);if(!l)return[];let c=[];for(const h of l){const u=i(h.segmentIndex);if(!u)return[];c.push(...h.reversed?[...u].reverse():u)}if(c=s?s(c):c,!gy(r,c))return[];n.push(c)}return n.length?[Object.assign(Object.assign({},o),{loops:n})]:[]})}function kz(t){return t.map(e=>Object.assign(Object.assign({},e),{tangentStart:e.tangentStart?Object.assign({},e.tangentStart):void 0,tangentEnd:e.tangentEnd?Object.assign({},e.tangentEnd):void 0}))}function Sse(t,e,r={}){const{vertices:i,segments:s}=t;if(!Number.isInteger(e)||!i[e])return t;const o=s.flatMap((f,g)=>f.start===e||f.end===e?[g]:[]);let n=null;if(r.heal!==!1&&o.length===2&&o.every(f=>s[f].start!==s[f].end)){if(n=Ese(i,s[o[0]],s[o[1]],e,r.maxError),!n)return t;n.start===n.end&&Nz(n)&&(n=null)}const a=f=>f>e?f-1:f,l=new Map,c=new Set(o),h=kz(s).filter((f,g)=>c.has(g)?!1:(l.set(g,l.size),!0)),u=h.length;n&&h.push(n);for(const f of h)f.start=a(f.start),f.end=a(f.end);const d=t.regions&&hU(t.regions,s,h,f=>c.has(f)?n?[u]:null:[l.get(f)],f=>{const g=f.filter((p,m)=>p!==u||m===0||f[m-1]!==p);return g.length>1&&g[0]===u&&g[g.length-1]===u&&g.pop(),g});return Object.assign({vertices:i.filter((f,g)=>g!==e).map(f=>Object.assign({},f)),segments:h},d!==void 0?{regions:d}:{})}function Tse(t,e){const{vertices:r,segments:i}=t;if(!Number.isInteger(e)||!r[e])return null;const s=[];if(i.forEach((n,a)=>{n.start===e&&s.push({index:a,end:"start"}),n.end===e&&s.push({index:a,end:"end"})}),s.length<2)return null;const o=kz(i);for(const n of s.slice(1))o[n.index][n.end]=r.length;return Object.assign({vertices:[...r.map(n=>Object.assign({},n)),Object.assign({},r[e])],segments:o},t.regions?{regions:hU(t.regions,i,o,n=>[n])}:{})}function Rse(t){var e,r;const i=(e=t.tangentStart)!==null&&e!==void 0?e:{x:0,y:0},s=(r=t.tangentEnd)!==null&&r!==void 0?r:{x:0,y:0},o=[t.start,t.end,i.x,i.y,s.x,s.y].join(":"),n=[t.end,t.start,s.x,s.y,i.x,i.y].join(":");return o<n?o:n}function Cse(t,e){const r=[];for(const i of t)r[r.length-1]===i&&e[i].start!==e[i].end?r.pop():r.push(i);for(;r.length>1&&r[0]===r[r.length-1]&&e[r[0]].start!==e[r[0]].end;)r.shift(),r.pop();return r}qV=function(t,e){return!Number.isInteger(e)||!t.vertices[e]?[]:t.segments.flatMap((r,i)=>{const s=[];return r.start===e&&s.push({segmentIndex:i,end:"start"}),r.end===e&&s.push({segmentIndex:i,end:"end"}),s})},Ztt=function(t,e,r){if(!Number.isInteger(e)||!t.vertices[e])return{ok:!1,reason:"invalid-vertex"};const i=qV(t,e),s=h=>`${h.segmentIndex}:${h.end}`,o=new Set(i.map(s)),n=new Set(r.map(s));if(!n.size||n.size>=i.length||n.size!==r.length||[...n].some(h=>!o.has(h)))return{ok:!1,reason:"invalid-endpoints"};const a=t.vertices.length,l=t.vertices.map((h,u)=>Object.assign(Object.assign({},h),u===e?{handleMirroring:"NONE"}:{}));l.push(Object.assign({},l[e]));const c=kz(t.segments);for(const h of r)c[h.segmentIndex][h.end]=a;return{ok:!0,network:Object.assign({vertices:l,segments:c},t.regions!==void 0?{regions:hU(t.regions,t.segments,c,h=>[h])}:{}),vertexMap:t.vertices.map((h,u)=>u===e?[u,a]:[u]),segmentMap:t.segments.map((h,u)=>[u]),selectedVertex:a}},WV=function(t,e,r){const{vertices:i,segments:s}=t;if(!Number.isInteger(e)||!Number.isInteger(r)||!i[e]||!i[r])return{ok:!1,reason:"invalid-vertex"};if(e===r)return{ok:!1,reason:"same-vertex"};const o=c=>{const h=c===e?r:c;return h>e?h-1:h},n=[],a=new Map,l=new Map;return kz(s).forEach((c,h)=>{if(c.start=o(c.start),c.end=o(c.end),c.start===c.end&&Nz(c)){a.set(h,[]);return}const u=Rse(c),d=l.get(u);if(d!==void 0){a.set(h,[d]);return}a.set(h,[n.length]),l.set(u,n.length),n.push(c)}),{ok:!0,network:Object.assign({vertices:i.filter((c,h)=>h!==e).map(c=>Object.assign({},c)),segments:n}
10294,t.regions?{regions:hU(t.regions,s,n,c=>a.get(c),c=>Cse(c,n))}:{}),vertexMap:i.map((c,h)=>[o(h)]),segmentMap:s.map((c,h)=>a.get(h)),selectedVertex:o(r)}};function Mse(t,e,r){const i=WV(t,e,r);return i.ok?i.network:null}function Bse(t,e){if(!t.length)return{minX:0,minY:0,maxX:0,maxY:0};let r=Math.min(...t.map(({x:n})=>n)),i=Math.max(...t.map(({x:n})=>n)),s=Math.min(...t.map(({y:n})=>n)),o=Math.max(...t.map(({y:n})=>n));return e.length?J0t(t,e,r,s,i,o):{minX:r,minY:s,maxX:i,maxY:o}}function U_t(t,e){if(!e)return;const r=Qt(it(),[e.x,e.y],t);if(!(Math.abs(r[0])<Hu&&Math.abs(r[1])<Hu))return{x:r[0],y:r[1]}}function Ose(t,e){const r=t.vertices.map(a=>{const l=Qt(it(),[a.x,a.y],e);return Object.assign(Object.assign({},a),{x:l[0],y:l[1]})}),i=t.segments.map(a=>Object.assign(Object.assign({},a),{tangentStart:U_t(e,a.tangentStart),tangentEnd:U_t(e,a.tangentEnd)})),{minX:s,minY:o}=Bse(r,i),n={vertices:r.map(a=>Object.assign(Object.assign({},a),{x:a.x-s,y:a.y-o})),segments:i.map(a=>Object.assign({},a))};return t.regions&&(n.regions=t.regions.map(a=>({fillRule:a.fillRule,loops:a.loops.map(l=>[...l])}))),n}function G_t(t,e,r){return Math.min(r,Math.max(e,t))}function Ise(t,e,r,i,s){const o=Math.cos(s),n=Math.sin(s),a=t-r,l=e-i;return{x:r+a*o-l*n,y:i+a*n+l*o}}function uU(t,e,r){var i;ou(t);const{x:s,y:o,width:n,height:a}=t,l=(i=t.rotation)!==null&&i!==void 0?i:0,c=l===0?{x:e,y:r}:Ise(e,r,s,o,-l),h=n>0?G_t((c.x-s)/n,0,1):.5,u=a>0?G_t((c.y-o)/a,0,1):.5;return{x:h,y:u,perimeter:!0,dx:0,dy:0}}const W_t=1e-6;function LJ(t,e){var r,i,s,o;const n=e.type;if(n!=="polyline"&&n!=="rough-polyline"&&n!=="path"&&n!=="rough-path"&&n!=="line"&&n!=="rough-line")return;const a=t.getEntity(e);if(!a)return;let l,c,h,u;if(a.has(_t)){const A=_t.getGeometryBounds({points:a.read(_t).points});l=A.minX,c=A.minY,h=A.maxX,u=A.maxY}else if(a.has(xt)){const A=a.has(wo)?a.read(wo):void 0,x=xt.getGeometryBounds(a.read(xt),A);l=x.minX,c=x.minY,h=x.maxX,u=x.maxY}else if(a.has(Mt)){const{x1:A,y1:x,x2:S,y2:T}=a.read(Mt),R=Mt.getGeometryBounds({x1:A,y1:x,x2:S,y2:T});l=R.minX,c=R.minY,h=R.maxX,u=R.maxY}else return;if(Math.abs(l)<W_t&&Math.abs(c)<W_t||!Number.isFinite(l+c+h+u))return;const d=t.getTransform(a),f=Qt(it(),[0,0],d),g=Qt(it(),[l,c],d),p=g[0]-f[0],m=g[1]-f[1],v=(r=t.getNodeById(e.id))!==null&&r!==void 0?r:e,b=((i=v.x)!==null&&i!==void 0?i:0)+p,y=((s=v.y)!==null&&s!==void 0?s:0)+m,_=h-l,w=u-c;if(a.has(_t)){const A=nc(v.points).map(x=>[x[0]-l,x[1]-c]);t.updateNode(v,{x:b,y,width:_,height:w,points:ip(A)})}else if(a.has(xt)){const A=xy(v.d,-l,-c);t.updateNode(v,{x:b,y,width:_,height:w,d:A})}else if(a.has(Mt)){const{x1:A,y1:x,x2:S,y2:T}=a.read(Mt);t.updateNode(v,{x:b,y,width:_,height:w,x1:A-l,y1:x-c,x2:S-l,y2:T-c})}const E=t.getEntity((o=t.getNodeById(e.id))!==null&&o!==void 0?o:v);if(E){Sr(E),_h(E),Iw(E);let A=E;for(;A!=null&&A.has(be);){const x=A.read(be).parent;if(!(x!=null&&x.has(Js)))break;Iw(x),A=x}}}const Dw=(t,e,r)=>[t[0]+(e[0]-t[0])*r,t[1]+(e[1]-t[1])*r];lm=function(t,e){var r,i,s,o,n,a,l,c;const h=t[e.start],u=t[e.end];if(!h||!u)return null;const d=[h.x,h.y],f=[u.x,u.y],g=[e.tangentStart,e.tangentEnd].some(p=>p&&Math.hypot(p.x,p.y)>=1e-6)?[d,[h.x+((i=(r=e.tangentStart)===null||r===void 0?void 0:r.x)!==null&&i!==void 0?i:0),h.y+((o=(s=e.tangentStart)===null||s===void 0?void 0:s.y)!==null&&o!==void 0?o:0)],[u.x+((a=(n=e.tangentEnd)===null||n===void 0?void 0:n.x)!==null&&a!==void 0?a:0),u.y+((c=(l=e.tangentEnd)===null||l===void 0?void 0:l.y)!==null&&c!==void 0?c:0)],f]:[d,Dw(d,f,1/3),Dw(d,f,2/3),f];return g.flat().every(Number.isFinite)?g:null};function j_t(t,e){const r=Dw(t[0],t[1],e),i=Dw(t[1],t[2],e),s=Dw(t[2],t[3],e),o=Dw(r,i,e),n=Dw(i,s,e),a=Dw(o,n,e);return[[t[0],r,o,a],[a,n,s,t[3]]]}const FS=(t,e)=>j_t(t,e)[0][3];function Lz(t,e){const r=1-e;return[0,1].map(i=>3*(r*r*(t[1][i]-t[0][i])+2*r*e*(t[2][i]-t[1][i])+e*e*(t[3][i]-t[2][i])))}function Dse(t,e){const r=n=>{const a=FS(t,n);return Math.pow(a[0]-e[0],2)+Math.pow(a[1]-e[1],2)};let i=0;for(let n=1;n<=64;n++)r(n/64)<r(i)&&(i=n/64);let s=Math.max(0,i-1/64),o=Math.min(1,i+1/64);for(let n=0;n<32;n++){const a=s+(o-s)/3,l=o-(o-s)/3;r(a)<r(l)?o=l:s=a}return(s+o)/2}function Pse(t,e,r,i){const s=t.segments[e],o=s&&lm(t.vertices,s);if(!o||r<=1e-4||r>=1-1e-4||![r,...i].every(Number.isFinite)||Math.hypot(...i)<1e-9)return t;const n=3*Math.pow(1-r,2)*r,a=3*(1-r)*r*r,l=n*n+a*a,c=t.segments.map(u=>Object.assign({},u));c[e]=Object.assign(Object.assign({},s),{tangentStart:{x:o[1][0]-o[0][0]+i[0]*n/l,y:o[1][1]-o[0][1]+i[1]*n/l}
10294,tangentEnd:{x:o[2][0]-o[3][0]+i[0]*a/l,y:o[2][1]-o[3][1]+i[1]*a/l}});const h=t.vertices.map((u,d)=>d===s.start||d===s.end?Object.assign(Object.assign({},u),{handleMirroring:"NONE"}):Object.assign({},u));return Object.assign(Object.assign({},t),{vertices:h,segments:c})}const dv=(t,e)=>t[0]*e[1]-t[1]*e[0],Pw=(t,e)=>[t[0]-e[0],t[1]-e[1]],Fw=(t,e)=>Math.hypot(...Pw(t,e));function UJ(t,e=0,r=1,i=0,s=[]){const o=Fw(t[0],t[3]),n=Fw(t[0],t[1])+Fw(t[1],t[2])+Fw(t[2],t[3]),a=Pw(t[3],t[0]),l=o?Math.max(Math.abs(dv(Pw(t[1],t[0]),a)),Math.abs(dv(Pw(t[2],t[0]),a)))/o:n;if(i>=18||l<=.01&&n-o<=.01)s.push({a:t[0],b:t[3],lo:e,hi:r});else{const[c,h]=j_t(t,.5),u=(e+r)/2;UJ(c,e,u,i+1,s),UJ(h,u,r,i+1,s)}return s}function Fse(t,e){for(const l of[0,1])if(Math.max(t.a[l],t.b[l])+1e-8<Math.min(e.a[l],e.b[l])||Math.max(e.a[l],e.b[l])+1e-8<Math.min(t.a[l],t.b[l]))return null;const r=Pw(t.b,t.a),i=Pw(e.b,e.a),s=Pw(e.a,t.a),o=dv(r,i);if(Math.abs(o)<=1e-12*Math.hypot(...r)*Math.hypot(...i))return null;const n=dv(s,i)/o,a=dv(s,r)/o;return n>=-1e-8&&n<=1+1e-8&&a>=-1e-8&&a<=1+1e-8?[t.lo+n*(t.hi-t.lo),e.lo+a*(e.hi-e.lo)]:null}function Nse(t,e,r,i){for(let s=0;s<16;s++){const o=Pw(FS(t,r),FS(e,i));if(Math.hypot(...o)<1e-9)break;const n=Lz(t,r),a=Lz(e,i),l=dv(n,a);if(Math.abs(l)<1e-14)break;if(r-=dv(o,a)/l,i-=dv(o,n)/l,r<-1e-6||r>1+1e-6||i<-1e-6||i>1+1e-6)return null}return Fw(FS(t,r),FS(e,i))>1e-6?null:[Math.max(0,Math.min(1,r)),Math.max(0,Math.min(1,i))]}function Uz(t,e){var r,i;const s=t.segments.map(u=>lm(t.vertices,u)),o=s.map(u=>u&&[Math.min(...u.map(d=>d[0])),Math.min(...u.map(d=>d[1])),Math.max(...u.map(d=>d[0])),Math.max(...u.map(d=>d[1]))]),n=s.map(u=>u?UJ(u):[]),a=[],l=u=>u>1e-6&&u<1-1e-6;for(let u=0;u<s.length;u++)for(let d=u;d<s.length;d++){const f=s[u],g=s[d];if(!f||!g||e&&!e.has(u)&&!e.has(d))continue;const p=o[u],m=o[d];if(!(p[2]<m[0]-1e-8||m[2]<p[0]-1e-8||p[3]<m[1]-1e-8||m[3]<p[1]-1e-8)&&!(u!==d&&(f.every((v,b)=>Fw(v,g[b])<1e-8)||f.every((v,b)=>Fw(v,g[3-b])<1e-8))))for(let v=0;v<n[u].length;v++)for(let b=u===d?v+2:0;b<n[d].length;b++){const y=Fse(n[u][v],n[d][b]),_=y&&Nse(f,g,...y);if(!_)continue;const[w,E]=_;if(!l(w)&&!l(E)||u===d&&Math.abs(w-E)<1e-5)continue;const A=Lz(f,w),x=Lz(g,E);if(Math.abs(dv(A,x))<=1e-7*Math.hypot(...A)*Math.hypot(...x))continue;const S=FS(f,w);let T=a.find(R=>Fw(R.point,S)<=1e-6);T||a.push(T={point:S,hits:[]});for(const R of[{edge:u,t:w},{edge:d,t:E}])T.hits.some(B=>B.edge===R.edge&&Math.abs(B.t-R.t)<1e-6)||T.hits.push(R)}}if(!a.length)return t;const c={vertices:t.vertices.map(u=>Object.assign({},u)),segments:t.segments.map(u=>Object.assign({},u)),regions:(r=t.regions)===null||r===void 0?void 0:r.map(u=>Object.assign(Object.assign({},u),{loops:u.loops.map(d=>[...d])}))},h=new Map;for(const u of a){const d=u.hits.find(g=>!l(g.t)),f=d?t.segments[d.edge][d.t<.5?"start":"end"]:c.vertices.length;d||c.vertices.push({x:u.point[0],y:u.point[1]});for(const g of u.hits)if(l(g.t)){const p=(i=h.get(g.edge))!==null&&i!==void 0?i:[];p.push({t:g.t,vertex:f}),h.set(g.edge,p)}}for(const[u,d]of h){let f=1;for(const g of d.sort((p,m)=>m.t-p.t)){const p=L_t(c,u,g.t/f);if(!(p<0)){for(const m of[c.segments[u],c.segments[c.segments.length-1]])m.start===p&&(m.start=g.vertex),m.end===p&&(m.end=g.vertex);c.vertices.pop(),f=g.t}}}return c}const CB=t=>t.end==="start"?"tangentStart":"tangentEnd";bG=function(t,e){return t.segments.flatMap((r,i)=>[...r.start===e?[{segmentIndex:i,end:"start"}]:[],...r.end===e?[{segmentIndex:i,end:"end"}]:[]])};function GJ(t,e,r,i=!1){var s,o,n;const a=t.segments[e.segmentIndex],l=a==null?void 0:a[e.end],c=t.vertices[l];if(!c||!Number.isFinite(r.x)||!Number.isFinite(r.y))return t;const h=t.vertices.map(g=>Object.assign({},g)),u=t.segments.map(g=>Object.assign({},g));u[e.segmentIndex][CB(e)]=Object.assign({},r),i&&(h[l].handleMirroring="NONE");const d=i?"NONE":(s=c.handleMirroring)!==null&&s!==void 0?s:"NONE",f=bG(t,l);if(f.length===2&&d!=="NONE"){const g=f.find(b=>b.segmentIndex!==e.segmentIndex||b.end!==e.end),p=Math.hypot(r.x,r.y),m=t.segments[g.segmentIndex][CB(g)],v=Math.hypot((o=m==null?void 0:m.x)!==null&&o!==void 0?o:0,(n=m==null?void 0:m.y)!==null&&n!==void 0?n:0);d==="ANGLE_AND_LENGTH"?u[g.segmentIndex][CB(g)]={x:-r.x,y:-r.y}:p>1e-9&&(u[g.segmentIndex][CB(g)]={x:-r.x*v/p,y:-r.y*v/p})}return{vertices:h,segments:u,regions:t.regions}}Qtt=function(t,e,r){if(!t.vertices[e]||!["NONE","ANGLE","ANGLE_AND_LENGTH"].includes(r))return t;const i=bG(t,e);if(i.length!==2&&r!=="NONE")return t;const s=t.vertices.map((a,l)=>l===e?Object.assign(Object.assign({},a),{handleMirroring:r}):Object.assign({},a)),o=Object.assign(Object.assign({},t),{vertices:s}),n=i.find(a=>{const l=t.segments[a.segmentIndex][CB(a)];return l&&Math.hypot(l.x,l.y)>1e-9});return r==="NONE"||!n?o:GJ(o,n,t.segments[n.segmentIndex][CB(n)])};const Nw=1e-9;function X_t(t,e,r){var i,s,o,n,a;const l=t[r?e.end:e.start],c=t[r?e.start:e.end],h=r?e.tangentEnd:e.tangentStart,u=r?e.tangentStart:e.tangentEnd,d=[[(i=h==null?void 0:h.x)!==null&&i!==void 0?i:0,(s=h==null?void 0:h.y)!==null&&s!==void 0?s:0],[c.x+((o=u==null?void 0:u.x)!==null&&o!==void 0?o:0)-l.x,c.y+((n=u==null?void 0:u.y)!==null&&n!==void 0?n:0)-l.y],[c.x-l.x,c.y-l.y]],f=(a=d.find(([_,w])=>Math.hypot(_,w)>Nw))!==null&&a!==void 0?a:[0,0],g=Math.atan2(f[1],f[0]),p=1e-4,m=[3*Math.pow(1-p,2)*p,3*(1-p)*p*p,Math.pow(p,3)],v=d.reduce((_,w,E)=>_+w[0]*m[E],0),b=d.reduce((_,w,E)=>_+w[1]*m[E],0),y=Math.atan2(f[0]*b-f[1]*v,f[0]*v+f[1]*b);return{angle:g,bend:y}}function z_t(t,e){let r=!1;const[i,s]=t;for(let o=0,n=e.length-1;o<e.length;n=o++){const a=e[o][0],l=e[o][1],c=e[n][0],h=e[n][1];l>s!=h>s&&i<(c-a)*(s-l)/(h-l)+a&&(r=!r)}return r}function kse(t){let e=0;for(let r=0,i=t.length-1;r<t.length;i=r++)e+=(t[i][0]+t[r][0])*(t[i][1]-t[r][1]);return e/2}function Lse(t,e){const r=[],i=Array.from({length:t.length},()=>[]);e.forEach((c,h)=>{if(!t[c.start]||!t[c.end])return;const u=r.length;r.push(Object.assign({segmentIndex:h,from:c.start,to:c.end,reversed:!1,twin:u+1},X_t(t,c,!1)),Object.assign({segmentIndex:h,from:c.end,to:c.start,reversed:!0,twin:u},X_t(t,c,!0))),i[c.start].push(u),i[c.end].push(u+1)});for(const c of i)c.sort((h,u)=>{const d=r[h].angle-r[u].angle;return Math.abs(d)>Nw?d:r[h].bend-r[u].bend||h-u});const s=new Array(r.length);for(const c of i)c.forEach((h,u)=>
10294{s[h]=u});const o=c=>{const h=r[c],u=i[h.to],d=s[h.twin];return u[(d-1+u.length)%u.length]},n=new Array(t.length).fill(-1);for(let c=0;c<t.length;c++){if(n[c]!==-1)continue;n[c]=c;const h=[c];for(;h.length;){const u=h.pop();for(const d of i[u]){const f=r[d].to;n[f]===-1&&(n[f]=c,h.push(f))}}}const a=new Array(r.length).fill(!1),l=[];for(let c=0;c<r.length;c++){if(a[c])continue;const h=[];let u=c,d=0,f=!0;do{if(u<0||a[u]){f=!1;break}if(a[u]=!0,h.push(u),u=o(u),++d>r.length+1){f=!1;break}}while(u!==c);if(!f||h.length===0)continue;const g=h.map(v=>r[v].segmentIndex),p=evt(t,e,h.map(v=>r[v]));if(p.length<3)continue;const m=kse(p);Math.abs(m)>Nw&&l.push({loop:g,polygon:p,area:m,component:n[r[c].from]})}return l}function MB(t,e){const r=Lse(t,e),i=r.filter(o=>o.area<0),s=i.map(o=>({region:{fillRule:"evenodd",loops:[o.loop]},contours:[o.polygon],area:-o.area}));for(const o of r.filter(n=>n.area>0)){let n=-1,a=1/0;i.forEach((l,c)=>{l.component!==o.component&&-l.area<a&&z_t(o.polygon[0],l.polygon)&&(n=c,a=-l.area)}),n!==-1&&(s[n].region.loops.push(o.loop),s[n].contours.push(o.polygon),s[n].area-=o.area)}return s}function Use(t,e){const[r,i]=t;return e.some((s,o)=>{const n=e[(o+1)%e.length],a=n[0]-s[0],l=n[1]-s[1],c=Math.hypot(a,l);return Math.abs(a*(i-s[1])-l*(r-s[0]))<=Nw*Math.max(c,1)&&r>=Math.min(s[0],n[0])-Nw&&r<=Math.max(s[0],n[0])+Nw&&i>=Math.min(s[1],n[1])-Nw&&i<=Math.max(s[1],n[1])+Nw})}function V_t(t,e){let r=null;for(const i of t)i.contours.some(s=>Use(e,s))||i.contours.reduce((s,o)=>s!==z_t(e,o),!1)&&(!r||i.area<r.area)&&(r=i);return r}function Gse(t,e){let r=0;for(let i=0;i<e.length;i++){const s=e[i],o=e[(i+1)%e.length],n=(o[0]-s[0])*(t[1]-s[1])-(t[0]-s[0])*(o[1]-s[1]);s[1]<=t[1]&&o[1]>t[1]&&n>0&&r++,s[1]>t[1]&&o[1]<=t[1]&&n<0&&r--}return r}function Gz(t,e,r,i){const s=(r??[]).flatMap(o=>{var n;const a=o.loops.map(l=>rvt(t,e,l));return!a.length||a.some(l=>l.length<3)?[]:[{contours:a,evenodd:o.fillRule?o.fillRule==="evenodd":((n=o.windingRule)===null||n===void 0?void 0:n.toLowerCase())==="evenodd"}]});return i.map(o=>{const n=kq(o.contours,"evenodd");if(n.length<6)return null;const a=[(n[0]+n[2]+n[4])/3,(n[1]+n[3]+n[5])/3];return s.some(({contours:l,evenodd:c})=>{const h=l.reduce((u,d)=>u+Gse(a,d),0);return c?Math.abs(h)%2===1:h!==0})})}function Wse(t,e,r,i,s){const o=Gz(t,e,r,i);return i.flatMap((n,a)=>o[a]!==null&&o[a]!==(n===s)?[{fillRule:"evenodd",loops:n.region.loops.map(l=>[...l])}]:[])}const Y_t=1e-6;function sl(t){return t.toFixed(4).replace(/\.?0+$/,"")}function jse(t,e){const r=Array.from({length:e},()=>[]);for(let i=0;i<t.length;i++){const s=t[i];s.start<0||s.end<0||s.start>=e||s.end>=e||(r[s.start].push({seg:i,other:s.end}),r[s.end].push({seg:i,other:s.start}))}return r}function $_t(t,e,r){const i=e[t];if(!i)return null;let s=null;for(const o of i)if(!r[o.seg]){if(s)return null;s=o}return s}function H_t(t,e,r,i,s){var o,n,a,l;const c=t[r],h=t[i];if(!c||!h)return"";let u,d;if(r===e.start&&i===e.end)u=e.tangentStart,d=e.tangentEnd;else if(r===e.end&&i===e.start)u=e.tangentEnd,d=e.tangentStart;else return"";const f=c.x,g=c.y,p=h.x,m=h.y,v=f+((o=u==null?void 0:u.x)!==null&&o!==void 0?o:0),b=g+((n=u==null?void 0:u.y)!==null&&n!==void 0?n:0),y=p+((a=d==null?void 0:d.x)!==null&&a!==void 0?a:0),_=m+((l=d==null?void 0:d.y)!==null&&l!==void 0?l:0),w=Math.hypot(v-f,b-g)<Y_t&&Math.hypot(y-p,_-m)<Y_t;return s?w?`M ${sl(f)} ${sl(g)} L ${sl(p)} ${sl(m)}`:`M ${sl(f)} ${sl(g)} C ${sl(v)} ${sl(b)} ${sl(y)} ${sl(_)} ${sl(p)} ${sl(m)}`:w?` L ${sl(p)} ${sl(m)}`:` C ${sl(v)} ${sl(b)} ${sl(y)} ${sl(_)} ${sl(p)} ${sl(m)}`}function Xse(t,e){if(!t.length||!e.length)return[];const r=t.length,i=jse(e,r),s=new Array(e.length).fill(!1),o=[];for(let n=0;n<e.length;n++){if(s[n])continue;const a=e[n],l=[{seg:a,from:a.start,to:a.end}];s[n]=!0;let c=a.end;for(;;){const h=$_t(c,i,s);if(!h)break;l.push({seg:e[h.seg],from:c,to:h.other}),s[h.seg]=!0,c=h.other}for(c=a.start;;){const h=$_t(c,i,s);if(!h)break;l.unshift({seg:e[h.seg],from:h.other,to:c}),s[h.seg]=!0,c=h.other}o.push(l)}return o}function zse(t,e){let r="";return t.forEach(({seg:i,from:s,to:o},n)=>{r+=H_t(e,i,s,o,n===0)}),r}function Vse(t,e,r){const i=gy(e,r);if(!i||i.some(({from:o,to:n})=>!t[o]||!t[n]))return"";const s=i.map(({segmentIndex:o,from:n,to:a},l)=>H_t(t,e[o],n,a,l===0)).join("");return s?`${s} Z`:""}function Yse(t){const e=t==null?void 0:t[0];if(!e)return"nonzero";if(e.fillRule)return e.fillRule;const r=e.windingRule;return r==="EVENODD"||r==="evenodd"?"evenodd":"nonzero"}function K_t(t,e,r){if(!(t!=null&&t.length)||!(e!=null&&e.length)||!(r!=null&&r.length))return"";const i=[];for(const s of r){const o=s.loops.map(n=>Vse(t,e,n));o.every(Boolean)&&i.push(...o)}return i.join(" ")}function $se(t,e){return!(t!=null&&t.length)||!(e!=null&&e.length)?"":Xse(t,e).map(r=>
10294zse(r,t)).filter(Boolean).join(" ")}const q_t=t=>t==null?void 0:t.some(e=>e.enabled!==!1&&e.opacity!==0&&(e.type!=="solid"||e.value!=="none"));class Hse{constructor(){this.sessions=new WeakMap}clear(e){var r;(r=this.sessions.get(e))===null||r===void 0||r.dispose()}update(e,r,i){var s;const o=e.getAppState(),n=i.length===1?i[0]:void 0;if(o.penbarSelected!==vt.SELECT||o.vectorNetworkEditMode!==So.FILL||r.key==="Escape"||!nr(n)||!n.has(ke)||!n.has(Mi)||!n.read(Mi).isEditing||n.has(tu)||!n.has(Ae))return this.clear(e),!1;const a=e.getNodeByEntity(n);if((a==null?void 0:a.type)!=="vector-network")return this.clear(e),!1;const l=n.read(ke);let c=this.sessions.get(e);if(!c||c.nodeId!==a.id||c.vertices!==l.vertices||c.segments!==l.segments||c.regions!==l.regions){this.clear(e);const v=Uz({vertices:l.vertices,segments:l.segments,regions:l.regions});c={geometry:v,regions:l.regions,nodeId:a.id,vertices:l.vertices,segments:l.segments,faces:MB(v.vertices,v.segments),dispose:()=>{}};const b=c;b.dispose=e.onDestroy(()=>{var y;(y=b.preview)===null||y===void 0||y.remove(),this.sessions.delete(e)}),this.sessions.set(e,c)}const h=ie.toGLMat3(n.read(Ae).matrix),u=_i(Bt(),h),[d,f]=r.pointerViewport,g=e.viewport2Canvas({x:d,y:f}),p=u&&Qt(it(),[g.x,g.y],u),m=r.pointerInside&&p?V_t(c.faces,[p[0],p[1]]):null;if(e.getCanvas().write(_o).value=m?"crosshair":"default",!m&&r.pointerDownTrigger&&r.pointerButton===0&&!e.elementsFromPoint(g).includes(n))return this.clear(e),e.updateNode(a,{isEditing:!1}),!1;if((r.pointerCancelled||!r.pointerInside)&&(c.pending=void 0),r.pointerDownTrigger&&!r.pointerCancelled&&r.pointerButton===0&&m&&(c.pending={face:m,point:[...r.pointerDownViewport]}),c.pending&&Math.hypot(d-c.pending.point[0],f-c.pending.point[1])>4&&(c.pending=void 0),r.pointerUpTrigger){if(m&&((s=c.pending)===null||s===void 0?void 0:s.face)===m){const v=q_t(a.fills),b=Wse(c.geometry.vertices,c.geometry.segments,v?c.geometry.regions:[],c.faces,m),y=o.penbarVectorNetwork.fills,_=v?a.fills:q_t(y)?y:[{type:"solid",value:"#147af3",opacity:1}];e.updateNode(a,Object.assign(Object.assign({},c.geometry),{regions:b,fills:_})),e.record()}c.pending=void 0}return this.preview(e,c,m,h),!0}preview(e,r,i,s){if(!i){r.preview&&(r.preview.style.display="none"),r.previewFace=void 0;return}const o=e.getSvgLayer();if(!o)return;if(!r.preview){const h=we("svg");h.setAttribute("data-vector-network-fill-preview",""),h.setAttribute("aria-hidden","true"),h.style.cssText="position:absolute;inset:0;width:100%;height:100%;pointer-events:none;overflow:hidden";const u=we("path");u.setAttribute("fill","#147af3"),u.setAttribute("fill-opacity","0.24"),u.setAttribute("fill-rule","evenodd"),u.setAttribute("stroke","#147af3"),u.setAttribute("stroke-width","1"),u.setAttribute("vector-effect","non-scaling-stroke"),h.append(u),o.append(h),r.preview=h,r.path=u}r.previewFace!==i&&(r.path.setAttribute("d",K_t(r.vertices,r.segments,[i.region])),r.previewFace=i);const n=(h,u)=>{const d=Qt(it(),[h,u],s);return e.canvas2Viewport({x:d[0],y:d[1]})},a=n(0,0),l=n(1,0),c=n(0,1);r.path.setAttribute("transform",`matrix(${l.x-a.x} ${l.y-a.y} ${c.x-a.x} ${c.y-a.y} ${a.x} ${a.y})`),r.preview.style.display=""}}const Kse='url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAABUFJREFUeAHtVltIXFcUPU6c0VGTWqdqRqtVTFrU+GFimgYpTUibQmm/JDZEKMF3rFjFigjFBi2I9ccPq6CIitEIvlFREYrioxYVK7UqPgk+2mh9j46jM/d07evVTjVpjTMN/eiGzT2ve/Y6+7HOYew/JLIjfQv2EuSMkXGhqqrq84iICG87O7vN/v7+VQnESwHCysrK4paXl3l1dTUnmZqaqiovL38PU3Jpyb8KRlZZWfmwra2No82dnZ0NsbGxfHR0lLAszszM1N69e9fjyD9mBWMbEBDgr9frdTY2NiIISQWA4S0tLYJWqyUwv9TV1cXcv3/fwwiEWYDYQM+vr6/PJCYmHgKQyWTcwsLioG/w9/cXAEYM0fT0dF1FRYW39L+MmSiUjA5JSUkPJicnRYNGho+BoRAhJHxjY4MjcT9iZhJ7KyurCzjcjpeX1zHjxn1ra2vBz8+Pz8/P89LS0ofMTGFQQB3b29sfZ2dnHzUuXL16lefk5FB1iCHY3NycbW5ufow5J6gtM4NQHM/FxMREUcLBsOHg5NeuXSObWwDXER0dnebu7h6M8UDoBagz+9MDJufCWejriO1UYGDgYczp5F1dXa1oU9L5IVRvKZVKV7Tl8fHx9ijf9Nra2gfmAGEJtS8sLMzr6+s7DAPxQUpKSjzaLtBXyHBoaOjZsbGxQvJMXl4en52d5SCzsOfse+IcoYWvent7v2PECQL5HzzxNtp2tCYyMlKNodXBwUGxEi5evMhHRkYoPwaRG492dnZ+wvzPILCSO3fueEp7n9gzSqiaOCEsLIxTtu/u7j7B2Hmau337ti0Zv3fvHlepVAYuiU6nM+Tn5/OgoCBuMBg4VVJubq4Ifnx8/NsXASFyQlxcXKRGoxFLDTHOI8/QJDZ7BHDkEcPe3h6Hp/Stra20TvDx8eGNjY0ioN7eXg7G5Lhf9LQPyjWIvUAoKM5eGRkZ35SUlJShTW5U4fRutDliTSfXwzNbICKdq6urnsbX1taeZGVllQYHB3+N5MwENk1RUZHg4eEhwCvr+Fqf1AuWuJKpvt3YfuKpoXKcIqqpqYm7ubnxpaWlaScnpxB4QQND2vDw8AysCZTL5f74kgZ4enp+QsTm4uIiIDc4wL1/zNBzAJDbVtg+OZHsQekUlxcWFlhmZiYDkL7FxcURlOMHMGqBuQ2Upxa5sEb/Q5VIwo25ublJqC9Kmq2srKglDwj/BIBJm+iN+jIQkOrmzZtiJyEhYRSfX3F6GZSGtNAtCSxVzw5Uh9M7Qxl4gqnVajkzQSyHh4frk5OTeUFBAe/u7i6XDnBGOpVxgonXdHp6+sfIE65QKMRquX79OoVGyU4pVnB9UmdnJ0cycdD1iGT8aGaLfXCFO2xqGhoaDIIg8IGBgR8wrIJas1PK2StXrlzGZrvFxcXiiUA+3z1rIZL1Bt1XUVFR3NHRkdbqfH19P8TUa8wEqibkKroBybi9vb0eScbBek9Rql9Aw9PS0j7b3t4eWF1d5UhQISQkxEAhwCPnK7ZfSSbdmjKpNL2GhoZ+hGvFVxLKkdfU1PCenh6RgFJTU8Xx+vp6YkE9CO1L9N9k++43+bZU4DHyBr4+uKy+P6Bheh0h08ULqaOjg94KHF6YvXTp0qeScQL+zIo7zUtGCRDOcL0tciLg1q1b7+KUNxwcHJQTExO/gZKf4oXdAwZsBi9oUAG/A9A6+2tJmwSAhPKB6Pqc1LaxtLSU6/cJgepfK32XodvMiHjMBYCESlAhAV
10294BIfTK0C9VJXwLE/24TczwmLYy+B8Y4+19OKH8AGG0Nxm0lh+0AAAAASUVORK5CYII=") 0 4, pointer';var qt;(function(t){t.IDLE="IDLE",t.READY_TO_BRUSH="READY_TO_BRUSH",t.BRUSH="BRUSH",t.READY_TO_SELECT="READY_TO_SELECT",t.SELECT="SELECT",t.READY_TO_MOVE="READY_TO_MOVE",t.MOVE="MOVE",t.READY_TO_RESIZE="READY_TO_RESIZE",t.RESIZE="RESIZE",t.READY_TO_ROTATE="READY_TO_ROTATE",t.ROTATE="ROTATE",t.READY_TO_MOVE_PIVOT="READY_TO_MOVE_PIVOT",t.MOVE_PIVOT="MOVE_PIVOT",t.READY_TO_MOVE_CONTROL_POINT="READY_TO_MOVE_CONTROL_POINT",t.MOVE_CONTROL_POINT="MOVE_CONTROL_POINT",t.EDITING="EDITING",t.LASSOING="LASSOING"})(qt||(qt={}));function dU(t,e){return!t||!e?!1:LS(t)?!0:!!e.fromId||!!e.toId||kS(e.sourcePoint)||kS(e.targetPoint)}function qse(t,e,r,i){if(e===void 0||e<0)return null;const s=t.type;if(s==="polyline"||s==="rough-polyline")return i==null||i<2?null:e===0?gt.X1Y1:e===i-1?gt.X2Y2:null;if(s==="path"||s==="rough-path"){if(!(r!=null&&r.length))return null;const o=mmt(r);return o.length<2?null:e===0?gt.X1Y1:e===o.length-1?gt.X2Y2:null}return null}class fU extends We{constructor(){super(),this.commands=new nE(this),this.cameras=this.query(e=>e.current.with(jt).read),this.cameras3D=this.query(e=>e.current.with(Bi).read),this.canvases=this.query(e=>e.current.with(wt).read),this.cameras2DFor3D=this.query(e=>e.current.with(jt,Pe).read),this.meshes3D=this.query(e=>e.current.with(Ns,Ni,ki).read),this.selected3D=this.query(e=>e.current.with(ar,ki).read),this.selections=new Map,this.vectorFillEditor=new Hse,this.query(e=>e.using(wt,jt,so,jc,ai,le,tu,Ce,Fs,Gt,ue,Ji,mh).read.update.and.using(Ae,xa,_o,Ii,ks,Us,_e,ze,be,Zi,Ce,bo,Gt,Js,ko,To,$t,et,ae,Yt,xt,_t,Mt,Wl,cl,hl,ai,he,Ls,Qn,Nt,ke,fe,wo,ro,Tn,Mi,Gc,yi,Sn,uE,tu,qo,ul,Hn,sm,La,je,fh,Kn,Lo,ar).write),this.query(e=>e.using(Pe,Pn,Gs,dl).read),this.query(e=>e.using(Bi,js,Ns,Ni,ki,ar).read)}shouldSuppress2DBrushSelection(e,r,i){if(Jj())return!0;const s=this.probePick3DAt(e,r,i);return s!=null&&s.kind!=="none"}shouldSuppress2DMove(e,r,i){if(Jj())return!0;const s=this.probePick3DAt(e,r,i);return(s==null?void 0:s.kind)==="gizmo"}probePick3DAt(e,r,i){const s=this.canvases.current.length||1,o=IS(this.cameras3D.current,e,s);if(!o)return null;const n=o.read(Bi),{width:a,height:l}=e.read(wt);if(a<=0||l<=0)return null;const c=n.linked?EB(this.cameras2DFor3D.current,e):void 0,h=I_t(n,a,l,a,l,c);return h?kJ(r,i,a,l,n,h,Ow(this.meshes3D.current,e,s),this.selected3D.current.filter(u=>Ow([u],e,s).length>0)):null}getTopmostEntity(e,r,i,s){const{x:o,y:n}=e.viewport2Canvas({x:r,y:i});return e.elementsFromPoint({x:o,y:n}).find(s)}resolveHighlightEntityFromHit(e,r){let i,s=e;for(;s.has(be);){const o=s.read(be).parent;if(o===r||o.has(jt))break;o.has(ze)&&(i=o),s=o}return i??e}handleSelectedMoving(e,r,i,s,o){const{snapToPixelGridSize:n,snapToPixelGridEnabled:a}=e.getAppState(),l=e.getCamera();l.write(Nt).status=Nn.MOVING;const c=this.selections.get(l.__id);if(!c.moveGesture){const{x:b,y}=SU(l);c.moveGesture={pointer:[r,i],bounds:e.getGeometryBounds(e.getAppState().layersSelected.map(_=>e.getNodeById(_))),gridOrigin:[b,y],applied:[0,0]}}const h=c.moveGesture;let u=[s-h.pointer[0],o-h.pointer[1]];if(a){const[b,y]=hne(h.gridOrigin[0]+u[0],h.gridOrigin[1]+u[1],n);u=[b-h.gridOrigin[0],y-h.gridOrigin[1]]}const{snapOffset:d,snapLines:f}=ane(e,u,c.lastSnapOffset,h.bounds),g=[u[0]+d[0],u[1]+d[1]],p=[g[0]-h.applied[0],g[1]-h.applied[1]];h.applied=g,c.lastSnapOffset=d,Zo&&this.renderSnapLines(c,f,e);const{selecteds:m,mask:v}=l.read(Nt);m.forEach(b=>{b.has(Us)&&b.remove(Us);const y=e.getNodeByEntity(b),_=_i(Bt(),e.getParentTransform(b));if(!_)return;const{x:w,y:E}=b.read(_e).translation;e.updateNodeOBB(y,{x:w+_[0]*p[0]+_[3]*p[1],y:E+_[1]*p[0]+_[4]*p[1]}),Sr(b),_h(b)}),Sr(v)}handleSelectedMoved(e,r){const i=e.getCamera();delete r.lastSnapOffset,delete r.moveGesture,e.setNodes(e.getNodes()),e.getAppState().layersCropping.length===0&&e.record();const{selecteds:s}=i.read(Nt);s.forEach(o=>{!N2(o)&&!o.has(Us)&&o.add(Us)}),i.write(Nt).status=Nn.MOVED,this.saveSelectedOBB(e,r)}obbWorldCenter(e){const{x:r,y:i,width:s,height:o,rotation:n,scaleX:a,scaleY:l}=e,c=s/2,h=o/2,u=Math.cos(n),d=Math.sin(n);return[r+c*a*u-h*l*d,i+c*a*d+h*l*u]}alignObbOriginToFixedPivot(e,r,i,s,o,n){const a=Math.cos(n),l=Math.sin(n),{scaleX:c,scaleY:h,width:u,height:d}=e;return{x:s-r*c*a+i*h*l,y:o-r*c*l-i*h*a,width:u,height:d,rotation:n,scaleX:c,scaleY:h}}getRotatePivotWorld(e,r){const i=e.getCamera(),{mask:s,rotatePivotX:o,rotatePivotY:n}=i.read(Nt);if(!Number.isNaN(o)&&!Number.isNaN(n)&&s){const{x:a,y:l}=e.transformer2Canvas({x:o,y:n},s);return[a,l]}return this.obbWorldCenter(r.obb)}getRotatePivotWorldStable(e,r){return r.rotatePivotWorldFixed?r.rotatePivotWorldFixed:this.getRotatePivotWorld(e,r)}handleRotatePivotMoving(e,r,i){const s=e.getCamera(),{mask:o,centerAnchor:n}=s.read(Nt);if(!o)return;const{x:a,y:l}=e.canvas2Transformer({x:r,y:i},o),c=s.write(Nt);c.rotatePivotX=a,c.rotatePivotY=l,c.rotatePivotPinned=!0,n!=null&&n.has(et)&&(Object.assign(n.write(et),{cx:a,cy:l}),Sr(n))}handleSelectedRotating(e,r,i){const s=e.getCamera(),o=this.selections.get(s.__id);if(o.rotateLastPointerAngle===void 0)return;o.rotateAccumulated===void 0&&(o.rotateAccumulated=0),s.write(Nt).status=Nn.ROTATING;const{selecteds:n}=s.read(Nt);
10294n.forEach(m=>{m.has(Us)&&m.remove(Us)});const[a,l]=this.getRotatePivotWorldStable(e,o),c=s.read(Nt),h=o.rotatePivotLocalFixed?o.rotatePivotLocalFixed[0]:Number.isNaN(c.rotatePivotX)?o.obb.width/2:c.rotatePivotX,u=o.rotatePivotLocalFixed?o.rotatePivotLocalFixed[1]:Number.isNaN(c.rotatePivotY)?o.obb.height/2:c.rotatePivotY,d=Math.atan2(i-l,r-a);let f=d-o.rotateLastPointerAngle;f=Math.atan2(Math.sin(f),Math.cos(f)),o.rotateLastPointerAngle=d,o.rotateAccumulated+=f;const g=o.obb.rotation+o.rotateAccumulated,p=this.alignObbOriginToFixedPivot(o.obb,h,u,a,l,g);this.fitSelected(e,p,o)}handleSelectedResizing(e,r,i,s,o,n){var a;const l=e.getCamera(),{resizingAnchorName:c,obb:h,cos:u,sin:d,label:f}=n,{rotation:g,scaleX:p,scaleY:m}=h,{layersSelected:v,flipEnabled:b}=e.getAppState();if(v.length===1&&(s=(a=e.getNodeById(v[0]).lockAspectRatio)!==null&&a!==void 0?a:s),[r,i]=this.snapResizePointer(e,n,r,i,s,o),l.write(Nt).status=Nn.RESIZING,c===gt.X1Y1||c===gt.X2Y2){const y=e.getNodeById(v[0]);if(!y)return;const _=e.getEntity(y);if(!(_!=null&&_.has(Ae)))return;dU(_,y)&&(n.bindingRebindLastCanvas={x:r,y:i},this.applyBindingRebindHover(e,r,i));const w=c===gt.X1Y1,E=_i(Bt(),ie.toGLMat3(_.read(Ae).matrix));if(!E)return;const A=Qt(it(),[r,i],E);if(y.type==="line"||y.type==="rough-line"){if(!_.has(Mt))return;const x=_.read(Mt);let S=x.x1,T=x.y1,R=x.x2,B=x.y2;w?(S=A[0],T=A[1]):(R=A[0],B=A[1]),e.updateNode(y,{x1:S,y1:T,x2:R,y2:B})}else if(_.has(_t)){const{points:x}=_.read(_t),S=x.map(T=>[T[0],T[1]]);w?S[0]=[A[0],A[1]]:S[S.length-1]=[A[0],A[1]],e.updateNode(y,{points:S.map(T=>T.join(",")).join(" ")})}else return;Sr(_),_h(_);{const x=ie.toGLMat3(_.read(Ae).matrix);let S,T;if(y.type==="line"||y.type==="rough-line"){const C=_.read(Mt);S=w?C.x2:C.x1,T=w?C.y2:C.y1}else{const{points:C}=_.read(_t),F=w?C[C.length-1]:C[0];S=F[0],T=F[1]}const R=Qt(it(),[S,T],x),B=r-R[0],O=i-R[1];jz(f,e,{x:R[0],y:R[1],width:B,height:O,rotate:!0})}}else{const{tlAnchor:y,trAnchor:_,blAnchor:w,brAnchor:E,mask:A}=l.read(Nt),x=y.read(et).cx,S=y.read(et).cy,T=E.read(et).cx,R=E.read(et).cy,{x:B,y:O}=e.canvas2Transformer({x:r,y:i},A);let C,F=c;F===gt.TOP_LEFT?C=y:F===gt.TOP_RIGHT?C=_:F===gt.BOTTOM_LEFT?C=w:F===gt.BOTTOM_RIGHT&&(C=E),C&&(b?Object.assign(C.write(et),{cx:B,cy:O}):C===y?Object.assign(C.write(et),{cx:Math.min(B,_.read(et).cx),cy:Math.min(O,w.read(et).cy)}):C===_?Object.assign(C.write(et),{cx:Math.max(B,y.read(et).cx),cy:Math.min(O,w.read(et).cy)}):C===w?Object.assign(C.write(et),{cx:Math.min(B,_.read(et).cx),cy:Math.max(O,y.read(et).cy)}):C===E&&Object.assign(C.write(et),{cx:Math.max(B,y.read(et).cx),cy:Math.max(O,y.read(et).cy)}));let U;if(F===gt.TOP_LEFT){if(b&&!s){const{cx:q,cy:L}=E.read(et);B>q&&O<=L?(F=gt.TOP_RIGHT,n.resizingAnchorName=gt.TOP_RIGHT):B<=q&&O>L?(F=gt.BOTTOM_LEFT,n.resizingAnchorName=gt.BOTTOM_LEFT):B>q&&O>L&&(F=gt.BOTTOM_RIGHT,n.resizingAnchorName=gt.BOTTOM_RIGHT)}if(s){const q=o?{x:h.width/2,y:h.height/2}:{x:E.read(et).cx,y:E.read(et).cy};U=Math.sqrt(Math.pow(q.x-B,2)+Math.pow(q.y-O,2));const{cx:L,cy:J}=y.read(et),tt=L>q.x?-1:1,bt=J>q.y?-1:1;Object.assign(y.write(et),{cx:q.x-U*u*tt,cy:q.y-U*d*bt})}}else if(F===gt.TOP_RIGHT){if(b&&!s){const{cx:q,cy:L}=w.read(et);B<q&&O<=L?(F=gt.TOP_LEFT,n.resizingAnchorName=gt.TOP_LEFT):B>=q&&O>L?(F=gt.BOTTOM_RIGHT,n.resizingAnchorName=gt.BOTTOM_RIGHT):B<q&&O>L&&(F=gt.BOTTOM_LEFT,n.resizingAnchorName=gt.BOTTOM_LEFT)}if(s){const q=o?{x:h.width/2,y:h.height/2}:{x:w.read(et).cx,y:w.read(et).cy};U=Math.sqrt(Math.pow(B-q.x,2)+Math.pow(q.y-O,2));const{cx:L,cy:J}=_.read(et),tt=L<q.x?-1:1,bt=J>q.y?-1:1;Object.assign(_.write(et),{cx:q.x+U*u*tt,cy:q.y-U*d*bt})}y.write(et).cy=_.read(et).cy,E.write(et).cx=_.read(et).cx}else if(F===gt.BOTTOM_LEFT){if(b&&!s){const{cx:q,cy:L}=_.read(et);B<=q&&O<L?(F=gt.TOP_LEFT,n.resizingAnchorName=gt.TOP_LEFT):B>q&&O>=L?(F=gt.BOTTOM_RIGHT,n.resizingAnchorName=gt.BOTTOM_RIGHT):B>q&&O<L&&(F=gt.TOP_RIGHT,n.resizingAnchorName=gt.TOP_RIGHT)}if(s){const q=o?{x:h.width/2,y:h.height/2}:{x:_.read(et).cx,y:_.read(et).cy};U=Math.sqrt(Math.pow(q.x-B,2)+Math.pow(O-q.y,2));const L=q.x<B?-1:1,J=O<q.y?-1:1;Object.assign(w.write(et),{cx:q.x-U*u*L,cy:q.y+U*d*J})}y.write(et).cx=w.read(et).cx,E.write(et).cy=w.read(et).cy}else if(F===gt.BOTTOM_RIGHT){if(b&&!s){const{cx:q,cy:L}=y.read(et);B<q&&O>=L?(F=gt.BOTTOM_LEFT,n.resizingAnchorName=gt.BOTTOM_LEFT):B>=q&&O<L?(F=gt.TOP_RIGHT,n.resizingAnchorName=gt.TOP_RIGHT):B<q&&O<L&&(F=gt.TOP_LEFT,n.resizingAnchorName=gt.TOP_LEFT)}if(s){const q=o?{x:h.width/2,y:h.height/2}:{x:y.read(et).cx,y:y.read(et).cy};U=Math.sqrt(Math.pow(B-q.x,2)+Math.pow(O-q.y,2));const L=E.read(et).cx<q.x?-1:1,J=E.read(et).cy<q.y?-1:1;Object.assign(E.write(et),{cx:q.x+U*u*L,cy:q.y+U*d*J})}}else if(F===gt.TOP_CENTER)if(!b)y.write(et).cy=Math.min(O,E.read(et).cy);else{const q=E.read(et).cy;y.write(et).cy=O,O>q&&(y.write(et).cy=q,E.write(et).cy=O,F=gt.BOTTOM_CENTER,n.resizingAnchorName=gt.BOTTOM_CENTER)}else if(F===gt.BOTTOM_CENTER)if(!b)E.write(et).cy=Math.max(O,y.read(et).cy);else{const q=y.read(et).cy;E.write(et).cy=O,O<q&&(E.write(et).cy=q,y.write(et).cy=O,F=gt.TOP_CENTER,n.resizingAnchorName=gt.TOP_CENTER)}else if(F===gt.MIDDLE_LEFT)if(!b)y.write(et).cx=Math.min(B,E.read(et).cx);else{const q=E.read(et).cx;y.write(et).cx=B,B>q&&(y.write(et).cx=q,E.write(et).cx=B,F=gt.MIDDLE_RIGHT,n.resizingAnchorName=gt.MIDDLE_RIGHT)}else if(F===gt.MIDDLE_RIGHT)if(!b)E.write(et).cx=Math.max(B,y.read(et).cx);else{const q=y.read(et).cx;E.write(et).cx=B,B<q&&(E.write(et).cx=q,y.write(et).cx=B,F=gt.MIDDLE_LEFT,n.resizingAnchorName=gt.MIDDLE_LEFT)}if(s){if(F===gt.MIDDLE_LEFT||F===gt.MIDDLE_RIGHT){const q=E.read(et).cx-y.read(et).cx,L=d/u,J=q*L-(R-S);E.write(et).cy=E.read(et).cy+J/2,y.write(et).cy=y.read(et).cy-J/2}else if(F===gt.TOP_CENTER||F===gt.BOTTOM_CENTER){const q=E.read(et).cy-y.read(et).cy,L=d/u,J=q/L-(T-x);E.write(et).cx=E.read(et).cx+J/2,y.write(et).cx=y.read(et).cx-J/2}}if(o){const q=y.read(et).cx-x,L=y.read(et).cy-S,J=E.read(et).cx-T,tt=E.read(et).cy-R;Object.assign(E.write(et),{cx:E.read(et).cx-q,cy:E.read(et).cy-L}),Object.assign(y.write(et),{cx:y.read(et).cx-J,cy:y.read(et).cy-tt})}const{cx:H,cy:N}=y.read(et),{cx:G,cy:Y}=E.read(et);{const q=G-H,L=Y-N;if(!b&&(q<=0||L<=0))return;const{x:J,y:tt}=e.transformer2Canvas({x:H,y:N},A);this.fitSelected(e,{x:J,y:tt,width:q,height:L,rotation:g,scaleX:p,scaleY:m},n),jz(f,e,{x:J,y:tt,width:q,height:L,rotation:g})}}}
10294snapResizePointer(e,r,i,s,o,n){if(!e.getAppState().snapToObjectsEnabled)return Zo&&this.clearSnapLines(r),[i,s];const a=r.resizingAnchorName;let l=[i,s],c;if(a!==gt.X1Y1&&a!==gt.X2Y2){const{mask:d,tlAnchor:f,brAnchor:g}=e.getCamera().read(Nt),{cx:p,cy:m}=f.read(et),{cx:v,cy:b}=g.read(et),y=e.canvas2Transformer({x:i,y:s},d);let _;if(a===gt.TOP_CENTER||a===gt.BOTTOM_CENTER)y.x=(p+v)/2,_=[0,1];else if(a===gt.MIDDLE_LEFT||a===gt.MIDDLE_RIGHT)y.y=(m+b)/2,_=[1,0];else if(o){const E=a===gt.TOP_RIGHT||a===gt.BOTTOM_RIGHT,A=a===gt.BOTTOM_LEFT||a===gt.BOTTOM_RIGHT,x=n?r.obb.width/2:E?p:v,S=n?r.obb.height/2:A?m:b,T=Math.hypot(y.x-x,y.y-S);_=[(Math.sign(y.x-x)||(E?1:-1))*r.cos,(Math.sign(y.y-S)||(A?1:-1))*r.sin],y.x=x+_[0]*T,y.y=S+_[1]*T}const w=e.transformer2Canvas(y,d);if(l=[w.x,w.y],_){const E=e.transformer2Canvas({x:y.x+_[0],y:y.y+_[1]},d);c=[E.x-w.x,E.y-w.y]}}const{snapOffset:h,snapLines:u}=lne(e,l,c);return Zo&&this.renderSnapLines(r,u,e),[l[0]+h[0],l[1]+h[1]]}handleControlPointMoving(e,r,i,s,o){var n,a,l,c,h;const u=e.getCamera();u.write(Nt).status=Nn.MOVING;const d=s.vectorEditDrag;if(d&&!d.modified){const S=e.canvas2Viewport({x:r,y:i});if(Math.hypot(S.x-d.startViewport[0],S.y-d.startViewport[1])<3)return}if(!((n=s.vectorEditDrag)===null||n===void 0)&&n.curve){const{original:S,curve:T}=s.vectorEditDrag,R=Qt(it(),[r,i],T.inverse);if(T.lastPointer&&Math.hypot(R[0]-T.lastPointer[0],R[1]-T.lastPointer[1])<1e-6)return;const B={vertices:(a=S.vertices)!==null&&a!==void 0?a:[],segments:(l=S.segments)!==null&&l!==void 0?l:[],regions:S.regions},O=Pse(B,T.index,T.t,[R[0]-T.pointer[0],R[1]-T.pointer[1]]);if(O===B&&!s.vectorEditDrag.modified)return;s.vectorEditDrag.modified=O!==B,T.lastPointer=[R[0],R[1]];const C=e.getNodeById(S.id);if(!C)return;e.updateNodeVectorNetwork(Object.assign(Object.assign({},C),{x:S.x,y:S.y}),O),Sr(e.getEntity(S)),this.rememberVectorEditGeometry(e,s),bh(e.getCanvas());return}if(s.activeTangentHandleIndex!==void 0&&s.activeTangentHandleIndex>=0){this.handleVectorNetworkTangentMoving(e,r,i,s,o);return}if(!((c=s.vectorEditDrag)===null||c===void 0)&&c.move){this.handleVectorNetworkMove(e,r,i,s);return}const f=s.activeControlPointIndex;if(f===void 0||f<0)return;const g=e.getAppState().layersSelected;if(g.length!==1)return;const p=e.getNodeById(g[0]);if(!p||p.type==="vector-network"||p.type!=="polyline"&&p.type!=="rough-polyline"&&p.type!=="path"&&p.type!=="rough-path")return;const m=e.getEntity(p);if(!(m!=null&&m.hasSomeOf(_t,xt)))return;const v=_i(Bt(),ie.toGLMat3(m.read(Ae).matrix));if(!v)return;const b=Qt(it(),[r,i],v),y=b[0],_=b[1];if(m.has(_t)){const{points:S}=m.read(_t);if(f>=S.length)return;const[T,R]=S[f];if(T===y&&R===_)return;S[f]=[y,_],e.updateNode(p,{points:S.map(B=>B.join(",")).join(" ")}),Sr(m),_h(m),dU(m,p)&&(s.bindingRebindLastCanvas={x:r,y:i},this.applyBindingRebindHover(e,r,i));return}const{controlPointMeta:w,pathControlCommands:E}=u.read(Nt),A=(h=w==null?void 0:w[f])!==null&&h!==void 0?h:null;if(!A||!(E!=null&&E.length))return;const x=E.map(S=>[...S]);n7t(x,A,y,_),e.updateNode(p,{d:ymt(x)}),u.write(Nt).pathControlCommands=x,dU(m,p)&&(s.bindingRebindLastCanvas={x:r,y:i},this.applyBindingRebindHover(e,r,i))}handleControlPointMoved(e,r){var i;const{layersSelected:s}=e.getAppState();if(s.length===1&&r.bindingRebindLastCanvas){const a=e.getNodeById(s[0]),l=a?e.getEntity(a):void 0,c=r.bindingRebindLastCanvas;if(delete r.bindingRebindLastCanvas,a&&dU(l,a)){const h=e.getCamera(),{pathControlCommands:u}=h.read(Nt);let d;l!=null&&l.has(_t)&&(d=l.read(_t).points.length);const f=qse(a,r.activeControlPointIndex,u,d);f!=null&&this.applyBindingRebindAt(e,a,f,c)}}const o=e.getCamera();if(this.mergeSnappedVectorNetworkVertexIfNeeded(e,r),!((i=r.vectorEditDrag)===null||i===void 0)&&i.modified){const a=e.getNodeById(r.vectorEditDrag.nodeId);if((a==null?void 0:a.type)==="vector-network"){const l={vertices:a.vertices,segments:a.segments,regions:a.regions},c=Uz(l);c!==l&&e.updateNodeVectorNetwork(a,c)}}e.setNodes(e.getNodes()),e.record();const{layersSelected:n}=e.getAppState();if(n.length===1){const a=e.getNodeById(n[0]),l=a?e.getEntity(a):void 0;a&&l&&(Sr(l),_h(l),LJ(e,a))}o.write(Nt).status=Nn.MOVED,this.saveSelectedOBB(e,r)}mergeSnappedVectorNetworkVertexIfNeeded(e,r){var i,s,o;const n=r.activeControlPointIndex;if(n===void 0||n<0||r.activeTangentHandleIndex!==void 0&&r.activeTangentHandleIndex>=0||r.activeSegmentIndex!==void 0&&r.activeSegmentIndex>=0||e.getAppState().vectorNetworkEditMode!==So.MOVE)return;const a=e.getAppState().layersSelected;if(a.length!==1)return;const l=e.getNodeById(a[0]);if(!l||l.type!=="vector-network")return;const c=e.getEntity(l);if(!(c!=null&&c.has(ke)))return;const h=c.read(ke),u=!((i=r.vectorEditDrag)===null||i===void 0)&&i.modified&&(s=r.vectorEditDrag.snapTarget)!==null&&s!==void 0?s:-1;if(u<0)return;const d={vertices:h.vertices.map(p=>Object.assign({},p)),segments:h.segments.map(p=>Object.assign(Object.assign({},p),{tangentStart:p.tangentStart?Object.assign({},p.tangentStart):void 0,tangentEnd:p.tangentEnd?Object.assign({},p.tangentEnd):void 0})),regions:(o=h.regions)===null||o===void 0?void 0:o.map(p=>({fillRule:p.fillRule,loops:p.loops.map(m=>[...m])}))},f=Mse(d,n,u);if(!f)return;e.updateNodeVectorNetwork(l,f);const g=u>n?u-1:u;r.activeControlPointIndex=g,this.setVectorNetworkSelectedVertex(e.getCamera(),e.getCanvas(),g),Sr(c)}handleVectorNetworkMove(e,r,i,s){const o=s.vectorEditDrag,n=o==null?void 0:o.move;if(!n)return;const a=Qt(it(),[r,i],n.inverse);
10294if(Math.hypot(a[0]-n.lastPointer[0],a[1]-n.lastPointer[1])<1e-6)return;n.lastPointer=[a[0],a[1]];const l=n.baseline,c=n.indices.length===1&&s.activeSegmentIndex===void 0?Mwt(e,l.vertices,n.matrix,n.indices[0],r,i):-1;o.snapTarget=c;const h=l.vertices.map((d,f)=>n.indices.includes(f)?Object.assign(Object.assign({},d),{x:c>=0?l.vertices[c].x:d.x+a[0]-n.pointer[0],y:c>=0?l.vertices[c].y:d.y+a[1]-n.pointer[1]}):Object.assign({},d)),u=e.getNodeById(o.nodeId);(u==null?void 0:u.type)==="vector-network"&&(o.modified=!0,e.updateNodeVectorNetwork(Object.assign(Object.assign({},u),{x:l.x,y:l.y}),{vertices:h,segments:l.segments,regions:l.regions}),Sr(e.getEntity(u)),this.rememberVectorEditGeometry(e,s),bh(e.getCanvas()))}beginVectorNetworkMove(e,r,i,s){const o=r.vectorEditDrag;if(!o)return;const n=e.getNodeById(o.nodeId);if((n==null?void 0:n.type)!=="vector-network")return;const a=ie.toGLMat3(e.getEntity(n).read(Ae).matrix),l=_i(Bt(),a);if(!l)return;const c=n.segments[r.activeSegmentIndex],h=c?[...new Set([c.start,c.end])]:[r.activeControlPointIndex];if(h.some(d=>d===void 0||!n.vertices[d]))return;const u=Qt(it(),[i,s],l);o.move={baseline:structuredClone(n),indices:h,inverse:l,matrix:a,pointer:[u[0],u[1]],lastPointer:[u[0],u[1]]}}handleVectorNetworkTangentMoving(e,r,i,s,o){var n,a;const l=s.activeTangentHandleIndex;if(l===void 0||l<0)return;const c=e.getAppState().layersSelected;if(c.length!==1)return;const h=e.getNodeById(c[0]);if(!h||h.type!=="vector-network")return;const u=e.getEntity(h),d=e.getCamera(),{vnTangentMeta:f}=d.read(Nt),g=f==null?void 0:f[l];if(!(u!=null&&u.has(ke))||!g)return;const p=_i(Bt(),ie.toGLMat3(u.read(Ae).matrix));if(!p)return;const m=Qt(it(),[r,i],p),v=u.read(ke),b=v.segments[g.segmentIndex];if(!b)return;const y=v.vertices[g.end==="start"?b.start:b.end];if(!y)return;const _=g.end==="start"?b.tangentStart:b.tangentEnd;if(!(Math.hypot(m[0]-y.x-((n=_==null?void 0:_.x)!==null&&n!==void 0?n:0),m[1]-y.y-((a=_==null?void 0:_.y)!==null&&a!==void 0?a:0))>1e-6)&&!(o&&y.handleMirroring&&y.handleMirroring!=="NONE"))return;s.vectorEditDrag&&(s.vectorEditDrag.modified=!0);const w=GJ(v,g,{x:m[0]-y.x,y:m[1]-y.y},o);w!==v&&(e.updateNodeVectorNetwork(h,w),Sr(u),this.rememberVectorEditGeometry(e,s),bh(e.getCanvas()))}rememberVectorEditGeometry(e,r){const i=r.vectorEditDrag;if(!i)return;const s=e.getNodeById(i.nodeId);(s==null?void 0:s.type)==="vector-network"&&(i.expected=Object.assign({},s),i.written=!0,i.worldMatrix=ie.toGLMat3(e.getEntity(s).read(Ae).matrix))}ownsVectorEditGeometry(e,r){const i=r.vectorEditDrag;if(!i)return!1;const s=e.getNodeById(i.nodeId);if((s==null?void 0:s.type)!=="vector-network"||s.isDeleted||["vertices","segments","regions","x","y","width","height","rotation","scaleX","scaleY","parentId"].some(n=>!Object.is(s[n],i.expected[n])))return!1;const o=e.getEntity(s);return!nr(o)||!o.has(Ae)?!1:ie.toGLMat3(o.read(Ae).matrix).every((n,a)=>Math.abs(n-i.worldMatrix[a])<1e-6)}cancelVectorEditDrag(e,r,i=!0){const s=r==null?void 0:r.vectorEditDrag;if(!s)return;const o=e.getNodeById(s.nodeId),n=this.ownsVectorEditGeometry(e,r);if(i&&n&&s.written&&(o==null?void 0:o.type)==="vector-network"){const{x:a,y:l,width:c,height:h,vertices:u,segments:d,regions:f}=s.original;e.updateNode(o,{x:a,y:l,width:c,height:h,vertices:u,segments:d,regions:f??[]}),Sr(e.getEntity(o))}this.setVectorNetworkSelectedVertex(e.getCamera(),e.getCanvas(),i&&n&&e.getAppState().layersSelected[0]===s.nodeId?s.selectedVertex:-1),delete r.vectorEditDrag,r.vectorDragCancelled=!0,r.activeControlPointIndex=void 0,r.activeSegmentIndex=void 0,r.activeSegmentMidpointIndex=void 0,r.activeTangentHandleIndex=void 0,r.mode=qt.IDLE,r.pointerMoveViewportX=NaN,r.pointerMoveViewportY=NaN,e.getCamera().write(Nt).status=Nn.IDLE,bh(e.getCanvas())}setVectorNetworkSelectedVertex(e,r,i){const s=e.write(Nt);s.selectedControlPointIndex!==i&&(s.selectedControlPointIndex=i,bh(r))}clearVectorNetworkSelectedVertex(e,r){const i=e.write(Nt);i.selectedControlPointIndex!==-1&&(i.selectedControlPointIndex=-1,bh(r))}insertControlPointFromMidpoint(e,r,i,s){var o;const n=s.activeSegmentMidpointIndex;if(n===void 0||n<0)return;const a=e.getAppState().layersSelected;if(a.length!==1)return;const l=e.getNodeById(a[0]);if(!l)return;if(l.type==="vector-network"){const p=e.getEntity(l);if(!(p!=null&&p.has(ke)))return;const m=p.read(ke),v={vertices:m.vertices.map(y=>Object.assign({},y)),segments:m.segments.map(y=>Object.assign(Object.assign({},y),{tangentStart:y.tangentStart?Object.assign({},y.tangentStart):void 0,tangentEnd:y.tangentEnd?Object.assign({},y.tangentEnd):void 0})),regions:(o=m.regions)===null||o===void 0?void 0:o.map(y=>({fillRule:y.fillRule,loops:y.loops.map(_=>[..._])}))},b=L_t(v,n,.5);if(b<0)return;e.updateNodeVectorNetwork(l,v),Sr(p),this.rememberVectorEditGeometry(e,s),s.vectorEditDrag&&(s.vectorEditDrag.modified=!0),s.activeControlPointIndex=b,s.activeSegmentMidpointIndex=void 0,this.setVectorNetworkSelectedVertex(e.getCamera(),e.getCanvas(),b);return}if(l.type!=="polyline"&&l.type!=="rough-polyline")return;const c=e.getEntity(l);if(!(c!=null&&c.has(_t)))return;const{points:h}=c.read(_t);if(n>=h.length-1)return;
10294const u=_i(Bt(),ie.toGLMat3(c.read(Ae).matrix));if(!u)return;const d=Qt(it(),[r,i],u),f=[...h],g=n+1;f.splice(g,0,[d[0],d[1]]),e.updateNode(l,{points:f.map(p=>p.join(",")).join(" ")}),Sr(c),_h(c),s.activeControlPointIndex=g,s.activeSegmentMidpointIndex=void 0}breakVectorNetworkAtVertex(e,r,i,s,o){var n,a;const l=i.activeControlPointIndex;if(l===void 0||l<0)return;const c=e.getAppState().layersSelected;if(c.length!==1)return;const h=e.getNodeById(c[0]);if(!h||h.type!=="vector-network")return;const u=e.getEntity(h);if(!(u!=null&&u.has(ke)))return;const d=u.read(ke),f={vertices:d.vertices.map(p=>Object.assign({},p)),segments:d.segments.map(p=>Object.assign(Object.assign({},p),{tangentStart:p.tangentStart?Object.assign({},p.tangentStart):void 0,tangentEnd:p.tangentEnd?Object.assign({},p.tangentEnd):void 0})),regions:(n=d.regions)===null||n===void 0?void 0:n.map(p=>({fillRule:p.fillRule,loops:p.loops.map(m=>[...m])}))},g=Tse(f,l);g&&((a=r.event)===null||a===void 0||a.stopPropagation(),e.updateNodeVectorNetwork(h,g),Sr(u),e.record()),e.setAppState({vectorNetworkEditMode:So.MOVE}),i.activeSegmentMidpointIndex=void 0,i.activeTangentHandleIndex=void 0,this.setVectorNetworkSelectedVertex(s,o,l),bh(o)}deleteActiveControlPoint(e,r,i){var s,o;const n=e.getAppState().layersSelected;if(n.length!==1)return;let a=e.getNodeById(n[0]);if(!a)return;const l=a.type==="vector-network"?e.getCamera().read(Nt).selectedControlPointIndex:i.activeControlPointIndex;if(l===void 0||l<0)return;if(a.type==="vector-network"&&i.vectorEditDrag){const d=i.vectorEditDrag.original.vertices.length;if(this.cancelVectorEditDrag(e,i),(s=r.event)===null||s===void 0||s.stopPropagation(),l>=d||(a=e.getNodeById(n[0]),(a==null?void 0:a.type)!=="vector-network"))return}if(a.type==="vector-network"){const d=e.getEntity(a);if(!(d!=null&&d.has(ke)))return;const f=d.read(ke);if(f.vertices.length<=1)return;r.event.stopPropagation();const g={vertices:f.vertices.map(m=>Object.assign({},m)),segments:f.segments.map(m=>Object.assign(Object.assign({},m),{tangentStart:m.tangentStart?Object.assign({},m.tangentStart):void 0,tangentEnd:m.tangentEnd?Object.assign({},m.tangentEnd):void 0})),regions:(o=f.regions)===null||o===void 0?void 0:o.map(m=>({fillRule:m.fillRule,loops:m.loops.map(v=>[...v])}))},p=Sse(g,l,{heal:!r.keyShiftKey});if(p===g)return;e.updateNodeVectorNetwork(a,p),Sr(d),e.record(),i.activeControlPointIndex=Math.min(l,p.vertices.length-1),i.activeSegmentMidpointIndex=void 0,i.activeTangentHandleIndex=void 0,this.setVectorNetworkSelectedVertex(e.getCamera(),e.getCanvas(),i.activeControlPointIndex),bh(e.getCanvas());return}if(a.type!=="polyline"&&a.type!=="rough-polyline")return;const c=e.getEntity(a);if(!(c!=null&&c.has(_t)))return;const{points:h}=c.read(_t);if(h.length<=2||l>=h.length)return;r.event.stopPropagation();const u=[...h];u.splice(l,1),e.updateNode(a,{points:u.map(d=>d.join(",")).join(" ")}),Sr(c),_h(c),LJ(e,e.getNodeById(a.id)),e.record(),i.activeControlPointIndex=Math.min(l,u.length-1),i.activeSegmentMidpointIndex=void 0,i.mode===qt.MOVE_CONTROL_POINT&&(i.mode=qt.READY_TO_MOVE_CONTROL_POINT)}applyBindingRebindHover(e,r,i){const s=e.elementsFromPoint({x:r,y:i});for(const o of s){if(o.has(Ii)||!o.has($t)&&!o.has(ae))continue;const n=e.getNodeByEntity(o);if(!n)continue;const a=n.type;if(a==="rect"||a==="ellipse"||a==="rough-rect"||a==="rough-ellipse"){e.highlightNodes([n]);return}}e.highlightNodes([])}handleSelectedResized(e,r){const{layersSelected:i}=e.getAppState();if(i.length===1&&r.bindingRebindLastCanvas&&(r.resizingAnchorName===gt.X1Y1||r.resizingAnchorName===gt.X2Y2)){const a=e.getNodeById(i[0]),l=a?e.getEntity(a):void 0;if(a&&dU(l,a)){const c=r.bindingRebindLastCanvas;delete r.bindingRebindLastCanvas,this.applyBindingRebindAt(e,a,r.resizingAnchorName,c)}}const s=e.getCamera(),o=s.write(Nt);if(o.status=Nn.RESIZED,o.resizeWidth=-1,o.resizeHeight=-1,e.setNodes(e.getNodes()),e.record(),i.length===1&&(r.resizingAnchorName===gt.X1Y1||r.resizingAnchorName===gt.X2Y2)){const a=e.getNodeById(i[0]);((a==null?void 0:a.type)==="line"||(a==null?void 0:a.type)==="rough-line")&&LJ(e,a)}const{selecteds:n}=s.read(Nt);
10294n.forEach(a=>{!N2(a)&&!a.has(Us)&&a.add(Us)}),this.saveSelectedOBB(e,r)}applyBindingRebindAt(e,r,i,s){const o=e.elementsFromPoint({x:s.x,y:s.y});let n;for(const l of o){if(l.has(Ii)||!l.has($t)&&!l.has(ae))continue;const c=e.getNodeByEntity(l);if(!c)continue;const h=c.type;if(h==="rect"||h==="ellipse"||h==="rough-rect"||h==="rough-ellipse"){n=c;break}}if(!n){i===gt.X1Y1?e.updateNode(r,{fromId:void 0,sourcePoint:{x:s.x,y:s.y},exitX:void 0,exitY:void 0,exitPerimeter:void 0,exitDx:void 0,exitDy:void 0}):e.updateNode(r,{toId:void 0,targetPoint:{x:s.x,y:s.y},entryX:void 0,entryY:void 0,entryPerimeter:void 0,entryDx:void 0,entryDy:void 0});return}const a=uU(n,s.x,s.y);i===gt.X1Y1?e.updateNode(r,{fromId:n.id,sourcePoint:void 0,exitX:a.x,exitY:a.y,exitPerimeter:a.perimeter,exitDx:a.dx,exitDy:a.dy}):e.updateNode(r,{toId:n.id,targetPoint:void 0,entryX:a.x,entryY:a.y,entryPerimeter:a.perimeter,entryDx:a.dx,entryDy:a.dy})}handleSelectedRotated(e,r){const i=e.getCamera(),s=i.write(Nt);s.status=Nn.ROTATED,s.transformerObbFrozenDuringRotate=!1,delete r.rotateLastPointerAngle,delete r.rotateAccumulated,delete r.rotatePivotWorldFixed,delete r.rotatePivotLocalFixed,e.setNodes(e.getNodes()),e.record();const{selecteds:o}=i.read(Nt);o.forEach(n=>{!N2(n)&&!n.has(Us)&&n.add(Us)}),this.saveSelectedOBB(e,r)}handleBrushing(e,r,i){const s=e.getCamera(),o=this.selections.get(s.__id),{pointerDownViewportX:n,pointerDownViewportY:a}=s.read(so);Sa(r,i,n,a)>10&&(this.renderBrush(e,o,Math.min(n,r),Math.min(a,i),Math.abs(r-n),Math.abs(i-a)),this.applyBrushSelection(e,o,!1))}execute(){this.cameras.current.forEach(e=>{var r,i,s,o;if(!e.has(jt))return;const{canvas:n}=e.read(jt);if(!n)return;const{inputPoints:a,api:l}=n.read(wt),c=l.getAppState().penbarSelected,h=n.read(le);if(c!==vt.SELECT){if(this.cancelVectorEditDrag(l,this.selections.get(e.__id)),l.getAppState().vectorNetworkSelectedVertex&&l.setAppState({vectorNetworkSelectedVertex:null}),this.vectorFillEditor.clear(l),c!==vt.VECTOR_NETWORK&&c!==vt.ERASER&&l.selectNodes([]),c!==vt.VECTOR_NETWORK){this.selections.has(e.__id)&&this.saveSelectedOBB(l,this.selections.get(e.__id));return}return}const{layersCropping:u}=l.getAppState();u.forEach(_=>{const w=l.getNodeById(_);w&&w.clipMode!=="soft"&&(l.updateNode(w,{clipMode:"soft",locked:!0}),l.deselectNodes([w]),l.selectNodes([l.getNodeByEntity(l.getChildren(w)[0])]))});const d=n.write(_o);if(nt(e,Nt),!this.selections.has(e.__id)){const _={mode:qt.IDLE,resizingAnchorName:gt.INSIDE,activeControlPointIndex:void 0,activeSegmentMidpointIndex:void 0,activeSegmentIndex:void 0,nodes:l.getNodes().map(E=>Object.assign(Object.assign({},E),l.getAbsoluteTransformAndSize(E))),obb:{x:0,y:0,width:0,height:0,rotation:0,scaleX:1,scaleY:1},sin:0,cos:0,pointerMoveViewportX:0,pointerMoveViewportY:0,brushContainer:we("svg"),snapContainer:we("svg"),label:Pr.get().getDocument().createElement("div"),editing:void 0};this.selections.set(e.__id,_);const w=l.onBeforeHistoryChange(()=>this.cancelVectorEditDrag(l,_));if(_.dispose=l.onDestroy(()=>{w(),this.vectorFillEditor.clear(l),_.brushContainer.remove(),_.snapContainer.remove(),_.label.remove(),this.selections.delete(e.__id)}),Zo){_.brushContainer.style.overflow="visible",_.brushContainer.style.position="absolute",_.snapContainer.style.overflow="visible",_.snapContainer.style.position="absolute";const E=l.getSvgLayer();if(E){E.appendChild(_.brushContainer),E.appendChild(_.snapContainer);const{label:A}=_;Wz(A),E.appendChild(_.label)}}}const f=this.selections.get(e.__id);if(h.pointerDownTrigger&&!h.pointerCancelled&&(f.vectorDragCancelled=!1),f.vectorEditDrag&&!this.ownsVectorEditGeometry(l,f)){this.cancelVectorEditDrag(l,f,!1);return}f.editing&&(!nr(f.editing)||!f.editing.has(Mi)||!f.editing.read(Mi).isEditing)&&(f.editing=void 0);const{selecteds:g}=e.read(Nt);if(g.length===1&&g[0].has(ke)&&(!g[0].has(Mi)||!g[0].read(Mi).isEditing)){const _=e.write(Nt);let w=!1;_.hoveredSegmentIndex!==-1&&(_.hoveredSegmentIndex=-1,w=!0),_.hoveredControlPointIndex!==-1&&(_.hoveredControlPointIndex=-1,w=!0),_.selectedControlPointIndex!==-1&&(_.selectedControlPointIndex=-1,w=!0),w&&bh(n)}f.vectorEditDrag&&(h.pointerCancelled||h.key==="Escape"||l.getAppState().vectorNetworkEditMode!==f.vectorEditDrag.editMode||((r=l.getNodeById(f.vectorEditDrag.nodeId))===null||r===void 0?void 0:r.isEditing)!==!0||!((i=l.getNodeById(f.vectorEditDrag.nodeId))===null||i===void 0)&&i.locked||((s=l.getNodeById(f.vectorEditDrag.nodeId))===null||s===void 0?void 0:s.visibility)==="hidden"||l.getAppState().layersSelected[0]!==f.vectorEditDrag.nodeId)&&this.cancelVectorEditDrag(l,f);const p=g.length===1?g[0]:void 0,m=e.read(Nt).selectedControlPointIndex,v=p&&l.getNodeByEntity(p),b=(v==null?void 0:v.type)==="vector-network"&&p.has(Mi)&&p.read(Mi).isEditing&&!((o=v.vertices)===null||o===void 0)&&o[m]?{nodeId:v.id,index:m}:null,y=l.getAppState().vectorNetworkSelectedVertex;if(((y==null?void 0:y.nodeId)!==(b==null?void 0:b.nodeId)||(y==null?void 0:y.index)!==(b==null?void 0:b.index))&&l.setAppState({vectorNetworkSelectedVertex:b}),this.vectorFillEditor.update(l,h,g)){f.mode=qt.IDLE,f.activeControlPointIndex=void 0,f.activeSegmentMidpointIndex=void 0,f.activeSegmentIndex=void 0,f.activeTangentHandleIndex=void 0,f.pointerMoveViewportX=NaN,f.pointerMoveViewportY=NaN;return}if(h.doubleClickTrigger&&c===vt.SELECT&&g.length===1){const _=g[0];if(!_.has(tu)&&!(_.has(Mi)&&_.read(Mi).isEditing)){const w=l.getNodeByEntity(_);if(w&&(_.hasSomeOf(_t,xt)&&!(LS(_)&&_.has(_t))||_.has(ke))){const E=w.type;
10294if(E==="polyline"||E==="rough-polyline"||E==="path"||E==="rough-path"||E==="vector-network"){nt(_,Mi),_.write(Mi).isEditing=!0,l.updateNode(w,{isEditing:!0}),l.setAppState({vectorNetworkEditMode:So.MOVE}),f.editing=_;const A=e.write(Nt);A.selectedControlPointIndex=-1,A.hoveredSegmentIndex=-1,A.hoveredControlPointIndex=-1,bh(n);return}}}}if(h.pointerDownTrigger){delete f.moveGesture,delete f.lastSnapOffset;const{selecteds:_}=e.read(Nt),w=_.length===1?_[0]:void 0,E=(w==null?void 0:w.has(ke))&&w.has(Mi)&&w.read(Mi).isEditing,[A,x]=h.pointerDownViewport;if(!E){const S=h.pointerType!=="touch"&&f.mode===qt.READY_TO_MOVE_PIVOT;f.mode=qt.IDLE,this.updateSelectionAtPointer(l,f,A,x,h,d,S),f.pointerMoveViewportX=NaN,f.pointerMoveViewportY=NaN}if(delete f.resizePointerOffset,E){f.editing=w;const{anchor:S,index:T}=vQ(l,{x:A,y:x});f.activeControlPointIndex=S===gt.CONTROL?T:void 0,f.activeTangentHandleIndex=S===gt.TANGENT?T:void 0,f.activeSegmentMidpointIndex=S===gt.SEGMENT_MIDPOINT?T:void 0,f.activeSegmentIndex=S===gt.SEGMENT?T:void 0;const R=S===gt.CONTROL||S===gt.TANGENT||S===gt.SEGMENT_MIDPOINT||S===gt.SEGMENT;f.mode=R?qt.READY_TO_MOVE_CONTROL_POINT:qt.IDLE,R||this.clearVectorNetworkSelectedVertex(e,n)}if(f.editing){if(f.mode===qt.IDLE){nt(f.editing,Mi),f.editing.write(Mi).isEditing=!1,l.updateNode(l.getNodeByEntity(f.editing),{isEditing:!1}),f.editing=void 0,f.mode=qt.SELECT,l.setAppState({editingPoints:[]});return}if(f.mode===qt.READY_TO_MOVE){l.setAppState({editingPoints:[[A,x]]});return}}if(f.mode===qt.IDLE)this.shouldSuppress2DBrushSelection(n,A,x)||(f.mode=qt.READY_TO_BRUSH,l.selectNodes([])),u.length>0&&l.applyCrop();else if(f.mode===qt.READY_TO_SELECT)f.mode=qt.SELECT;else if(f.mode===qt.READY_TO_MOVE){const S=this.getTopmostEntity(l,A,x,B=>!B.has(Ii)),T=S?l.getNodeByEntity(S):void 0,R=l.getAppState().layersSelected;T&&!R.includes(T.id)||h.shiftKey?f.mode=qt.SELECT:this.shouldSuppress2DMove(n,A,x)||(u.length>0?d.value="move":d.value="grab",f.mode=qt.MOVE)}else if(f.mode===qt.READY_TO_RESIZE||f.mode===qt.READY_TO_ROTATE){if(this.saveSelectedOBB(l,f),f.mode===qt.READY_TO_RESIZE)delete f.rotateLastPointerAngle,delete f.rotateAccumulated,delete f.rotatePivotWorldFixed,delete f.rotatePivotLocalFixed,e.write(Nt).transformerObbFrozenDuringRotate=!1,f.mode=qt.RESIZE,h.pointerType==="touch"&&(f.resizePointerOffset=this.getResizePointerOffset(l,f.resizingAnchorName,A,x));else if(f.mode===qt.READY_TO_ROTATE){const[S,T]=this.getRotatePivotWorld(l,f);f.rotatePivotWorldFixed=[S,T];const R=e.read(Nt),B=Number.isNaN(R.rotatePivotX)?f.obb.width/2:R.rotatePivotX,O=Number.isNaN(R.rotatePivotY)?f.obb.height/2:R.rotatePivotY;if(f.rotatePivotLocalFixed=[B,O],l.getAppState().layersSelected.length>1){const N=e.write(Nt);N.transformerObbFrozenDuringRotate=!0;const G=N.gestureFrozenSelectionOBB,Y=f.obb;G.x=Y.x,G.y=Y.y,G.width=Y.width,G.height=Y.height,G.rotation=Y.rotation,G.scaleX=Y.scaleX,G.scaleY=Y.scaleY}let{x:C,y:F}=l.viewport2Canvas({x:A,y:x});const{snapToPixelGridEnabled:U,snapToPixelGridSize:H}=l.getAppState();U&&(C=oy(C,H),F=oy(F,H)),f.rotateLastPointerAngle=Math.atan2(F-T,C-S),f.rotateAccumulated=0,f.mode=qt.ROTATE}}else if(f.mode===qt.READY_TO_MOVE_PIVOT)f.mode=qt.MOVE_PIVOT;else if(f.mode===qt.READY_TO_MOVE_CONTROL_POINT){const S=l.getAppState().vectorNetworkEditMode,T=l.getAppState().layersSelected[0],R=T?l.getNodeById(T):void 0;if((R==null?void 0:R.type)==="vector-network"){if((f.activeTangentHandleIndex!==void 0||S===So.MOVE||S===So.CUT&&f.activeSegmentMidpointIndex!==void 0)&&(f.vectorEditDrag={nodeId:R.id,original:structuredClone(R),expected:Object.assign({},R),worldMatrix:ie.toGLMat3(l.getEntity(R).read(Ae).matrix),editMode:S,selectedVertex:e.read(Nt).selectedControlPointIndex,startViewport:[A,x]}),S===So.CUT&&f.activeControlPointIndex!==void 0&&f.activeSegmentMidpointIndex===void 0&&f.activeTangentHandleIndex===void 0){this.breakVectorNetworkAtVertex(l,h,f,e,n),f.mode=qt.IDLE,f.pointerMoveViewportX=NaN,f.pointerMoveViewportY=NaN;return}else f.activeControlPointIndex!==void 0&&f.activeSegmentMidpointIndex===void 0&&f.activeTangentHandleIndex===void 0&&this.setVectorNetworkSelectedVertex(e,n,f.activeControlPointIndex);if(S===So.BEND&&f.activeTangentHandleIndex===void 0&&f.activeSegmentMidpointIndex===void 0&&f.activeSegmentIndex===void 0)return}const{x:B,y:O}=l.viewport2Canvas({x:A,y:x});if((R==null?void 0:R.type)==="vector-network"&&S===So.BEND&&f.activeSegmentIndex!==void 0){const C=f.activeSegmentIndex,F=ie.toGLMat3(l.getEntity(R).read(Ae).matrix
10294),U=_i(Bt(),F),H=lm(R.vertices,R.segments[C]);if(!U||!H)return;const N=H.map(q=>{const L=Qt(it(),q,F),J=l.canvas2Viewport({x:L[0],y:L[1]});return[J.x,J.y]}),G=Dse(N,[A,x]);if(G<=1e-4||G>=1-1e-4)return;const Y=Qt(it(),[B,O],U);f.vectorEditDrag={nodeId:R.id,original:structuredClone(R),expected:Object.assign({},R),worldMatrix:Kst(F),editMode:S,selectedVertex:e.read(Nt).selectedControlPointIndex,startViewport:[A,x],curve:{index:C,t:G,inverse:U,pointer:[Y[0],Y[1]]}}}f.activeSegmentMidpointIndex!==void 0&&f.activeSegmentMidpointIndex>=0&&this.insertControlPointFromMidpoint(l,B,O,f),f.vectorEditDrag&&S!==So.BEND&&this.beginVectorNetworkMove(l,f,B,O),f.mode=qt.MOVE_CONTROL_POINT}if(f.mode===qt.SELECT||f.mode===qt.READY_TO_BRUSH){const S=this.getTopmostEntity(l,A,x,T=>!T.has(Ii));if(S){const T=l.getNodeByEntity(S);T&&(l.getAppState().layersSelected.length>1&&l.getAppState().layersSelected.includes(T.id)?l.deselectNodes([T]):l.selectNodes([T],h.shiftKey)),f.mode===qt.READY_TO_BRUSH&&(f.mode=qt.SELECT)}l.getAppState().layersSelected.length>0&&!this.shouldSuppress2DMove(n,A,x)&&(f.mode=qt.MOVE)}this.saveSelectedOBB(l,f)}if(e.has(Pe)&&a.length===0){const[_,w]=h.pointerViewport;(f.pointerMoveViewportX!==_||f.pointerMoveViewportY!==w)&&(f.pointerMoveViewportX=_,f.pointerMoveViewportY=w,this.updateSelectionAtPointer(l,f,_,w,h,d))}if(a.forEach(_=>{const w=_.write(xa),{prevPoint:[E,A]}=w,[x,S]=h.pointerViewport;if(E===x&&A===S)return;let{x:T,y:R}=l.viewport2Canvas({x:E,y:A}),{x:B,y:O}=l.viewport2Canvas({x,y:S});f.mode===qt.RESIZE&&f.resizePointerOffset&&(B-=f.resizePointerOffset[0],O-=f.resizePointerOffset[1]);const{snapToPixelGridEnabled:C,snapToPixelGridSize:F}=l.getAppState();if(C&&f.mode!==qt.MOVE&&(T=oy(T,F),R=oy(R,F),B=oy(B,F),O=oy(O,F)),f.mode===qt.READY_TO_BRUSH||f.mode===qt.BRUSH){if(Jj()){this.hideBrush(f),f.mode=qt.IDLE;return}this.handleBrushing(l,x,S),f.mode=qt.BRUSH}else if(f.mode===qt.MOVE){if(Jj())return;u.length>0?d.value="move":d.value="grabbing",this.handleSelectedMoving(l,T,R,B,O)}else f.mode===qt.RESIZE?this.handleSelectedResizing(l,B,O,h.shiftKey,h.altKey,f):f.mode===qt.ROTATE?this.handleSelectedRotating(l,B,O):f.mode===qt.MOVE_PIVOT?this.handleRotatePivotMoving(l,B,O):f.mode===qt.MOVE_CONTROL_POINT&&this.handleControlPointMoving(l,B,O,f,h.altKey)}),(h.key==="Escape"||h.pointerCancelled)&&(delete f.moveGesture,delete f.lastSnapOffset,Zo&&this.clearSnapLines(f)),h.key==="Escape"){if(f.editing){const _=l.getNodeByEntity(f.editing);nt(f.editing,Mi),f.editing.write(Mi).isEditing=!1,_&&l.updateNode(_,{isEditing:!1}),f.editing=void 0,l.setAppState({editingPoints:[]})}l.selectNodes([]),l.highlightNodes([]),this.saveSelectedOBB(l,f),f.mode===qt.BRUSH&&this.hideBrush(f),(f.mode===qt.ROTATE||f.mode===qt.READY_TO_ROTATE)&&(delete f.rotateLastPointerAngle,delete f.rotateAccumulated,delete f.rotatePivotWorldFixed,delete f.rotatePivotLocalFixed,e.write(Nt).transformerObbFrozenDuringRotate=!1),l.getAppState().layersCropping.length>0&&l.cancelCrop()}else(h.key==="Backspace"||h.key==="Delete")&&this.deleteActiveControlPoint(l,h,f);h.pointerUpTrigger&&!f.vectorDragCancelled&&(NS(f.label),f.mode===qt.BRUSH?(this.hideBrush(f),this.applyBrushSelection(l,f,!1)):f.mode===qt.MOVE?(this.handleSelectedMoved(l,f),f.mode=qt.READY_TO_MOVE):f.mode===qt.RESIZE||f.mode===qt.READY_TO_RESIZE?(this.handleSelectedResized(l,f),f.mode=qt.READY_TO_RESIZE):f.mode===qt.ROTATE?(this.handleSelectedRotated(l,f),f.mode=qt.READY_TO_ROTATE):f.mode===qt.MOVE_PIVOT||f.mode===qt.READY_TO_MOVE_PIVOT?f.mode=qt.READY_TO_MOVE_PIVOT:(f.mode===qt.MOVE_CONTROL_POINT||f.mode===qt.READY_TO_MOVE_CONTROL_POINT)&&(this.handleControlPointMoved(l,f),delete f.vectorEditDrag,f.activeSegmentIndex=void 0,f.mode=qt.READY_TO_MOVE_CONTROL_POINT),d.value="default",Zo&&this.clearSnapLines(f))})}finalize(){this.selections.forEach(e=>{var r;return(r=e.dispose)===null||r===void 0?void 0:r.call(e)}),this.selections.clear()}getResizePointerOffset(e,r,i,s){const o=e.getCamera().read(Nt);let n=o.mask,a,l;if(r===gt.X1Y1||r===gt.X2Y2){const u=r===gt.X1Y1?o.x1y1Anchor:o.x2y2Anchor,{cx:d,cy:f}=u.read(et);a=d,l=f,n=o.lineMask}else{const{cx:u,cy:d}=o.tlAnchor.read(et),{cx:f,cy:g}=o.brAnchor.read(et);a=r===gt.TOP_LEFT||r===gt.BOTTOM_LEFT||r===gt.MIDDLE_LEFT?u:r===gt.TOP_RIGHT||r===gt.BOTTOM_RIGHT||r===gt.MIDDLE_RIGHT?f:(u+f)/2,l=r===gt.TOP_LEFT||r===gt.TOP_RIGHT||r===gt.TOP_CENTER?d:r===gt.BOTTOM_LEFT||r===gt.BOTTOM_RIGHT||r===gt.BOTTOM_CENTER?g:(d+g)/2}const c=e.transformer2Canvas({x:a,y:l},n),h=e.viewport2Canvas({x:i,y:s});return[h.x-c.x,h.y-c.y]}updateSelectionAtPointer(e,r,i,s,o,n,a=o.pointerType!=="touch"){var l;const c=e.getCamera(),h=e.getCanvas(),{penbarSelected:u,layersCropping:d,layersLassoing:f}=e.getAppState();let g=this.getTopmostEntity(e,i,s,v=>!v.has(Ii));g?(g=this.resolveHighlightEntityFromHit(g,c),r.mode!==qt.BRUSH&&r.mode!==qt.MOVE&&r.mode!==qt.ROTATE&&r.mode!==qt.RESIZE&&r.mode!==qt.MOVE_PIVOT&&r.mode!==qt.MOVE_CONTROL_POINT&&(r.mode=qt.READY_TO_SELECT)):r.mode!==qt.BRUSH&&r.mode!==qt.ROTATE&&r.mode!==qt.RESIZE&&r.mode!==qt.MOVE_PIVOT&&r.mode!==qt.MOVE_CONTROL_POINT&&(r.mode=qt.IDLE);const{mask:p,selecteds:m}=c.read(Nt);if(n.value="default",m.length>=1){const{anchor:v,cursor:b,index:y}=vQ(e,{x:i,y:s},o.pointerType)||{}
10294,_=v===gt.CENTER&&!a?gt.INSIDE:v,w=m.length===1?m[0]:void 0;if(w!=null&&w.has(ke)&&u===vt.SELECT&&w.has(Mi)&&w.read(Mi).isEditing){const E=c.write(Nt),A=e.getAppState().vectorNetworkEditMode,x=(A===So.MOVE||A===So.BEND||A===So.CUT)&&w?yQ(e,w,i,s):-1,S=_===gt.CONTROL?y:-1;let T=!1;E.hoveredSegmentIndex!==x&&(E.hoveredSegmentIndex=x,T=!0),E.hoveredControlPointIndex!==S&&(E.hoveredControlPointIndex=S,T=!0),T&&bh(h)}if(r.mode!==qt.BRUSH&&_)if(_===gt.CONTROL)n.value="crosshair",r.activeControlPointIndex=y,r.activeSegmentMidpointIndex=void 0,r.activeSegmentIndex=void 0,r.activeTangentHandleIndex=void 0,r.mode=qt.READY_TO_MOVE_CONTROL_POINT,g=void 0;else if(_===gt.TANGENT)n.value="crosshair",r.activeTangentHandleIndex=y,r.activeControlPointIndex=void 0,r.activeSegmentMidpointIndex=void 0,r.activeSegmentIndex=void 0,r.mode=qt.READY_TO_MOVE_CONTROL_POINT,g=void 0;else if(_===gt.CENTER)n.value="move",r.activeControlPointIndex=void 0,r.activeSegmentMidpointIndex=void 0,r.activeSegmentIndex=void 0,r.mode=qt.READY_TO_MOVE_PIVOT,g=void 0;else if(_===gt.SEGMENT_MIDPOINT)n.value="crosshair",r.activeControlPointIndex=void 0,r.activeSegmentMidpointIndex=y,r.activeSegmentIndex=void 0,r.mode=qt.READY_TO_MOVE_CONTROL_POINT,g=void 0;else if(_===gt.SEGMENT)r.activeTangentHandleIndex=void 0,n.value="move",r.activeControlPointIndex=void 0,r.activeSegmentMidpointIndex=void 0,r.activeSegmentIndex=y,r.mode=qt.READY_TO_MOVE_CONTROL_POINT,g=void 0;else if(r.activeControlPointIndex=void 0,r.activeSegmentMidpointIndex=void 0,r.activeSegmentIndex=void 0,f.length>0)_===gt.INSIDE&&(n.value=Kse,r.mode=qt.LASSOING);else{const{rotation:E,scale:A}=p.read(_e);n.value=(l=sne(b,E,"",Math.sign(A[0]*A[1])<0))!==null&&l!==void 0?l:b,r.resizingAnchorName=_,b.includes("rotate")?(r.mode!==qt.ROTATE&&(r.mode=qt.READY_TO_ROTATE),g=void 0):b.includes("resize")||_===gt.X1Y1||_===gt.X2Y2?(r.mode!==qt.RESIZE&&(r.mode=qt.READY_TO_RESIZE),g=void 0):_===gt.INSIDE?g&&g!==m[0]&&m.length===1||o.shiftKey?r.mode=qt.READY_TO_SELECT:r.mode!==qt.MOVE&&r.mode!==qt.ROTATE&&r.mode!==qt.RESIZE&&(r.mode=qt.READY_TO_MOVE):g&&r.mode!==qt.ROTATE&&r.mode!==qt.RESIZE&&(r.mode=qt.READY_TO_SELECT),d.length>0&&_===gt.INSIDE&&(n.value="move")}}if(g&&(N2(g)||this.shouldSuppress2DBrushSelection(h,i,s))&&(g=void 0),g){const v=e.getNodeByEntity(g);v&&e.highlightNodes([v])}else e.highlightNodes([])}applyBrushSelection(e,r,i){if(r.brushContainer){const s=r.brushContainer.firstChild;if(!s)return;const o=parseFloat(s.getAttribute("x")||"0"),n=parseFloat(s.getAttribute("y")||"0"),a=parseFloat(s.getAttribute("width")||"0"),l=parseFloat(s.getAttribute("height")||"0"),{x:c,y:h}=e.viewport2Canvas({x:o,y:n}),{x:u,y:d}=e.viewport2Canvas({x:o+a,y:n+l}),f=e.elementsFromBBox(c,h,u,d).filter(g=>!g.has(Ii)&&g.has(be)&&g.read(be).parent.has(jt)).map(g=>e.getNodeByEntity(g));e.selectNodes(f),i&&e.highlightNodes(f),this.saveSelectedOBB(e,r)}}saveSelectedOBB(e,r){var i;const s=e.getCamera(),o=[...e.getAppState().layersSelected].sort(),n=[...(i=r.selectedNodeIds)!==null&&i!==void 0?i:[]].sort();if(o.length!==n.length||o.some((u,d)=>u!==n[d])){delete r.moveGesture,delete r.lastSnapOffset,Zo&&this.clearSnapLines(r);const u=s.write(Nt);if(u.rotatePivotPinned=!1,u.rotatePivotX=NaN,u.rotatePivotY=NaN,r.editing){const d=e.getNodeByEntity(r.editing),f=d==null?void 0:d.id;o.length===1&&o[0]===f||(nt(r.editing,Mi),r.editing.write(Mi).isEditing=!1,d&&e.updateNode(d,{isEditing:!1}),r.editing=void 0,e.setAppState({editingPoints:[]}))}}const a=SU(s);r.obb={x:a.x,y:a.y,width:a.width,height:a.height,rotation:a.rotation,scaleX:a.scaleX,scaleY:a.scaleY};const{width:l,height:c}=r.obb,h=Math.sqrt(Math.pow(l,2)+Math.pow(c,2));r.sin=Math.abs(c/h),r.cos=Math.abs(l/h),r.nodes=[...e.getNodes().map(u=>Object.assign(Object.assign({},u),e.getAbsoluteTransformAndSize(u)))],r.selectedNodeIds=o}fitSelected(e,r,i){const s=e.getCamera(),{selecteds:o}=s.read(Nt),{width:n,height:a}=r,l=.01,c={x:i.obb.x,y:i.obb.y,width:i.obb.width,height:i.obb.height,rotation:i.obb.rotation,scaleX:i.obb.scaleX,scaleY:i.obb.scaleY},h=s.read(Nt).status,u=o.length>1&&h===Nn.ROTATING,d=Bt();if(u){const v=r.rotation-c.rotation,[b,y]=this.getRotatePivotWorldStable(e,i);Yc(d),bi(d,d,[b,y]),Mo(d,d,v),bi(d,d,[-b,-y])}else{const v=Bt();bi(v,v,[c.x,c.y]),Mo(v,v,c.rotation),xh(v,v,[c.width/1e7,c.height/1e7]);const b=Bt(),y=r.width/1e7,_=r.height/1e7,{flipEnabled:w}=e.getAppState();w?(bi(b,b,[r.x,r.y]),Mo(b,b,r.rotation),xh(b,b,[y,_])):(bi(b,b,[r.x,r.y]),Mo(b,b,r.rotation),bi(b,b,[r.width<0?r.width:0,r.height<0?r.height:0]),xh(b,b,[Math.abs(y),Math.abs(_)])),us(d,b,_i(Bt(),v))}const f=[],g=new Set,p=v=>{if(!g.has(v)){if(g.add(v),v.has(Js)){const b=e.getNodeByEntity(v);if(b&&(b.type==="iconfont"||b.type==="icon_font")){f.push(v);return}if(v.has(ze)){const{children:y}=v.read(ze);
10294y.forEach(_=>p(_))}return}f.push(v)}};o.forEach(v=>p(v));let m=!1;if(f.forEach(v=>{var b;const y=e.getNodeByEntity(v);if(!y)return;const _=i.nodes.find(O=>O.id===y.id);if(!_)return;const w=e.getParentTransform(v),E=e.getTransform(_),A=Bt();us(A,w,E),us(A,d,A),us(A,_i(Bt(),w),A);const{rotation:x,translation:S,scale:T}=Q8(A),R={x:S[0],y:S[1],width:Math.max(Math.abs(_.width*T[0]),l),height:Math.max(Math.abs(_.height*T[1]),l),rotation:x,scaleX:c.scaleX*(Math.sign(n)||1),scaleY:c.scaleY*(Math.sign(a)||1)},B=i.mode===qt.ROTATE&&v.hasSomeOf(_t,xt,Mt,ke);if(!B&&v.hasSomeOf(_t,xt,Mt,ke)){const O=Math.sign(n)||1,C=Math.sign(a)||1;R.scaleX=Math.sign(c.scaleX||1)*O,R.scaleY=Math.sign(c.scaleY||1)*C}if(e.updateNodeOBB(y,R,y.lockAspectRatio,B?void 0:A,_),o.length===1&&v.has(Yt)){const O=v.read(Yt);if(O.wordWrap&&((b=O.wordWrapWidth)!==null&&b!==void 0?b:0)>0){const C=s.write(Nt);C.resizeWidth=R.width,C.resizeHeight=R.height,m=!0}}Sr(v),_h(v)}),!m){const v=s.write(Nt);v.resizeWidth=-1,v.resizeHeight=-1}}hideBrush(e){e.brushContainer&&e.brushContainer.setAttribute("visibility","hidden"),e.mode=qt.IDLE}renderBrush(e,r,i,s,o,n){var a;const{brushContainer:l}=r;l.setAttribute("visibility","visible");const c=e.getCamera().read(jt).canvas,{mode:h,colors:u}=c.read(ul),d=Object.assign(Object.assign({},Ty[h]),(a=u[h])!==null&&a!==void 0?a:{});let f=l.firstChild;f||(f=we("rect"),f.setAttribute("x","0"),f.setAttribute("y","0"),f.setAttribute("width","0"),f.setAttribute("height","0"),f.setAttribute("opacity","0.5"),f.setAttribute("stroke-width","1"),l.appendChild(f)),f.setAttribute("fill",d.selectionBrushFill),f.setAttribute("stroke",d.selectionBrushStroke),f.setAttribute("x",i.toString()),f.setAttribute("y",s.toString()),f.setAttribute("width",o.toString()),f.setAttribute("height",n.toString())}clearSnapLines(e){const{snapContainer:r}=e;r.innerHTML=""}renderSnapLines(e,r,i){const{snapLineStroke:s,snapLineStrokeWith:o}=i.getAppState(),{snapContainer:n}=e;this.clearSnapLines(e),r.forEach(a=>{const{type:l,points:c}=a;if(l==="points"){const h=c.map(d=>i.canvas2Viewport({x:d[0],y:d[1]})),u=we("polyline");u.setAttribute("points",h.map(d=>`${d.x},${d.y}`).join(" ")),u.setAttribute("stroke",s),u.setAttribute("stroke-width",`${o}`),n.appendChild(u),h.forEach(d=>{const f=we("line");f.setAttribute("x1",`${d.x-4}`),f.setAttribute("y1",`${d.y-4}`),f.setAttribute("x2",`${d.x+4}`),f.setAttribute("y2",`${d.y+4}`),f.setAttribute("stroke",s),f.setAttribute("stroke-width",`${o}`),n.appendChild(f);const g=we("line");g.setAttribute("x1",`${d.x-4}`),g.setAttribute("y1",`${d.y+4}`),g.setAttribute("x2",`${d.x+4}`),g.setAttribute("y2",`${d.y-4}`),g.setAttribute("stroke",s),g.setAttribute("stroke-width",`${o}`),n.appendChild(g)})}else if(l==="gap"){const{x:h,y:u}=i.canvas2Viewport({x:c[0][0],y:c[0][1]}),{x:d,y:f}=i.canvas2Viewport({x:c[1][0],y:c[1][1]}),g=Math.sqrt(Math.pow(c[0][0]-c[1][0],2)+Math.pow(c[0][1]-c[1][1],2)),p=[h,u],m=[d,f],{direction:v}=a,b=8,y=b/2,_=b/4;if(v==="horizontal"){const w=[(p[0]+m[0])/2,p[1]];this.renderSnapLine([p[0],p[1]-b],[p[0],p[1]+b],i,n),this.renderSnapLine([w[0]-_,w[1]-y],[w[0]-_,w[1]+y],i,n),this.renderSnapLine([w[0]+_,w[1]-y],[w[0]+_,w[1]+y],i,n),this.renderSnapLine([m[0],m[1]-b],[m[0],m[1]+b],i,n),this.renderSnapLine(p,m,i,n);const E=we("text");E.setAttribute("x",`${w[0]}`),E.setAttribute("y",`${w[1]+16}`),E.setAttribute("text-anchor","middle"),E.setAttribute("dominant-baseline","middle"),E.textContent=`${g.toFixed(0)}`,E.setAttribute("fill",s),E.setAttribute("font-size","12"),n.appendChild(E)}else{const w=[p[0],(p[1]+m[1])/2];this.renderSnapLine([p[0]-b,p[1]],[p[0]+b,p[1]],i,n),this.renderSnapLine([w[0]-y,w[1]-_],[w[0]+y,w[1]-_],i,n),this.renderSnapLine([w[0]-y,w[1]+_],[w[0]+y,w[1]+_],i,n),this.renderSnapLine([m[0]-b,m[1]],[m[0]+b,m[1]],i,n),this.renderSnapLine(p,m,i,n);const E=we("text");E.setAttribute("x",`${w[0]+16}`),E.setAttribute("y",`${w[1]}`),E.setAttribute("text-anchor","start"),E.setAttribute("dominant-baseline","middle"),E.textContent=`${g.toFixed(0)}`,E.setAttribute("fill",s),E.setAttribute("font-size","12"),n.appendChild(E)}}})}renderSnapLine(e,r,i,s){const{snapLineStroke:o,snapLineStrokeWith:n}=i.getAppState(),a=we("line");a.setAttribute("x1",`${e[0]}`),a.setAttribute("y1",`${e[1]}`),a.setAttribute("x2",`${r[0]}`),a.setAttribute("y2",`${r[1]}`),a.setAttribute("stroke",o),a.setAttribute("stroke-width",`${n}`),s.appendChild(a)}}const Z_t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function BB(t,e,r){const i=r[0];if(e!=null&&t>=e)throw new Error(t+" >= "+e);if(t.slice(-1)===i||e&&e.slice(-1)===i)throw new Error("trailing zero");if(e){let n=0;for(;(t[n]||i)===e[n];)n++;if(n>0)return e.slice(0,n)+BB(t.slice(n),e.slice(n),r)}const s=t?r.indexOf(t[0]):0,o=e!=null?r.indexOf(e[0]):r.length;if(o-s>1){const n=Math.round(.5*(s+o));return r[n]}else return e&&e.length>1?e.slice(0,1):r[s]+BB(t.slice(1),null,r)}function J_t(t){if(t.length!==Q_t(t[0]))throw new Error("invalid integer part of order key: "+t)}function Q_t(t){if(t>="a"&&t<="z")return t.charCodeAt(0)-97+2;if(t>="A"&&t<="Z")return 90-t.charCodeAt(0)+2;throw new Error("invalid order key head: "+t)}function pU(t){const e=Q_t(t[0]);if(e>t.length)throw new Error("invalid order key: "+t);return t.slice(0,e)}function tbt(t,e){if(t==="A"+e[0].repeat(26))throw new Error("invalid order key: "+t);const r=pU(t);if(t.slice(r.length).slice(-1)===e[0])throw new Error("invalid order key: "+t)}function ebt(t,e){J_t(t);const[r,...i]=t.split("");let s=!0;for(let o=i.length-1;s&&o>=0;o--){const n=e.indexOf(i[o])+1;
10294n===e.length?i[o]=e[0]:(i[o]=e[n],s=!1)}if(s){if(r==="Z")return"a"+e[0];if(r==="z")return null;const o=String.fromCharCode(r.charCodeAt(0)+1);return o>"a"?i.push(e[0]):i.pop(),o+i.join("")}else return r+i.join("")}function Zse(t,e){J_t(t);const[r,...i]=t.split("");let s=!0;for(let o=i.length-1;s&&o>=0;o--){const n=e.indexOf(i[o])-1;n===-1?i[o]=e.slice(-1):(i[o]=e[n],s=!1)}if(s){if(r==="a")return"Z"+e.slice(-1);if(r==="A")return null;const o=String.fromCharCode(r.charCodeAt(0)-1);return o<"Z"?i.push(e.slice(-1)):i.pop(),o+i.join("")}else return r+i.join("")}function OB(t,e,r=Z_t){if(t!=null&&tbt(t,r),e!=null&&tbt(e,r),t!=null&&e!=null&&t>=e)throw new Error(t+" >= "+e);if(t==null){if(e==null)return"a"+r[0];const l=pU(e),c=e.slice(l.length);if(l==="A"+r[0].repeat(26))return l+BB("",c,r);if(l<e)return l;const h=Zse(l,r);if(h==null)throw new Error("cannot decrement any more");return h}if(e==null){const l=pU(t),c=t.slice(l.length);return ebt(l,r)??l+BB(c,null,r)}const i=pU(t),s=t.slice(i.length),o=pU(e),n=e.slice(o.length);if(i===o)return i+BB(s,n,r);const a=ebt(i,r);if(a==null)throw new Error("cannot increment any more");return a<e?a:i+BB(s,null,r)}function WJ(t,e,r,i=Z_t){if(r===0)return[];if(r===1)return[OB(t,e,i)];if(e==null){let n=OB(t,e,i);const a=[n];for(let l=0;l<r-1;l++)n=OB(n,e,i),a.push(n);return a}if(t==null){let n=OB(t,e,i);const a=[n];for(let l=0;l<r-1;l++)n=OB(t,n,i),a.push(n);return a.reverse(),a}const s=Math.floor(r/2),o=OB(t,e,i);return[...WJ(t,o,s,i),o,...WJ(o,e,r-s-1,i)]}function rbt(t,e){return t.read(Ls).value-e.read(Ls).value}class ibt extends We{constructor(){super(),this.transforms=this.query(e=>e.added.with(_e)),this.zIndexes=this.query(e=>e.added.and.changed.with(Ls).trackWrites),this.query(e=>e.using(Ls,Gs).write.and.using(ze,be,jt).read)}execute(){this.transforms.added.forEach(i=>{nt(i,Ls)});const e=new Map,r=i=>{if(i.has(jt))return;const s=En(i);let o=e.get(s);o||(o=new Set,e.set(s,o)),o.add(i)};this.zIndexes.added.forEach(r),this.zIndexes.changed.forEach(r),e.forEach((i,s)=>{const o=Ov(s,rbt);this.reconcileFractionalIndices(o,i)})}reconcileFractionalIndices(e,r){const i=e.length;let s=0;for(;s<i;){if(!r.has(e[s])){s++;continue}let o=s;for(;o<i&&r.has(e[o]);)o++;const n=s-1>=0?e[s-1]:null,a=o<i?e[o]:null,l=(n==null?void 0:n.has(Gs))&&n.read(Gs).value||null,c=(a==null?void 0:a.has(Gs))&&a.read(Gs).value||null,h=WJ(l,c,o-s);for(let u=s;u<o;u++)nt(e[u],Gs,{value:h[u-s]});s=o}}}class IB extends We{constructor(){super(...arguments),this.entities=this.query(e=>e.current.with(Tn).usingAll.write),this.viewportCulling=this.attach(cG),this.canvases=this.query(e=>e.current.with(wt).read)}execute(){for(const r of this.entities.current)this.viewportCulling.remove(r);for(const r of this.entities.current)r.delete();const e=this.canvases.current.map(r=>r.read(wt).api);for(const r of e)r==null||r.flushPendingTasks();for(const r of e)r==null||r.flushAfterDeleteTasks()}}var jJ=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},gU;nG=class extends We{constructor(){super(),this.commands=new nE(this),this.highlighted=this.query(t=>t.added.and.removed.with(Us)),this.bounds=this.query(t=>t.changed.with(fe).trackWrites),gU.set(this,new WeakMap),this.query(t=>t.using(fe,Pe,wt,jt,Gs,Nt,je,fh).read.and.using(wt,Ae,Ii,Us,_e,ze,be,Zi,Ce,Gt,Fs,$t,et,ae,xt,_t,Mt,Yt,Js,ai,Ls,Xc,Qn,Tn,wo,he).write)}execute(){this.highlighted.removed.forEach(t=>{if(!nr(t))return;const e=En(t);nr(e)&&this.remove(t,e)}),this.highlighted.added.forEach(t=>{if(!nr(t))return;const e=En(t);nr(e)&&e.has(jt)&&this.createOrUpdate(t,e)}),this.bounds.changed.forEach(t=>{if(!nr(t))return;let e=t;for(;e&&nr(e);){if(e.has(Us)){const i=En(e);nr(i)&&i.has(jt)&&this.createOrUpdate(e,i);break}if(!e.has(be))break;const r=e.read(be).parent;if(!r||!nr(r))break;e=r}})}createOrUpdate(t,e){if(!nr(t)||!nr(e)||!e.has(jt)||!t.has(fe))return;if(N2(t)){this.remove(t,e);return}const{canvas:r}=e.read(jt);if(!(r!=null&&r.has(wt)))return;const{selectionOBB:i,transformOBB:s}=t.read(fe),o=t.has(_t)||t.has(xt)||t.has(Mt)||t.has(ai)?s:i,{x:n,y:a,width:l,height:c,rotation:h,scaleX:u,scaleY:d}=o;let f=jJ(this,gU,"f").get(t);if(f||(f=this.commands.spawn(new Ii(va.HIGHLIGHTER),new _e,new Zi,new Fs([{type:"solid",value:Zs,opacity:1}]),new Gt({width:2}),new Ls(ij),new Qn,new he).id().hold(),this.commands.entity(e).appendChild(this.commands.entity(f)),this.commands.execute(),jJ(this,gU,"f").set(t,f)),Zr(f,Ae),Zr(f,et),Zr
10294(f,ae),Zr(f,$t),Zr(f,xt),Zr(f,_t),f.write(he).value="visible",Object.assign(f.write(_e),{translation:{x:n,y:a},rotation:h,scale:{x:u,y:d}}),t.has(et)){nt(f,et);const{cx:g,cy:p,r:m}=t.read(et);Object.assign(f.write(et),{cx:g,cy:p,r:m})}else if(t.has(ae)){nt(f,ae);const{cx:g,cy:p,rx:m,ry:v}=t.read(ae);Object.assign(f.write(ae),{cx:g,cy:p,rx:m,ry:v})}else if(t.has($t))nt(f,$t),Object.assign(f.write($t),{width:l,height:c});else if(t.has(Js))nt(f,$t),Object.assign(f.write($t),{width:l,height:c});else if(t.has(xt)){nt(f,xt);const{d:g}=t.read(xt);Object.assign(f.write(xt),{d:g})}else if(t.has(_t)){nt(f,_t);const{points:g}=t.read(_t);Object.assign(f.write(_t),{points:g})}else if(t.has(Mt)){nt(f,_t);const{x1:g,y1:p,x2:m,y2:v}=t.read(Mt);Object.assign(f.write(_t),{points:[[g,p],[m,v]]})}else if(t.has(ai)){nt(f,_t);const{points:g}=t.read(ai);Object.assign(f.write(_t),{points:g.map(p=>[p.x,p.y])})}else if(t.has(Yt)){nt(f,_t);const{selectionOBB:{width:g,height:p}}=t.read(fe);Object.assign(f.write(_t),{points:[[0,p],[g,p]]})}Sr(f),_h(f)}remove(t,e){if(!nr(t))return;const r=jJ(this,gU,"f").get(t);!r||!nr(r)||(r.write(he).value="hidden")}},gU=new WeakMap;const Dc=[];for(let t=0;t<256;++t)Dc.push((t+256).toString(16).slice(1));function Jse(t,e=0){return(Dc[t[e+0]]+Dc[t[e+1]]+Dc[t[e+2]]+Dc[t[e+3]]+"-"+Dc[t[e+4]]+Dc[t[e+5]]+"-"+Dc[t[e+6]]+Dc[t[e+7]]+"-"+Dc[t[e+8]]+Dc[t[e+9]]+"-"+Dc[t[e+10]]+Dc[t[e+11]]+Dc[t[e+12]]+Dc[t[e+13]]+Dc[t[e+14]]+Dc[t[e+15]]).toLowerCase()}const Qse=new Uint8Array(16);function toe(){return crypto.getRandomValues(Qse)}oc=function(t,e,r){return crypto.randomUUID?crypto.randomUUID():eoe(t)};function eoe(t,e,r){var s;t=t||{};const i=t.random??((s=t.rng)==null?void 0:s.call(t))??toe();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Jse(i)}const sbt={[vt.DRAW_RECT]:"rect",[vt.DRAW_TRIANGLE]:"path",[vt.DRAW_PENTAGON]:"path",[vt.DRAW_HEXAGON]:"path",[vt.DRAW_ELLIPSE]:"ellipse",[vt.DRAW_LINE]:"polyline",[vt.DRAW_ARROW]:"polyline",[vt.DRAW_ROUGH_RECT]:"rough-rect",[vt.DRAW_ROUGH_ELLIPSE]:"rough-ellipse",[vt.DRAW_ROUGH_LINE]:"rough-polyline",[vt.DRAW_ICONFONT]:"iconfont"};class XJ extends We{constructor(){super(),this.cameras=this.query(e=>e.current.with(jt).read),this.selections=new Map,this.query(e=>e.using(fe,Pe,so).read.update.and.using(wt,Ae,xa,le,_o,jt,Ii,ks,Us,_e,ze,be,Zi,Ce,bo,Gt,$t,et,ae,xt,_t,he,Ls,Qn,Xc,Nt,ba,qo).write)}execute(){this.cameras.current.forEach(e=>{if(!e.has(jt))return;const{canvas:r}=e.read(jt);if(!r)return;const{inputPoints:i,api:s}=r.read(wt),o=s.getAppState(),n=o.penbarSelected,a={[vt.DRAW_RECT]:o.penbarDrawRect,[vt.DRAW_TRIANGLE]:o.penbarDrawTriangle,[vt.DRAW_PENTAGON]:o.penbarDrawPentagon,[vt.DRAW_HEXAGON]:o.penbarDrawHexagon,[vt.DRAW_ELLIPSE]:o.penbarDrawEllipse,[vt.DRAW_LINE]:o.penbarDrawLine,[vt.DRAW_ROUGH_RECT]:o.penbarDrawRoughRect,[vt.DRAW_ROUGH_ELLIPSE]:o.penbarDrawRoughEllipse,[vt.DRAW_ROUGH_LINE]:o.penbarDrawRoughLine,[vt.DRAW_ICONFONT]:o.penbarDrawIconfont};if(n===vt.DRAW_ARROW||n!==vt.DRAW_RECT&&n!==vt.DRAW_TRIANGLE&&n!==vt.DRAW_PENTAGON&&n!==vt.DRAW_HEXAGON&&n!==vt.DRAW_ELLIPSE&&n!==vt.DRAW_LINE&&n!==vt.DRAW_ROUGH_RECT&&n!==vt.DRAW_ROUGH_ELLIPSE&&n!==vt.DRAW_ROUGH_LINE&&n!==vt.DRAW_ICONFONT)return;const l=r.write(le),c=r.write(_o);c.value="crosshair";let h=this.selections.get(e.__id);if(!h&&(h={rectBrush:void 0,triangleBrush:void 0,pentagonBrush:void 0,hexagonBrush:void 0,ellipseBrush:void 0,lineBrush:void 0,arrowBrush:void 0,roughRectBrush:void 0,roughEllipseBrush:void 0,roughLineBrush:void 0,iconFontBrush:void 0,label:Pr.get().getDocument().createElement("div"),x:0,y:0,width:0,height:0},this.selections.set(e.__id,h),Zo)){const{label:u}=h;Wz(u),s.getSvgLayer().appendChild(h.label)}if(i.forEach(u=>{const d=u.write(xa),{prevPoint:[f,g]}=d,[p,m]=l.pointerViewport;if(f===p&&g===m)return;const v=l.shiftKey||n===vt.DRAW_ICONFONT;s.runAtNextTick(()=>{this.handleBrushing(s,n,p,m,a[n===vt.DRAW_ICONFONT?vt.DRAW_RECT:n],v)})}),l.key==="Escape"&&this.hideBrush(s,h),l.pointerUpTrigger){const u=this.selections.get(e.__id);if(Zo&&u.label.style.visibility==="hidden")return;const{x:d,y:f,width:g,height:p}=u;if(!this.getBrush(u,n)||g===0&&p===0)return;s.runAtNextTick(()=>{this.hideBrush(s,u);const m=s.getNodes().reduce((b,y)=>{var _;return Math.max(b,(_=y.zIndex)!==null&&_!==void 0?_:0)},0),v=Object.assign({id:oc(),type:sbt[n],version:0,zIndex:m+1},a[n],n===vt.DRAW_LINE||n===vt.DRAW_ROUGH_LINE?{points:`${d},${f} ${d+g},${f+p}`}:n===vt.DRAW_TRIANGLE||n===vt.DRAW_PENTAGON||n===vt.DRAW_HEXAGON?(()=>{const b=n===vt.DRAW_TRIANGLE?3:n===vt.DRAW_PENTAGON?5:6,y=Rne(b,g,p);return y?{x:d+y.offsetX,y:f+y.offsetY,width:y.width,height:y.height,d:y.d}:{x:d,y:f,width:g,height:p,d:bwt(b,g,p)}})():n===vt.DRAW_ICONFONT?{x:d,y:f,width:g,height:p,lockAspectRatio:!0}:{x:d,y:f,width:g,height:p});s.setAppState({penbarSelected:vt.SELECT}),s.updateNode(v),s.selectNodes([v]),s.record(),Zo&&s.element.dispatchEvent(new CustomEvent("ic-rect-drawn",{detail:{node:v}}))})}})}
10294finalize(){this.selections.forEach(e=>{e.label.remove()}),this.selections.clear()}handleBrushing(e,r,i,s,o,n=!1){const a=e.getCamera(),l=this.selections.get(a.__id),{pointerDownViewportX:c,pointerDownViewportY:h,pointerDownCanvasX:u,pointerDownCanvasY:d}=a.read(so);if(Sa(i,s,c,h)>10){let f=r===vt.DRAW_RECT?l.rectBrush:r===vt.DRAW_TRIANGLE?l.triangleBrush:r===vt.DRAW_PENTAGON?l.pentagonBrush:r===vt.DRAW_HEXAGON?l.hexagonBrush:r===vt.DRAW_ROUGH_RECT?l.roughRectBrush:r===vt.DRAW_ELLIPSE?l.ellipseBrush:r===vt.DRAW_LINE?l.lineBrush:r===vt.DRAW_ROUGH_ELLIPSE?l.roughEllipseBrush:r===vt.DRAW_ROUGH_LINE?l.roughLineBrush:r===vt.DRAW_ICONFONT?l.iconFontBrush:l.arrowBrush;f||(f=Object.assign({id:oc(),type:sbt[r===vt.DRAW_ICONFONT?vt.DRAW_RECT:r],visibility:"hidden",zIndex:g2,strokeAttenuation:!0},r===vt.DRAW_LINE||r===vt.DRAW_ROUGH_LINE?{points:"0,0 0,0"}:r===vt.DRAW_TRIANGLE||r===vt.DRAW_PENTAGON||r===vt.DRAW_HEXAGON?{x:0,y:0,width:0,height:0,d:""}:{x:0,y:0,width:0,height:0}),e.updateNode(f,void 0,!1),r===vt.DRAW_RECT?l.rectBrush=f:r===vt.DRAW_ROUGH_RECT?l.roughRectBrush=f:r===vt.DRAW_TRIANGLE?l.triangleBrush=f:r===vt.DRAW_PENTAGON?l.pentagonBrush=f:r===vt.DRAW_HEXAGON?l.hexagonBrush=f:r===vt.DRAW_ELLIPSE?l.ellipseBrush=f:r===vt.DRAW_LINE?l.lineBrush=f:r===vt.DRAW_ROUGH_ELLIPSE?l.roughEllipseBrush=f:r===vt.DRAW_ROUGH_LINE?l.roughLineBrush=f:r===vt.DRAW_ICONFONT?l.iconFontBrush=f:l.arrowBrush=f,e.getEntity(f).add(Ii,{type:va.BRUSH}));let{x:g,y:p}=e.viewport2Canvas({x:i,y:s}),m=u,v=d;const{snapToPixelGridEnabled:b,snapToPixelGridSize:y}=e.getAppState();b&&(m=oy(m,y),v=oy(v,y),g=oy(g,y),p=oy(p,y));let _=g-m,w=p-v;const E=r===vt.DRAW_LINE||r===vt.DRAW_ROUGH_LINE,A=r===vt.DRAW_TRIANGLE||r===vt.DRAW_PENTAGON||r===vt.DRAW_HEXAGON,x=r===vt.DRAW_ICONFONT;E||((n||x)&&(Math.abs(_)>Math.abs(w)?_=Math.sign(_)*Math.abs(w):w=Math.sign(w)*Math.abs(_)),_<0&&(m+=_,_=-_),w<0&&(v+=w,w=-w)),e.updateNode(f,r===vt.DRAW_LINE||r===vt.DRAW_ROUGH_LINE?Object.assign(Object.assign({},o),{visibility:"visible",points:`${m},${v} ${g},${p}`}):A?Object.assign(Object.assign({},o),{visibility:"visible",x:m,y:v,width:_,height:w,d:bwt(r===vt.DRAW_TRIANGLE?3:r===vt.DRAW_PENTAGON?5:6,_,w)}):Object.assign(Object.assign({},o),{visibility:"visible",x:m,y:v,width:_,height:w}),!1);const{label:S}=l;jz(S,e,{x:m,y:v,width:_,height:w,rotate:E}),l.x=m,l.y=v,l.width=_,l.height=w}}hideBrush(e,r){const i=e.getAppState().penbarSelected,s=this.getBrush(r,i);s&&e.updateNode(s,{visibility:"hidden"},!1),NS(r.label)}getBrush(e,r){const{rectBrush:i,triangleBrush:s,pentagonBrush:o,hexagonBrush:n,roughRectBrush:a,roughEllipseBrush:l,ellipseBrush:c,lineBrush:h,roughLineBrush:u,arrowBrush:d,iconFontBrush:f}=e;return r===vt.DRAW_RECT?i:r===vt.DRAW_TRIANGLE?s:r===vt.DRAW_PENTAGON?o:r===vt.DRAW_HEXAGON?n:r===vt.DRAW_ROUGH_RECT?a:r===vt.DRAW_ROUGH_ELLIPSE?l:r===vt.DRAW_ELLIPSE?c:r===vt.DRAW_LINE?h:r===vt.DRAW_ROUGH_LINE?u:r===vt.DRAW_ICONFONT?f:d}}function Wz(t,e={}){Zo&&(t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.padding="4px",t.style.borderRadius="4px",t.style.backgroundColor=Zs,t.style.color="white",t.style.visibility="hidden",Object.assign(t.style,e))}function NS(t){Zo&&(t.style.visibility="hidden")}function jz(t,e,{x:r,y:i,width:s,height:o,rotate:n,rotation:a}){if(Zo)if(e.getAppState().penbarDrawSizeLabelVisible&&(t.style.visibility="visible"),t.innerText=`${Math.round(Math.abs(s))} \xD7 ${Math.round(Math.abs(o))}`,n){const{x:l,y:c}=e.canvas2Viewport({x:r+s/2,y:i+o/2});t.style.top=`${c}px`,t.style.left=`${l}px`;let h=Math.atan2(o,s)*(180/Math.PI);h>=90&&h<=180?h=h-180:h<=-90&&h>=-180&&(h=h+180),t.style.transform=`translate(-50%, -50%) rotate(${h}deg)`}else if(a){const l=Math.cos(a),c=Math.sin(a),h=[{mx:s/2,my:o,nx:0,ny:1},{mx:s/2,my:0,nx:0,ny:-1},{mx:s,my:o/2,nx:1,ny:0},{mx:0,my:o/2,nx:-1,ny:0}];let u=h[0],d=-1/0;for(const _ of h){const w=_.nx*c+_.ny*l;w>d&&(d=w,u=_)}const f=r+u.mx*l-u.my*c,g=i+u.mx*c+u.my*l,{x:p,y:m}=e.canvas2Viewport({x:f,y:g});t.style.top=`${m}px`,t.style.left=`${p}px`;const v=u.nx*l-u.ny*c,b=u.nx*c+u.ny*l,y=Math.atan2(-v,b)*(180/Math.PI);t.style.transform=`translate(-50%, 8px) rotate(${y}deg)`}else{const{x:l,y:c}=e.canvas2Viewport({x:r+s/2,y:i+o});t.style.top=`${c}px`,t.style.left=`${l}px`,t.style.transform="translate(-50%, 8px)"}}function obt(t,e,{x:r,y:i,text:s,viewportYOffset:o=0}){if(Zo){if(!e.getAppState().penbarNameLabelVisible){t.style.visibility="hidden";return}t.style.visibility="visible",t.style.pointerEvents="none",t.innerText=s;const{x:n,y:a}=e.canvas2Viewport({x:r,y:i});t.style.top=`${a+o}px`,t.style.left=`${n}px`,t.style.transform="translate(4px, 4px)"}}var kw=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Ey;function roe(t){const{selectionOBB:e,transformOBB:r}=t.read(fe);return t.has(_t)||t.has(xt)||t.has(Mt)||t.has(ai)?r:e}class nbt extends We{constructor(){super(),Ey.set(this,new Map),this.named=this.query(e=>e.current.with(ba,fe).read),this.removed=this.query(e=>e.removed.with(ba)),this.query(e=>e.using(Pe,fe,ba,jt,wt,Ii,he,jc,be,ze,_t,xt,Mt,ai,Js,ks,Us).read)}
10294execute(){Zo&&(this.removed.removed.forEach(e=>{const r=kw(this,Ey,"f").get(e.__id);r&&(r.remove(),kw(this,Ey,"f").delete(e.__id))}),this.named.current.forEach(e=>{if(e.has(Ii))return;const{value:r}=e.read(ba);if(!(r!=null&&r.trim())){const h=kw(this,Ey,"f").get(e.__id);h&&NS(h);return}if(e.has(he)&&e.read(he).value==="hidden"){const h=kw(this,Ey,"f").get(e.__id);h&&NS(h);return}if(e.has(jc)){const h=kw(this,Ey,"f").get(e.__id);h&&NS(h);return}if(!e.has(ks)&&!e.has(Us)){const h=kw(this,Ey,"f").get(e.__id);h&&NS(h);return}const i=En(e),{canvas:s}=i.read(jt);if(!s)return;const{api:o}=s.read(wt),n=o.getSvgLayer();if(!n)return;const{x:a,y:l}=roe(e);let c=kw(this,Ey,"f").get(e.__id);c||(c=Pr.get().getDocument().createElement("div"),Wz(c,{display:"block",maxWidth:"100px",boxSizing:"border-box",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",backgroundColor:"transparent",color:Zs,padding:"0"}),c.style.zIndex="1",n.appendChild(c),kw(this,Ey,"f").set(e.__id,c)),obt(c,o,{x:a,y:l,text:r,viewportYOffset:-24})}))}}Ey=new WeakMap;class zJ extends We{constructor(){super(),this.cameras=this.query(e=>e.current.with(jt).read),this.states=new Map,this.query(e=>e.using(fe,Pe,so,Gs,dl).read.update.and.using(wt,Ae,_e,xa,le,_o,jt,Ii,Zi,$t,et,Mt,_t,xt,ae,Ce,Gt,Fs,yi,Us,qo,bo,Ls,he,ba,be,ze,tu,ks,Nt,Js,Wl,hl,cl,Tn,wo,ul,mh,ue).write)}execute(){this.cameras.current.forEach(e=>{var r,i,s,o,n,a;if(!e.has(jt))return;const{canvas:l}=e.read(jt);if(!l)return;const{inputPoints:c,api:h}=l.read(wt);if(h.getAppState().penbarSelected!==vt.DRAW_ARROW){const g=this.states.get(e.__id);g&&this.clearArrowConnectState(h,g),this.states.delete(e.__id);return}const u=l.read(le),d=l.write(_o);d.value="crosshair";let f=this.states.get(e.__id);if(f||(f={phase:"idle"},this.states.set(e.__id,f)),u.pointerDownTrigger){const[g,p]=u.pointerViewport,{x:m,y:v}=h.viewport2Canvas({x:g,y:p}),b=this.pickBindTarget(h,m,v);if(!b){if(f.phase==="picked_source"){const y=h.getAppState().penbarDrawArrow,_=h.getNodes().reduce((w,E)=>{var A;return Math.max(w,(A=E.zIndex)!==null&&A!==void 0?A:0)},0);if(f.sourceId){const w=h.getNodeById(f.sourceId);if(!w){this.clearArrowConnectState(h,f),h.highlightNodes([]);return}const E=Object.assign(Object.assign({id:oc()},y),{type:"path",version:0,zIndex:_+1,fromId:w.id,exitX:f.exitX,exitY:f.exitY,exitPerimeter:(r=f.exitPerimeter)!==null&&r!==void 0?r:!0,exitDx:(i=f.exitDx)!==null&&i!==void 0?i:0,exitDy:(s=f.exitDy)!==null&&s!==void 0?s:0,targetPoint:{x:m,y:v},edgeStyle:qh.ORTHOGONAL,curved:!0,bezier:!0});this.finishArrowEdge(h,f,E)}else if(f.sourceCanvas){const w=Object.assign(Object.assign({id:oc()},y),{type:"path",version:0,zIndex:_+1,sourcePoint:Object.assign({},f.sourceCanvas),targetPoint:{x:m,y:v},edgeStyle:qh.ORTHOGONAL,curved:!0});this.finishArrowEdge(h,f,w)}else this.clearArrowConnectState(h,f);this.clearArrowConnectState(h,f),h.highlightNodes([]);return}if(f.phase==="idle"){f.phase="picked_source",f.sourceCanvas={x:m,y:v},delete f.sourceId,delete f.exitX,delete f.exitY,delete f.exitPerimeter,delete f.exitDx,delete f.exitDy,h.highlightNodes([]);return}}if(f.phase==="idle"){const y=uU(b,m,v);f.phase="picked_source",f.sourceId=b.id,delete f.sourceCanvas,f.exitX=y.x,f.exitY=y.y,f.exitPerimeter=y.perimeter,f.exitDx=y.dx,f.exitDy=y.dy;return}if(f.phase==="picked_source"){if(f.sourceId&&b.id===f.sourceId)return;const y=uU(b,m,v),_=h.getAppState().penbarDrawArrow,w=h.getNodes().reduce((E,A)=>{var x;return Math.max(E,(x=A.zIndex)!==null&&x!==void 0?x:0)},0);if(f.sourceId){const E=h.getNodeById(f.sourceId),A=b;if(!E){this.clearArrowConnectState(h,f),h.highlightNodes([]);return}const x=Object.assign(Object.assign({id:oc()},_),{type:"path",version:0,zIndex:w+1,fromId:E.id,toId:A.id,exitX:f.exitX,exitY:f.exitY,exitPerimeter:(o=f.exitPerimeter)!==null&&o!==void 0?o:!0,exitDx:(n=f.exitDx)!==null&&n!==void 0?n:0,exitDy:(a=f.exitDy)!==null&&a!==void 0?a:0,entryX:y.x,entryY:y.y,entryPerimeter:y.perimeter,entryDx:y.dx,entryDy:y.dy,edgeStyle:qh.ORTHOGONAL,curved:!0,bezier:!0});this.finishArrowEdge(h,f,x)}else if(f.sourceCanvas){const E=b,A=Object.assign(Object.assign({id:oc()},_),{type:"path",version:0,zIndex:w+1,sourcePoint:Object.assign({},f.sourceCanvas),toId:E.id,entryX:y.x,entryY:y.y,entryPerimeter:y.perimeter,entryDx:y.dx,entryDy:y.dy,edgeStyle:qh.ORTHOGONAL,curved:!0,bezier:!0});this.finishArrowEdge(h,f,A)}this.clearArrowConnectState(h,f),h.highlightNodes([])}}if(e.has(Pe)&&(c.length===0||f.phase==="picked_source")){const[g,p]=u.pointerViewport;if(f.pointerMoveViewportX!==g&&f.pointerMoveViewportY!==p){f.pointerMoveViewportX=g,f.pointerMoveViewportY=p;const{x:m,y:v}=h.viewport2Canvas({x:g,y:p});f.pointerMoveCanvasX=m,f.pointerMoveCanvasY=v;const b=this.pickBindTarget(h,m,v);f.bindTarget=b,f.phase==="idle"?b?h.highlightNodes([b]):h.highlightNodes([]):b&&b.id!==f.sourceId?h.highlightNodes([b]):b&&b.id===f.sourceId?h.highlightNodes([b]):h.highlightNodes([]),f.phase==="picked_source"&&this.syncArrowPreview(h,f,m,v,b)}}u.key==="Escape"&&(this.clearArrowConnectState(h,f),h.highlightNodes([])),u.pointerUpTrigger})}finishArrowEdge(e,r,i){this.removeArrowPreview(e,r),e.runAtNextTick(()=>{e.setAppState({penbarSelected:vt.SELECT}),e.updateNode(i),e.selectNodes([i]),e.record()})}removeArrowPreview(e,r){r.previewEdgeId&&(e.deleteNodesById([r.previewEdgeId]),delete r.previewEdgeId)}syncArrowPreview(e,r,i,s,o){var n,a,l,c,h,u,d,f,g;if(r.phase!=="picked_source")return;const p=e.getAppState().penbarDrawArrow,m=e.getNodes().reduce((A,x)=>{var S;return Math.max(A,(S=x.zIndex)!==null&&S!==void 0?S:0)},0),v=((n=p.strokeOpacity)!==null&&n!==void 0?n:1)*.45,b=(a=r.previewEdgeId)!==null&&a!==void 0?a:oc();r.previewEdgeId||(r.previewEdgeId=b);const y=e.getNodeById(b),_=(l=y==null?void 0:y.version)!==null&&l!==void 0?l:0;let w;if(r.sourceId){const A=e.getNodeById(r.sourceId);if(!A)return;if(o&&o.id!==r.sourceId){const x=uU(o,i,s);w=Object.assign(Object.assign({id:b},p),{type:"path",version:_,zIndex:m+1,fromId:A.id,exitX:r.exitX,exitY:r.exitY,exitPerimeter:(c=r.exitPerimeter)!==null&&c!==void 0?c:!0,exitDx:(h=r.exitDx)!==null&&h!==void 0?h:0,exitDy:(u=r.exitDy)!==null&&u!==void 0?u:0,toId:o.id,entryX:x.x,entryY:x.y,entryPerimeter:x.perimeter,entryDx:x.dx,entryDy:x.dy,edgeStyle:qh.ORTHOGONAL,curved:!0,bezier:!0,strokeOpacity:v})}else w=Object.assign(Object.assign({id:b},p),{type:"path",version:_,zIndex:m+1,fromId:A.id,exitX:r.exitX,exitY:r.exitY,exitPerimeter:(d=r.exitPerimeter)!==null&&d!==void 0?d:!0,exitDx:(f=r.exitDx)!==null&&f!==void 0?f:0,exitDy:(g=r.exitDy)!==null&&g!==void 0?g:0,targetPoint:{x:i,y:s},edgeStyle:qh.ORTHOGONAL,curved:!0,bezier:!0,strokeOpacity:v})}else if(r.sourceCanvas)if(o){const A=uU(o,i,s);w=Object.assign(Object.assign({id:b},p),{type:"path",version:_,zIndex:m+1,sourcePoint:Object.assign({},r.sourceCanvas),toId:o.id,entryX:A.x,entryY:A.y,entryPerimeter:A.perimeter,entryDx:A.dx,entryDy:A.dy,edgeStyle:qh.ORTHOGONAL,curved:!0,bezier:!0,strokeOpacity:v})}else w=Object.assign(Object.assign({id:b},p),{type:"path",version:_,zIndex:m+1,sourcePoint:Object.assign({},r.sourceCanvas),targetPoint:{x:i,y:s},edgeStyle:qh.ORTHOGONAL,curved:!0,bezier:!0,strokeOpacity:v});else return;e.updateNode(w);const E=e.getEntity(w);Sr(E),_h(E)}clearArrowConnectState(e,r){this.removeArrowPreview(e,r),r.phase="idle",delete r.sourceId,delete r.sourceCanvas,delete r.exitX,delete r.exitY,delete r.exitPerimeter,delete r.exitDx,delete r.exitDy}pickBindTarget(e,r,i){const s=e.elementsFromPoint({x:r,y:i});for(const o of s){if(o.has(Ii)||!o.has($t)&&!o.has(ae))continue;const n=e.getNodeByEntity(o);if(!n)continue;const a=n.type;if(a==="rect"||a==="ellipse"||a==="rough-rect"||a==="rough-ellipse")return n}}}function abt(t,e,r,i=s=>s){return t*i(.5-e*(.5-r))}function ioe(t){return[-t[0],-t[1]]}function jg(t,e){return[t[0]+e[0],t[1]+e[1]]}function qf(t,e){return[t[0]-e[0],t[1]-e[1]]}function Xg(t,e){return[t[0]*e,t[1]*e]}function soe(t,e){return[t[0]/e,t[1]/e]}function mU(t){return[t[1],-t[0]]}function lbt(t,e){return t[0]*e[0]+t[1]*e[1]}function ooe(t,e){return t[0]===e[0]&&t[1]===e[1]}function noe(t){return Math.hypot(t[0],t[1])}function aoe(t){return t[0]*t[0]+t[1]*t[1]}function cbt(t,e){return aoe(qf(t,e))}function hbt(t){return soe(t,noe(t))}function loe(t,e){return Math.hypot(t[1]-e[1],t[0]-e[0])}function yU(t,e,r){let i=Math.sin(r),s=Math.cos(r),o=t[0]-e[0],n=t[1]-e[1],a=o*s-n*i,l=o*i+n*s;return[a+e[0],l+e[1]]}function VJ(t,e,r){return jg(t,Xg(qf(e,t),r))}function ubt(t,e,r){return jg(t,Xg(e,r))}var{min:DB,PI:coe}=Math,dbt=.275,vU=coe+1e-4;function hoe(t,e={}){let{size:r=16,smoothing:i=.5,thinning:s=.5,simulatePressure:o=!0,easing:n=H=>H,start:a={},end:l={},last:c=!1}=e,{cap:h=!0,easing:u=H=>H*(2-H)}=a,{cap:d=!0,easing:f=H=>--H*H*H+1}=l;if(t.length===0||r<=0)return[];let g=t[t.length-1].runningLength,p=a.taper===!1?0:a.taper===!0?Math.max(r,g):a.taper,m=l.taper===!1?0:l.taper===!0?Math.max(r,g):l.taper,v=Math.pow(r*i,2),b=[],y=[],_=t.slice(0,10).reduce((H,N)=>{let G=N.pressure;if(o){let Y=DB(1,N.distance/r),q=DB(1,1-Y);G=DB(1,H+(q-H)*(Y*dbt))}return(H+G)/2},t[0].pressure),w=abt(r,s,t[t.length-1].pressure,n),E,A=t[0].vector,x=t[0].point,S=x,T=x,R=S,B=!1;for(let H=0;H<t.length;H++){let{pressure:N}=t[H],{point:G,vector:Y,distance:q,runningLength:L}=t[H];
10294if(H<t.length-1&&g-L<3)continue;if(s){if(o){let Ht=DB(1,q/r),Lt=DB(1,1-Ht);N=DB(1,_+(Lt-_)*(Ht*dbt))}w=abt(r,s,N,n)}else w=r/2;E===void 0&&(E=w);let J=L<p?u(L/p):1,tt=g-L<m?f((g-L)/m):1;w=Math.max(.01,w*Math.min(J,tt));let bt=(H<t.length-1?t[H+1]:t[H]).vector,ct=H<t.length-1?lbt(Y,bt):1,Xt=lbt(Y,A)<0&&!B,It=ct!==null&&ct<0;if(Xt||It){let Ht=Xg(mU(A),w);for(let Lt=1/13,tr=0;tr<=1;tr+=Lt)T=yU(qf(G,Ht),G,vU*tr),b.push(T),R=yU(jg(G,Ht),G,vU*-tr),y.push(R);x=T,S=R,It&&(B=!0);continue}if(B=!1,H===t.length-1){let Ht=Xg(mU(Y),w);b.push(qf(G,Ht)),y.push(jg(G,Ht));continue}let zt=Xg(mU(VJ(bt,Y,ct)),w);T=qf(G,zt),(H<=1||cbt(x,T)>v)&&(b.push(T),x=T),R=jg(G,zt),(H<=1||cbt(S,R)>v)&&(y.push(R),S=R),_=N,A=Y}let O=t[0].point.slice(0,2),C=t.length>1?t[t.length-1].point.slice(0,2):jg(t[0].point,[1,1]),F=[],U=[];if(t.length===1){if(!(p||m)||c){let H=ubt(O,hbt(mU(qf(O,C))),-(E||w)),N=[];for(let G=1/13,Y=G;Y<=1;Y+=G)N.push(yU(H,O,vU*2*Y));return N}}else{if(!(p||m&&t.length===1))if(h)for(let N=1/13,G=N;G<=1;G+=N){let Y=yU(y[0],O,vU*G);F.push(Y)}else{let N=qf(b[0],y[0]),G=Xg(N,.5),Y=Xg(N,.51);F.push(qf(O,G),qf(O,Y),jg(O,Y),jg(O,G))}let H=mU(ioe(t[t.length-1].vector));if(m||p&&t.length===1)U.push(C);else if(d){let N=ubt(C,H,w);for(let G=1/29,Y=G;Y<1;Y+=G)U.push(yU(N,C,vU*3*Y))}else U.push(jg(C,Xg(H,w)),jg(C,Xg(H,w*.99)),qf(C,Xg(H,w*.99)),qf(C,Xg(H,w)))}return b.concat(U,y.reverse(),F)}function fbt(t,e={}){var r;let{streamline:i=.5,size:s=16,last:o=!1}=e;if(t.length===0)return[];let n=.15+(1-i)*.85,a=Array.isArray(t[0])?t:t.map(({x:f,y:g,pressure:p=.5})=>[f,g,p]);if(a.length===2){let f=a[1];a=a.slice(0,-1);for(let g=1;g<5;g++)a.push(VJ(a[0],f,g/4))}a.length===1&&(a=[...a,[...jg(a[0],[1,1]),...a[0].slice(2)]]);let l=[{point:[a[0][0],a[0][1]],pressure:a[0][2]>=0?a[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],c=!1,h=0,u=l[0],d=a.length-1;for(let f=1;f<a.length;f++){let g=o&&f===d?a[f].slice(0,2):VJ(u.point,a[f],n);if(ooe(u.point,g))continue;let p=loe(g,u.point);if(h+=p,f<d&&!c){if(h<s)continue;c=!0}u={point:g,pressure:a[f][2]>=0?a[f][2]:.5,vector:hbt(qf(u.point,g)),distance:p,runningLength:h},l.push(u)}return l[0].vector=((r=l[1])==null?void 0:r.vector)||[0,0],l}function pbt(t,e={}){return hoe(fbt(t,e),e)}const uoe='url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAKOSURBVHgB7VY7jBJRFH2Dk2VgIYp8AobYSEFCY2JpY0NBZ2MtJoSSBAjh0wANnZQmUEJNAR0lgcYWAwQsVLZhlV/4GJCded47wopZ0HVn2G04yQl5P865nzczhBxxxBHSwVxzbicURAa4XC5lt9tNU0o/wu9bGJ/8jwkpYBKJBAfCnzKZDNXr9bRQKMCQfna73dyhTTB+v18FYt1oNEo5juOr1So9PT3lcYzzhzRxRXw0GqEoHQ6H4nht4sshTFyKh8Nhqlar+clkQgVBoDzPiybQDJrIZrO00+m8IzLij8i1Wi0PBmir1RKF0cDGBJbDZDKJWbDZbEoiQxaupB0jb7fbFNZos9kUhTETWAboBaFUKtF6vZ6Hdcm3YmfNUQzZaDREE2hmOp3iupBMJulisTg3Go1PYe2BFAN7G2475VgGLAeURYCrieLfoATP4fxjIEduiL+Kb1KOxHKAASEej4viBoPhBZx/AtTeNPpriW91/WXkcogrvF6vGjv4TsTxIPz3h1gsduviCCafz7/BjmZZlscrdZviYgaKxWImFArRYDB4cPFdr2NmtVoReJCQ2Wz2a5NCQUCXMAxDxuMxsVgsNBKJMMC+1Wp91e/3z2DbVyAeoESiAZxjITKiUql+uwLxwWBAzGazbOIIdsccnc/nPfioIE6nk4Iws1wuxWzkcjmaSqWYQCAgi7gY2I45jcPhsMEzvFoulzWVSoVAvQma8Hg8BOp9ZrfbX/d6PRQ/lyK+zwA+Nh+CiWc+n++lTqd7BD1xAeVga7Xa+3Q6XVQql
10294VMwJFl8nwHsAQ3wPlANxFfpPeAP4AXwO3AAXAAFIhH7rgyaOFmLs+t9/NrExoikyP9lYN8eWUSP2MZP4geL9VfezEoAAAAASUVORK5CYII=") 4 28, pointer';oG=class extends We{constructor(){super(),this.cameras=this.query(t=>t.current.with(jt).read),this.selections=new Map,this.query(t=>t.using(fe,Pe,so,Gs).read.update.and.using(wt,Ae,xa,le,_o,jt,Ii,ks,Us,_e,ze,be,Zi,Ce,bo,Gt,_t,he,Ls,Qn,Nt,ba).write)}execute(){this.cameras.current.forEach(t=>{var e;if(!t.has(jt))return;const{canvas:r}=t.read(jt);if(!r)return;const{inputPoints:i,api:s}=r.read(wt),o=s.getAppState(),n=o.penbarSelected,{freehand:a}=o.penbarPencil;if(n!==vt.PENCIL)return;const l=r.write(le),c=r.write(_o);c.value=uoe;let h=this.selections.get(t.__id);if(h||(this.selections.set(t.__id,{brush:void 0,pointsBeforeSimplify:[],points:[],lastPointInViewport:[0,0]}),h=this.selections.get(t.__id)),l.pointerDownTrigger){h.pointsBeforeSimplify=[],h.points=[];const{pointerDownCanvasX:u,pointerDownCanvasY:d}=t.read(so);h.pointsBeforeSimplify.push({x:u,y:d})}if(i.forEach(u=>{const d=u.write(xa),{prevPoint:[f,g]}=d,[p,m]=l.pointerViewport;f===p&&g===m||s.runAtNextTick(()=>{this.handleBrushing(s,p,m,o.penbarPencil)})}),l.key==="Escape"){const{brush:u}=h;u&&s.updateNode(u,{visibility:"hidden"},!1)}if(l.pointerUpTrigger){const{brush:u}=this.selections.get(t.__id);if(Zo&&u.visibility==="hidden"||!u||((e=u.points)===null||e===void 0?void 0:e.length)===0)return;s.runAtNextTick(()=>{var d;s.updateNode(u,{visibility:"hidden"},!1);const f=s.getNodes().reduce((m,v)=>{var b;return Math.max(m,(b=v.zIndex)!==null&&b!==void 0?b:0)},0),g=Object.assign({id:oc(),version:0,zIndex:f+1},o.penbarPencil),p=h.points.map(m=>[m.x,m.y]);if(a){const m=Mpt(pbt(p));g.type="path",g.d=m,g.fills=[{type:"solid",value:String((d=o.penbarPencil.stroke)!==null&&d!==void 0?d:"#000"),opacity:1}],g.strokeWidth=0,g.tessellationMethod=im.LIBTESS}else g.type="polyline",g.points=ip(p);s.setAppState({penbarSelected:vt.SELECT}),s.updateNode(g),s.selectNodes([g]),s.record(),Zo&&s.element.dispatchEvent(new CustomEvent("ic-pencil-drawn",{detail:{node:g}}))})}})}handleBrushing(t,e,r,i){var s;const{freehand:o}=t.getAppState().penbarPencil,n=t.getCamera(),a=this.selections.get(n.__id),{zoom:l}=n.read(Pe),{pointerDownViewportX:c,pointerDownViewportY:h}=n.read(so);if(Sa(e,r,c,h)>10){let u=a.brush;if(u||(u=Object.assign(o?{id:oc(),type:"path",d:"M 0 0 L 1 1",visibility:"hidden",zIndex:g2}:{id:oc(),type:"polyline",points:"0,0 0,0",visibility:"hidden",zIndex:g2},i),t.updateNode(u,void 0,!1),t.getEntity(u).add(Ii,{type:va.BRUSH}),a.brush=u),Sa(e,r,a.lastPointInViewport[0],a.lastPointInViewport[1])>10){const{x:d,y:f}=t.viewport2Canvas({x:e,y:r});a.pointsBeforeSimplify.push({x:d,y:f}),a.lastPointInViewport=[e,r];const g=1/l;a.points=DV(a.pointsBeforeSimplify,g);const p=a.points.map(m=>[m.x,m.y]);if(p.length<=2)return;t.updateNode(u,o?Object.assign(Object.assign({visibility:"visible",d:Mpt(pbt(p))},i),{strokeWidth:0,fills:[{type:"solid",value:String((s=i.stroke)!==null&&s!==void 0?s:"#000"),opacity:1}],tessellationMethod:im.LIBTESS}):Object.assign({visibility:"visible",points:ip(p)},i),!1)}}}};const doe=10,foe=4,gbt=t=>({x:-t.x,y:-t.y});function mbt(t,e,r,i){return Object.assign(Object.assign({start:t,end:e},r&&{tangentStart:Object.assign({},r)}),i&&{tangentEnd:Object.assign({},i)})}IV=class extends We{constructor(){super(),this.cameras=this.query(t=>t.current.with(jt).read),this.sessions=new WeakMap,this.query(t=>t.using(Pe,fe).read.and.using(wt,ul,le,be,ze,Ae,Nt,ks,_o,_e,Zi,ke,Ce,Fs,Gt,bo,he,ba,Ls,Gs,$t,ae,et,yi,Sn,ue,xt,ko,To,La,mh,Tn,Us).write)}execute(){var t,e,r,i,s;for(const o of this.cameras.current){const n=o.read(jt).canvas;if(!(n!=null&&n.has(wt)))continue;const{api:a}=n.read(wt);if(a.getAppState().penbarSelected!==vt.VECTOR_NETWORK){(t=this.sessions.get(a))===null||t===void 0||t.dispose();continue}let l=this.sessions.get(a);const c=(l==null?void 0:l.nodeId)&&a.getNodeById(l.nodeId);if(l!=null&&l.nodeId&&((c==null?void 0:c.type)!=="vector-network"||c.vertices!==l.vertices||c.segments!==l.segments||!Object.is(c.version,l.version)||c.locked||c.isDeleted||c.visibility==="hidden"||!a.getAppState().layersSelected.includes(l.nodeId))&&(l.dispose(),l=void 0),!l){l={active:0,dispose:()=>{}};const v=l;v.dispose=a.onDestroy(()=>{var b;(b=v.preview)===null||b===void 0||b.remove(),this.sessions.delete(a)}),this.sessions.set(a,l)}const h=n.read(le);if(h.key==="Escape"||h.key==="Enter"){this.finish(a,l);continue}if(!l.first&&!l.pending){const v=a.getAppState().layersSelected,b=v.length===1&&a.getNodeById(v[0]),y=b&&b.type==="vector-network"&&!b.locked&&!b.isDeleted&&b.visibility!=="hidden"&&this.inverse(a,b)?b:void 0;l.nodeId=y==null?void 0:y.id,l.vertices=y==null?void 0:y.vertices,l.segments=y==null?void 0:y.segments,l.ver
10294sion=y==null?void 0:y.version}const[u,d]=h.pointerViewport,f=a.viewport2Canvas({x:u,y:d});if((h.pointerCancelled||!h.pointerInside)&&(l.pending=void 0),h.pointerDownTrigger&&!h.pointerCancelled&&h.pointerButton===0){const[v,b]=h.pointerDownViewport,y=a.viewport2Canvas({x:v,y:b}),_=this.snap(a,l,y);l.pending={anchor:_>=0?this.vertex(a,l,_):y,viewport:{x:v,y:b},snap:_}}const g=l.pending,p=g&&Math.hypot(u-g.viewport.x,d-g.viewport.y)>=foe?{x:f.x-g.anchor.x,y:f.y-g.anchor.y}:void 0;if(h.pointerUpTrigger&&g&&(this.commit(a,l,g.anchor,g.snap,p),l.pending=void 0,this.sessions.get(a)!==l))continue;const m=this.snap(a,l,f);if(n.write(_o).value=m>=0?"pointer":"crosshair",!h.pointerInside){l.preview&&(l.preview.style.display="none");continue}this.preview(a,l,(r=(e=l.pending)===null||e===void 0?void 0:e.anchor)!==null&&r!==void 0?r:m>=0?this.vertex(a,l,m):f,l.pending?p:void 0,(s=(i=l.pending)===null||i===void 0?void 0:i.snap)!==null&&s!==void 0?s:m)}}vertex(t,e,r){if(!e.nodeId)return r===0?e.first:void 0;const i=t.getNodeById(e.nodeId),s=i==null?void 0:i.vertices[r];if(!s)return;const o=ie.toGLMat3(t.getEntity(i).read(Ae).matrix),n=Qt(it(),[s.x,s.y],o);return{x:n[0],y:n[1]}}inverse(t,e){const r=t.getEntity(e);return r!=null&&r.has(Ae)?_i(Bt(),ie.toGLMat3(r.read(Ae).matrix)):null}snap(t,e,r){var i,s;const o=t.canvas2Viewport(r);let n=-1,a=doe;const l=e.nodeId?(s=(i=e.vertices)===null||i===void 0?void 0:i.length)!==null&&s!==void 0?s:0:e.first?1:0;for(let c=0;c<l;c++){const h=t.canvas2Viewport(this.vertex(t,e,c)),u=Math.hypot(h.x-o.x,h.y-o.y);u<a&&(n=c,a=u)}return n}incoming(t,e,r){if(r)return gbt(r);if(!t.resumed&&e===0&&t.initialOutgoing)return gbt(t.initialOutgoing)}commit(t,e,r,i,s){var o,n,a;if(!e.first){e.first=Object.assign({},r),e.outgoing=s,e.nodeId&&i>=0?(e.resumed=!0,e.active=i):(e.nodeId=void 0,e.vertices=void 0,e.segments=void 0,e.active=0,e.initialOutgoing=s,t.selectNodes([]));return}if(i===e.active){this.finish(t,e);return}const l=e.nodeId?t.getNodeById(e.nodeId):void 0,c=l?{x:(o=l.x)!==null&&o!==void 0?o:0,y:(n=l.y)!==null&&n!==void 0?n:0}:e.first,h=l?this.inverse(t,l):void 0;if(l&&!h){this.finish(t,e);return}const u=h?Qt(it(),[r.x,r.y],h):[r.x-c.x,r.y-c.y],d=A=>A&&(h?{x:h[0]*A.x+h[3]*A.y,y:h[1]*A.x+h[4]*A.y}:Object.assign({},A)),f=l?l.vertices.map(A=>Object.assign({},A)):[Object.assign({x:0,y:0},e.initialOutgoing&&{handleMirroring:"ANGLE_AND_LENGTH"})],g=l?l.segments.map(A=>Object.assign({},A)):[],p=i>=0?i:f.length,m=mbt(e.active,p,d(e.outgoing),d(this.incoming(e,i,s))),v=(A,x)=>{var S,T,R,B;return Math.hypot(((S=A==null?void 0:A.x)!==null&&S!==void 0?S:0)-((T=x==null?void 0:x.x)!==null&&T!==void 0?T:0),((R=A==null?void 0:A.y)!==null&&R!==void 0?R:0)-((B=x==null?void 0:x.y)!==null&&B!==void 0?B:0))<1e-6};if(g.some(A=>A.start===e.active&&A.end===p&&v(A.tangentStart,m.tangentStart)&&v(A.tangentEnd,m.tangentEnd)||A.end===e.active&&A.start===p&&v(A.tangentEnd,m.tangentStart)&&v(A.tangentStart,m.tangentEnd))){this.finish(t,e);return}i<0&&f.push(Object.assign({x:u[0],y:u[1]},s&&{handleMirroring:"ANGLE_AND_LENGTH"})),!e.resumed&&i===0&&s&&g.length&&(g[0]=Object.assign(Object.assign({},g[0]),{tangentStart:d(s)}),f[0].handleMirroring="ANGLE_AND_LENGTH"),g.push(m);const b={vertices:f,segments:g,regions:(a=l==null?void 0:l.regions)!==null&&a!==void 0?a:[]},y=Uz(b,new Set([g.length-1])),_=!e.resumed&&(i>=0||y!==b)?MB(y.vertices,y.segments).map(A=>A.region):y.regions,w=l??Object.assign(Object.assign({},t.getAppState().penbarVectorNetwork),{id:oc(),version:1,type:"vector-network",zIndex:t.getNodes().reduce((A,x)=>{var S;return Math.max(A,(S=x.zIndex)!==null&&S!==void 0?S:0)},0)+1,x:c.x,y:c.y,width:0,height:0,vertices:[],segments:[]});l||t.updateNode(Object.assign(Object.assign(Object.assign({},w),y),{regions:_})),t.updateNodeVectorNetwork(w,Object.assign(Object.assign({},y),{regions:_}));const E=t.getNodeById(w.id);Sr(t.getEntity(E)),t.selectNodes([E]),e.nodeId=E.id,e.vertices=E.vertices,e.segments=E.segments,e.version=E.version,e.active=p,e.outgoing=s,t.record(),bh(t.getCanvas()),i>=0&&this.finish(t,e)}preview(t,e,r,i,s){var o,n,a,l,c,h,u,d;if(!e.first&&!e.pending&&s<0){e.preview&&(e.preview.style.display="none");return}const f=t.getSvgLayer();if(!f)return;if(!e.preview){const _=we("svg");_.setAttribute("data-vector-network-pen-preview",""),_.setAttribute("aria-hidden","true"),_.style.cssText="position:absolute;inset:0;width:100%;height:100%;pointer-events:none;overflow:hidden",f.append(_),e.preview=_}const g=e.preview;g.style.display="";const p=_=>t.canvas2Viewport(_),m=e.first&&this.vertex(t,e,e.active),v=JSON.stringify([m,r,e.outgoing,this.incoming(e,s,i),i,s,p({x:0,y:0}),p({x:1,y:0}),p({x:0,y:1})]);if(e.previewKey===v)return;e.previewKey=v,g.replaceChildren();const b=(_,w,E=!1)=>{const A=we("path");A.setAttribute("d",_),A.setAttribute("data-pen-part",w),A.setAttribute("fill","none"),A.setAttribute("stroke","#147af3"),A.setAttribute("stroke-width","1"),E&&A.setAttribute("stroke-dasharray","4 3"),g.append(A)},y=(_,w=3)=>{const E=p(_),A=we("circle");A.setAttribute("cx",String(E.x)),A.setAttribute("cy",String(E.y)),A.setAttribute("r",String(w)),A.setAttribute("fill","white"),A.setAttribute("stroke","#147af3"),g.append(A)};if(m&&s!==e.active){const _=mbt(0,1,e.outgoing,this.incoming(e,s,i)),w=p(m),E=p({x:m.x+((n=(o=_.tangentStart)===null||o===void 0?void 0:o.x)!==null&&n!==void 0?n:0),y:m.y+((l=(a=_.tangentStart)===null||a===void 0?void 0:a.y)!==null&&l!==void 0?l:0)}),A=p({x:r.x+((h=(c=_.tangentEnd)===null||c===void 0?void 0:c.x)!==null&&h!==void 0?h:0),y:r.y+((d=(u=_.tangentEnd)===null||u===void 0?void 0:u.y)!==null&&d!==void 0?d:0)}),x=p(r);b(`M ${w.x} ${w.y} C ${E.x} ${E.y} ${A.x} ${A.y} ${x.x} ${x.y}`,"curve"),y(m)}if(y(r,s>=0?5:3),i){const _=p({x:r.x-i.x,y:r.y-i.y}),w=p({x:r.x+i.x,y:r.y+i.y});b(`M ${_.x} ${_.y} L ${w.x} ${w.y}`,"handles",!0),y({x:r.x+i.x,y:r.y+i.y}),y({x:r.x-i.x,y:r.y-i.y})}}finish(t,e){e.dispose(),t.setAppState({penbarSelected:vt.SELECT}),bh(t.getCanvas())}};var ybt=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};const poe='url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAMpSURBVHgB7VZNSBtREJ5sQv6MIdHaGm3THEpjW6o92JjoQW859CJY66HtRYREEA1CqBeLB0UoXqrUgzcPueihVMzFW7VoRUgRakURFRT8gZZi0pIY903nrausloKQjS0lHwz7suzL+3bmm28W4B+D5g/rrEE4f2BPT495ZWXlIfwFMtDW1laSTqe/jY6OIuHz2NjY45mZmQqXy2W8DCKaaDQa6OrqQpvNJubl5WE4HMahoSHc3NxkOzs7r
10294+TnBFARZ0qwt7dXtLGxAcPDw8Ls7Czo9XqYm5sDt9uNHR0d4VQq9YmeY6AiiTMEKO0afuj+/j6Ul5dDb28vRCIRSCaTQjweZ93d3Q8mJiZC9CyCStCdJyAtNL+Xenx8XMjPz4e+vr5H9PM1qARlBlCn02kpzVLqlWCMAWkCDAYDJBKJMrqlBZUEqSSgX11d/eDxeGB6ehpPDubgGdnd3YWjoyOwWq1X19bWIs3NzQ55n2qdYS4oKLhB9U7QGskLUIna2lpOSoqamhokct9DoZBDTQJcD0UktCB1AgqCwCgbrKWlBYuLi6WDFxYWJDKBQIA5nU6+/CLvVaUr+JvYKG41NDQ8EUUxPjk5iYODg9wPWGVlpXT44eGhdLXb7WJ/fz8S2ZeK/RmDZ+EKxR2TyeSrrq5+1tnZ+YJMKEXmdFqOxsZGrKurQxIrknekybxcoGIpuMKtFNcpuOLvzs/Pv21vb0efzydypywtLZWIkHOixWJhlK1lea9qBqWRiZgoSkic3q2treWBgQGuBba0tHSajaamJrG1tVX1UihhpHI46VpGIny3vb2N5AcsGAwyToB8QyoFtWaaJqkLsjSwzEaj8SZd79fX1z+nc3/4/X50OBwiWTQuLi4iueRJKbSQBfC3MlDwvr9H49m/vr4e45OSfrOpqSkkgiIJEquqqq6ByhNTCd4lNirBbbpWjIyMvDk4OBBpcEmjm3Twnu5bIEtZOAHPhlnWhdvr9T4l1/wYi8WihYWFHjhu4wtnIBPB8InF29UOx28sUiQpvlL8vOifZKpYrUyE64PrISWHat8LF4UGLuvDNYcccvjv8Au1hn6W8NMbDwAAAABJRU5ErkJggg==") 4 28, pointer';class YJ extends We{constructor(){super(),this.cameras=this.query(e=>e.current.with(jt).read),this.selections=new Map,this.query(e=>e.using(fe,Pe,so).read.update.and.using(wt,Ae,xa,le,_o,jt,Ii,ks,Us,_e,ze,be,Zi,Ce,bo,Gt,_t,ai,he,Ls,Qn,Nt,ba).write)}execute(){this.cameras.current.forEach(e=>{var r;if(!e.has(jt))return;const{canvas:i}=e.read(jt);if(!i)return;const{inputPoints:s,api:o}=i.read(wt);if(o.getAppState().penbarSelected!==vt.BRUSH)return;const n=i.write(le),a=i.write(_o),l=n.pressure;a.value=poe;let c=this.selections.get(e.__id);if(c||(this.selections.set(e.__id,{brush:void 0,points:[],lastPointInViewport:[0,0]}),c=this.selections.get(e.__id)),n.pointerDownTrigger){c.points=[];const{pointerDownCanvasX:h,pointerDownCanvasY:u}=e.read(so);c.points.push({x:h,y:u,radius:l})}if(s.forEach(h=>{const u=h.write(xa),{prevPoint:[d,f]}=u,[g,p]=n.pointerViewport;d===g&&f===p||o.runAtNextTick(()=>{this.handleBrushing(o,g,p,l)})}),n.key==="Escape"){const{brush:h}=c;h&&o.updateNode(h,{visibility:"hidden"},!1)}if(n.pointerUpTrigger){const{brush:h}=this.selections.get(e.__id);if(Zo&&h.visibility==="hidden"||!h||((r=h.points)===null||r===void 0?void 0:r.length)===0)return;o.runAtNextTick(()=>{var u;const d=o.getAppState().penbarBrush,{stamps:f}=d,g=ybt(d,["stamps"]);o.updateNode(h,{visibility:"hidden"},!1);const p=(u=f==null?void 0:f.find(b=>b.active))!==null&&u!==void 0?u:f==null?void 0:f[0],m=o.getNodes().reduce((b,y)=>{var _;return Math.max(b,(_=y.zIndex)!==null&&_!==void 0?_:0)},0),v=Object.assign({id:oc(),type:"brush",version:0,zIndex:m+1,points:h.points,brushStamp:p==null?void 0:p.src},g);o.setAppState({penbarSelected:vt.SELECT}),o.updateNode(v),o.selectNodes([v]),o.record()})}})}handleBrushing(e,r,i,s){var o;const n=e.getCamera(),a=this.selections.get(n.__id),l=e.getAppState().penbarBrush,{stamps:c}=l,h=ybt(l,["stamps"]),u=(o=c==null?void 0:c.find(g=>g.active))!==null&&o!==void 0?o:c==null?void 0:c[0],{pointerDownViewportX:d,pointerDownViewportY:f}=n.read(so);if(Sa(r,i,d,f)>10){let g=a.brush;if(g||(g=Object.assign({id:oc(),type:"brush",points:"0,0,0",visibility:"hidden",zIndex:g2},h),e.updateNode(g,void 0,!1),e.getEntity(g).add(Ii,{type:va.BRUSH}),a.brush=g),Sa(r,i,a.lastPointInViewport[0],a.lastPointInViewport[1])>10){const{x:p,y:m}=e.viewport2Canvas({x:r,y:i});if(a.points.push({x:p,y:m,radius:s}),a.lastPointInViewport=[r,i],a.points.length<=1)return;const v=fbt(a.points);e.updateNode(g,Object.assign({visibility:"visible",points:oq(v.map(({point:b,pressure:y})=>({x:b[0],y:b[1],radius:y*h.strokeWidth}))),brushStamp:u==null?void 0:u.src},h),!1)}}}}class $J extends We{constructor(){super(),this.cameras=this.query(e=>e.current.with(jt).read),this.query(e=>e.using(fe,Pe).read.update.and.using(wt,Ae,xa,le,_o,jt,Ii,ks,Us,_e,ze,be,Zi,Ce,bo,Gt,_t,ai,he,Ls,Qn,Nt,ba,ko,ka).write)}execute(){this.cameras.current.forEach(e=>{if(!e.has(jt))return;const{canvas:r}=e.read(jt);if(!r)return;const{api:i}=r.read(wt);if(i.getAppState().penbarSelected!==vt.DRAW_POINT)return;const s=r.write(le);if(s.pointerUpTrigger&&!s.pointerCancelled&&Zo){const[o,n]=s.pointerDownViewport,a=i.viewport2Canvas({x:o,y:n});i.element.dispatchEvent(new CustomEvent("ic-point-drawn",{detail:a}))}})}}class HJ extends We{constructor(){super(),this.htmls=this.query(e=>e.added.and.changed.and.removed.with(ko,Ae).trackWrites),this.embeds=this.query(e=>e.added.and.changed.and.removed.with(To,Ae).trackWrites),this.culled=this.query(e=>e.withAny(ko,To).addedChangedOrRemoved.with(jc).trackWrites),this.editables=this.query(e=>e.withAny(ko,To).addedOrChanged.with(Mi).trackWrites),this.query(e=>e.using(jt,wt,be,Ae).read.and.using(ka,To).write)}
10294execute(){Zo&&(this.culled.addedChangedOrRemoved.forEach(e=>{e.read(ka).element.style.display=e.has(jc)?"none":"block"}),this.editables.addedOrChanged.forEach(e=>{const{element:r}=e.read(ka),{isEditing:i}=e.read(Mi);if(r.style.pointerEvents=i?"auto":"none",e.has(To)){const s=r.querySelector("iframe");s&&(s.style.pointerEvents=i?"auto":"none")}}),this.htmls.added.forEach(e=>{const{html:r,width:i,height:s}=e.read(ko),{element:o}=e.read(ka);o||(e.write(ka).element=document.createElement("div"));const{matrix:n}=e.read(Ae),a=En(e),{canvas:l}=a.read(jt),{api:c}=l.read(wt),h=c.getHtmlLayer(),u=e.read(ka).element;u.innerHTML=r,u.style.position="absolute",u.style.pointerEvents="none",u.style.overflow="hidden",u.style.transformOrigin="top left",u.style.contain="size layout",h.appendChild(u),this.updateCSSTransform(u,n,i,s)}),this.htmls.changed.forEach(e=>{const r=e.read(ka).element,{matrix:i}=e.read(Ae),{width:s,height:o}=e.read(ko);this.updateCSSTransform(r,i,s,o)}),this.htmls.removed.forEach(e=>{this.accessRecentlyDeletedData();const r=En(e),{canvas:i}=r.read(jt),{api:s}=i.read(wt),o=s.getHtmlLayer(),{element:n}=e.read(ka);o.removeChild(n)}),this.embeds.added.forEach(e=>{const{url:r,width:i,height:s}=e.read(To),{element:o}=e.read(ka);o||(e.write(ka).element=document.createElement("div"));const{matrix:n}=e.read(Ae),a=En(e),{canvas:l}=a.read(jt),{api:c}=l.read(wt),h=c.getHtmlLayer(),u=e.read(ka).element;u.style.position="absolute",u.style.pointerEvents="none",u.style.overflow="hidden",u.style.transformOrigin="top left",u.style.contain="size layout";let d=r;const f=Kjt(r);f&&(d=une(f));const g=document.createElement("iframe");g.src=d,g.draggable=!1,g.frameBorder="0",g.referrerPolicy="no-referrer-when-downgrade",g.tabIndex=-1,g.style.border="0",g.style.pointerEvents="none",g.sandbox=qjt(Object.assign(Object.assign({},Zjt),{"allow-presentation":!0,"allow-popups-to-escape-sandbox":!0})),u.appendChild(g),h.appendChild(u),this.updateCSSTransform(u,n,i,s,g)}),this.embeds.changed.forEach(e=>{const r=e.read(ka).element,i=r.querySelector("iframe"),{matrix:s}=e.read(Ae),{width:o,height:n}=e.read(To);this.updateCSSTransform(r,s,o,n,i)}),this.embeds.removed.forEach(e=>{this.accessRecentlyDeletedData();const r=En(e),{canvas:i}=r.read(jt),{api:s}=i.read(wt),o=s.getHtmlLayer(),{element:n}=e.read(ka);o.removeChild(n)}),this.accessRecentlyDeletedData(!1))}updateCSSTransform(e,r,i,s,o){e.style.transform=`matrix(${Hd(r.m00)}, ${Hd(r.m01)}, ${Hd(r.m10)}, ${Hd(r.m11)}, ${Hd(r.m20)}, ${Hd(r.m21)})`,e.style.width=`${Hd(i)}px`,e.style.height=`${Hd(s)}px`,o&&(o.width=`${Hd(i)}px`,o.height=`${Hd(s)}px`)}}function goe(t){const e={};return kS(t.targetPoint)&&(e.targetPoint={x:t.targetPoint.x,y:t.targetPoint.y}),kS(t.sourcePoint)&&(e.sourcePoint={x:t.sourcePoint.x,y:t.sourcePoint.y}),e}class KJ extends We{constructor(){super(),this.boundeds=this.query(e=>e.with(cl).changed.with(fe).trackWrites),this.query(e=>e.using(fe,jt,Gs,ze,be,$t,ae,Ii,Ls,ko,To,ue).read.and.using(wt,Ae,_e,Nt,Mt,_t,xt,Ww,Yt,cl,Wl,hl,mh,La,Sn).write)}execute(){const e=new Set;this.boundeds.changed.forEach(r=>{const{fromBindings:i,toBindings:s,partialBindings:o}=r.read(cl);[...i,...s,...o].forEach(n=>{e.add(n)})}),e.forEach(r=>{var i,s,o,n,a;const l=En(r);if(!l.has(jt))return;const{canvas:c}=l.read(jt);if(!(c!=null&&c.has(wt)))return;const{api:h}=c.read(wt),u=h.getNodeByEntity(r);if(!u)return;let d;if(u.type==="path"||u.type==="rough-path"){const p=u;p.d&&(d={d:p.d,x:(i=p.x)!==null&&i!==void 0?i:0,y:(s=p.y)!==null&&s!==void 0?s:0,rotation:(o=p.rotation)!==null&&o!==void 0?o:0,scaleX:(n=p.scaleX)!==null&&n!==void 0?n:1,scaleY:(a=p.scaleY)!==null&&a!==void 0?a:1})}if(delete u.x,delete u.y,delete u.width,delete u.height,r.has(Wl)){const{from:p,to:m}=r.read(Wl),v=h.getNodeByEntity(p),b=h.getNodeByEntity(m);d!=null&&rQ(v,b,u,d)||Mbt(v,b,u)}else if(r.has(hl)){const{attached:p,sourceIsAttached:m}=r.read(hl),v=h.getNodeByEntity(p),b=m!==0,y=b?v:null,_=b?null:v;d!=null&&rQ(y,_,u,d)||_U(y,_,u)}else return;ou(u);const f=goe(u);u.type==="line"||u.type==="rough-line"?h.updateNode(u,Object.assign({x1:u.x1,y1:u.y1,x2:u.x2,y2:u.y2,x:u.x,y:u.y,width:u.width,height:u.height},f)):u.type==="polyline"||u.type==="rough-polyline"?h.updateNode(u,Object.assign({points:u.points,x:u.x,y:u.y,width:u.width,height:u.height},f)):(u.type==="path"||u.type==="rough-path")&&h.updateNode(u,Object.assign({d:u.d,x:u.x,y:u.y,width:u.width,height:u.height},f)),Sr(r);const g=r.has(_t)?r.read(_t).points:r.has(Mt)?[[r.read(Mt).x1,r.read(Mt).y1],[r.read(Mt).x2,r.read(Mt).y2]]:r.has(xt)?Rbt(r.read(xt).d):null;g&&g.length>
10294=2&&r.has(ze)&&r.read(ze).children.forEach(p=>{if(!p.has(Ww)||!p.has(Yt))return;const{labelPosition:m,labelOffset:v}=p.read(Ww),{point:[b,y],normal:[_,w]}=vmt(g,m),E=b+_*v,A=y+w*v,x=h.getNodeByEntity(p);if(!x)return;const S=gwt(x,E,A);h.updateNode(x,S)})})}}class vbt extends We{constructor(){super(),this.cameras3D=this.query(e=>e.current.with(Bi).read),this.cameras2D=this.query(e=>e.current.with(jt,Pe).read),this.canvases=this.query(e=>e.current.with(wt).read),this.meshes3D=this.query(e=>e.current.with(Ns,Ni,ki).read),this.selected3D=this.query(e=>e.current.with(ar,ki).write),this.query(e=>e.using(le,Bi,jt,wt,js,Pe,Ns,Ni,ki,ar,Gd,fh).read.and.using(ar,ki).write)}execute(){for(const e of this.canvases.current){if(!e.has(le))continue;const r=this.resolveCamera3D(e);if(!r)continue;const i=r.camera,{api:s}=e.read(wt);if(this.syncMesh3DLayers(s,e),s.getAppState().penbarSelected!==vt.SELECT)continue;const o=e.read(le);if(!o.pointerDownTrigger&&!o.pointerUpTrigger){this.updateGizmoHover(o,i,e),this.handleDrag(o,i,e);continue}if(o.pointerUpTrigger){this.handlePointerUp(e);continue}o.pointerDownTrigger&&this.handlePointerDown(o,i,e)}}resolveCamera3D(e){const r=this.canvases.current.length||1,i=IS(this.cameras3D.current,e,r);if(i)return{camera:i.read(Bi)}}canvasMeshes(e){const r=this.canvases.current.length||1;return Ow(this.meshes3D.current,e,r)}canvasSelected(e){const r=this.canvases.current.length||1;return this.selected3D.current.filter(i=>Ow([i],e,r).length>0)}resolveMesh3DSourceNode(e,r){if(r.has(Gd))return e.getNodeByEntity(r.read(Gd).source);if(r.has(fh))return e.getNodeByEntity(r.read(fh).source)}syncMesh3DLayers(e,r){const i=this.canvasMeshes(r).map(s=>{var o;const n=this.resolveMesh3DSourceNode(e,s),a=(o=n==null?void 0:n.id)!==null&&o!==void 0?o:`mesh3d:${s.__id}`,l=s.read(Ns);return{id:a,name:(n==null?void 0:n.name)||`3D Mesh ${s.__id}`,sourceNodeId:n==null?void 0:n.id,vertexCount:l.vertexCount,entity:s}});e.setMesh3DLayers(i),e.setSelectedMesh3DLayerIds(this.canvasSelected(r).map(s=>e.getMesh3DLayerIdByEntity(s)).filter(s=>!!s))}handlePointerDown(e,r,i){const{api:s}=i.read(wt),[o,n]=e.pointerViewport,{width:a,height:l}=this.getViewportSize(i);if(a<=0||l<=0)return;const c=this.buildPickScene(r,a,l,i);if(!c)return;const h=this.canvasMeshes(i),u=this.canvasSelected(i),d=kJ(o,n,a,l,r,c,h,u);if(d.kind==="gizmo"){const g=d.entity.read(ki),p=g.translation,m=g.rotation,v=[p[0],p[1],p[2]],b=this.buildRay(o,n,a,l,r,c,i,v),y=d.entity.write(ar);y.activeAxis=d.axis,y.activePartKind=d.partKind,y.initialTranslation=[...p],y.initialRotation=[...m],y.initialScale=[...g.scale],y.dragHitStart=null,y.dragAngleStart=null;let _=!1;if(d.partKind==="rotate"&&R_t(d.axis)&&b){const w=Pz(b,p,B_t(m,d.axis));w&&(y.dragAngleStart=O_t(w,p,d.axis,m),_=!0)}else if(d.partKind==="translate"&&b){const w=this.intersectRayWithConstraintPlane(b,d.axis,p);w&&(y.dragHitStart=w,_=!0)}y.dragging=_,Zj(_),_||(y.dragHitStart=null,y.dragAngleStart=null);return}const f=d.kind==="mesh"?d.entity:null;for(const g of u)g!==f&&g.has(ar)&&g.remove(ar);f?(f.has(ar)||f.add(ar,{mode:"transform",activeAxis:"none",activePartKind:null,dragging:!1}),s.runAtNextTick(()=>s.syncMesh3DLayerAppState(f))):s.runAtNextTick(()=>s.clearMesh3DLayerAppState()),Zj(!1),tX(i,f!=null)}updateGizmoHover(e,r,i){const s=this.canvasSelected(i);for(const u of s)if(u.has(ar)&&u.read(ar).dragging)return;if(s.length===0)return;const[o,n]=e.pointerViewport,{width:a,height:l}=this.getViewportSize(i);if(a<=0||l<=0)return;const c=this.buildPickScene(r,a,l,i);if(!c)return;const h=kJ(o,n,a,l,r,c,this.canvasMeshes(i),s);for(const u of s){if(!u.has(ar))continue;const d=u.write(ar);h.kind==="gizmo"&&h.entity===u?(d.activeAxis=h.axis,d.activePartKind=h.partKind):(d.activeAxis="none",d.activePartKind=null)}}handlePointerUp(e){let r=!1;
10294for(const i of this.canvasSelected(e)){if(!i.has(ar))continue;i.read(ar).dragging&&(r=!0);const s=i.write(ar);s.dragging=!1,s.activeAxis="none",s.activePartKind=null,s.dragHitStart=null,s.dragAngleStart=null}if(r&&e.has(wt)){const{api:i}=e.read(wt);i.setNodes(i.getNodes()),i.record()}Zj(!1)}handleDrag(e,r,i){let s=!1;for(const o of this.canvasSelected(i)){if(!o.has(ar))continue;const n=o.read(ar);if(!n.dragging||n.activeAxis==="none")continue;const[a,l]=e.pointerViewport,{width:c,height:h}=this.getViewportSize(i);if(c<=0||h<=0)continue;const u=this.buildPickScene(r,c,h,i);if(!u)continue;const d=o.read(ki),f=[d.translation[0],d.translation[1],d.translation[2]],g=this.buildRay(a,l,c,h,r,u,i,f);if(!g)continue;s=!0,o.write(ar);const p=o.write(ki);if(n.activePartKind==="rotate"&&R_t(n.activeAxis)&&n.initialRotation&&n.dragAngleStart!==null){const m=this.computeConstrainedRotation(g,n.activeAxis,d.translation,n.initialRotation,n.dragAngleStart);m&&(p.rotation=m)}else if(n.activePartKind==="translate"&&n.initialTranslation&&n.dragHitStart){const m=this.computeConstrainedTranslation(g,n.activeAxis,n.initialTranslation,n.dragHitStart);m&&(p.translation=m)}}Zj(s)}constraintPlaneNormal(e){return e==="x"||e==="z"||e==="xz"?[0,1,0]:e==="y"||e==="xy"?[0,0,1]:e==="yz"?[1,0,0]:null}intersectRayWithConstraintPlane(e,r,i){const s=this.constraintPlaneNormal(r);return s?Pz(e,i,s):null}computeConstrainedRotation(e,r,i,s,o){const n=Pz(e,i,B_t(s,r));if(!n)return null;const a=O_t(n,i,r,s),l=_se(a-o),c=[...s];return r==="x"?c[0]=s[0]+l:r==="y"?c[1]=s[1]+l:c[2]=s[2]+l,c}computeConstrainedTranslation(e,r,i,s){const o=this.constraintPlaneNormal(r);if(!o)return null;const n=Pz(e,i,o);if(!n)return null;const a=[n[0]-s[0],n[1]-s[1],n[2]-s[2]],l=[...i];return(r==="x"||r==="xy"||r==="xz")&&(l[0]=i[0]+a[0]),(r==="y"||r==="xy"||r==="yz")&&(l[1]=i[1]+a[1]),(r==="z"||r==="xz"||r==="yz")&&(l[2]=i[2]+a[2]),l}buildPickScene(e,r,i,s){const o=e.linked?EB(this.cameras2D.current,s):void 0,{width:n,height:a}=s.read(wt);return I_t(e,r,i,n>0?n:r,a>0?a:i,o)}buildRay(e,r,i,s,o,n,a,l){if(n.mode==="linkedPerspective"){const h=EB(this.cameras2D.current,a);if(!h)return null;const u=ie.toGLMat3(h.read(Pe).viewProjectionMatrixInv),d=Be(e/i*2-1,1-r/s*2),f=Qt(it(),d,u),g=[o.eye[0],o.eye[1],o.eye[2]],p=[f[0],f[1],0],m=Xa();return KO(m,p,g),Zst(m)<1e-8?null:(qO(m,m),{origin:g,direction:[m[0],m[1],m[2]]})}const c=w_t(n.projMatrix,n.viewMatrix);return __t(e,r,i,s,c)}getViewportSize(e){const{width:r,height:i}=e.read(wt);return{width:r,height:i}}}const moe=` 10295layout(std140) uniform SceneUniforms3D { 10296 mat4 u_ProjectionMatrix3D; 10297 mat4 u_ViewMatrix3D; 10298 mat4 u_CanvasViewProjection3D; 10299 // xy: Z-axis screen bias (linked perspective), z: linked flag 10300 vec4 u_SceneParams; 10301}; 10302 10303layout(std140) uniform ModelUniforms3D { 10304 mat4 u_ModelMatrix3D; 10305 mat4 u_NormalMatrix3D; 10306 vec4 u_BaseColor; 10307 vec4 u_LightParams; 10308 vec4 u_LightDirection; 10309 vec4 u_CanvasAnchor; 10310}; 10311 10312layout(location = 0) in vec3 a_Position3D; 10313layout(location = 1) in vec3 a_Normal3D; 10314layout(location = 2) in vec4 a_GizmoColor; 10315 10316out vec4 v_GizmoColor; 10317 10318void main() { 10319 v_GizmoColor = a_GizmoColor; 10320 if (u_SceneParams.w > 0.5) { 10321 v_GizmoColor = vec4(1.0, 1.0, 0.0, a_GizmoColor.a); 10322 } 10323 vec4 worldPos = u_ModelMatrix3D * vec4(a_Position3D, 1.0); 10324 10325 if (u_SceneParams.z > 0.5) { 10326 vec4 clip2d = u_CanvasViewProjection3D * vec4(worldPos.xy, 0.0, 1.0); 10327 vec4 anchor2d = u_CanvasViewProjection3D * 10328 vec4(u_CanvasAnchor.xy, 0.0, 1.0); 10329 vec4 viewPos = u_ViewMatrix3D * worldPos; 10330 vec4 clipP = u_ProjectionMatrix3D * viewPos; 10331 vec4 viewRef = u_ViewMatrix3D * 10332 vec4(worldPos.x, worldPos.y, u_CanvasAnchor.z, 1.0); 10333 float clipPwRef = (u_ProjectionMatrix3D * viewRef).w; 10334 float pw = clipP.w; 10335 if (abs(pw) < 1e-6) { 10336 pw = pw >= 0.0 ? 1e-6 : -1e-6; 10337 } 10338 float scale = pw / clipPwRef; 10339 gl_Position.xy = anchor2d.xy + (clip2d.xy - anchor2d.xy) * scale; 10340 if (u_LightParams.y > 0.5) { 10341 float zDelta = worldPos.z - u_CanvasAnchor.z; 10342 gl_Position.xy += u_SceneParams.xy * zDelta * clip2d.w; 10343 } 10344 gl_Position.z = clipP.z * clip2d.w / pw; 10345 gl_Position.w = clip2d.w; 10346 } else {
10347 gl_Position = u_ProjectionMatrix3D * u_ViewMatrix3D * worldPos; 10348 } 10349} 10350`,yoe=` 10351in vec4 v_GizmoColor; 10352 10353out vec4 outputColor; 10354 10355void main() { 10356 outputColor = v_GizmoColor; 10357} 10358`,qJ=52;class _bt extends We{constructor(){super(),this.setupDevice=this.attach(G3),this.canvases=this.query(e=>e.current.with(wt).read),this.cameras3D=this.query(e=>e.current.with(Bi).read),this.cameras2D=this.query(e=>e.current.with(jt,Pe).read),this.selected3D=this.query(e=>e.current.with(ar,ki).read),this.deviceStates=new WeakMap,this.trackedDevices=new Set,Rre(this),this.query(e=>e.using(js).read.and.current.with(cs,wt,jt,Bi,Pe,ar,ki).read)}hasGizmoContent(e){if(e){const r=this.canvases.current.length||1;return this.selected3D.current.some(i=>i.has(ar)&&Ow([i],e,r).length>0)}return this.selected3D.current.some(r=>r.has(ar))}drawGizmos(e,r,i,s){if(!this.hasGizmoContent(r)||i<=0||s<=0)return;const o=this.initPipeline(r);if(!o)return;const n=this.canvases.current.length||1,a=IS(this.cameras3D.current,r,n);if(!a)return;const l=a.read(Bi),c=l.linked?EB(this.cameras2D.current,r):void 0,{width:h,height:u}=r.read(wt),d=l.linked&&h>0&&u>0?h/u:i/s,f=y_t(l,d,c);e.setViewport(0,0,i,s),e.setPipeline(o.pipeline);for(const g of this.selected3D.current){if(!g.has(ar)||!Ow([g],r,n).length)continue;const p=g.read(ki),m=g.read(ar),v=p.translation,b=T_t(l.eye,v,l.fovy,u>0?u:s,150,l.linked),y=b*Math.max(S_t,NJ*2),_=[...o.gizmoParts].sort((E,A)=>bbt(E)-bbt(A)),w=p.rotation;for(const E of _){const A=m.activeAxis===E.axis&&m.activePartKind===E.partKind;this.uploadSceneUniforms(o,E.sceneUniformBuffer,f,v,y,A);const x=M_t(v,w,b,E.partKind),S=this.uploadModelUniforms(E.modelUniformBuffer,x,v,E.color,C_t(E.partKind,E.axis));o.program.setUniformsLegacy(Object.assign(Object.assign({},o.sceneLegacyUniforms),S)),e.setBindings(E.bindings),e.setVertexInput(o.inputLayout,[{buffer:E.vertexBuffer},{buffer:E.normalBuffer},{buffer:E.colorBuffer}],{buffer:E.indexBuffer}),e.drawIndexed(E.indexCount)}}}uploadSceneUniforms(e,r,i,s,o,n){let a=[...i.sceneParams];if(i.mode==="linkedPerspective"){const c=v_t(i);if(c.mode==="linkedPerspective"){const h=A_t(s,o,c);a=[h[0],h[1],1,0]}}a[3]=n?1:0;const l=ese(Object.assign(Object.assign({},i),{sceneParams:a}));r.setSubData(0,new Uint8Array(l.buffer)),e.sceneLegacyUniforms={u_ProjectionMatrix3D:Ai.toGLMat4(i.projMatrix),u_ViewMatrix3D:Ai.toGLMat4(i.viewMatrix),u_CanvasViewProjection3D:Ai.toGLMat4(i.canvasViewProjection),u_SceneParams:a}}uploadModelUniforms(e,r,i,s,o){const n=cc();M4(n,r),M$(n,n);const a=new Float32Array(qJ);return a.set(r,0),a.set(n,16),a.set(s,32),a.set([1,o?1:0,0,0],36),a.set([-.5,-.7,-.5,0],40),a.set([i[0],i[1],i[2],0],44),e.setSubData(0,new Uint8Array(a.buffer)),{u_ModelMatrix3D:r,u_NormalMatrix3D:n,u_BaseColor:s,u_LightParams:[1,o?1:0,0,0],u_LightDirection:[-.5,-.7,-.5,0],u_CanvasAnchor:[i[0],i[1],i[2],0]}}initPipeline(e){if(!e.has(cs))return null;const{device:r,renderCache:i}=e.read(cs);return this.ensureDeviceState(r,i)}ensureDeviceState(e,r){const i=this.deviceStates.get(e);if(i)return i;const s=r.createProgram({vertex:{glsl:moe,entryPoint:"main"},fragment:{glsl:yoe,entryPoint:"main"}}),o=r.createInputLayout({vertexBufferDescriptors:[{arrayStride:12,stepMode:Pi.VERTEX,attributes:[{format:X.F32_RGB,offset:0,shaderLocation:0}]},{arrayStride:12,stepMode:Pi.VERTEX,attributes:[{format:X.F32_RGB,offset:0,shaderLocation:1}]},{arrayStride:16,stepMode:Pi.VERTEX,attributes:[{format:X.F32_RGBA,offset:0,shaderLocation:2}]}],indexBufferFormat:X.U32_R,program:s}),n=r.createRenderPipeline({inputLayout:o,program:s,colorAttachmentFormats:[X.U8_RGBA_RT],depthStencilAttachmentFormat:X.D24_S8,topology:Ia.TRIANGLES,megaStateDescriptor:_j({attachmentsState:[{channelWriteMask:oo.ALL,rgbBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.SRC_ALPHA,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA},alphaBlendState:{blendMode:Li.ADD,blendSrcFactor:Re.ONE,blendDstFactor:Re.ONE_MINUS_SRC_ALPHA}}],blendConstant:Ra,depthWrite:!1,depthCompare:li.ALWAYS,cullMode:jl.NONE})}),a=this.uploadGizmoMeshes(e,x_t());for(const c of a)c.bindings=e.createBindings({pipeline:n,uniformBufferBindings:[{buffer:c.sceneUniformBuffer},{buffer:c.modelUniformBuffer}]});const l={program:s,pipeline:n,inputLayout:o,gizmoParts:a,sceneLegacyUniforms:{}};return this.deviceStates.set(e,l),this.trackedDevices.add(e),l}getActiveDevices(){const e=new Set;
10358for(const r of this.canvases.current)r.has(cs)&&e.add(r.read(cs).device);return e}dropDeviceState(e){var r;const i=this.deviceStates.get(e);if(i){for(const s of i.gizmoParts)try{(r=s.bindings)===null||r===void 0||r.destroy(),s.vertexBuffer.destroy(),s.normalBuffer.destroy(),s.colorBuffer.destroy(),s.indexBuffer.destroy(),s.sceneUniformBuffer.destroy(),s.modelUniformBuffer.destroy()}catch{}this.deviceStates.delete(e),this.trackedDevices.delete(e)}}uploadGizmoMeshes(e,r){return r.map(i=>{const s=i.positions.length/3,o=new Float32Array(s*4);for(let f=0;f<s;f++)o[f*4]=i.color[0],o[f*4+1]=i.color[1],o[f*4+2]=i.color[2],o[f*4+3]=i.color[3];const n=e.createBuffer({viewOrSize:i.positions,usage:Ee.VERTEX,hint:rr.STATIC}),a=e.createBuffer({viewOrSize:i.normals,usage:Ee.VERTEX,hint:rr.STATIC}),l=e.createBuffer({viewOrSize:o,usage:Ee.VERTEX,hint:rr.STATIC}),c=e.createBuffer({viewOrSize:i.indices,usage:Ee.INDEX,hint:rr.STATIC}),h=i.axis==="xy"||i.axis==="xz"||i.axis==="yz",u=e.createBuffer({viewOrSize:qJ*4,usage:Ee.UNIFORM,hint:rr.DYNAMIC}),d=e.createBuffer({viewOrSize:qJ*4,usage:Ee.UNIFORM,hint:rr.DYNAMIC});return{vertexBuffer:n,normalBuffer:a,colorBuffer:l,indexBuffer:c,indexCount:i.indices.length,color:i.color,axis:i.axis,partKind:i.kind,isPlane:h,sceneUniformBuffer:u,modelUniformBuffer:d,bindings:null}})}finalize(){Mre(this);for(const e of[...this.trackedDevices])this.dropDeviceState(e)}execute(){const e=this.getActiveDevices();for(const r of[...this.trackedDevices])e.has(r)||this.dropDeviceState(r)}}function bbt(t){return t.isPlane?0:t.partKind==="rotate"?1:2}function voe(t){return t==="line"||t==="rough-line"||t==="polyline"||t==="rough-polyline"||t==="path"||t==="rough-path"}function _oe(t,e,r){var i,s,o,n,a;if(!voe(r.type))return;e.has(Wl)&&Zr(e,Wl),e.has(hl)&&Zr(e,hl);const l=r,c=l.fromId?t.getNodeById(l.fromId):void 0,h=l.toId?t.getNodeById(l.toId):void 0;if(!Xz(l,c,h))return;if(l.fromId&&l.toId&&c&&h){const d=t.getEntity(c),f=t.getEntity(h);nt(d,cl),nt(f,cl),nt(e,Wl,{from:d,to:f})}else if(c&&!h){const d=t.getEntity(c);nt(d,cl),nt(e,hl,{attached:d,sourceIsAttached:1})}else if(h&&!c){const d=t.getEntity(h);nt(d,cl),nt(e,hl,{attached:d,sourceIsAttached:0})}let u;if(r.type==="path"||r.type==="rough-path"){const d=r;d.d&&(u={d:d.d,x:(i=d.x)!==null&&i!==void 0?i:0,y:(s=d.y)!==null&&s!==void 0?s:0,rotation:(o=d.rotation)!==null&&o!==void 0?o:0,scaleX:(n=d.scaleX)!==null&&n!==void 0?n:1,scaleY:(a=d.scaleY)!==null&&a!==void 0?a:1})}if(delete r.x,delete r.y,delete r.width,delete r.height,u!=null&&rQ(c??null,h??null,r,u)||_U(c??null,h??null,r),ou(r),typeof r.x=="number"&&(e.write(_e).translation.x=r.x),typeof r.y=="number"&&(e.write(_e).translation.y=r.y),r.type==="line"||r.type==="rough-line"){const d=r;e.write(Mt).x1=d.x1,e.write(Mt).y1=d.y1,e.write(Mt).x2=d.x2,e.write(Mt).y2=d.y2}else if(r.type==="polyline"||r.type==="rough-polyline"){const{points:d}=r;e.write(_t).points=nc(d)}else if(r.type==="path"||r.type==="rough-path"){const{d}=r;e.write(xt).d=d}}var ZJ=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};const wbt=()=>Date.now(),JJ=["display","padding","margin","gap","rowGap","columnGap","alignItems","alignSelf","justifyContent","flexDirection","flexWrap","flexGrow","flexShrink","flexBasis","flex","minWidth","maxWidth","minHeight","maxHeight"];function Ebt(t,e,r,i){return i.some(s=>s in t&&!e.includes(s)&&t[s]!==r[s])}function boe(t,e,r,i,s){return t.has(mh)?Object.is(e,r)?JJ.some(o=>o in e&&!i.includes(o)):Ebt(e,i,s,JJ):!1}const QJ=["flexGrow","flexShrink","flexBasis","alignSelf","padding","margin","minWidth","maxWidth","minHeight","maxHeight","content","fontSize","lineHeight","fontFamily","fontWeight","fontStyle","letterSpacing","width","height"];function woe(t,e,r,i){return Object.is(t,e)?QJ.some(s=>s in t&&!r.includes(s)):Ebt(t,r,i,QJ)}function Abt(t){Zr(t,uE),nt(t,uE)}nt=function(t,e,r){t.has(e)||t.add(e),r&&Object.assign(t.write(e),r)},Zr=function(t,e){t.has(e)&&t.remove(e)};function Eoe(t,e){if(e.kind==="path"&&t.has(xt)||e.kind==="ellipse"&&t.has(ae)||e.kind==="line"&&t.has(Mt)){if(e.kind==="path"){const r=t.write(xt);r.d=e.d,r.fillRule=cX(e.style)}
10358else if(e.kind==="ellipse"){const r=t.write(ae);r.cx=e.cx,r.cy=e.cy,r.rx=e.rx,r.ry=e.ry}else{const r=t.write(Mt);r.x1=e.x1,r.y1=e.y1,r.x2=e.x2,r.y2=e.y2}nt(t,Sn);return}Zr(t,xt),Zr(t,ae),Zr(t,Mt),e.kind==="path"?nt(t,xt,{d:e.d,tessellationMethod:im.LIBTESS,fillRule:cX(e.style)}):e.kind==="ellipse"?nt(t,ae,{cx:e.cx,cy:e.cy,rx:e.rx,ry:e.ry}):nt(t,Mt,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2}),nt(t,Sn)}function Aoe(t,e,r){var i,s,o,n,a,l,c;if(!t.has(ze))return;const h=r.getAppState().variables,u=r.getAppState().themeMode,d=(i=e.width)!==null&&i!==void 0?i:0,f=(s=e.height)!==null&&s!==void 0?s:0,g=r.getNodes().map(O=>O.id===e.id?e:O),p=Object.assign(Object.assign({},e),tmt(e.id,g)),m=k2(p,h,u),{userColorStroke:v,userColorFill:b,rSw:y}=nX(p,h,u,m),_=ds((o=e.iconFontName)!==null&&o!==void 0?o:"",h,u),w=ds((n=e.iconFontFamily)!==null&&n!==void 0?n:"lucide",h,u),E=dX(String((a=_??e.iconFontName)!==null&&a!==void 0?a:""),String((l=w??e.iconFontFamily)!==null&&l!==void 0?l:"lucide"),d,f),A=p.filter;let x=!1;if(A!=null&&`${A}`.trim()!==""){const O=ds(A,h,u);typeof O=="string"&&iv(O)&&(x=!0)}else if(t.has(La)){const O=t.read(La).value;iv(O)&&(x=!0)}const S=O=>{nt(O,he,{value:"hidden"}),nt(O,yi)};if(!E||E.length===0){const O=t.read(ze).children;for(let C=0;C<O.length;C++)S(O[C]);if(t.has(Hn)&&d>0&&f>0){const C=t.write(Hn);C.layoutWidth=d,C.layoutHeight=f}nt(t,Js,m),Zr(t,Gt),nt(t,yi);return}const T=e.zIndex!=null?e.zIndex:0,R=(c=e.visibility)!==null&&c!==void 0?c:"inherited";for(let O=0;O<E.length;O++){const C=E[O];let F;const U=t.read(ze).children;if(O<U.length)F=U[O],nt(F,he,{value:"inherited"}),Eoe(F,C);else{const G=r.getCommands().spawn();wmt(G,C,{userColorStroke:v,userColorFill:b,rSw:y,zIndex:T,visibility:R,name:`${e.id}__i${O}`,strokeAsPlaceholderFillForRasterFilter:x}),r.getCommands().entity(t).appendChild(G),r.getCommands().execute(),F=G.id()}const H=pX(C.style,v,b);nt(F,Gt,{width:fX(C.style,y,{primKind:C.kind}),linecap:mX(C.style.strokeLinecap),linejoin:yX(C.style.strokeLinejoin)}),H&&H!=="none"&&nt(F,Fs,{layers:[{type:"solid",value:H}]});const N=gX(C.style,b,v,C.kind,x);N&&N!=="none"?(nt(F,Ce,{layers:[{type:"solid",value:N}]}),dZ(C,x,N)?nt(F,sm):Zr(F,sm)):(Zr(F,Ce),Zr(F,sm)),nt(F,yi)}const B=t.read(ze).children;for(let O=E.length;O<B.length;O++)S(B[O]);if(t.has(Hn)&&d>0&&f>0){const O=t.write(Hn);O.layoutWidth=d,O.layoutHeight=f}nt(t,Js,m),Zr(t,Gt),nt(t,yi)}class ma{static empty(){return ma.create(new Map,new Map,new Map,void 0)}static stripIrrelevantProps(e){const{id:r,updated:i,version:s,versionNonce:o}=e;return ZJ(e,["id","updated","version","versionNonce"])}static calculate(e,r,i){if(e===r)return ma.empty();const s=new Map,o=new Map,n=new Map;for(const a of e.values())if(!r.get(a.id)){const l=Object.assign(Object.assign({},a),{isDeleted:!1}),c={isDeleted:!0},h=lh.create(l,c,ma.stripIrrelevantProps);o.set(a.id,h)}for(const a of r.values()){const l=e.get(a.id);if(!l){const c={isDeleted:!0},h=Object.assign(Object.assign({},a),{isDeleted:!1}),u=lh.create(c,h,ma.stripIrrelevantProps);s.set(a.id,u);continue}if(!_w(l,a)){const c=lh.calculate(l,a,ma.stripIrrelevantProps);if(typeof l.isDeleted=="boolean"&&typeof a.isDeleted=="boolean"&&l.isDeleted!==a.isDeleted){l.isDeleted&&!a.isDeleted?s.set(a.id,c):o.set(a.id,c);continue}lh.isEmpty(c)||n.set(a.id,c)}}return ma.create(s,o,n,i)}static checkForVisibleDifference(e,r){return e.isDeleted&&r.isDeleted!==!1?!1:e.isDeleted&&r.isDeleted===!1||e.isDeleted===!1&&r.isDeleted?!0:lh.isRightDifferent(e,r)}static applyDelta(e,r,i={containsVisibleDifference:!0,containsZindexDifference:!0}){const s=ZJ(r.inserted,[]);if(!i.containsVisibleDifference){const{fractionalIndex:a}=s,l=ZJ(s,["fractionalIndex"]),c=ma.checkForVisibleDifference(e,l);i.containsVisibleDifference=c}i.containsZindexDifference||(i.containsZindexDifference=r.deleted.fractionalIndex!==r.inserted.fractionalIndex);const o=[...new Set([...Object.keys(r.deleted),...Object.keys(r.inserted)])].filter(a=>r.inserted[a]===void 0);!e.isDeleted&&o.some(a=>a in e)&&(i.containsVisibleDifference=!0);const n=wwt(e,s,o.length>0);return o.forEach(a=>{delete n[a]}),n}static create(e,r,i,s,o={shouldRedistribute:!1}){let n;if(o.shouldRedistribute){const a=new Map,l=new Map,c=new Map,h=[...e,...r,...i];for(const[u,d]of h)this.satisfiesAddition(d)?a.set(u,d):this.satisfiesRemoval(d)?l.set(u,d):c.set(u,d);n=new ma(a,l,c,s)}else n=new ma(e,r,i,s);return n}constructor(e,r,i,s){this.added=e,this.removed=r,this.updated=i,this.api=s}inverse(){const e=o=>{const n=new Map;for(const[a,l]of o.entries())n.set(a,lh.create(l.inserted,l.deleted));return n},r=e(this.added),i=e(this.removed),s=e(this.updated);return ma.create(i,r,s,this.api)}applyLatestChanges(e){const r=a=>l=>{const c={};for(const h of Object.keys(l))c[h]=h==="isDeleted"?!!a[h]:a[h];return c},i=a=>{const l=new Map;for(const[c,h]of a.entries()){const u=e.get(c);if(u){const d=lh.create(h.deleted,h.inserted,r(u),"inserted");l.set(c,d)}else l.set(c,h)}return l},s=i(this.added),o=i(this.removed),n=i(this.updated);return ma.create(s,o,n,this.api,{shouldRedistribute:!0})}applyTo(e,r){const i=new Map(e),s={containsVisibleDifference:!1,containsZindexDifference:!1},o=ma.createApplier(i,r,s);return o(this.added),o(this.removed),o(this.updated),this.api&&!this.isEmpty()&&this.api.replaceDocument([...i.values()],"remote"),[i,s.containsVisibleDifference]}isEmpty(){return this.added.size===0&&this.removed.size===0&&this.updated.size===0}}ma.satisfiesAddition=({deleted:t,inserted:e})=>t.isDeleted===!0&&!e.isDeleted,ma.satisfiesRemoval=({deleted:t,inserted:e})=>!t.isDeleted&&e.isDeleted===!0,ma.satisfiesUpdate=({deleted:t,inserted:e})=>!!t.isDeleted==!!e.isDeleted,ma.createGetter=(t,e,r)=>(i,s)=>{let o=t.get(i);return o||(o=e.get(i),o&&(r.containsZindexDifference=!0,(s.isDeleted===!1||s.isDeleted!==!0&&o.isDeleted===!1)&&(r.containsVisibleDifference=!0))),o},ma.createApplier=(t,e,r)=>{const i=ma.createGetter(t,e,r);return s=>Array.from(s.entries()).reduce((o,[n,a])=>{const l=i(n,a.inserted);if(l){const c=ma.applyDelta(l,a,r);t.set(c.id,c),o.set(c.id,c)}return o},new Map)};function xoe(t,e,r,i){const s=e.fills;return Array.isArray(s)?s.length===0?(Zr(t,Ce),nt(t,yi),!0):(t.has(Ce)||nt(t,Ce),t.write(Ce).layers=PL(s,r,i),nt(t,yi),!0):(Zr(t,Ce),nt(t,yi),!1)}function Soe(t,e,r,i){var s,o;const n=e.strokes;
10358if(!Array.isArray(n))return Zr(t,Fs),nt(t,yi),!1;if(n.length===0)return Zr(t,Fs),Zr(t,Gt),nt(t,yi),!0;const a=PL(n,r,i);t.has(Fs)||nt(t,Fs),t.write(Fs).layers=a;const l=t.has(Gt)?t.read(Gt):void 0,c=(o=(s=sX(e.strokeDashCap))!==null&&s!==void 0?s:l==null?void 0:l.dashcap)!==null&&o!==void 0?o:"none",h=n.find(Dd),u=a.find(Dd),d=u!=null&&typeof u.value=="string"?u.value:void 0,f=qy(h!=null&&typeof h.value=="string"?h.value:void 0);if(t.has(Gt)){const g=t.read(Gt);nt(t,Gt,{colorVariableRef:d!=null&&d.trim()!==""?f:"",width:g.width,linecap:g.linecap,linejoin:g.linejoin,miterlimit:g.miterlimit,dasharray:g.dasharray,dashoffset:g.dashoffset,dashcap:c,alignment:g.alignment,widthVariableRef:g.widthVariableRef})}else d!=null&&d.trim()!==""&&nt(t,Gt,{colorVariableRef:f,dashcap:c});return nt(t,yi),!0}const Toe=(t,e,r,i=[],s)=>{var o,n,a,l,c;let h=!1;const u=e,d={};for(const mt of JJ)mt in r&&!i.includes(mt)&&(d[mt]=u[mt]);const f={};for(const mt of QJ)mt in r&&!i.includes(mt)&&(f[mt]=u[mt]);for(const mt in r){const Pt=r[mt];i.includes(mt)||(e[mt]=Pt),h=!0}if(!h)return e;su(e),zc(e);const g=s.getAppState().variables,p=s.getAppState().themeMode,m=e,v=s.getNodes().map(mt=>mt.id===m.id?m:mt),b=Object.assign(Object.assign({},m),tmt(m.id,v)),{name:y,visibility:_}=r,{parentId:w,zIndex:E,strokeWidth:A,strokeLinecap:x,strokeLinejoin:S,strokeAlignment:T,opacity:R,innerShadowColor:B,innerShadowBlurRadius:O,innerShadowOffsetX:C,innerShadowOffsetY:F,dropShadowColor:U,dropShadowBlurRadius:H,dropShadowOffsetX:N,dropShadowOffsetY:G,fontSize:Y,x:q,y:L,width:J,height:tt,cornerRadius:bt,rotation:ct,scaleX:Xt,scaleY:It,points:zt,d:Ht,anchorX:Lt,anchorY:tr,fontWeight:Gr,fontStyle:re,fontKerning:ci,textAlign:Dt,textBaseline:rt,content:At,sizeAttenuation:Vt,strokeAttenuation:de,decorationColor:Rt,decorationLine:De,decorationThickness:st,decorationStyle:ve,roughRoughness:Ct,roughBowing:mi,roughFillStyle:ws,roughFillWeight:$r,roughHachureAngle:Ne,roughHachureGap:mo,roughCurveStepCount:Es,roughCurveFitting:z,roughDisableMultiStroke:ut,roughDisableMultiStrokeFill:M,roughSimplification:D,roughDashOffset:k,roughDashGap:j,roughZigzagOffset:Q,roughPreserveVertices:ft,roughFillLineDash:ht,roughFillLineDashOffset:ge,roughSeed:Ge,markerStart:Ye,markerEnd:Ki,markerFactor:Wr,x1:hi,y1:Xs,x2:Kr,y2:zs,lockAspectRatio:qu,editable:vv,isEditing:lr,locked:V,filter:pt,brushStamp:Ot,clipMode:ee}=r,qr=e.type,Oe=qr==="iconfont"||qr==="icon_font";if("parentId"in r)if(w){const mt=s.getNodeById(w);if(mt){const Pt=s.getEntity(mt);
10358nt(t,be),nt(Pt,ze),t.write(be).parent=Pt}}else nt(t,be),t.write(be).parent=s.getCamera();if("name"in r&&(t.write(ba).value=y),"lockAspectRatio"in r&&(qu?nt(t,Mv):Zr(t,Mv)),"zIndex"in r&&(t.write(Ls).value=E??0),"visibility"in r&&(t.write(he).value=_),("fills"in r||"fill"in r||"fillLayers"in r)&&!Oe&&(xoe(t,e,g,p),t.has(ue)&&(I3(t),nt(t,Sn))),"brushStamp"in r&&(EO(Ot)||iT(Ot))&&Bbt(Ot,t),"clipMode"in r&&(nt(t,Gc,{value:ee}),nt(t,yi),Ov(t).forEach(mt=>{nt(mt,yi)})),("strokes"in r||"stroke"in r||"strokeOpacity"in r)&&!Oe&&(Soe(t,e,g,p),t.has(ue)&&(I3(t),nt(t,Sn))),"strokeWidth"in r&&!Oe){const mt=ds(A,g,p);nt(t,Gt,Object.assign(Object.assign({},mt!=null?{width:typeof mt=="number"?mt:Number(mt)}:{}),{widthVariableRef:qy(A)}))}if("strokeLinecap"in r&&!Oe&&nt(t,Gt,{linecap:x}),"strokeLinejoin"in r&&!Oe&&nt(t,Gt,{linejoin:S}),"strokeAlignment"in r&&!Oe&&nt(t,Gt,{alignment:T}),"strokeDasharray"in r&&!Oe){const mt=e.strokeDasharray,Pt=mt==="none"||mt===void 0?[0,0]:(()=>{var He;const ui=mt.includes(",")?mt.split(","):mt.trim().split(/\s+/).filter(Boolean),kl=Number(ui[0]),rc=Number((He=ui[1])!==null&&He!==void 0?He:ui[0]);return[Number.isFinite(kl)?kl:0,Number.isFinite(rc)?rc:0]})();nt(t,Gt,{dasharray:Pt})}if("strokeDashoffset"in r&&!Oe){const mt=e.strokeDashoffset,Pt=typeof mt=="number"?mt:parseFloat(String(mt??"0"));nt(t,Gt,{dashoffset:Number.isFinite(Pt)?Pt:0})}if("strokeDashCap"in r&&!Oe){const mt=e.strokeDashCap;nt(t,Gt,{dashcap:(o=sX(mt))!==null&&o!==void 0?o:"none"})}if("opacity"in r&&nt(t,bo,{opacity:R}),"animation"in r){const mt=r.animation;if(mt&&Array.isArray(mt.keyframes)&&mt.keyframes.length>0){const Pt=new XX(mt.keyframes,mt.options);t.has(_a)||t.add(_a),t.write(_a).controller=Pt}else Zr(t,_a)}if("dropShadowColor"in r&&nt(t,ro,{color:ds(U,g,p)}),"dropShadowBlurRadius"in r&&nt(t,ro,{blurRadius:H}),"dropShadowOffsetX"in r&&nt(t,ro,{offsetX:N}),"dropShadowOffsetY"in r&&nt(t,ro,{offsetY:G}),"innerShadowColor"in r&&nt(t,ac,{color:ds(B,g,p)}),"innerShadowBlurRadius"in r&&nt(t,ac,{blurRadius:O}),"innerShadowOffsetX"in r&&nt(t,ac,{offsetX:C}),"innerShadowOffsetY"in r&&nt(t,ac,{offsetY:F}),"sizeAttenuation"in r&&(Vt?nt(t,Xc):Zr(t,Xc)),"strokeAttenuation"in r&&(de?nt(t,Qn):Zr(t,Qn)),"decorationColor"in r&&nt(t,wa,{color:ds(Rt,g,p)}),"decorationLine"in r&&nt(t,wa,{line:De}),"decorationStyle"in r&&nt(t,wa,{style:ve}),"decorationThickness"in r&&nt(t,wa,{thickness:st}),"roughRoughness"in r&&nt(t,ue,{roughness:Ct}),"roughBowing"in r&&nt(t,ue,{bowing:mi}),"roughFillStyle"in r&&(nt(t,ue,{fillStyle:ws}),nt(t,yi)),"roughFillWeight"in r&&nt(t,ue,{fillWeight:$r}),"roughHachureAngle"in r&&nt(t,ue,{hachureAngle:Ne}),"roughHachureGap"in r&&nt(t,ue,{hachureGap:mo}),"roughCurveStepCount"in r&&nt(t,ue,{curveStepCount:Es}),"roughCurveFitting"in r&&nt(t,ue,{curveFitting:z}),"roughDisableMultiStroke"in r&&nt(t,ue,{disableMultiStroke:ut}),"roughDisableMultiStrokeFill"in r&&nt(t,ue,{disableMultiStrokeFill:M}),"roughSimplification"in r&&nt(t,ue,{simplification:D}),"roughDashOffset"in r&&nt(t,ue,{dashOffset:k}),"roughDashGap"in r&&nt(t,ue,{dashGap:j}),"roughZigzagOffset"in r&&nt(t,ue,{zigzagOffset:Q}),"roughPreserveVertices"in r&&nt(t,ue,{preserveVertices:ft}),"roughFillLineDash"in r&&nt(t,ue,{fillLineDash:ht}),"roughFillLineDashOffset"in r&&nt(t,ue,{fillLineDashOffset:ge}),"roughSeed"in r&&nt(t,ue,{seed:Ge}),"markerStart"in r&&nt(t,qo,{start:Ye}),"markerEnd"in r&&nt(t,qo,{end:Ki}),"markerFactor"in r&&nt(t,qo,{factor:Wr}),"anchorX"in r&&(t.write(Yt).anchorX=Lt),"anchorY"in r&&(t.write(Yt).anchorY=tr),"fontSize"in r){const mt=ds(Y,g,p);t.write(Yt).fontSize=typeof mt=="number"?mt:Number(mt),t.write(Yt).fontSizeVariableRef=qy(Y)}if("wordWrapWidth"in r){const mt=r.wordWrapWidth;mt!==void 0&&(t.write(Yt).wordWrapWidth=mt)}if("fontFamily"in r){const mt=r.fontFamily,Pt=ds(mt,g,p),He=Pt!=null&&String(Pt).trim()!==""?String(Pt):"sans-serif";t.write(Yt).fontFamily=He}if("fontWeight"in r&&(t.write(Yt).fontWeight=Gr),"fontStyle"in r&&(t.write(Yt).fontStyle=re),"fontVariant"in r){const mt=r.fontVariant,Pt=ds(mt,g,p);Pt!=null&&(t.write(Yt).fontVariant=String(Pt))}if("fontKerning"in r&&(t.write(Yt).fontKerning=ci),"letterSpacing"in r){const mt=r.letterSpacing,Pt=ds(mt,g,p),He=typeof Pt=="number"?Pt:parseFloat(String(Pt??""));Number.isFinite(He)&&(t.write(Yt).letterSpacing=He)}if("lineHeight"in r){const mt=r.lineHeight,Pt=ds(mt,g,p),He=typeof Pt=="number"?Pt:parseFloat(String(Pt??""));Number.isFinite(He)&&He>=0&&(t.write(Yt).lineHeight=He)}if(("textAlign"in r||"textBaseline"in r)&&!("anchorX"in r)&&!("anchorY"in r)&&t.has(Yt)){const mt=t.read(Yt),Pt=mt.textAlign,He=mt.textBaseline,ui="textAlign"in r?Dt:Pt,kl="textBaseline"in r?rt:He,rc=om(mt),{width:Kg=0,fontMetrics:Wd}=rc;if(Wd){const qg=Kg/2;let jd=mt.anchorX,Jf=mt.anchorY;
10358const kc=ph=>ph==="center"?-qg:ph==="right"||ph==="end"?-qg*2:0,er=kc(Pt),My=kc(ui),Zg=jd+er-My;let Zu=Jf;if(He!==kl){const ph=((mt.lineHeight||mt.fontSize)-Wd.fontSize)/2,VS=u3(He,Wd)-ph,Xe=u3(kl,Wd)-ph;Zu=Jf+VS-Xe}t.write(Yt).anchorX=Zg,t.write(Yt).anchorY=Zu,e.anchorX=Zg,e.anchorY=Zu}}if("textAlign"in r&&(t.write(Yt).textAlign=Dt),"textBaseline"in r&&(t.write(Yt).textBaseline=rt),"content"in r&&(t.write(Yt).content=At),"x"in r&&q!==void 0&&!Na(q)&&(t.write(_e).translation.x=q),"y"in r&&L!==void 0&&!Na(L)&&(t.write(_e).translation.y=L),"rotation"in r&&ct!==void 0&&(t.write(_e).rotation=ct),"scaleX"in r&&Xt!==void 0&&(t.write(_e).scale.x=Xt),"scaleY"in r&&It!==void 0&&(t.write(_e).scale.y=It),"width"in r&&J!==void 0&&!Na(J)&&(t.has($t)?t.write($t).width=J:t.has(ae)?Object.assign(t.write(ae),{rx:J/2,cx:J/2}):t.has(ko)?t.write(ko).width=J:t.has(To)&&(t.write(To).width=J)),"height"in r&&tt!==void 0&&!Na(tt)&&(t.has($t)?t.write($t).height=tt:t.has(ae)?Object.assign(t.write(ae),{ry:tt/2,cy:tt/2}):t.has(ko)?t.write(ko).height=tt:t.has(To)&&(t.write(To).height=tt)),("width"in r||"height"in r)&&(t.has(ae)||t.has($t))&&(nt(t,Sn),nt(t,yi)),("width"in r||"height"in r)&&t.has(La)&&s.runAtNextTick(()=>{nt(t,yi)}),"cornerRadius"in r&&bt!==void 0&&t.has($t)){const mt=ds(bt,g,p),Pt=typeof mt=="number"?mt:parseFloat(String(mt??""));Number.isFinite(Pt)&&(t.write($t).cornerRadius=Math.max(0,Pt),nt(t,Sn),nt(t,yi))}if("points"in r&&(t.has(_t)?t.write(_t).points=nc(zt):t.has(ai)&&(t.write(ai).points=v3(zt))),"d"in r&&t.has(xt)&&(t.write(xt).d=Ht),("vertices"in r||"segments"in r||"regions"in r)&&t.has(ke)){const mt=t.write(ke),Pt=e;"vertices"in r&&Pt.vertices&&(mt.vertices=Pt.vertices),"segments"in r&&Pt.segments&&(mt.segments=Pt.segments),"regions"in r&&(mt.regions=Pt.regions),nt(t,Sn),nt(t,yi)}if("x1"in r&&(t.write(Mt).x1=hi),"y1"in r&&(t.write(Mt).y1=Xs),"x2"in r&&(t.write(Mt).x2=Kr),"y2"in r&&(t.write(Mt).y2=zs),("x1"in r||"y1"in r||"x2"in r||"y2"in r)&&t.has(Mt)&&(nt(t,Sn),t.has(ue)&&I3(t)),"hitStrokeWidth"in r){const mt=r.hitStrokeWidth,Pt=mt!=null&&Number.isFinite(mt)&&mt>=0?mt:-1;t.has(Mt)?t.write(Mt).hitStrokeWidth=Pt:t.has(_t)?t.write(_t).hitStrokeWidth=Pt:t.has(xt)&&(t.write(xt).hitStrokeWidth=Pt)}if("editable"in r&&(vv?nt(t,Mi):Zr(t,Mi)),"isEditing"in r&&(nt(t,Mi),t.write(Mi).isEditing=!!lr),"locked"in r)if(V){nt(t,tu);const mt=s.getNodeByEntity(t);s.deselectNodes([mt]),s.unhighlightNodes([mt])}else Zr(t,tu);if("filter"in r&&(nt(t,La,{value:pt}),nt(t,yi),t.has(Hn)&&Ov(t).forEach(mt=>{nt(mt,yi)})),"blendMode"in r){const mt=e.blendMode;mt!=null&&mt!=="normal"?nt(t,zy,{mode:mt}):t.has(zy)&&Zr(t,zy),nt(t,yi)}if("extrude3d"in r&&t.has($t)){const mt=kgt(r.extrude3d);mt===void 0?Zr(t,Lo):nt(t,Lo,{depth:mt})}if(m.type==="mesh3d"){const mt=r;if("z"in r||"rotation3d"in r||"scale3d"in r||"material3d"in r||"camera3d"in r||"geometry"in r||"x"in r||"y"in r||"width"in r||"height"in r){const Pt=t.write(je);if("geometry"in r&&mt.geometry!=null&&(Pt.geometry=yw(mt.geometry)),"z"in r&&mt.z!=null&&(Pt.z=mt.z),"rotation3d"in r&&mt.rotation3d&&(Pt.rotation3d=[...mt.rotation3d]),"scale3d"in r&&mt.scale3d!=null&&(Pt.scale3d=mt.scale3d),"material3d"in r&&mt.material3d){const ui=mt.material3d;ui.baseColor!=null&&(Pt.baseColor=nZ(ui.baseColor)),ui.ambient!=null&&(Pt.ambient=ui.ambient),ui.diffuse!=null&&(Pt.diffuse=ui.diffuse),ui.specular!=null&&(Pt.specular=ui.specular),ui.shininess!=null&&(Pt.shininess=ui.shininess),ui.metallic!=null&&(Pt.metallic=ui.metallic),ui.roughness!=null&&(Pt.roughness=ui.roughness),"map"in ui&&(Pt.map=(n=ui.map)!==null&&n!==void 0?n:null),"specularMap"in ui&&(Pt.specularMap=(a=ui.specularMap)!==null&&a!==void 0?a:null),"bumpMap"in ui&&(Pt.bumpMap=(l=ui.bumpMap)!==null&&l!==void 0?l:null),ui.bumpScale!=null&&(Pt.bumpScale=ui.bumpScale)}const He=Pt.meshEntity;if(He&&nr(He)&&("rotation3d"in r||"scale3d"in r||"z"in r||"material3d"in r||"geometry"in r||"x"in r||"y"in r||"width"in r||"height"in r)){const ui=t,kl=He,rc="geometry"in r;s.runAtNextTick(()=>{!nr(ui)||!nr(kl)||!ui.has(je)||ui.read(je).meshEntity!==kl||(rc&&Xgt(ui,kl),eX(ui,kl),GX(ui))})}}}if(m.type==="light3d"){const mt=t.write(Kn),Pt=r;
10358if("lightType"in r&&Pt.lightType&&(mt.type=Pt.lightType),"color"in r&&(mt.color=Ygt(Pt.color)),"intensity"in r&&Pt.intensity!=null&&(mt.intensity=Pt.intensity),"direction"in r&&Pt.direction&&(mt.direction=[...Pt.direction]),"range"in r&&Pt.range!=null&&(mt.range=Pt.range),"innerConeAngle"in r&&Pt.innerConeAngle!=null&&(mt.innerConeAngle=Pt.innerConeAngle),"outerConeAngle"in r&&Pt.outerConeAngle!=null&&(mt.outerConeAngle=Pt.outerConeAngle),("x"in r||"y"in r||"z"in r)&&t.has(_e)){const He=t.read(_e).translation;mt.position=["x"in r&&Pt.x!=null?Pt.x:He.x,"y"in r&&Pt.y!=null?Pt.y:He.y,(c=Pt.z)!==null&&c!==void 0?c:mt.position[2]]}}if("display"in r&&(r.display==="flex"?nt(t,mh):(Zr(t,mh),Zr(t,uE))),boe(t,r,e,i,d)&&Abt(t),woe(r,e,i,f)){const mt=e.parentId;if(mt){const Pt=s.getNodeById(mt);if(Pt&&Pt.display==="flex"){const He=s.getEntity(Pt);He!=null&&He.has(mh)&&Abt(He)}}}"version"in r&&(e.version=0),("fromId"in r||"toId"in r||"sourcePoint"in r||"targetPoint"in r||"exitX"in r||"exitY"in r||"exitPerimeter"in r||"exitDx"in r||"exitDy"in r||"entryX"in r||"entryY"in r||"entryPerimeter"in r||"entryDx"in r||"entryDy"in r)&&(t.has(_t)||t.has(Mt)||t.has(xt))&&_oe(s,t,e);{const mt=e.type;(mt==="iconfont"||mt==="icon_font")&&("fills"in r||"strokes"in r||"stroke"in r||"strokeOpacity"in r||"strokeWidth"in r||"strokeLinecap"in r||"strokeLinejoin"in r||"strokeAlignment"in r||"strokeDasharray"in r||"strokeDashoffset"in r||"strokeDashCap"in r||"width"in r||"height"in r||"iconFontName"in r||"iconFontFamily"in r)&&Aoe(t,e,s)}return e.type==="g"&&("fills"in r||"strokes"in r||"stroke"in r||"strokeOpacity"in r||"strokeWidth"in r||"fillRule"in r||"opacity"in r||"strokeLinecap"in r||"strokeLinejoin"in r||"strokeDasharray"in r||"strokeDashoffset"in r||"strokeDashCap"in r)&&nt(t,Js,k2(b,g,p)),e.version++,e.versionNonce=VK(),e.updated=wbt(),Object.keys(e).forEach(mt=>{e[mt]===void 0&&delete e[mt]}),e};var xbt=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};const Ay=new WeakMap;function Roe(t){Ay.delete(t)}function Coe(t){var e;if(!t||typeof t!="string")return!1;const r=t.trim();if(/^data:image\/svg\+xml/i.test(r))return!0;const i=(e=r.split(/[?#]/)[0])!==null&&e!==void 0?e:r;if(/\.svg$/i.test(i))return!0;try{return new URL(r,"https://local.invalid/").pathname.toLowerCase().endsWith(".svg")}catch{return!1}}function Moe(t,e,r,i){return xbt(this,void 0,void 0,function*(){return typeof Image>"u"||e<1||r<1?null:new Promise(s=>{const o=new Image;(t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//"))&&(o.crossOrigin="anonymous");const n=a=>s(a);o.onload=()=>{let a;if(typeof document<"u"){const c=document.createElement("canvas");c.width=e,c.height=r,a=c}else a=new OffscreenCanvas(e,r);const l=a.getContext("2d");if(!l){n(null);return}l.imageSmoothingEnabled=!0,"imageSmoothingQuality"in l&&(l.imageSmoothingQuality="high");try{lz(l,o,o.naturalWidth,o.naturalHeight,e,r,i)}catch{n(null);return}createImageBitmap(a).then(c=>n(c)).catch(()=>n(null))},o.onerror=()=>n(null),o.src=t})})}function Sbt(t){const{entity:e,url:r,targetW:i,targetH:s,sourceW:o,sourceH:n,rasterOptions:a}=t;if(!Coe(r)||i<=o+.5&&s<=n+.5)return;const l=`${r}\0${i}\0${s}\0${o}\0${n}`;Ay.get(e)!==l&&(Ay.set(e,l),xbt(this,void 0,void 0,function*(){const c=yield Moe(r,i,s,a);if(!c){Ay.get(e)===l&&Ay.delete(e);return}if(Ay.get(e)!==l){c.close();return}if(!e.has(Ce)){c.close(),Ay.delete(e);return}if(!Nh(e).some(h=>h.type==="image"&&h.value===r)){c.close(),Ay.delete(e);return}cJ(r,c),nt(e,yi),Ay.get(e)===l&&Ay.delete(e)}))}var Boe=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};ou=function(t){var e,r;if(t.type==="g"||t.type==="light3d")return t;if(me(t.width)||me(t.height)||me(t.x)||me(t.y)){const{type:i}=t;let s;if(i==="rect"||i==="html"||i==="embed"||i==="iconfont")s=$t.getGeometryBounds(t);else if(i==="ellipse"||i==="rough-ellipse")s=ae.getGeometryBounds(t);
10358else if(i==="polyline"||i==="rough-polyline")s=_t.getGeometryBounds(t);else if(i==="line"||i==="rough-line")s=Mt.getGeometryBounds(t);else if(i==="path"||i==="rough-path")s=xt.getGeometryBounds(t);else if(i==="text"){const o=om(t);s=Yt.getGeometryBounds(t,o)}else i==="brush"?s=ai.getGeometryBounds(t):i==="vector-network"&&(s=ke.getGeometryBounds(t));if(s)t.x=s.minX,t.y=s.minY,t.width=s.maxX-s.minX,t.height=s.maxY-s.minY,i==="polyline"||i==="rough-polyline"?t.points=ip(nc(t.points).map(o=>[o[0]-s.minX,o[1]-s.minY])):i==="line"||i==="rough-line"?(t.x1=t.x1-s.minX,t.y1=t.y1-s.minY,t.x2=t.x2-s.minX,t.y2=t.y2-s.minY):i==="path"||i==="rough-path"?t.d=xy(t.d,-s.minX,-s.minY):i==="brush"?t.points=oq(v3(t.points).map(o=>Object.assign(Object.assign({},o),{x:o.x-s.minX,y:o.y-s.minY}))):i==="text"?(t.anchorX=((e=t.anchorX)!==null&&e!==void 0?e:0)-s.minX,t.anchorY=((r=t.anchorY)!==null&&r!==void 0?r:0)-s.minY):i==="vector-network"&&(t.vertices=t.vertices.map(o=>Object.assign(Object.assign({},o),{x:o.x-s.minX,y:o.y-s.minY})));else throw new Error("Cannot infer x, y, width or height for node");return t}};function tQ(t,e){return(t%e+e)%e}function Ooe(t,e,r){if(t.length===0)return"";const i=null,s=t,o=s[s.length-1],n=[];let a=s[0],l=1;const c=(d,f)=>{n.push(`M ${Zt(d)} ${Zt(f)}`)},h=(d,f)=>{n.push(`L ${Zt(d)} ${Zt(f)}`)},u=(d,f,g,p)=>{n.push(`Q ${Zt(d)} ${Zt(f)} ${Zt(g)} ${Zt(p)}`)};for(c(a.x,a.y);l<s.length-1;){let d=s[tQ(l,s.length)],f=a.x-d.x,g=a.y-d.y;if((f!==0||g!==0)&&i==null){let p=Math.sqrt(f*f+g*g);const m=f*Math.min(r,p/2)/p,v=g*Math.min(r,p/2)/p,b=d.x+m,y=d.y+v;h(b,y);let _=s[tQ(l+1,s.length)];for(;l<s.length-2&&Math.round(_.x-d.x)===0&&Math.round(_.y-d.y)===0;)_=s[tQ(l+2,s.length)],l++;f=_.x-d.x,g=_.y-d.y,p=Math.max(1,Math.sqrt(f*f+g*g));const w=f*Math.min(r,p/2)/p,E=g*Math.min(r,p/2)/p,A=d.x+w,x=d.y+E;u(d.x,d.y,A,x),d={x:A,y:x}}else h(d.x,d.y);a=d,l++}return h(o.x,o.y),n.join(" ")}function Tbt(t){if(t.length<2)return"";const e=[`M ${Zt(t[0].x)} ${Zt(t[0].y)}`],r=t.length;for(let o=1;o<r-2;o++){const n=t[o],a=t[o+1],l=(n.x+a.x)/2,c=(n.y+a.y)/2;e.push(`Q ${Zt(n.x)} ${Zt(n.y)} ${Zt(l)} ${Zt(c)}`)}const i=t[r-2],s=t[r-1];return e.push(`Q ${Zt(i.x)} ${Zt(i.y)} ${Zt(s.x)} ${Zt(s.y)}`),e.join(" ")}function Ioe(t){const e=t.length;if(e<2)return"";const r=[`M ${Zt(t[0].x)} ${Zt(t[0].y)}`];if(e===2)return r.push(`L ${Zt(t[1].x)} ${Zt(t[1].y)}`),r.join(" ");if((e-1)%3===0){for(let i=1;i+2<e;i+=3){const s=t[i],o=t[i+1],n=t[i+2];r.push(`C ${Zt(s.x)} ${Zt(s.y)} ${Zt(o.x)} ${Zt(o.y)} ${Zt(n.x)} ${Zt(n.y)}`)}return r.join(" ")}return Tbt(t)}function Rbt(t){if(!t)return null;const e=ep(t),r=[];for(const i of e){const[s,...o]=i;s==="M"||s==="L"?r.push([o[0],o[1]]):s==="Q"?r.push([o[2],o[3]]):s==="C"&&r.push([o[4],o[5]])}return r.length>=2?r:null}function kS(t){return t!=null&&Number.isFinite(t.x)&&Number.isFinite(t.y)}function Xz(t,e,r){const i=e!=null||kS(t.sourcePoint),s=r!=null||kS(t.targetPoint);return i&&s}function Doe(t){if(!t)return!1;const e=_X(t),r=e.filter(o=>o[0]==="C").length,i=e.filter(o=>o[0]==="Q").length;if(r>0&&i>0||e.length<2||e[0][0]!=="M")return!1;const s=e[1][0];return r===1&&i===0?s==="C":r===0&&i===1?s==="Q":!1}function Cbt(t,e){var r,i,s;const o=ie.toGLMat3(ie.fromTransform(new _e({translation:{x:e.x,y:e.y},rotation:(r=e.rotation)!==null&&r!==void 0?r:0,scale:{x:(i=e.scaleX)!==null&&i!==void 0?i:1,y:(s=e.scaleY)!==null&&s!==void 0?s:1}})));return EU(t,o)}function Poe(t,e){var r,i,s;const o=ie.toGLMat3(ie.fromTransform(new _e({translation:{x:e.x,y:e.y},rotation:(r=e.rotation)!==null&&r!==void 0?r:0,scale:{x:(i=e.scaleX)!==null&&i!==void 0?i:1,y:(s=e.scaleY)!==null&&s!==void 0?s:1}}))),n=Bt();return _i(n,o)?EU(t,n):t}function eQ(t,e){var r,i,s,o,n,a;const l=t,c=xt.getGeometryBounds({d:l.d}),h=ie.toGLMat3(ie.fromTransform(new _e({translation:{x:e.x,y:e.y},rotation:(r=e.rotation)!==null&&r!==void 0?r:0,scale:{x:(i=e.scaleX)!==null&&i!==void 0?i:1,y:(s=e.scaleY)!==null&&s!==void 0?s:1}}))),u=Qt(it(),[c.minX,c.minY],h);l.d=xy(l.d,-c.minX,-c.minY),t.x=u[0],t.y=u[1],t.rotation=(o=e.rotation)!==null&&o!==void 0?o:0,t.scaleX=(n=e.scaleX)!==null&&n!==void 0?n:1,t.scaleY=(a=e.scaleY)!==null&&a!==void 0?a:1;const d=xt.getGeometryBounds({d:l.d}
10358);t.width=d.maxX-d.minX,t.height=d.maxY-d.minY}function Foe(t){const e=Cbt(t.d,t),r=_X(e);return Noe(r)}function Noe(t){if(t.length<1||t[0][0]!=="M")return null;const e=t[0],r={x:e[1],y:e[2]},i=t[t.length-1],s=i[0];let o;if(s==="C")o={x:i[5],y:i[6]};else if(s==="Q")o={x:i[3],y:i[4]};else if(s==="L")o={x:i[1],y:i[2]};else return null;return{start:r,end:o}}function koe(t,e,r){var i;t&&ou(t),e&&ou(e);const s=r;s.absolutePoints=[null,null],pmt(s,t,e),fmt(s,null,t,e),cmt(s,t,e);const o=(i=s.absolutePoints)===null||i===void 0?void 0:i.filter(n=>n!=null);return delete s.absolutePoints,!o||o.length<2?null:{start:o[0],end:o[o.length-1]}}function Loe(t,e,r,i,s){const o=t.map(l=>[...l]);if(o.length===0)return o;const n=o[0];if(n[0]==="M"&&(n[1]+=e,n[2]+=r),o.length>1){const l=o[1];(l[0]==="C"||l[0]==="Q")&&(l[1]+=e,l[2]+=r)}const a=o[o.length-1];return a[0]==="C"?(a[3]+=i,a[4]+=s,a[5]+=i,a[6]+=s):a[0]==="Q"?(a[1]+=i,a[2]+=s,a[3]+=i,a[4]+=s):a[0]==="L"&&(a[1]+=i,a[2]+=s),o}function rQ(t,e,r,i){const s=r.type;if(s!=="path"&&s!=="rough-path"||!Doe(i.d))return!1;const o=r,n=Foe(i),a=koe(t,e,o);if(!n||!a)return!1;const l=!!o.fromId,c=!!o.toId,h=l?a.start.x-n.start.x:0,u=l?a.start.y-n.start.y:0,d=c?a.end.x-n.end.x:0,f=c?a.end.y-n.end.y:0,g=1e-5;if(Math.abs(h)<g&&Math.abs(u)<g&&Math.abs(d)<g&&Math.abs(f)<g)return r.d=i.d,eQ(r,i),!0;const p=Cbt(i.d,i),m=_X(p),v=Loe(m,h,u,d,f),b=ymt(v);return r.d=Poe(b,i),eQ(r,i),!0}function _U(t,e,r){t&&ou(t),e&&ou(e);const i=r;if(i.absolutePoints=[null,null],pmt(i,t,e),fmt(i,null,t,e),cmt(i,t,e),i.absolutePoints=DV(i.absolutePoints),r.type==="line"||r.type==="rough-line"){const s=i.absolutePoints.filter(o=>o!=null);if(s.length>=2){r.x1=s[0].x,r.y1=s[0].y;const o=s[s.length-1];r.x2=o.x,r.y2=o.y}}else if(r.type==="polyline"||r.type==="rough-polyline")r.points=ip(i.absolutePoints.map(s=>[s.x,s.y]));else if(r.type==="path"||r.type==="rough-path")if(r.bezier){const s=i.absolutePoints.filter(o=>o!=null);s.length>=2&&(r.d=Ioe(s))}else if(r.curved){const s=i.absolutePoints.filter(o=>o!=null);s.length>=2&&(r.d=Tbt(s))}else{const s=i.absolutePoints.filter(o=>o!=null);if(s.length>=2){const o=typeof r.arcSize=="number"?r.arcSize:10;r.rounded?r.d=Ooe(s,!0,o):r.d=`M ${Zt(s[0].x)} ${Zt(s[0].y)} `+s.slice(1).map(n=>`L ${Zt(n.x)} ${Zt(n.y)}`).join(" ")}}delete i.absolutePoints}function Mbt(t,e,r){_U(t,e,r)}function Uoe(t,e){var r,i;const s=t.id;if(!s)return;const o=e.filter(a=>a.type==="text"&&a.parentId===s&&a.edgeLabelPosition!=null&&!Number.isNaN(a.edgeLabelPosition));if(o.length===0)return;let n=null;if(t.type==="polyline"||t.type==="rough-polyline")n=nc(t.points);else if(t.type==="line"||t.type==="rough-line"){const a=t;n=[[a.x1,a.y1],[a.x2,a.y2]]}else(t.type==="path"||t.type==="rough-path")&&(n=Rbt(t.d));if(!(!n||n.length<2))for(const a of o){const l=(r=a.edgeLabelPosition)!==null&&r!==void 0?r:.5,c=(i=a.edgeLabelOffset)!==null&&i!==void 0?i:0,{point:[h,u],normal:[d,f]}=vmt(n,l),g=h+d*c,p=u+f*c,m=Object.assign(Object.assign({},a),{anchorX:g,anchorY:p});delete m.x,delete m.y,delete m.width,delete m.height,ou(m),Object.assign(a,{x:m.x,y:m.y,width:m.width,height:m.height,anchorX:m.anchorX,anchorY:m.anchorY})}}function Bbt(t,e){return Boe(this,void 0,void 0,function*(){const r=yield Pr.get().createImage(t);Roe(e),cJ(t,r),nt(e,Ce,{layers:[{type:"image",value:t}]}),nt(e,yi)})}function bU(t,e){const{roughSeed:r,roughRoughness:i,roughBowing:s,roughFillStyle:o,roughFillWeight:n,roughHachureAngle:a,roughHachureGap:l,roughCurveStepCount:c,roughCurveFitting:h,roughFillLineDash:u,roughFillLineDashOffset:d,roughDisableMultiStroke:f,roughDisableMultiStrokeFill:g,roughSimplification:p,roughDashOffset:m,roughDashGap:v,roughZigzagOffset:b,roughPreserveVertices:y}=t;e.insert(new ue({seed:r,roughness:i,bowing:s,fillStyle:o,fillWeight:n,hachureAngle:a,hachureGap:l,curveStepCount:c,curveFitting:h,fillLineDash:u,fillLineDashOffset:d,disableMultiStroke:f,disableMultiStrokeFill:g,simplification:p,dashOffset:m,dashGap:v,zigzagOffset:b,preserveVertices:y}))}function iQ(t,e,r,i,s){var o,n,a,l,c,h,u,d,f,g,p,m,v,b,y,_,w,E,A,x,S,T,R,B,O,C,F,U,H,N,G,Y,q,L,J,tt;
10358const bt=lj(t,s==null?void 0:s.lookupNodes),ct=FL(t,bt),Xt=lj(ct,s==null?void 0:s.lookupNodes);for(const re of Xt)su(re),zc(re);const It=fZ(Xt);let zt=[];i&&(zt=Array.from(i.keys()));const Ht=Array.from(new Set([...zt,...ct.map(re=>re.id)]));let Lt=ct.filter(re=>!me(re.parentId)).map(re=>[re.parentId,re.id]);ct.forEach(re=>{if(re.type==="line"||re.type==="polyline"||re.type==="path"||re.type==="rough-line"||re.type==="rough-polyline"||re.type==="rough-path"){const{fromId:ci,toId:Dt}=re;ci&&Lt.push([ci,re.id]),Dt&&Lt.push([Dt,re.id])}}),Lt=Lt.filter(([re,ci])=>Xt.some(Dt=>Dt.id===re)&&Xt.some(Dt=>Dt.id===ci));const tr=Pgt.array(Ht,Lt);i||(i=new Map);const Gr=[];for(const re of tr){const ci=ct.find(Xe=>Xe.id===re);if(!ci)continue;const Dt=ci;Dt.type||(Dt.type="rect");const{parentId:rt,type:At}=ci;if(At==="ref")throw new Error("ref nodes must be expanded before serializedNodesToEntities (expandRefSerializedNodes)");const Vt=s==null?void 0:s.variables,de=s==null?void 0:s.themeMode,Rt=(o=It.get(re))!==null&&o!==void 0?o:{},De=Object.assign(Object.assign({},Dt),Rt);let st=!1;const ve=[],Ct=r.spawn();if(i.set(re,Ct),At==="line"||At==="rough-line"||At==="polyline"||At==="rough-polyline"||At==="path"||At==="rough-path"){const Xe=Dt,{fromId:Dr,toId:yo}=Xe,vo=Dr?Xt.find(Ho=>Ho.id===Dr):void 0,$n=yo?Xt.find(Ho=>Ho.id===yo):void 0;if(Xz(Xe,vo,$n)){if(_U(vo??null,$n??null,Dt),Dr&&yo&&vo&&$n){const Ho=i.get(Dr),Ll=Ho==null?void 0:Ho.id().hold(),Jg=i.get(yo),Xd=Jg==null?void 0:Jg.id().hold();nt(Ll,cl),nt(Xd,cl),Ct.insert(new Wl({from:Ll,to:Xd}))}else if(vo&&!$n){const Ho=i.get(Dr),Ll=Ho==null?void 0:Ho.id().hold();nt(Ll,cl),Ct.insert(new hl({attached:Ll,sourceIsAttached:1}))}else if($n&&!vo){const Ho=i.get(yo),Ll=Ho==null?void 0:Ho.id().hold();nt(Ll,cl),Ct.insert(new hl({attached:Ll,sourceIsAttached:0}))}}}if(At==="mesh3d"){const Xe=Dt,Dr=typeof Xe.scale3d=="number"?Xe.scale3d:(a=(n=Xe.scale3d)===null||n===void 0?void 0:n[0])!==null&&a!==void 0?a:100;(l=Dt.width)!==null&&l!==void 0||(Dt.width=Dr),(c=Dt.height)!==null&&c!==void 0||(Dt.height=Dr)}At==="light3d"&&((h=Dt.x)!==null&&h!==void 0||(Dt.x=0),(u=Dt.y)!==null&&u!==void 0||(Dt.y=0),(d=Dt.width)!==null&&d!==void 0||(Dt.width=0),(f=Dt.height)!==null&&f!==void 0||(Dt.height=0)),ou(Dt);const mi=Dt;(At==="line"||At==="rough-line"||At==="polyline"||At==="rough-polyline"||At==="path"||At==="rough-path")&&Xz(mi,mi.fromId?Xt.find(Xe=>Xe.id===mi.fromId):void 0,mi.toId?Xt.find(Xe=>Xe.id===mi.toId):void 0)&&Uoe(Dt,Xt);const{x:ws,y:$r,width:Ne,height:mo,rotation:Es=0,scaleX:z=1,scaleY:ut=1}=Dt,M=ws??0,D=$r??0,k=Ne??0,j=mo??0;if(Ct.insert(new _e({translation:{x:M,y:D},rotation:Es,scale:{x:z,y:ut}})),Ct.insert(new Zi),At==="g")Ct.insert(new Js(k2(De,Vt,de)));else if(At==="mesh3d"){const Xe=Dt,Dr=(g=Xe.material3d)!==null&&g!==void 0?g:{};Ct.insert(new $t({x:0,y:0,width:k,height:j,cornerRadius:0})),Ct.insert(new je({geometry:yw(Xe.geometry),z:(p=Xe.z)!==null&&p!==void 0?p:0,rotation3d:(m=Xe.rotation3d)!==null&&m!==void 0?m:[0,0,0],scale3d:(v=Xe.scale3d)!==null&&v!==void 0?v:100,baseColor:nZ(Dr.baseColor),ambient:(b=Dr.ambient)!==null&&b!==void 0?b:.25,diffuse:(y=Dr.diffuse)!==null&&y!==void 0?y:.75,specular:(_=Dr.specular)!==null&&_!==void 0?_:.4,shininess:(w=Dr.shininess)!==null&&w!==void 0?w:48,metallic:(E=Dr.metallic)!==null&&E!==void 0?E:0,roughness:(A=Dr.roughness)!==null&&A!==void 0?A:1,map:(x=Dr.map)!==null&&x!==void 0?x:null,specularMap:(S=Dr.specularMap)!==null&&S!==void 0?S:null,bumpMap:(T=Dr.bumpMap)!==null&&T!==void 0?T:null,bumpScale:(R=Dr.bumpScale)!==null&&R!==void 0?R:1,camera3d:Xe.camera3d})),s!=null&&s.canvas&&Ct.insert(new js({canvas:s.canvas}))}else if(At==="light3d"){const Xe=Dt;Ct.insert(new Kn(Object.assign(Object.assign({type:Xe.lightType,color:Ygt(Xe.color),intensity:(B=Xe.intensity)!==null&&B!==void 0?B:1,direction:(O=Xe.direction)!==null&&O!==void 0?O:[-.5,-.7,-.5],position:[M,D,(C=Xe.z)!==null&&C!==void 0?C:0],range:(F=Xe.range)!==null&&F!==void 0?F:0},Xe.innerConeAngle!=null?{innerConeAngle:Xe.innerConeAngle}:{}),Xe.outerConeAngle!=null?{outerConeAngle:Xe.outerConeAngle}:{}))),s!=null&&s.canvas&&Ct.insert(new js({canvas:s.canvas}))}else if(At==="ellipse"||At==="rough-ellipse")Ct.insert(new ae({cx:k/2,cy:j/2,rx:k/2,ry:j/2})),At==="rough-ellipse"&&bU(Dt,Ct);else if(At==="rect"||At==="rough-rect"){const{cornerRadius:Xe}=Dt,Dr=ds(Xe,Vt,de),yo=(()=>
10358{if(Dr==null)return;const vo=typeof Dr=="number"?Dr:parseFloat(String(Dr));return Number.isFinite(vo)?Math.max(0,vo):void 0})();if(Ct.insert(new $t({x:0,y:0,width:k,height:j,cornerRadius:yo??0})),At==="rough-rect"&&bU(Dt,Ct),At==="rect"){const vo=kgt(Dt.extrude3d);vo!==void 0&&Ct.insert(new Lo({depth:vo}))}}else if(At==="polyline"||At==="rough-polyline"){const{points:Xe,hitStrokeWidth:Dr}=Dt;Ct.insert(new _t(Object.assign({points:nc(Xe)},Dr!=null&&Dr>=0?{hitStrokeWidth:Dr}:{}))),At==="rough-polyline"&&bU(Dt,Ct)}else if(At==="line"||At==="rough-line"){const{x1:Xe,y1:Dr,x2:yo,y2:vo,hitStrokeWidth:$n}=Dt;Ct.insert(new Mt(Object.assign({x1:Xe,y1:Dr,x2:yo,y2:vo},$n!=null&&$n>=0?{hitStrokeWidth:$n}:{}))),At==="rough-line"&&bU(Dt,Ct)}else if(At==="brush"){const{points:Xe,brushType:Dr,brushStamp:yo,stampInterval:vo,stampMode:$n,stampNoiseFactor:Ho,stampRotationFactor:Ll}=Dt;Ct.insert(new ai({points:v3(Xe),type:Dr,stampInterval:vo,stampMode:$n,stampNoiseFactor:Ho,stampRotationFactor:Ll})),yo&&Bbt(yo,Ct.id())}else if(At==="path"||At==="rough-path"){const{d:Xe,fillRule:Dr,tessellationMethod:yo,hitStrokeWidth:vo}=Dt;Ct.insert(new xt(Object.assign({d:Xe,fillRule:Dr,tessellationMethod:yo},vo!=null&&vo>=0?{hitStrokeWidth:vo}:{}))),At==="rough-path"&&bU(Dt,Ct)}else if(At==="text"){const{anchorX:Xe,anchorY:Dr,content:yo,fontFamily:vo,fontSize:$n,fontWeight:Ho="normal",fontStyle:Ll="normal",fontVariant:Jg="normal",fontKerning:Xd=!0,letterSpacing:Qg=0,lineHeight:ic=0,whiteSpace:zd="normal",wordWrap:_v=!1,wordWrapWidth:bv,maxLines:Ul,textAlign:Yw="start",textBaseline:Ko="alphabetic",decorationThickness:Qf=0,decorationColor:$w="black",decorationLine:sc="none",decorationStyle:nl="solid",edgeLabelPosition:By,edgeLabelOffset:YS}=Dt,wv=ds($n,Vt,de),Hw=ds($w,Vt,de),Oy=e.map(Ev=>Ev.read(Xy).bitmapFont).find(Ev=>Ev.fontFamily===vo);Ct.insert(new Yt({anchorX:Xe,anchorY:Dr,content:yo,fontFamily:vo,fontSize:typeof wv=="number"?wv:Number(wv),fontSizeVariableRef:qy($n),fontWeight:Ho,fontStyle:Ll,fontVariant:Jg,fontKerning:Xd,letterSpacing:Qg,lineHeight:ic,whiteSpace:zd,wordWrap:_v,wordWrapWidth:bv,maxLines:Ul,textAlign:Yw,textBaseline:Ko,bitmapFont:Oy})),sc!=="none"&&Qf>0&&Ct.insert(new wa({color:Hw,line:sc,style:nl,thickness:Qf})),By!=null&&!Number.isNaN(By)&&Ct.insert(new Ww({labelPosition:By,labelOffset:YS??0}))}else if(At==="vector-network"){const{vertices:Xe,segments:Dr,regions:yo}=Dt;Ct.insert(new ke({vertices:Xe,segments:Dr,regions:yo}))}else if(At==="html"){const{html:Xe}=Dt;Ct.insert(new ko({x:0,y:0,width:k,height:j,html:Xe})),Ct.insert(new ka)}else if(At==="embed"){const{url:Xe}=Dt;Ct.insert(new To({x:0,y:0,width:k,height:j,url:Xe})),Ct.insert(new ka)}else if(At==="iconfont"){const{iconFontName:Xe="",iconFontFamily:Dr="lucide"}=Dt,yo=ds(Xe,Vt,de),vo=ds(Dr,Vt,de),$n=De,Ho=k2($n,Vt,de),{userColorStroke:Ll,userColorFill:Jg,rSw:Xd}=nX($n,Vt,de,Ho),Qg=dX(String((U=yo??Xe)!==null&&U!==void 0?U:""),String((H=vo??Dr)!==null&&H!==void 0?H:"lucide"),k,j);if(Qg&&Qg.length>0){Ct.insert(new Js(Ho)),st=!0;const ic=Dt.visibility,zd=De.filter,_v=zd!=null&&`${zd}`.trim()!==""?ds(zd,Vt,de):void 0,bv=typeof _v=="string"&&iv(_v);for(let Ul=0;Ul<Qg.length;Ul++){const Yw=Qg[Ul],Ko=r.spawn();wmt(Ko,Yw,{userColorStroke:Ll,userColorFill:Jg,rSw:Xd,zIndex:Dt.zIndex!=null?Dt.zIndex:0,visibility:(N=ic)!==null&&N!==void 0?N:"inherited",name:`${re}__i${Ul}`,strokeAsPlaceholderFillForRasterFilter:bv}),Ct.appendChild(Ko),ve.push(Ko)}}else{Ct.insert(new $t({x:0,y:0,width:k,height:j,cornerRadius:0}));const ic=De,zd=oT(ic);oX(ic)==null&&zd!=null&&(ic.strokes=[{type:"solid",value:zd,opacity:1}]),ic.strokeWidth==null&&(ic.strokeWidth=2),ic.fills=[{type:"solid",value:"none",opacity:1}]}Ct.insert(new Hn({iconFontName:String((G=yo??Xe)!==null&&G!==void 0?G:""),iconFontFamily:String((Y=vo??Dr)!==null&&Y!==void 0?Y:"lucide"),layoutWidth:k>0?k:0,layoutHeight:j>0?j:0}))}Dt.clipMode&&Ct.insert(new Gc(Dt.clipMode));const{opacity:Q}=De,ft=De,ht=Array.isArray(ft.fills)?ft.fills:null;ht&&ht.length>=1&&!st&&Ct.insert(new Ce(PL(ht,Vt,de)));const ge=De,Ge=Array.isArray(ge.strokes)?ge.strokes:null;let Ye=null;Ge&&Ge.length>=1&&!st&&(Ye=PL(Ge,Vt,de),Ct.insert(new Fs(Ye)));const{strokeWidth:Ki,strokeDasharray:Wr,strokeDashCap:hi,strokeLinecap:Xs,strokeLinejoin:Kr,strokeMiterlimit:zs,strokeDashoffset:qu,strokeAlignment:vv}=De,lr=Ge==null?void 0:Ge.find(Dd),V=ds(Ki,Vt,de);if((Ye!=null&&Ye.length>0||V!=null||Ki!==void 0)&&!st){const Xe=V!==void 0?V:Ki,Dr=Xe!=null?{width:typeof Xe=="number"?Xe:Number(Xe)}:{},yo=Wr==="none"?[0,0]:(L=(q=Wr!=null&&Wr.includes(",")?Wr==null?void 0:Wr.split(","):Wr==null?void 0:Wr.split(" "))===null||q===void 0?void 0:q.map(Number))!==null&&L!==void 0?L:[0,0];Ct.insert(new Gt(Object.assign(Object.assign({},Dr),{colorVariableRef:qy(lr!=null&&typeof lr.value=="string"?lr.value:void 0),widthVariableRef:qy(Ki),dasharray:yo,linecap:Xs,linejoin:Kr,miterlimit:zs,dashoffset:qu,alignment:vv,dashcap:(J=sX(hi))!==null&&J!==void 0?J:"none"})))}const{markerStart:pt,markerEnd:Ot,markerFactor:ee}=Dt;(pt||Ot)&&Ct.insert(new qo({start:pt,end:Ot,factor:ee})),(Q!=null||ht&&ht.length>=1||Ge&&Ge.length>
10358=1)&&Ct.insert(new bo({opacity:Q??1}));const{dropShadowBlurRadius:qr,dropShadowColor:Oe,dropShadowOffsetX:mt,dropShadowOffsetY:Pt}=Dt;qr&&Ct.insert(new ro({color:ds(Oe,Vt,de),blurRadius:qr,offsetX:mt,offsetY:Pt}));const{innerShadowBlurRadius:He,innerShadowColor:ui,innerShadowOffsetX:kl,innerShadowOffsetY:rc}=Dt;He&&Ct.insert(new ac({color:ds(ui,Vt,de),blurRadius:He,offsetX:kl,offsetY:rc}));const{visibility:Kg}=Dt;Ct.insert(new he(Kg));const{name:Wd}=Dt;Ct.insert(new ba(Wd));const{lockAspectRatio:qg}=Dt;qg&&Ct.insert(new Mv);const{zIndex:jd}=Dt;Ct.insert(new Ls(jd??0));const{sizeAttenuation:Jf,strokeAttenuation:kc}=Dt;Jf&&Ct.insert(new Xc),kc&&Ct.insert(new Qn);const{wireframe:er}=Dt;er&&Ct.insert(new jy(!0));const{locked:My}=Dt;My&&Ct.insert(new tu);const{animation:Zg}=Dt;Zg&&Array.isArray(Zg.keyframes)&&Zg.keyframes.length>0&&Ct.insert(new _a({keyframes:Zg.keyframes,options:Zg.options}));const{filter:Zu}=Dt;if(Zu&&(Ct.insert(new La({value:Zu})),Ct.insert(new yi),At==="iconfont"||At==="icon_font"))for(const Xe of ve)Xe.insert(new yi);const{blendMode:ph}=Dt;ph!=null&&ph!=="normal"&&Ct.insert(new zy({mode:ph}));const{display:VS}=Dt;VS==="flex"&&Ct.insert(new mh),rt&&((tt=i.get(rt))===null||tt===void 0||tt.appendChild(Ct)),Gr.push(Ct.id().hold())}return{entities:Gr,idEntityMap:i}}const Goe={auto:"alphabetic",central:"middle",middle:"middle",alphabetic:"alphabetic",ideographic:"ideographic",hanging:"hanging"};function Woe(t){const{viewBox:e,width:r,height:i}=t,{x:s,y:o,width:n,height:a}=e.baseVal;return n===0||a===0||r.baseVal.unitType===2||i.baseVal.unitType===2?{x:s,y:o,zoom:1}:{x:s,y:o,zoom:Math.min(r.baseVal.value/n,i.baseVal.value/a)}}EG=function(t,e=[],r,i=0,s){var o,n;const a=[];for(const l of t){let c=l.tagName.toLowerCase(),h=l.id||oc();if(c==="svg")c="g";else if(c==="defs"){e.push(...Array.from(l.childNodes));continue}else if(c==="use"){const f=l.getAttribute("xlink:href");if(f){const g=e.find(p=>p.id===f.replace("#",""));if(g)return EG([g],e,r)}continue}else if(c==="tspan")continue;let u=!1;if(c==="g"&&Array.from(l.children).filter(f=>f.tagName!=="defs").length===1&&(u=!0,h=void 0,s=l.attributes),!u){const f=[...Array.from(l.attributes),...Array.from(s||[])].reduce((v,b)=>{let y=joe(b.name),_=b.value;if(_.startsWith("url(#"))if(y==="markerStart"||y==="markerEnd")_="line";else{const w=_.replace("url(#","").replace(")",""),E=e.find(A=>A.id===w);E&&(_=Xoe(E))}return c==="rect"&&(y==="rx"||y==="ry")?(y="cornerRadius",_=Number(_)):y==="cx"||y==="cy"||y==="x"||y==="y"||y==="x1"||y==="y1"||y==="x2"||y==="y2"||y==="rx"||y==="ry"||y==="r"||y==="width"||y==="height"||y==="opacity"||y==="fillOpacity"||y==="strokeOpacity"||y==="strokeWidth"||y==="strokeMiterlimit"||y==="strokeDashoffset"||y==="fontSize"?_=Number(_.replace("px","")):y==="textAnchor"&&(y="textAlign",_==="middle"&&(_="center")),v[y]=_,v},{});if(c==="circle")c="ellipse",Object.assign(f,{rx:f.r,ry:f.r}),delete f.r;else if(c==="text"){if(l.style.font&&(f.fontFamily=l.style.fontFamily,f.fontSize=Number(l.style.fontSize.replace("px","")),f.fontStyle=l.style.fontStyle,f.fontWeight=l.style.fontWeight,f.fontVariant=l.style.fontVariant),l.style.fill&&(f.fills=[{type:"solid",value:l.style.fill,opacity:1}]),l.style.textDecoration){const[w,E,A,x]=l.style.textDecoration.split(" ");f.decorationStyle=A,f.decorationLine=w,f.decorationColor=x,f.decorationThickness=Number(E.replace("px",""))}const v=Array.from(l.children).filter(w=>w.tagName==="tspan");v.length>0?f.content=v.map(w=>w.textContent).join(` 10359`):f.content=(o=l.textContent)===null||o===void 0?void 0:o.trim();const b=(n=l.attributes.getNamedItem("dominant-baseline"))===null||n===void 0?void 0:n.value;b&&(f.textBaseline=Goe[b]);const{x:y,y:_}=f;f.anchorX=y,f.anchorY=_,delete f.x,delete f.y,delete f.style}else if(c==="polygon"){c="path";const v=nc(f.points);let b="";v.forEach((y,_)=>{_===0?b+=`M${y[0]},${y[1]}`:b+=`L${y[0]},${y[1]}`}),b+="Z",f.d=b,delete f.points}const g=l.getAttribute("visibility");g&&(f.visibility=g);const p=l.getAttribute("vector-effect");p&&(f.sizeAttenuation=p==="non-scaling-size",f.strokeAttenuation=p==="non-scaling-stroke"),f.name=l.getAttribute("name")||c==="text"&&f.content||`Layer ${h}`,f.zIndex=i++;const m=Object.assign(Object.assign({id:h,parentId:me(r)?void 0:`${r}`,type:c},Ibt[c]),f);su(m),zc(m),a.push(m),zoe(f.transform||"",m)}
10359const d=EG(Array.from(l.children),e,h,0,s).filter(Boolean);a.push(...d)}return a};function joe(t){return t.replace(/-([a-z])/g,(e,r)=>r.toUpperCase())}function wU(t){return lc(t.baseVal)?t.baseVal:t.baseVal.valueInSpecifiedUnits}function Xoe(t){if(t.tagName==="linearGradient"){const{x1:e,y1:r,x2:i,y2:s}=t,o=Math.atan2(wU(s)-wU(r),wU(i)-wU(e))*180/Math.PI,n=Array.from(t.querySelectorAll("stop")).map(a=>{const l=wU(a.offset);return`${a.getAttribute("stop-color")} ${l*100}%`});return`linear-gradient(${o}deg, ${n.join(",")})`}else t.tagName;return""}function zoe(t,e){var r,i;let s;e.type==="text"&&(s=om(e),e.fontBoundingBoxAscent=s.fontMetrics.fontBoundingBoxAscent,e.fontBoundingBoxDescent=s.fontMetrics.fontBoundingBoxDescent,e.hangingBaseline=s.fontMetrics.hangingBaseline,e.ideographicBaseline=s.fontMetrics.ideographicBaseline);const{minX:o,minY:n,maxX:a,maxY:l}=dYt(e,s);if(e.x=o,e.y=n,e.width=a-o,e.height=l-n,e.rotation=0,e.scaleX=1,e.scaleY=1,t!==""){const h=[];m9t(t).forEach(v=>{const{type:b}=v;if(b==="translate"){const{tx:y,ty:_}=v;h.push(Jx(y,_))}else if(b==="scale"){const{sx:y,sy:_}=v;h.push(P2(y,_))}else if(b==="rotate"){const{cx:y,cy:_,angle:w}=v;h.push(eZ(w,y-o,_-n))}else b==="matrix"&&h.push(f9t(v))});const u=$j(h),{translate:{tx:d,ty:f},scale:{sx:g,sy:p},rotation:{angle:m}}=y9t(u);e.x=d+o,e.y=f+n,e.rotation=m,e.scaleX=g,e.scaleY=p}const{type:c}=e;c==="ellipse"?(delete e.cx,delete e.cy,delete e.rx,delete e.ry):c==="polyline"?e.points=ip(nc(e.points).map(h=>[h[0]-o,h[1]-n])):c==="path"?e.d=xy(e.d,-o,-n):c==="text"?(e.anchorX=((r=e.anchorX)!==null&&r!==void 0?r:0)-o,e.anchorY=((i=e.anchorY)!==null&&i!==void 0?i:0)-n):c==="line"&&(e.x1=e.x1-o,e.y1=e.y1-n,e.x2=e.x2-o,e.y2=e.y2-n),delete e.transform}function xy(t,e,r){const i=ep(t),s=e!==0,o=r!==0;return i.forEach(n=>{const[a]=n;a==="M"||a==="L"?(s&&(n[1]+=e),o&&(n[2]+=r)):a==="H"?s&&(n[1]+=e):a==="V"?o&&(n[1]+=r):a==="A"?(s&&(n[6]+=e),o&&(n[7]+=r)):a==="T"?(s&&(n[1]+=e),o&&(n[2]+=r)):a==="C"?(s&&(n[1]+=e,n[3]+=e,n[5]+=e),o&&(n[2]+=r,n[4]+=r,n[6]+=r)):(a==="S"||a==="Q")&&(s&&(n[1]+=e,n[3]+=e),o&&(n[2]+=r,n[4]+=r))}
10359),i.forEach(n=>{for(let a=1;a<n.length;a++){const l=n[a];typeof l=="number"&&Number.isFinite(l)&&(n[a]=Obt(l,2))}}),Bv(i)}const Voe=1e-8;function Obt(t,e){if(!Number.isFinite(t))return t;const r=Math.pow(10,e),i=Math.round(t*r)/r;return Object.is(i,-0)||Math.abs(i)<Voe&&r>=1?0:i}function Yoe(t){const e=Kst(t);return e[6]=0,e[7]=0,e[8]=1,e}function EU(t,e){const r=ep(t);return r.forEach(i=>{const[s]=i;if(s==="M"||s==="L"||s==="T"){const[o,n]=Qt(it(),[i[1],i[2]],e);i[1]=o,i[2]=n}else if(s==="H"){const[o]=Qt(it(),[i[1],0],e);i[1]=o}else if(s==="V"){const[,o]=Qt(it(),[0,i[1]],e);i[1]=o}else if(s==="A"){const o=e[0],n=e[1],a=e[3],l=e[4],c=Math.hypot(o,n),h=Math.hypot(a,l);i[1]=i[1]*c,i[2]=i[2]*h;const[u,d]=Qt(it(),[i[6],i[7]],e);i[6]=u,i[7]=d}else if(s==="C"){const[o,n]=Qt(it(),[i[1],i[2]],e);i[1]=o,i[2]=n;const[a,l]=Qt(it(),[i[3],i[4]],e);i[3]=a,i[4]=l;const[c,h]=Qt(it(),[i[5],i[6]],e);i[5]=c,i[6]=h}else if(s==="Q"||s==="S"){const[o,n]=Qt(it(),[i[1],i[2]],e);i[1]=o,i[2]=n;const[a,l]=Qt(it(),[i[3],i[4]],e);i[3]=a,i[4]=l}}),r.forEach(i=>{for(let s=1;s<i.length;s++){const o=i[s];typeof o=="number"&&Number.isFinite(o)&&(i[s]=Obt(o,2))}}),Bv(r)}function sQ(t,e,r,i){const s=Math.PI/6,o=-Math.PI/6,n=t+r*Math.cos(s+i),a=e+r*Math.sin(s+i),l=t+r*Math.cos(o+i),c=e+r*Math.sin(o+i);return[[n,a],[t,e],[l,c]]}var zz=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},oQ=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};const Vh={strokes:[{type:"solid",value:"none",opacity:1}],strokeOpacity:1,strokeWidth:1,strokeLinecap:"butt",strokeLinejoin:"miter",strokeAlignment:"center",strokeMiterlimit:4,strokeDasharray:"0,0",strokeDashoffset:0,strokeDashCap:"none"},AU={markerStart:"none",markerEnd:"none",markerFactor:3},Ld={fillOpacity:1},tc={visibility:"inherited",x:0,y:0,scaleX:1,scaleY:1,rotation:0,opacity:1},Ibt={rect:Object.assign(Object.assign(Object.assign({x:0,y:0,width:0,height:0,cornerRadius:0,dropShadowColor:"none",dropShadowOffsetX:0,dropShadowOffsetY:0,dropShadowBlurRadius:0,innerShadowBlurRadius:0,innerShadowColor:"none",innerShadowOffsetX:0,innerShadowOffsetY:0},tc),Ld),Vh),"rough-rect":Object.assign(Object.assign(Object.assign({x:0,y:0,width:0,height:0,cornerRadius:0},tc),Ld),Vh),"rough-ellipse":Object.assign(Object.assign(Object.assign({cx:0,cy:0,rx:0,ry:0},tc),Ld),Vh),"rough-line":Object.assign(Object.assign({x1:0,y1:0,x2:0,y2:0,hitStrokeWidth:-1},tc),Vh),"rough-polyline":Object.assign(Object.assign(Object.assign(Object.assign({hitStrokeWidth:-1},tc),Ld),Vh),AU),"rough-path":Object.assign(Object.assign(Object.assign(Object.assign({hitStrokeWidth:-1},tc),Ld),Vh),AU),ellipse:Object.assign(Object.assign(Object.assign({cx:0,cy:0,rx:0,ry:0},tc),Ld),Vh),line:Object.assign(Object.assign(Object.assign({x1:0,y1:0,x2:0,y2:0,hitStrokeWidth:-1},tc),Vh),AU),polyline:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({hitStrokeWidth:-1},tc),Ld),Vh),AU),{fill:"none"}),brush:Object.assign(Object.assign(Object.assign({},tc),Ld),Vh),path:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({fillRule:"nonzero",hitStrokeWidth:-1},tc),Ld),Vh),AU),{fill:"none"}),text:Object.assign(Object.assign(Object.assign({fontFamily:"sans-serif",fontSize:12,fontWeight:"normal",fontStyle:"normal",fontVariant:"normal",letterSpacing:0,whiteSpace:"normal",textAlign:"start",textBaseline:"alphabetic",lineHeight:0,leading:0},tc),Ld),Vh),g:Object.assign(Object.assign({},tc),{strokeOpacity:1}),"vector-network":Object.assign(Object.assign(Object.assign({},tc),Ld),Vh),html:{x:0,y:0,width:0,height:0,html:""},embed:{x:0,y:0,width:0,height:0,url:""},iconfont:Object.assign(Object.assign(Object.assign({x:0,y:0,width:24,height:24,iconFontName:"",iconFontFamily:"lucide"},tc),Ld),Vh),mesh3d:Object.assign({x:0,y:0,width:100,height:100,z:0,geometry:"cube",scale3d:100,rotation3d:[0,0,0]},tc),light3d:Object.assign({x:0,y:0,lightType:"directional",intensity:1,direction:[-.5,-.7,-.5],z:0},tc),ref:Object.assign(Object.assign(Object.assign({x:0,y:0,width:0,height:0,ref:""},tc),Ld),Vh)};function nQ(t,e,r){if(!Number.isFinite(r)||r<=0)return 0;const i=Na(t)?parseFloat(t):Number(t??0),s=Na(e)?parseFloat(e):Number(e??0);if(!Number.isFinite(i)||!Number.isFinite(s)||i<=0||s<=0)return 0;const o=Math.min(i,s)/2;return Math.min(r,o)}function Dbt(t,e,r){const i=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),s=`${e}: ${i}`,o=t.getAttribute("style");t.setAttribute("style",o!=null&&o.trim()?`${o.trim()}; ${s}`:s)}function Vz(t){return zz(this,void 0,void 0,function*(){var e,r,i;const s=[],o=new Map;for(const f of t)o.set(f.id,f);const n=new Set(o.keys());for(const f of t)su(f),zc(f);const a=fZ(t),l=new Map,c=new WeakMap,h=t.map(f=>f.id),u=t.filter(f=>!me(f.parentId)&&n.has(f.parentId)).map(f=>[f.parentId,f.id]),d=Pgt.array(h,u);for(const f of d){const g=o.get(f),{id:p,parentId:m,type:v}=g,b=oQ(g,["id","parentId","type"]),y=v==null?void 0:v.startsWith("rough-"),_=v==="vector-network",w=!y&&!_&&we(v==="iconfont"?"g":v),E=b,{x:A=0,y:x=0,width:S,height:T,scaleX:R=1,scaleY:B=1,rotation:O=0,innerShadowColor:C,innerShadowOffsetX:F,innerShadowOffsetY:U,innerShadowBlurRadius:H,dropShadowColor:N,dropShadowOffsetX:G,dropShadowOffsetY:Y,dropShadowBlurRadius:q,decorationColor:L,decorationLine:J,decorationStyle:tt,decorationThickness:bt,strokeAlignment:ct,tessellationMethod:Xt,cornerRadius:It,zIndex:zt,anchorX:Ht,anchorY:Lt,fontFamily:tr,fontSize:Gr,fontWeight:re,fontStyle:ci,fontVariant:Dt,fontKerning:rt,content:At,letterSpacing:Vt,lineHeight:de,whiteSpace:Rt,wordWrap:De,wordWrapWidth:st,textAlign:ve,textBaseline:Ct,bitmapFontKerning:mi,physical:ws,esdt:$r,leading:Ne,maxLines:mo,visibility:Es,fractionalIndex:z,fontBoundingBoxAscent:ut,fontBoundingBoxDescent:M,hangingBaseline:D,ideographicBaseline:k,textOverflow:j,markerStart:Q,markerEnd:ft,markerFactor:ht,filter:ge,
10359sizeAttenuation:Ge,strokeAttenuation:Ye,hitStrokeWidth:Ki,svgDataAttributes:Wr,version:hi,versionNonce:Xs,updated:Kr,clipMode:zs,display:qu,alignItems:vv,justifyContent:lr,padding:V,margin:pt,gap:Ot,rowGap:ee,columnGap:qr,flexBasis:Oe,flexGrow:mt,flexShrink:Pt,flexDirection:He,flexWrap:ui,minWidth:kl,maxWidth:rc,minHeight:Kg,maxHeight:Wd,fromId:qg,toId:jd,orthogonal:Jf,exitX:kc,exitY:er,exitPerimeter:My,exitDx:Zg,exitDy:Zu,entryX:ph,entryY:VS,entryPerimeter:Xe,entryDx:Dr,entryDy:yo,edgeStyle:vo,sourceJettySize:$n,targetJettySize:Ho,jettySize:Ll,sourcePortConstraint:Jg,targetPortConstraint:Xd,portConstraint:Qg,iconFontName:ic,iconFontFamily:zd,lockAspectRatio:_v,blendMode:bv}=E,Ul=oQ(E,["x","y","width","height","scaleX","scaleY","rotation","innerShadowColor","innerShadowOffsetX","innerShadowOffsetY","innerShadowBlurRadius","dropShadowColor","dropShadowOffsetX","dropShadowOffsetY","dropShadowBlurRadius","decorationColor","decorationLine","decorationStyle","decorationThickness","strokeAlignment","tessellationMethod","cornerRadius","zIndex","anchorX","anchorY","fontFamily","fontSize","fontWeight","fontStyle","fontVariant","fontKerning","content","letterSpacing","lineHeight","whiteSpace","wordWrap","wordWrapWidth","textAlign","textBaseline","bitmapFontKerning","physical","esdt","leading","maxLines","visibility","fractionalIndex","fontBoundingBoxAscent","fontBoundingBoxDescent","hangingBaseline","ideographicBaseline","textOverflow","markerStart","markerEnd","markerFactor","filter","sizeAttenuation","strokeAttenuation","hitStrokeWidth","svgDataAttributes","version","versionNonce","updated","clipMode","display","alignItems","justifyContent","padding","margin","gap","rowGap","columnGap","flexBasis","flexGrow","flexShrink","flexDirection","flexWrap","minWidth","maxWidth","minHeight","maxHeight","fromId","toId","orthogonal","exitX","exitY","exitPerimeter","exitDx","exitDy","entryX","entryY","entryPerimeter","entryDx","entryDy","edgeStyle","sourceJettySize","targetJettySize","jettySize","sourcePortConstraint","targetPortConstraint","portConstraint","iconFontName","iconFontFamily","lockAspectRatio","blendMode"]),Yw=(e=a.get(f))!==null&&e!==void 0?e:{},Ko=Object.assign(Object.assign({},Ul),Yw);su(Ko),zc(Ko);const Qf=Ky(Ko.fills);if(Qf){Ko.fill=Qf.fill;const qi=(r=Qf.fillOpacity)!==null&&r!==void 0?r:1,_n=typeof qi=="number"&&Number.isFinite(qi)?qi:parseFloat(String(qi));Ko.fillOpacity=Number.isFinite(_n)?Math.max(0,Math.min(1,_n)):1}const $w=rv(Ko.strokes);if($w){Ko.stroke=$w.stroke;const qi=(i=$w.strokeOpacity)!==null&&i!==void 0?i:1,_n=typeof qi=="number"&&Number.isFinite(qi)?qi:parseFloat(String(qi));Ko.strokeOpacity=Number.isFinite(_n)?Math.max(0,Math.min(1,_n)):1}const sc=Ko,nl=Object.assign(Object.assign({},g),Yw);if(w&&Object.entries(Ko).forEach(([qi,_n])=>{qi==="hitStrokeWidth"||qi==="svgDataAttributes"||qi==="filter"||qi==="fills"||qi==="strokes"||`${_n}`!=""&&`${Ibt[v][qi]}`!=`${_n}`&&(lc(_n)&&(_n=ti(_n)),w.setAttribute(Pbt(qi),`${_n}`))}),(v==="rect"||v==="ellipse"||v==="polyline"||v==="path")&&(sc.fill||w.setAttribute("fill","none")),v==="ellipse")w.setAttribute("cx",`${Na(S)?S:ti(S/2)}`),w.setAttribute("cy",`${Na(T)?T:ti(T/2)}`),w.setAttribute("rx",`${Na(S)?S:ti(S/2)}`),w.setAttribute("ry",`${Na(T)?T:ti(T/2)}`);else if(v==="rect"){w.setAttribute("width",`${Na(S)?S:ti(S)}`),w.setAttribute("height",`${Na(T)?T:ti(T)}`);{const qi=nQ(S,T,Number(It)||0);if(qi>0){const _n=ti(qi);w.setAttribute("rx",_n),w.setAttribute("ry",_n)}}}else if(v==="text"){let qi=0,_n=0;ve==="center"?qi=(S??0)/2:(ve==="right"||ve==="end")&&(qi=S??0),_n+=((de||Gr)-Gr)/2,w.setAttribute("x",`${ti(qi)}`),w.setAttribute("y",`${ti(_n)}`),w.removeAttribute("fill")}ve&&(ve==="center"?w.setAttribute("text-anchor","middle"):ve==="right"||ve==="end"?w.setAttribute("text-anchor","end"):(ve==="left"||ve==="start")&&w.setAttribute("text-anchor","start")),Ge&&w.setAttribute("vector-effect","non-scaling-size"),Ye&&w.setAttribute("vector-effect","non-scaling-stroke");const By=ct==="inner"||ct==="outer",YS=Q&&Q!=="none"||ft&&ft!=="none",wv=sc.fill&&Na(sc.fill)&&(iT(sc.fill)||EO(sc.fill)),Hw=sc.fill&&Na(sc.fill)&&sT(sc.fill),Oy=sc.fill&&Dv(sc.fill),Ev=Ko.stroke&&Na(Ko.stroke)&&sT(Ko.stroke),$S=Ko.stroke&&Dv(Ko.stroke),Av=!!zs,Kw=u.some(([qi])=>qi===f);let As;(Kw&&v!=="g"||By&&v!=="polyline"||y||_||wv||Hw||Oy||Ev||$S||YS||Av)&&(As=we("g"),w&&As.appendChild(w));let jU;By&&(jU=Hoe(nl,w,As));const Iy=jU??w;H>0&&Koe(nl,w),q>0&&qoe(nl,w||As),wv&&(yield XV(nl,w,As)),(Hw||Oy)&&jV(nl,w,As),(Ev||$S)&&Iy&&Ubt(nl,Iy,As??w),YS&&!y&&Iy&&zV(nl,Iy,As),Av&&(yield Joe(nl,w,As)),As=As||w,As.id=`node-${f}`;const HS=nl.filter;typeof HS=="string"&&HS.trim()!==""&&Dbt(As,"filter",HS.trim());const KB=oYt(bv);if(KB&&Dbt(As,"mix-blend-mode",KB),Fbt(As,{hitStrokeWidth:Ki,svgDataAttributes:Wr}),Es==="hidden"&&As.setAttribute("visibility","hidden"),It&&v!=="rect"){const qi=nQ(S,T,Number(It)||0);if(qi>0){const _n=ti(qi);As.setAttribute("rx",_n),As.setAttribute("ry",_n)}}if(y&&tne(nl,As),At&&ene(nl,As,w),v==="iconfont"||v==="icon_font"){const qi=As&&w&&As!==w?w:As;qi&&ine(qi,nl)}_&&Qoe(nl,As);const xv=ie.from_scale_angle_translation({x:R,y:B},O,{x:A??0,y:x??0}),KS=xv.m00,qB=xv.m01,XU=xv.m10,Ju=xv.m11,ZB=xv.m20,zU=xv.m21;if((KS!==1||qB!==0||XU!==0||Ju!==1||ZB!==0||zU!==0)&&As.setAttribute("transform",`matrix(${ti(KS)},${ti(qB)},${ti(XU)},${ti(Ju)},${ti(ZB)},${ti(zU)})`),l.set(f,As),c.set(As,f),m!=null&&n.has(m)){const qi=l.get(m);qi?qi.appendChild(As):s.push(As)}else s.push(As)}return s.sort((f,g)=>{const p=c.get(f),m=c.get(g),v=o.get(p),b=o.get(m);return vO(v.fractionalIndex,b.fractionalIndex)}),s})}function Pbt(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function $oe(t){return t.startsWith("data-")?t:`data-${Pbt(t)}`}function Fbt(t,e){const{hitStrokeWidth:r,svgDataAttributes:i}=e;if(r!=null&&Number.isFinite(r)&&r>=0&&t.setAttribute("data-hit-stroke-width",String(r)),i&&typeof i=="object")for(const[s,o]of Object.entries(i))o==null||String(o)===""||t.setAttribute($oe(s),String(o))}function Hoe(t,e,r){const{type:i}=t,{strokeWidth:s,strokeAlignment:o}=t,n=o==="inner",a=s/2;
10359if(i==="polyline"){const{points:l}=t,c=l.split(" ").map(u=>u.split(",").map(Number)),h=BJ(c,n,s);e.setAttribute("points",ip(h));return}else{const l=e.cloneNode();if(e.setAttribute("stroke","none"),l.setAttribute("fill","none"),i==="ellipse"){const{width:c,height:h}=t,u=n?-a:a;l.setAttribute("rx",`${ti((c??0)/2+u)}`),l.setAttribute("ry",`${ti((h??0)/2+u)}`)}else if(i==="rect"){const{width:c,height:h,strokeWidth:u,cornerRadius:d}=t,f=(c??0)+(n?-u:u),g=(h??0)+(n?-u:u);if(l.setAttribute("x",`${ti(n?a:-a)}`),l.setAttribute("y",`${ti(n?a:-a)}`),l.setAttribute("width",`${ti(f)}`),l.setAttribute("height",`${ti(g)}`),d){const p=nQ(f,g,d);if(p>0){const m=ti(p);l.setAttribute("rx",m),l.setAttribute("ry",m)}}}return r.appendChild(l),l}}function Koe(t,e,r){const{id:i}=t,{innerShadowOffsetX:s,innerShadowOffsetY:o,innerShadowBlurRadius:n,innerShadowColor:a}=t,l=we("defs"),c=we("filter");c.id=`filter_inner_shadow_${i}`;const h=we("feComponentTransfer");h.setAttribute("in","SourceAlpha");const u=we("feFuncA");u.setAttribute("type","table"),u.setAttribute("tableValues","1 0"),h.appendChild(u),c.appendChild(h);const d=we("feGaussianBlur");d.setAttribute("stdDeviation",`${(n||0)/4}`),c.appendChild(d);const f=we("feOffset");f.setAttribute("dx",`${(s||0)/2}`),f.setAttribute("dy",`${(o||0)/2}`),f.setAttribute("result","offsetblur"),c.appendChild(f);const g=we("feFlood");g.setAttribute("flood-color",a),g.setAttribute("result","color"),c.appendChild(g);const p=we("feComposite");p.setAttribute("in2","offsetblur"),p.setAttribute("operator","in"),c.appendChild(p);const m=we("feComposite");m.setAttribute("in2","SourceAlpha"),m.setAttribute("operator","in"),c.appendChild(m);const v=we("feMerge");c.appendChild(v);const b=we("feMergeNode");b.setAttribute("in","SourceGraphic");const y=we("feMergeNode");v.appendChild(b),v.appendChild(y),l.appendChild(c),e.appendChild(l);const _=e.getAttribute("filter")||"";e.setAttribute("filter",`${_} url(#${c.id})`.trim())}function qoe(t,e,r){const{id:i,width:s,height:o,dropShadowBlurRadius:n,dropShadowColor:a,dropShadowOffsetX:l,dropShadowOffsetY:c}=t,h=we("defs"),u=we("filter");u.id=`filter_drop_shadow_${i}`;const d=we("feDropShadow");d.setAttribute("dx",`${(l||0)/2*Math.sign(s??0)}
10359`),d.setAttribute("dy",`${(c||0)/2*Math.sign(o??0)}`),d.setAttribute("stdDeviation",`${(n||0)/4}`),d.setAttribute("flood-color",a),u.appendChild(d),h.appendChild(u),e.appendChild(h);const f=e.getAttribute("filter")||"";e.setAttribute("filter",`${f} url(#${u.id})`.trim())}function aQ(t,e,r){var i;const{width:s,height:o}=t,n=0,a=0;if(r.type==="mesh-gradient"){const h=`meshg_${QL(`${r.backgroundColor}|${r.colors.join("|")}`)}`;let u=e.querySelector(`#${h}`);if(!u){u=we("linearGradient"),u.setAttribute("gradientUnits","userSpaceOnUse");const m=(i=r.colors[4])!==null&&i!==void 0?i:"#888888";u.innerHTML=`<stop offset="0" stop-color="${r.backgroundColor}"></stop><stop offset="1" stop-color="${m}"></stop>`,u.id=h,e.appendChild(u)}const{x1:d,y1:f,x2:g,y2:p}=dE([n,a],s??0,o??0,0);return u.setAttribute("x1",`${d}`),u.setAttribute("y1",`${f}`),u.setAttribute("x2",`${g}`),u.setAttribute("y2",`${p}`),h}const l=Y0t(Object.assign(Object.assign({},r),{min:[n,a],width:s??0,height:o??0}));let c=e.querySelector(`#${l}`);if(!c){c=we(r.type==="linear-gradient"?"linearGradient":"radialGradient"),c.setAttribute("gradientUnits","userSpaceOnUse");let h="";r.steps.sort((u,d)=>u.offset.value-d.offset.value).forEach(({offset:u,color:d})=>{h+=`<stop offset="${u.value/100}" stop-color="${d}"></stop>`}),c.innerHTML=h,c.id=l,e.appendChild(c)}if(r.type==="linear-gradient"){const{angle:h}=r,{x1:u,y1:d,x2:f,y2:g}=dE([n,a],s??0,o??0,h);c.setAttribute("x1",`${u}`),c.setAttribute("y1",`${d}`),c.setAttribute("x2",`${f}`),c.setAttribute("y2",`${g}`)}else if(r.type==="radial-gradient"){const{cx:h,cy:u,size:d}=r,{x:f,y:g,r:p}=pO([n,a],s??0,o??0,h,u,d);c.setAttribute("cx",`${f}`),c.setAttribute("cy",`${g}`),c.setAttribute("r",`${p}`)}return l}function Nbt(t,e,r,i="fill"){const s=i==="stroke"?`filter-${t.id}-stroke-gradient`:`filter-${t.id}-gradient`;let o=e.querySelector(`#${s}`);o||(o=we("filter"),o.setAttribute("filterUnits","userSpaceOnUse"),o.setAttribute("x","0%"),o.setAttribute("y","0%"),o.setAttribute("width","100%"),o.setAttribute("height","100%"),o.id=s,e.appendChild(o));let n=0;r.forEach((l,c)=>{const h=aQ(t,e,l),u=`${h}_rect`,d=we("rect");d.setAttribute("x","0"),d.setAttribute("y","0"),d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.setAttribute("fill",`url(#${h})`),d.id=u,e.appendChild(d);const f=we("feImage");if(f.setAttribute("href",`#${u}`),f.setAttribute("result",`${s}-${c}`),o.appendChild(f),c>0){const g=we("feBlend");g.setAttribute("in",c===1?`${s}-${c-1}`:`${s}-blended-${n-1}`),g.setAttribute("in2",`${s}-${c}`),g.setAttribute("result",`${s}-blended-${n++}`),g.setAttribute("mode","multiply"),o.appendChild(g)}});const a=we("feComposite");return a.setAttribute("in",`${s}-blended-${n}`),a.setAttribute("in2","SourceGraphic"),a.setAttribute("operator","in"),o.appendChild(a),s}function Zoe(t,e,r,i){const{repetition:s,transform:o,width:n,height:a}=r,l=we("pattern");o&&l.setAttribute("patternTransform",o),l.setAttribute("patternUnits","userSpaceOnUse"),l.id=i,e.appendChild(l);const{x:c,y:h,width:u,height:d}=t;l.setAttribute("x",`${c}`),l.setAttribute("y",`${h}`);let f=n??0,g=a??0;return s==="repeat-x"?g=d??0:s==="repeat-y"?f=u??0:s==="no-repeat"&&(f=u??0,g=d??0),l.setAttribute("width",`${f}`),l.setAttribute("height",`${g}`),l}function kbt(t,e,r){const{width:i,height:s}=t,o=$0t({pattern:r});if(!e.querySelector(`#${o}`)){const n=r.image;if(n){const a=we("image");a.setAttribute("href",n);const l=Zoe(t,e,r,o);e.appendChild(l),l.appendChild(a),a.setAttribute("x","0"),a.setAttribute("y","0"),a.setAttribute("width",`${r.width||i}`),a.setAttribute("height",`${r.height||s}`)}}return o}jV=function(t,e,r){var i;const s=Lbt(r),o=(i=oT(t))!==null&&i!==void 0?i:"";if(Dv(o)){const n=kbt(t,s,o);e==null||e.setAttribute("fill",`url(#${n})`)}else{const n=nm(o);if(n.length===1){const a=aQ(t,s,n[0]);e==null||e.setAttribute("fill",`url(#${a})`)}else{const a=Nbt(t,s,n);e==null||e.setAttribute("filter",`url(#${a})`),e==null||e.setAttribute("fill","black")}}};function Lbt(t){const e=t.firstElementChild;if((e==null?void 0:e.localName)==="defs")return e;const r=we("defs");return t.prepend(r),r}function Ubt(t,e,r){var i,s;const o=Lbt(r);zc(t);const n=(s=(i=rv(t.strokes))===null||i===void 0?void 0:i.stroke)!==null&&s!==void 0?s:"";
10359if(!(!n||String(n).trim()===""))if(Dv(n)){const a=kbt(t,o,n);e==null||e.setAttribute("stroke",`url(#${a})`)}else{const a=nm(n);if(a.length===1){const l=aQ(t,o,a[0]);e==null||e.setAttribute("stroke",`url(#${l})`)}else if(a.length>1){const l=Nbt(t,o,a,"stroke"),c=(e==null?void 0:e.getAttribute("filter"))||"";e==null||e.setAttribute("filter",`${c} url(#${l})`.trim()),e==null||e.setAttribute("stroke","black")}}}function Gbt(t,e,r,i=!1){var s,o;zc(t);const n=rv(t.strokes),a=(s=n==null?void 0:n.stroke)!==null&&s!==void 0?s:"none",l=(o=n==null?void 0:n.strokeOpacity)!==null&&o!==void 0?o:1,c=typeof l=="number"&&Number.isFinite(l)?l:parseFloat(String(l))||1,{strokeWidth:h,strokeLinecap:u,strokeLinejoin:d,markerFactor:f=3}=t,g=`marker-${r}-${i?"end":"start"}-${h}`;if(!e.querySelector(`#${g}`)){const p=h*f,m=p*f,v=p*f,b=v/f,y=we("marker");if(y.setAttribute("id",g),y.setAttribute("markerUnits","userSpaceOnUse"),y.setAttribute("markerWidth",`${m}`),y.setAttribute("markerHeight",`${m}`),y.setAttribute("viewBox",`-${b} -${b} ${v} ${v}`),y.setAttribute("refX","0"),y.setAttribute("refY","0"),i?y.setAttribute("orient","auto"):y.setAttribute("orient","auto-start-reverse"),e.appendChild(y),r==="line"||r==="triangle"||r==="diamond"){const _=we("path");let w="";if(r==="line"){const E=sQ(0,0,p,Math.PI);w=`M ${E[0][0]} ${E[0][1]} L ${E[1][0]} ${E[1][1]} L ${E[2][0]} ${E[2][1]}`,_.setAttribute("fill","none")}else if(r==="triangle"){const E=sQ(0,0,p,Math.PI);w=`M ${E[0][0]} ${E[0][1]} L ${E[1][0]} ${E[1][1]} L ${E[2][0]} ${E[2][1]} Z`,_.setAttribute("fill",a),!me(c)&&c!==1&&_.setAttribute("fill-opacity",`${c}`)}else{const E=[0,0],A=[-(p*.5),0],x=[-p,0],S=p*.4,T=[A[0],A[1]-S],R=[A[0],A[1]+S];w=`M ${E[0]} ${E[1]} L ${T[0]} ${T[1]} L ${x[0]} ${x[1]} L ${R[0]} ${R[1]} Z`,_.setAttribute("fill",a),!me(c)&&c!==1&&_.setAttribute("fill-opacity",`${c}`)}_.setAttribute("stroke",a),_.setAttribute("stroke-width",`${h}`),!me(c)&&c!==1&&_.setAttribute("stroke-opacity",`${c}`),me(u)||_.setAttribute("stroke-linecap",u),me(d)||_.setAttribute("stroke-linejoin",d),_.setAttribute("d",w),y.appendChild(_)}}return g}zV=function(t,e,r){const{markerStart:i,markerEnd:s}=t,o=we("defs");if(r.prepend(o),i!=="none"){const n=Gbt(t,o,i);e==null||e.setAttribute("marker-start",`url(#${n})`)}if(s!=="none"){const n=Gbt(t,o,s,!0);e==null||e.setAttribute("marker-end",`url(#${n})`)}};function Wbt(t,e){return zz(this,arguments,void 0,function*(r,i,s=!1){const o=s?`mask-${r.id}`:`clip-path-${r.id}`;if(!i.querySelector(`#${o}`)){const n=we(s?"mask":"clipPath");n.setAttribute("id",o);const{clipMode:a}=r,l=oQ(r,["clipMode"]),[c]=yield Vz([l]);if(c.removeAttribute("id"),c.removeAttribute("transform"),s){const h=we("rect");h.setAttribute("x","-10000"),h.setAttribute("y","-10000"),h.setAttribute("width","20000"),h.setAttribute("height","20000"),h.setAttribute("fill","white"),n.appendChild(h),c.setAttribute("fill","black"),c.setAttribute("stroke","black")}n.appendChild(c),i.appendChild(n)}return o})}function Joe(t,e,r){return zz(this,void 0,void 0,function*(){const{clipMode:i}=t,s=we("defs");if(r.prepend(s),i==="clip"){const o=yield Wbt(t,s);r.setAttribute("clip-path",`url(#${o})`)}else if(i==="erase"){const o=yield Wbt(t,s,!0);r.setAttribute("mask",`url(#${o})`)}})}function Qoe(t,e){var r,i;su(t),zc(t);const{vertices:s=[],segments:o=[],regions:n}=t,a=Ky(t.fills),l=a==null?void 0:a.fill,c=(r=a==null?void 0:a.fillOpacity)!==null&&r!==void 0?r:1,h=typeof c=="number"&&Number.isFinite(c)?c:parseFloat(String(c))||1,u=rv(t.strokes),d=u==null?void 0:u.stroke,f=(i=u==null?void 0:u.strokeOpacity)!==null&&i!==void 0?i:1,g=typeof f=="number"&&Number.isFinite(f)?f:parseFloat(String(f))||1,{strokeWidth:p=1,strokeLinecap:m,strokeLinejoin:v,strokeDasharray:b,strokeDashoffset:y,opacity:_}=t,w=K_t(s,o,n);if(w&&l&&`${l}`!="none"){const A=we("path");A.setAttribute("d",w),A.setAttribute("fill",`${l}`),h!==1&&A.setAttribute("fill-opacity",`${ti(Math.max(0,Math.min(1,h)))}`),A.setAttribute("fill-rule",Yse(n)),A.setAttribute("stroke","none"),e.appendChild(A)}const E=$se(s,o);if(E&&d&&`${d}`!="none"&&p>0){const A=we("path");A.setAttribute("d",E),A.setAttribute("fill","none"),A.setAttribute("stroke",`${d}`),A.setAttribute("stroke-width",`${ti(p)}`),g!==1&&A.setAttribute("stroke-opacity",`${ti(Math.max(0,Math.min(1,g)))}`),m&&A.setAttribute("stroke-linecap",m),v&&A.setAttribute("stroke-linejoin",v),b&&b!=="0,0"&&b!=="0"&&(A.setAttribute("stroke-dasharray",b),y&&A.setAttribute("stroke-dashoffset",`${ti(y)}`)),e.appendChild(A)}
10359_!=null&&Number.isFinite(_)&&_!==1&&e.setAttribute("opacity",`${ti(_)}`)}function tne(t,e){var r,i,s,o;su(t),zc(t);const n=Ky(t.fills),a=(r=n==null?void 0:n.fill)!==null&&r!==void 0?r:"none",l=(i=n==null?void 0:n.fillOpacity)!==null&&i!==void 0?i:1,c=typeof l=="number"&&Number.isFinite(l)?l:parseFloat(String(l))||1,{strokeWidth:h}=t,u=(o=(s=rv(t.strokes))===null||s===void 0?void 0:s.stroke)!==null&&o!==void 0?o:"none";if(t.roughFillStyle==="watercolor"){const d=Cte(t);d&&d.forEach(f=>{const g=we("path");g.setAttribute("d",Ste(f)),g.setAttribute("fill",a),g.setAttribute("fill-opacity",String(wte*c)),g.setAttribute("stroke","none"),e.appendChild(g)})}j0t(t).forEach(d=>{const{type:f}=d,g=cpt(d),p=Bv(g,2),m=we("path");m.setAttribute("d",p),e.appendChild(m),f==="fillSketch"?(m.setAttribute("stroke",a),m.setAttribute("stroke-width",`${h}`),m.setAttribute("fill","none")):f==="path"?(m.setAttribute("stroke",u),m.setAttribute("fill","none"),m.setAttribute("stroke-width",`${h}`)):f==="fillPath"&&(m.setAttribute("fill",a),m.setAttribute("stroke","none"))})}function ene(t,e,r){su(t),zc(t);const i=Ky(t.fills),s=i==null?void 0:i.fill,{content:o,fontFamily:n,fontSize:a,fontWeight:l,fontStyle:c,fontVariant:h,decorationLine:u,decorationStyle:d,decorationColor:f,decorationThickness:g,letterSpacing:p}=t,m=s??"#000";e.setAttribute("dominant-baseline","hanging");const{lineHeight:v,lines:b}=om(t);if(b.length>1?b.forEach((y,_)=>{const w=we("tspan");w.textContent=y,w.setAttribute("x","0"),_>0&&w.setAttribute("dy",`${ti(v)}`),e.appendChild(w)}):e.textContent=o,e===r)e.setAttribute("font-family",n),e.setAttribute("font-size",`${a}`),l&&e.setAttribute("font-weight",`${l}`),c&&e.setAttribute("font-style",c),h&&e.setAttribute("font-variant",h),p&&e.setAttribute("letter-spacing",`${ti(p)}`),e.setAttribute("fill",m);else{let y="";const _=D2({fontFamily:n,fontSize:a,fontWeight:l,fontStyle:c,fontVariant:h});_&&(y+=`font: ${_};`),m&&(y+=`fill: ${m};`),p!==0&&(y+=`letter-spacing: ${ti(p)}px;`),y&&e.setAttribute("style",y)}if(u!=="none"&&g>0){const y=e.getAttribute("style")||"";e.setAttribute("style",y+`text-decoration: ${d} ${u} ${f} ${g}px;`)}}XV=function(t,e,r){return zz(this,void 0,void 0,function*(){var i;const s=Object.assign({},t);su(s),zc(s);let o=(i=oT(s))!==null&&i!==void 0?i:"";if(!o){e.setAttribute("fill","none");return}const n=we("defs"),a=we("pattern");a.id=`image-fill_${t.id}`,a.setAttribute("patternUnits","objectBoundingBox"),a.setAttribute("patternContentUnits","objectBoundingBox"),a.setAttribute("width","1"),a.setAttribute("height","1");const l=we("image");iT(o)&&(o=(yield SV(o)).toDataURL()),l.setAttribute("href",o),l.setAttribute("x","0"),l.setAttribute("y","0"),l.setAttribute("width","1"),l.setAttribute("height","1"),l.setAttribute("preserveAspectRatio","none"),a.appendChild(l),n.appendChild(a),r.appendChild(n),e.setAttribute("fill",`url(#${a.id})`)})};const rne=/^data:([a-z]+\/[a-z0-9\-\+]+)?(;charset=[a-z0-9\-]+)?(;base64)?,[a-z0-9\!\$&',\(\)\*\+,;=\-\._\~:@\/\?%\s]*$/i;EO=function(t){return rne.test(t)},iT=function(t){return t&&(t.startsWith("http")||t.startsWith("https")||t.startsWith("/"))};function ti(t){return t.toFixed(3).replace(/\.?0+$/,"")}function jbt(t,e){if(t==null)return e;const r=typeof t=="number"?t:parseFloat(String(t));return!Number.isFinite(r)||r<=0?e:r}function lQ(t,e,r,i,s){const o=gX(e.style,i,r,e.kind,!1);o&&o!=="none"?t.setAttribute("fill",o):t.setAttribute("fill","none");const n=fX(e.style,s,{primKind:e.kind}),a=pX(e.style,r,i);n>0?(t.setAttribute("stroke",a),t.setAttribute("stroke-width",ti(n)),t.setAttribute("stroke-linecap",mX(e.style.strokeLinecap)),t.setAttribute("stroke-linejoin",yX(e.style.strokeLinejoin))):t.setAttribute("stroke","none")}function ine(t,e){const r=jbt(e.width,24),i=jbt(e.height,24),{iconFontName:s="",iconFontFamily:o="lucide"}=e,n=k2(e,void 0,void 0),{userColorStroke:a,userColorFill:l,rSw:c}=nX(e,void 0,void 0,n),h=dX(String(s),String(o),r,i);if(!(!h||h.length===0))for(const u of h)if(u.kind==="path"){const d=we("path");d.setAttribute("d",u.d),lQ(d,u,a,l,c),t.appendChild(d)}else if(u.kind==="ellipse"){const d=we("ellipse");d.setAttribute("cx",ti(u.cx)),d.setAttribute("cy",ti(u.cy)),d.setAttribute("rx",ti(u.rx)),d.setAttribute("ry",ti(u.ry)),lQ(d,u,a,l,c),t.appendChild(d)}else{const d=we("line");d.setAttribute("x1",ti(u.x1)),d.setAttribute("y1",ti(u.y1)),d.setAttribute("x2",ti(u.x2)),d.setAttribute("y2",ti(u.y2)),lQ(d,u,a,l,c),t.appendChild(d)}}function Xbt(t){const e=Pr.get().getDocument().implementation.createDocumentType("svg","-//W3C//DTD SVG 1.1//EN","http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"),r=Pr.get().getDocument().implementation.createDocument("http://www.w3.org/2000/svg","svg",e);return r.replaceChild(t,r.documentElement),Pr.get().getXMLSerializer().serializeToString(r)}function zbt(t){return`data:image/svg+xml;charset=utf8,${encodeURIComponent(Xbt(t))}`}const Vbt="<path d='m19.7432 17.0869-4.072 4.068 2.829 2.828-8.473-.013-.013-8.47 2.841 2.842 4.075-4.068 1.414-1.415-2.844-2.842h8.486v8.484l-2.83-2.827z' fill='%23fff'/><path d='m18.6826 16.7334-4.427 4.424 1.828 1.828-5.056-.016-.014-5.054 1.842 1.841 4.428-4.422 2.474-2.475-1.844-1.843h5.073v5.071l-1.83-1.828z' fill='%23000'/>",Ybt="<path d='m9 17.9907v.005l5.997 5.996.001-3.999h1.999 2.02v4l5.98-6.001-5.98-5.999.001 4.019-2.021.002h-2l.001-4.022zm1.411.003 3.587-3.588-.001 2.587h3.5 2.521v-2.585l3.565 3.586-3.564 3.585-.001-2.585h-2.521l-3.499-.001-.001 2.586z' fill='%23fff'/><path d='m17.4971 18.9932h2.521v2.586l3.565-3.586-3.565-3.585v2.605h-2.521-3.5v-2.607l-3.586 3.587 3.586 3.586v-2.587z' fill='%23000'/>",Yz='<path d="M22.4789 9.45728L25.9935 12.9942L22.4789 16.5283V14.1032C18.126 14.1502 14.6071 17.6737 14.5675 22.0283H17.05L13.513 25.543L9.97889 22.0283H12.5674C12.6071 16.5691 17.0214 12.1503 22.4789 12.1031L22.4789 9.45728Z" fill="black"/><path fill-rule="evenodd" clip-rule="evenodd" d="M21.4789 7.03223L27.4035 12.9945L21.4789 18.9521V15.1868C18.4798 15.6549 16.1113 18.0273 15.649 21.0284H19.475L13.5128 26.953L7.55519 21.0284H11.6189C12.1243 15.8155 16.2679 11.6677 21.4789 11.1559L21.4789 7.03223ZM22.4789 12.1031C17.0214 12.1503 12.6071 16.5691 12.5674 22.0284H9.97889L13.513 25.543L17.05 22.0284H14.5675C14.5705 21.6896 14.5947 21.3558 14.6386 21.0284C15.1157 17.4741 17.9266 14.6592 21.4789 14.1761C21.8063 14.1316 22.1401 14.1069 22.4789 14.1032V16.5284L25.9935 12.9942L22.4789 9.45729L22.4789 12.1031Z" fill="white"/>';function Lw(t,e,r,i,s,o=16,n=16){const a=(-r-e)*(Math.PI/180),l=Math.sin(a),c=Math.cos(a),h=1*c-1*l,u=1*l+1*c;return`url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: ${s};'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='${h}' dy='${u}' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='${i?" scale(-1 1) translate(-32 0)":""} rotate(${e+r} 16 16)' filter='url(%23shadow)'>`+t.replaceAll('"',"'")+`</g></svg>") ${o} ${n}, pointer`}const $bt={default:()=>"default","ew-resize":(t,e,r)=>Lw(Ybt,t,0,e,r),"ns-resize":(t,e,r)=>Lw(Ybt,t,90,e,r),"nesw-resize":(t,e,r)=>Lw(Vbt,t,0,e,r),"nwse-resize":(t,e,r)=>Lw(Vbt,t,90,e,r),"nwse-rotate":(t,e,r)=>Lw(Yz,t,0,e,r),"nesw-rotate":(t,e,r)=>Lw(Yz,t,90,e,r),"senw-rotate":(t,e,r)=>Lw(Yz,t,180,e,r),"swne-rotate":(t,e,r)=>Lw(Yz,t,270,e,r)};function sne(t,e=0,r="black",i=!1){var s;return(s=$bt[t])===null||s===void 0?void 0:s.call($bt,id*e,i,r)}var $z=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};let Hbt,Kbt,qbt;rO={svg:"image/svg+xml",png:"image/png",jpg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif",jfif:"image/jfif",heic:"image/heic",heif:"image/heif"},Kd=Object.assign({text:"text/plain",html:"text/html",json:"application/json",binary:"application/octet-stream"},rO),Hbt=[Kd.text,Kd.html,...Object.values(rO)],Kbt=typeof navigator<"u"&&"clipboard"in navigator&&"writeText"in navigator.clipboard,qbt=t=>{t||(t=" ");const e=document.documentElement.getAttribute("dir")==="rtl",r=document.createElement("textarea");r.style.border="0",r.style.padding="0",r.style.margin="0",r.style.position="absolute",r.style[e?"right":"left"]="-9999px";const i=window.pageYOffset||document.documentElement.scrollTop;r.style.top=`${i}px`,r.style.fontSize="12pt",r.setAttribute("readonly",""),r.value=t,document.body.appendChild(r);let s=!1;try{r.select(),r.setSelectionRange(0,r.value.length),s=document.execCommand("copy")}catch(o){console.error(o)}return r.remove(),s};function one(t,e){return $z(this,void 0,void 0,function*(){var r,i;if(Kbt)try{yield navigator.clipboard.writeText(t||"");return}catch(s){console.error(s)}try{if(e){if((r=e.clipboardData)===null||r===void 0||r.setData(Kd.text,t||""),((i=e.clipboardData)===null||i===void 0?void 0:i.getData(Kd.text))!==t)throw new Error("Failed to setData on clipboardEvent");return}}catch(s){console.error(s)}if(!qbt(t))throw new Error("Error copying to clipboard.")})}let Zbt,Jbt,Qbt;Zbt=t=>{var e;const r=(e=t.clipboardData)===null||e===void 0?void 0:e.getData(Kd.html);if(!r)return null;try{const i=new DOMParser().parseFromString(r,Kd.html);if(twt(i.body).length)return{type:"html",value:r}}catch(i){console.error(`error in parseHTMLFromPaste: ${i.message}`)}return null},Jbt=(t,...e)=>$z(void 0,[t,...e],void 0,function*(r,i=!1){var s;try{return!i&&r&&Zbt(r)||{type:"text",value:(((s=r.clipboardData)===null||s===void 0?void 0:s.getData(Kd.text))||"").trim()}}catch{return{type:"text",value:""}}}),Qbt=t=>!!Array.isArray(t),ztt=(t,...e)=>$z(void 0,[t,...e],void 0,function*(r,i=!1){const s=yield Jbt(r,i);if(s.type==="html")return{html:s.value};try{const o=JSON.parse(s.value);if(Qbt(o))return{elements:o}}catch{}return{text:s.value}}),Xtt=({types:t,files:e})=>{var r,i,s,o;!t&&!e&&console.warn("createPasteEvent: no types or files provided");const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(t)for(const[a,l]of Object.entries(t)){if(typeof l!="string"){e=e||[],e.push(l);continue}try{if((r=n.clipboardData)===null||r===void 0||r.setData(a,l),((i=n.clipboardData)===null||i===void 0?void 0:i.getData(a))!==l)throw new Error(`Failed to set "${a}" as clipboardData item`)}catch(c){throw new Error(c.message)}}if(e){let a=-1;for(const l of e){a++;try{if((s=n.clipboardData)===null||s===void 0||s.items.add(l),((o=n.clipboardData)===null||o===void 0?void 0:o.files[a])!==l)throw new Error(`Failed to set file "${l.name}" as clipboardData item`)}catch(c){throw new Error(c.message)}}}return n};function twt(t){var e;let r=[];for(const i of Array.from(t.childNodes))if(i.nodeType===3){const s=(e=i.textContent)===null||e===void 0?void 0:e.trim();s&&r.push({type:"text",value:s})}else if(i instanceof HTMLImageElement){const s=i.getAttribute("src");s&&s.startsWith("http")&&r.push({type:"imageUrl",value:s})}else r=r.concat(twt(i));return r}GV=t=>!!t&&Object.values(rO).includes(t),Ttt=()=>$z(void 0,void 0,void 0,function*(){var t,e,r,i;const s={};let o;try{o=yield(t=navigator.clipboard)===null||t===void 0?void 0:t.read()}catch(n){try{if(!((e=navigator.clipboard)===null||e===void 0)&&e.readText){console.warn(`navigator.clipboard.readText() failed (${n.message}). Failling back to navigator.clipboard.read()`);const a=yield(r=navigator.clipboard)===null||r===void 0?void 0:r.readText();if(a)return{[Kd.text]:a}}}catch(a){if(!((i=navigator.clipboard)===null||i===void 0)&&i.read)console.warn(`navigator.clipboard.readText() failed (${a.message}). Failling back to navigator.clipboard.read()`);else{if(a.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${a.message}`),s;throw a}}throw n}for(const n of o)for(const a of n.types)if(Hbt.includes(a))try{if
10359(a===Kd.text||a===Kd.html)s[a]=yield(yield n.getType(a)).text();else if(GV(a)){const l=yield n.getType(a),c=new File([l],"",{type:a});s[a]=c}else throw new Error(`Unsupported clipboard type: ${a}`)}catch(l){console.warn(l.message)}return Object.keys(s).length===0&&console.warn("No clipboard data found from clipboard.read()."),s});function ewt(t){const e=new Map;for(const r of t)e.set(r.id,oc());return t.map(r=>{const i=r.parentId,s=i&&e.has(i)?e.get(i):void 0;return Object.assign(Object.assign({},r),{id:e.get(r.id),parentId:s})})}const Pc=t=>Math.round(t*Math.pow(10,6))/Math.pow(10,6),rwt=t=>{const e=new Map;for(const r of t){const i=r.join(",");e.has(i)||e.set(i,r)}return Array.from(e.values())},iwt=99999,Hz=({minX:t,minY:e,maxX:r,maxY:i})=>[[t,e],[r,e],[t,i],[r,i],[(t+r)/2,(e+i)/2]],swt=(t,[e,r])=>new Qe(t.minX+e,t.minY+r,t.maxX+e,t.maxY+r),owt=t=>{const e=t.getNodes(),r=new Map(e.map(n=>[n.id,n])),i=new Set(t.getAppState().layersSelected),s=new Set,o=n=>{var a,l;const c=new Set;let h=(a=r.get(n))===null||a===void 0?void 0:a.parentId;for(;h&&!c.has(h);)c.add(h),h=(l=r.get(h))===null||l===void 0?void 0:l.parentId;return c};return i.forEach(n=>o(n).forEach(a=>s.add(a))),e.flatMap(n=>{if(i.has(n.id)||s.has(n.id)||[...o(n.id)].some(c=>i.has(c)))return[];const a=t.getEntity(n);if(!a||a.has(jc)||a.has(Pn)&&!a.read(Pn).visible)return[];const l=t.getGeometryBounds([n]);return[l.minX,l.minY,l.maxX,l.maxY].every(Number.isFinite)?[l]:[]})},nwt=t=>{const e=t.getAppState().snapToObjectsDistance,r=t.getCamera().read(Pe).zoom;return Number.isFinite(e)&&r>0?Math.max(0,e)/r:0},Kz=(t,e,r,i,s)=>{for(const o of t)for(const n of e){const a=Pc(n[0]-o[0]),l=Pc(n[1]-o[1]);Math.abs(a)<=s[0]&&(Math.abs(a)<s[0]&&(r.length=0),r.push({type:"point",points:[o,n],offset:a}),s[0]=Math.abs(a)),Math.abs(l)<=s[1]&&(Math.abs(l)<s[1]&&(i.length=0),i.push({type:"point",points:[o,n],offset:l}),s[1]=Math.abs(l))}},awt=(t,e,r,i,s)=>{const{horizontalGaps:o,verticalGaps:n}=e,{minX:a,minY:l,maxX:c,maxY:h}=t,u=(a+c)/2,d=(l+h)/2;for(const f of o){if(!tj([l,h],f.overlap))continue;const g=f.startSide[0][0]+f.length/2,p=Pc(g-u);if(f.length>c-a&&Math.abs(p)<=s[0]){Math.abs(p)<s[0]&&(r.length=0),s[0]=Math.abs(p);const E={type:"gap",direction:"center_horizontal",gap:f,offset:p};r.push(E);continue}const{maxX:m}=f.endBounds,v=a-m,b=Pc(f.length-v);if(Math.abs(b)<=s[0]){Math.abs(b)<s[0]&&(r.length=0),s[0]=Math.abs(b);const E={type:"gap",direction:"side_right",gap:f,offset:b};r.push(E);continue}const{minX:y}=f.startBounds,_=y-c,w=Pc(_-f.length);if(Math.abs(w)<=s[0]){Math.abs(w)<s[0]&&(r.length=0),s[0]=Math.abs(w);const E={type:"gap",direction:"side_left",gap:f,offset:w};r.push(E);continue}}for(const f of n){if(!tj([a,c],f.overlap))continue;const g=f.startSide[0][1]+f.length/2,p=Pc(g-d);if(f.length>h-l&&Math.abs(p)<=s[1]){Math.abs(p)<s[1]&&(i.length=0),s[1]=Math.abs(p);const E={type:"gap",direction:"center_vertical",gap:f,offset:p};i.push(E);continue}const{minY:m}=f.startBounds,v=m-h,b=Pc(v-f.length);if(Math.abs(b)<=s[1]){Math.abs(b)<s[1]&&(i.length=0),s[1]=Math.abs(b);const E={type:"gap",direction:"side_top",gap:f,offset:b};i.push(E);continue}const{maxY:y}=f.endBounds,_=Pc(l-y),w=f.length-_;if(Math.abs(w)<=s[1]){Math.abs(w)<s[1]&&(i.length=0),s[1]=Math.abs(w);const E={type:"gap",direction:"side_bottom",gap:f,offset:w};i.push(E);continue}}},nne=t=>{const e=t.sort((n,a)=>n.minX-a.minX),r=[];let i=0;t:for(let n=0;n<e.length;n++){const a=e[n];for(let l=n+1;l<e.length;l++){if(++i>iwt)break t;const c=e[l],{minY:h,maxX:u,maxY:d}=a,{minX:f,minY:g,maxY:p}=c;u<f&&tj([h,d],[g,p])&&r.push({startBounds:a,endBounds:c,startSide:[[u,h],[u,d]],endSide:[[f,g],[f,p]],length:f-u,overlap:ej([h,d],[g,p])})}}const s=t.sort((n,a)=>n.minY-a.minY),o=[];i=0;t:for(let n=0;n<s.length;n++){const a=s[n];for(let l=n+1;l<s.length;l++){if(++i>iwt)break t;const c=s[l],{minX:h,maxX:u,maxY:d}=a,{minX:f,minY:g,maxX:p}=c;d<g&&tj([h,u],[f,p])&&o.push({startBounds:a,endBounds:c,startSide:[[h,d],[u,d]],endSide:[[f,g],[p,g]],length:g-d,overlap:ej([h,u],[f,p])})}}return{horizontalGaps:r,verticalGaps:o}},ane=(t,e,r,i=t.getGeometryBounds(t.getAppState().layersSelected.map(s=>t.getNodeById(s))))=>{if(!t.getAppState().snapToObjectsEnabled||!t.getAppState().layersSelected.length)return{snapOffset:[0,0],snapLines:[]};const s=owt(t),o=s.flatMap(Hz),n=nne(s),a=swt(i,e),l=nwt(t),c=[l,l],h=[],u=[];Kz(Hz(a),o,h,u,c),awt(a,n,h,u,c);const d=(p,m)=>{var v,b,y,_;const w=r==null?void 0:r[m];return(_=(b=(v=p.find(E=>Pc(E.offset)===Pc(w)))===null||v===void 0?void 0:v.offset)!==null&&b!==void 0?b:(y=p[0])===null||y===void 0?void 0:y.offset)!==null&&_!==void 0?_:0},f=[d(h,0),d(u,1)],g=swt(a,f);return c[0]=c[1]=1e-6,h.length=u.length=0,Kz(Hz(g),o,h,u,c),awt(g,n,h,u,c),{snapOffset:f,snapLines:[...lwt(h,u),...cne(g,[...h,...u].filter(p=>p.type==="gap"))]}},lne=(t,e,r)=>{var i,s,o,n;if(!t.getAppState().snapToObjectsEnabled)return{snapOffset:[0,0],snapLines:[]};const a=owt(t).flatMap(Hz),l=nwt(t),c=[],h=[],u=[l,l];let d,f;if(r){const g=Math.hypot(...r);if(!g)return{snapOffset:[0,0],snapLines:[]};f=[r[0]/g,r[1]/g];let p=1/0;for(const m of a)for(const v of[0,1]){if(Math.abs(f[v])<1e-6)continue;const b=Pc((m[v]-e[v])/f[v]);Math.abs(b)<=l&&Math.abs(b)<Math.abs(p)&&(p=b)}d=Number.isFinite(p)?[f[0]*p,f[1]*p]:[0,0]}else Kz([e],a,c,h,u),d=[(s=(i=c[0])===null||i===void 0?void 0:i.offset)!==null&&s!==void 0?s:0,(n=(o=h[0])===null||o===void 0?void 0:o.offset)!==null&&n!==void 0?n:0];return c.length=h.length=0,Kz([[e[0]+d[0],e[1]+d[1]]],a,c,h,[1e-6,1e-6]),f&&Math.abs(f[0])<1e-6&&(c.length=0),f&&Math.abs(f[1])<1e-6&&(h.length=0),{snapOffset:d,snapLines:lwt(c,h)}},lwt=(t,e)=>{const r={},i={};if(t.length>0){for(const s of t)if(s.type==="point"){const o=Pc(s.points[0][0]);r[o]||(r[o]=[]),r[o].push(...s.points.map(n=>[Pc(n[0]),Pc(n[1])]))}}if(e.length>0){for(const s of e)if(s.type==="point"){const o=Pc(s.points[0][1]);i[o]||(i[o]=[]),i[o].push(...s.points.map(n=>[Pc(n[0]),Pc(n[1])]))}}return Object.entries(r).map(([s,o])=>({type:"points",points:rwt(o.map(n=>[Number(s),n[1]]).sort((n,a)=>n[1]-a[1]))})).concat(Object.entries(i).map(([s,o])=>({type:"points",points:rwt(o.map(n=>[n[0],Number(s)]).sort((n,a)=>n[0]-a[0]))})))},cne=(t,e)=>{const r=[],{minX:i,minY:s,maxX:o,maxY:n}=t;
10359for(const a of e){const{minX:l,minY:c,maxX:h,maxY:u}=a.gap.startBounds,{minX:d,minY:f,maxX:g,maxY:p}=a.gap.endBounds,m=ej([s,n],a.gap.overlap),v=ej([i,o],a.gap.overlap);switch(a.direction){case"center_horizontal":{if(m){const b=(m[0]+m[1])/2;r.push({type:"gap",direction:"horizontal",points:[[a.gap.startSide[0][0],b],[i,b]]},{type:"gap",direction:"horizontal",points:[[o,b],[a.gap.endSide[0][0],b]]})}break}case"center_vertical":{if(v){const b=(v[0]+v[1])/2;r.push({type:"gap",direction:"vertical",points:[[b,a.gap.startSide[0][1]],[b,s]]},{type:"gap",direction:"vertical",points:[[b,n],[b,a.gap.endSide[0][1]]]})}break}case"side_right":{if(m){const b=(m[0]+m[1])/2;r.push({type:"gap",direction:"horizontal",points:[[h,b],[d,b]]},{type:"gap",direction:"horizontal",points:[[g,b],[i,b]]})}break}case"side_left":{if(m){const b=(m[0]+m[1])/2;r.push({type:"gap",direction:"horizontal",points:[[o,b],[l,b]]},{type:"gap",direction:"horizontal",points:[[h,b],[d,b]]})}break}case"side_top":{if(v){const b=(v[0]+v[1])/2;r.push({type:"gap",direction:"vertical",points:[[b,n],[b,c]]},{type:"gap",direction:"vertical",points:[[b,u],[b,f]]})}break}case"side_bottom":{if(v){const b=(v[0]+v[1])/2;r.push({type:"gap",direction:"vertical",points:[[b,u],[b,f]]},{type:"gap",direction:"vertical",points:[[b,p],[b,s]]})}break}}}return r},hne=(t,e,r)=>r?[Math.round(t/r)*r,Math.round(e/r)*r]:[t,e],une=t=>{let e=t.toString();const r=t.hostname.replace(/^www./,"");if(r==="youtu.be"){const i=t.pathname.split("/").filter(Boolean)[0],s=new URLSearchParams(t.search),o=s.get("t");o&&(s.set("start",o),s.delete("t"));const n=s.toString()?"?"+s.toString():"";e=`https://www.youtube.com/embed/${i}${n}`}else if((r==="youtube.com"||r==="m.youtube.com")&&t.pathname.match(/^\/watch/)){const i=t.searchParams.get("v"),s=new URLSearchParams(t.search);s.delete("v");const o=s.get("t");o&&(s.set("start",o),s.delete("t"));const n=s.toString()?"?"+s.toString():"";e=`https://www.youtube.com/embed/${i}${n}`}return e},dne=/TITLE +"([^"]*)"/,fne=/LUT_3D_SIZE +(\d+)/,pne=/DOMAIN_MIN +([\d.]+) +([\d.]+) +([\d.]+)/,gne=/DOMAIN_MAX +([\d.]+) +([\d.]+) +([\d.]+)/,cwt=/^([\d.e+-]+) +([\d.e+-]+) +([\d.e+-]+) *$/gm;function hwt(t){let e=dne.exec(t);const r=e!==null?e[1]:null;if(e=fne.exec(t),e===null)throw new Error("parseAdobeCube: Missing LUT_3D_SIZE information");const i=Number(e[1]);if(!Number.isFinite(i)||i<1)throw new Error(`parseAdobeCube: invalid LUT_3D_SIZE (${String(e[1])})`);let s=[0,0,0],o=[1,1,1];if(e=pne.exec(t),e!==null&&(s=[Number(e[1]),Number(e[2]),Number(e[3])]),e=gne.exec(t),e!==null&&(o=[Number(e[1]),Number(e[2]),Number(e[3])]),s[0]>o[0]||s[1]>o[1]||s[2]>o[2])throw new Error("parseAdobeCube: Invalid input domain");const n=[];for(cwt.lastIndex=0;(e=cwt.exec(t))!==null;)n.push([Number(e[1]),Number(e[2]),Number(e[3])]);const a=Math.pow(i,3);if(n.length!==a)throw new Error(`parseAdobeCube: expected ${a} RGB rows, got ${n.length}`);const l=new Uint8Array(a*4),c=new Float32Array(a*4);for(let h=0;h<a;h++){const u=n[h],d=h*4,f=u[0],g=u[1],p=u[2];c[d]=f,c[d+1]=g,c[d+2]=p,c[d+3]=1,l[d]=Math.max(0,Math.min(255,Math.round(f*255))),l[d+1]=Math.max(0,Math.min(255,Math.round(g*255))),l[d+2]=Math.max(0,Math.min(255,Math.round(p*255))),l[d+3]=255}return{title:r,size:i,domainMin:s,domainMax:o,volumeRgba:l,volumeRgbaF32:c}}function mne(t){const e=new Float32Array(1),r=new Int32Array(e.buffer);e[0]=t;const i=r[0],s=i>>16&32768,o=(i>>23&255)-127+15,n=i&8388607;if((i&2139095040)===2139095040)return i&8388607?s|32256:s|31744;if((i&2139095040)===0)return s;if(o>=31)return s|31744;if(o<=0){if(o<-10)return s;const a=n|8388608,l=14-o;let c=a>>l;return a&1<<l-1&&c++,s|c}return s|o<<10|n>>13}const qz=new WeakMap,uwt=new Set;Att=function(t){uwt.has(t)||(uwt.add(t),console.warn(`[LUT] Missing registered cube for key "${t}". Use registerCubeLutFromText(device, "${t}", cubeText).`))};function yne(t){return t==="f32"?X.F32_RGBA:t==="f16"?X.F16_RGBA:X.U8_RGBA_NORM}function vne(t,e){const r=t.length;if(e==="f32"){const s=new Float32Array(r);return s.set(t),s}const i=new Uint16Array(r);for(let s=0;s<r;s++)i[s]=mne(t[s]);return i}function _ne(t,e,r,i){var s;let o=qz.get(t);if(o||(o=new Map,qz.set(t,o)),o.has(e))return;const n=hwt(r),a=(s=i==null?void 0:i.atlasFormat)!==null&&s!==void 0?s:"u8",l=yne(a
10359),c=n.size,h=a==="u8"?n.volumeRgba:vne(n.volumeRgbaF32,a),u=t.createTexture({dimension:Xr.TEXTURE_3D,format:l,width:c,height:c,depthOrArrayLayers:c,mipLevelCount:1,usage:vi.SAMPLED});u.setImageData([h]),o.set(e,{texture:u,size:n.size,domainMin:n.domainMin,domainMax:n.domainMax})}btt=function(t,e){var r;return(r=qz.get(t))===null||r===void 0?void 0:r.get(e)},set=function(t){const e=qz.get(t);return!e||e.size===0?[]:[...e.keys()]};const dwt={workingSize:512,iterations:40};function bne(t,e,r,i,s,o){const n=r.length,a=new Int32Array(n*4);for(let l=0;l<n;l++){const c=r[l],h=c%s,u=Math.floor(c/s);a[l*4+0]=h<s-1&&t[c+1]?c+1:-1,a[l*4+1]=h>0&&t[c-1]?c-1:-1,a[l*4+2]=u>0&&t[c-s]?c-s:-1,a[l*4+3]=u<o-1&&t[c+s]?c+s:-1}return{interiorPixels:r,boundaryPixels:i,pixelCount:n,neighborIndices:a}}function wne(t,e,r,i,s,o){const n=new Float32Array(i*s),{interiorPixels:a,neighborIndices:l,pixelCount:c}=t,h=1.9,u=1-h;let d=0,f=0;for(let b=0;b<c;b++){const y=a[b],_=y/i|0;y-_*i+_&1?f++:d++}const g=new Uint32Array(d),p=new Uint32Array(f);let m=0,v=0;for(let b=0;b<c;b++){const y=a[b],_=y/i|0;y-_*i+_&1?p[v++]=b:g[m++]=b}for(let b=0;b<o;b++){for(let y=0;y<d;y++){const _=g[y],w=_<<2,E=a[_],A=l[w],x=l[w+1],S=l[w+2],T=l[w+3];let R=0;A>=0&&(R+=n[A]),x>=0&&(R+=n[x]),S>=0&&(R+=n[S]),T>=0&&(R+=n[T]),n[E]=h*(.01+R)*.25+u*n[E]}for(let y=0;y<f;y++){const _=p[y],w=_<<2,E=a[_],A=l[w],x=l[w+1],S=l[w+2],T=l[w+3];let R=0;A>=0&&(R+=n[A]),x>=0&&(R+=n[x]),S>=0&&(R+=n[S]),T>=0&&(R+=n[T]),n[E]=h*(.01+R)*.25+u*n[E]}}return n}vtt=function(t,e){var r,i,s;const o=dwt,n=(r=e==null?void 0:e.workingSize)!==null&&r!==void 0?r:o.workingSize,a=(i=e==null?void 0:e.iterations)!==null&&i!==void 0?i:o.iterations,l=(s=e==null?void 0:e.measurePerformance)!==null&&s!==void 0?s:!1,c=l?performance.now():0,h=t.width,u=t.height;if(h<1||u<1)return t;const d=Math.min(h,u),f=n/d,g=Math.max(1,Math.round(h*f)),p=Math.max(1,Math.round(u*f));if(typeof document>"u")return t;const m=document.createElement("canvas");m.width=h,m.height=u;const v=m.getContext("2d");if(!v)return t;v.putImageData(t,0,0);const b=document.createElement("canvas");b.width=g,b.height=p;const y=b.getContext("2d",{willReadFrequently:!0});y.drawImage(m,0,0,g,p);const _=l?performance.now():0,w=y.getImageData(0,0,g,p).data,E=new Uint8Array(g*p);for(let N=0,G=0;N<w.length;N+=4,G++){const Y=w[N+3];E[G]=Y===0?0:1}const A=[],x=[];for(let N=0;N<p;N++)for(let G=0;G<g;G++){const Y=N*g+G;if(!E[Y])continue;let q=!1;G===0||G===g-1||N===0||N===p-1?q=!0:q=!E[Y-1]||!E[Y+1]||!E[Y-g]||!E[Y+g]||!E[Y-g-1]||!E[Y-g+1]||!E[Y+g-1]||!E[Y+g+1],q?A.push(Y):x.push(Y)}l&&console.log(`[liquidMetal Poisson] mask: ${(performance.now()-_).toFixed(2)}ms, interior=${x.length}`);const S=bne(E,new Uint8Array(g*p),new Uint32Array(x),new Uint32Array(A),g,p),T=l?performance.now():0,R=wne(S,E,new Uint8Array(g*p),g,p,a);l&&console.log(`[liquidMetal Poisson] solve ${g}\xD7${p} it=${a}: ${(performance.now()-T).toFixed(2)}ms`);let B=0;for(let N=0;N<x.length;N++){const G=x[N];R[G]>B&&(B=R[G])}const O=document.createElement("canvas");O.width=g,O.height=p;const C=O.getContext("2d"),F=C.createImageData(g,p);for(let N=0;N<p;N++)for(let G=0;G<g;G++){const Y=N*g+G,q=Y*4;if(!E[Y])F.data[q]=255,F.data[q+1]=255,F.data[q+2]=255,F.data[q+3]=0;else{const L=255*(1-(B>0?R[Y]/B:0));F.data[q]=L,F.data[q+1]=L,F.data[q+2]=L,F.data[q+3]=255}}C.putImageData(F,0,0),v.save(),v.imageSmoothingEnabled=!0,v.imageSmoothingQuality="high",v.clearRect(0,0,h,u),v.drawImage(O,0,0,g,p,0,0,h,u),v.restore();const U=v.getImageData(0,0,h,u),H=t.data;for(let N=0;N<U.data.length;N+=4){const G=H[N+3],Y=U.data[N+3];G===0?(U.data[N]=255,U.data[N+1]=0):(U.data[N]=Y===0?0:U.data[N],U.data[N+1]=G),U.data[N+2]=255,U.data[N+3]=255}return l&&console.log(`[liquidMetal Poisson] total: ${(performance.now()-c).toFixed(2)}ms for ${h}\xD7${u}`),U};function Ene(t){return t.queryVendorInfo().platformString!=="WebGPU"}_tt=function(t){var e,r,i,s,o,n,a;const{width:l,height:c,data:h}=t;if(l<=0||c<=0)return new ImageData(t.width,t.height);const u=l*c,d=new Uint8ClampedArray(u);for(let A=0;A<u;A++){const x=A*4,S=(e=h[x])!==null&&e!==void 0?e:0,T=(r=h[x+1])!==null&&r!==void 0?r:0,R=(i=h[x+2])!==null&&i!==void 0?i:0;d[A]=.299*S+.587*T+.114*R|0}const f=Math.max(l,c),g=Math.floor(f*.15),p=g,m=Math.max(1,Math.round(.12*g)),v=5,b=cQ(d,l,c,p,3),y=cQ(d,l,c,m,3),_=cQ(d,l,c,v,1),w=new ImageData(l,c),E=w.data;for(let A=0;A<u;A++){const x=A*4;E[x]=(s=_[A])!==null&&s!==void 0?s:0,E[x+1]=(o=b[A])!==null&&o!==void 0?o:0,E[x+2]=(n=y[A])!==null&&n!==void 0?n:0,E[x+3]=(a=h[x+3])!==null&&a!==void 0?a:255}return w};function fwt(t,e,r,i){var s,o,n,a,l,c;if(i<=0)return t.slice();const h=new Uint8ClampedArray(e*r),u=new Uint32Array(e*r);for(let d=0;d<r;d++){let f=0;for(let g=0;g<e;g++){const p=d*e+g,m=(s=t[p])!==null&&s!==void 0?s:0;f+=m,u[p]=f+(d>0&&(o=u[p-e])!==null&&o!==void 0?o:0)}}for(let d=0;d<r;d++){const f=Math.max(0,d-i),g=Math.min(r-1,d+i);for(let p=0;p<e;p++){const m=Math.max(0,p-i),v=Math.min(e-1,p+i),b=g*e+v,y=g*e+(m-1),_=(f-1)*e+v,w=(f-1)*e+(m-1),E=(n=u[b])!==null&&n!==void 0?n:0,A=m>0&&(a=u[y])!==null&&a!==void 0?a:0,x=f>0&&(l=u[_])!==null&&l!==void 0?l:0,S=m>0&&f>0&&(c=u[w])!==null&&c!==void 0?c:0,T=E-A-x+S,R=(v-m+1)*(g-f+1);h[d*e+p]=Math.round(T/R)}}return h}function cQ(t,e,r,i,s){if(i<=0||s<=1)return fwt(t,e,r,i);let o=t,n=t;
10359for(let a=0;a<s;a++)n=fwt(o,e,r,i),o=n;return n}const Ku=64;function zg(t,e,r){let i=Math.random();return r&&(i=r(i)),t+(e-t)*i}function hQ(t){return Math.random()<t}const Ane={minR:10,maxR:40,maxDrops:900,rainChance:.3,rainLimit:3,dropletsRate:50,dropletsSize:[2,4],dropletsCleaningRadiusMultiplier:.43,raining:!0,globalTimeScale:1,trailRate:1,autoShrink:!0,spawnArea:[-.1,.95],trailScaleRange:[.2,.5],collisionRadius:.65,collisionRadiusIncrease:.01,dropFallMultiplier:1,collisionBoostMultiplier:.05,collisionBoost:1};function pwt(t){return Object.assign({spreadX:0,spreadY:0,momentum:0,momentumX:0,lastSpawn:0,nextSpawn:0,parent:null,isNew:!0,killed:!1,shrink:0},t)}class xne{constructor(e,r,i,s,o,n){this.dropsGfx=[],this.drops=[],this.dropletsCounter=0,this.textureCleaningIterations=0,this.dropletsPixelDensity=1,this.width=e,this.height=r,this.scale=i,this.options=Object.assign(Object.assign({},Ane),n);const a=Pr.get();this.canvas=a.createCanvas(e,r),this.ctx=this.canvas.getContext("2d"),this.dropletsCanvas=a.createCanvas(e*this.dropletsPixelDensity,r*this.dropletsPixelDensity),this.dropletsCtx=this.dropletsCanvas.getContext("2d"),this.renderDropsGfx(s,o),this.clearDropletsGfx=a.createCanvas(128,128);const l=this.clearDropletsGfx.getContext("2d");l.fillStyle="#000",l.beginPath(),l.arc(64,64,64,0,Math.PI*2),l.fill()}get deltaR(){return this.options.maxR-this.options.minR}get area(){return this.width*this.height/this.scale}get areaMultiplier(){return Math.sqrt(this.area/(1024*768))}renderDropsGfx(e,r){const i=Pr.get(),s=i.createCanvas(Ku,Ku),o=s.getContext("2d");this.dropsGfx=Array.from({length:255},(n,a)=>{const l=i.createCanvas(Ku,Ku),c=l.getContext("2d");return o.clearRect(0,0,Ku,Ku),o.globalCompositeOperation="source-over",o.drawImage(e,0,0,Ku,Ku),o.globalCompositeOperation="screen",o.fillStyle=`rgba(0,0,${a},1)`,o.fillRect(0,0,Ku,Ku),c.globalCompositeOperation="source-over",c.drawImage(r,0,0,Ku,Ku),c.globalCompositeOperation="source-in",c.drawImage(s,0,0,Ku,Ku),l})}drawDrop(e,r){if(this.dropsGfx.length===0)return;const{x:i,y:s,r:o,spreadX:n,spreadY:a}=r,l=1,c=1.5;let h=Math.max(0,Math.min(1,(o-this.options.minR)/this.deltaR*.9));h*=1/((r.spreadX+r.spreadY)*.5+1),e.globalAlpha=1,e.globalCompositeOperation="source-over";const u=Math.floor(h*(this.dropsGfx.length-1)),d=this.dropsGfx[u];e.drawImage(d,(i-o*l*(n+1))*this.scale,(s-o*c*(a+1))*this.scale,o*2*l*(n+1)*this.scale,o*2*c*(a+1)*this.scale)}drawDroplet(e,r,i){this.drawDrop(this.dropletsCtx,pwt({x:e*this.dropletsPixelDensity,y:r*this.dropletsPixelDensity,r:i*this.dropletsPixelDensity,spreadX:0,spreadY:0,momentum:0,momentumX:0,lastSpawn:0,nextSpawn:0,parent:null,isNew:!1,killed:!1,shrink:0}))}clearDroplets(e,r,i=30){const s=this.dropletsCtx;s.globalCompositeOperation="destination-out",s.drawImage(this.clearDropletsGfx,(e-i)*this.dropletsPixelDensity*this.scale,(r-i)*this.dropletsPixelDensity*this.scale,i*2*this.dropletsPixelDensity*this.scale,i*2*this.dropletsPixelDensity*this.scale*1.5)}createDrop(e){return this.drops.length>=this.options.maxDrops*this.areaMultiplier?null:pwt(e)}addDrop(e){return e==null||this.drops.length>=this.options.maxDrops*this.areaMultiplier?!1:(this.drops.push(e),!0)}updateRain(e){const r=[];if(!this.options.raining)return r;const i=this.options.rainLimit*e*this.areaMultiplier;let s=0;for(;hQ(this.options.rainChance*e*this.areaMultiplier)&&s<i;){s++;const o=zg(this.options.minR,this.options.maxR,a=>Math.pow(a,3)),n=this.createDrop({x:zg(0,this.width/this.scale),y:zg(this.height/this.scale*this.options.spawnArea[0],this.height/this.scale*this.options.spawnArea[1]),r:o,momentum:1+(o-this.options.minR)*.1+zg(0,2),spreadX:1.5,spreadY:1.5});n&&r.push(n)}return r}updateDroplets(e){if(this.textureCleaningIterations>0&&(this.textureCleaningIterations-=1*e,this.dropletsCtx.globalCompositeOperation="destination-out",this.dropletsCtx.fillStyle=`rgba(0,0,0,${.05*e})`,this.dropletsCtx.fillRect(0,0,this.width*this.dropletsPixelDensity,this.height*this.dropletsPixelDensity)),this.options.raining){this.dropletsCounter+=this.options.dropletsRate*e*this.areaMultiplier;const r=Math.floor(this.dropletsCounter);this.dropletsCounter-=r;for(let i=0;i<r;i++)this.drawDroplet(zg(0,this.width/this.scale),zg(0,this.height/this.scale),zg(this.options.dropletsSize[0],this.options.dropletsSize[1],s=>s*s))}this.ctx.drawImage(this.dropletsCanvas,0,0,this.width,this.height)}update(e){e*=this.options.globalTimeScale,this.ctx.clearRect(0,0,this.width,this.height);const r=[];this.updateDroplets(e);const i=this.updateRain(e);r.push(...i),this.drops.sort((s,o)=>{const n=s.y*(this.width/this.scale)+s.x,a=o.y*(this.width/this.scale)+o.x;return n>a?1:n===a?0:-1}),this.drops.forEach((s,o)=>
10359{if(s.killed)return;if(hQ((s.r-this.options.minR*this.options.dropFallMultiplier)*(.1/this.deltaR)*e)&&(s.momentum+=zg(0,s.r/this.options.maxR*4)),this.options.autoShrink&&s.r<=this.options.minR&&hQ(.05*e)&&(s.shrink+=.01),s.r-=s.shrink*e,s.r<=0&&(s.killed=!0),this.options.raining&&(s.lastSpawn+=s.momentum*e*this.options.trailRate,s.lastSpawn>s.nextSpawn)){const l=this.createDrop({x:s.x+zg(-s.r,s.r)*.1,y:s.y-s.r*.01,r:s.r*zg(this.options.trailScaleRange[0],this.options.trailScaleRange[1]),spreadY:s.momentum*.1,parent:s,momentum:0,momentumX:0,lastSpawn:0,nextSpawn:0,spreadX:0,isNew:!0,killed:!1,shrink:0});l&&(r.push(l),s.r*=Math.pow(.97,e),s.lastSpawn=0,s.nextSpawn=zg(this.options.minR,this.options.maxR)-s.momentum*2*this.options.trailRate+(this.options.maxR-s.r))}s.spreadX*=Math.pow(.4,e),s.spreadY*=Math.pow(.7,e);const n=s.momentum>0;n&&!s.killed&&(s.y+=s.momentum*this.options.globalTimeScale,s.x+=s.momentumX*this.options.globalTimeScale,s.y>this.height/this.scale+s.r&&(s.killed=!0));const a=(n||s.isNew)&&!s.killed;s.isNew=!1,a&&this.drops.slice(o+1,o+70).forEach(l=>{if(s===l||s.r<=l.r||s.parent===l||l.parent===s||l.killed)return;const c=l.x-s.x,h=l.y-s.y;if(Math.sqrt(c*c+h*h)<(s.r+l.r)*(this.options.collisionRadius+s.momentum*this.options.collisionRadiusIncrease*e)){const u=s.r,d=l.r,f=Math.PI*u*u,g=Math.PI*d*d;let p=Math.sqrt((f+g*.8)/Math.PI);p>this.options.maxR&&(p=this.options.maxR),s.r=p,s.momentumX+=c*.1,s.spreadX=0,s.spreadY=0,l.killed=!0,s.momentum=Math.max(l.momentum,Math.min(40,s.momentum+p*this.options.collisionBoostMultiplier+this.options.collisionBoost))}}),s.momentum-=Math.max(1,this.options.minR*.5-s.momentum)*.1*e,s.momentum<0&&(s.momentum=0),s.momentumX*=Math.pow(.7,e),s.killed||(r.push(s),n&&this.options.dropletsRate>0&&this.clearDroplets(s.x,s.y,s.r*this.options.dropletsCleaningRadiusMultiplier),this.drawDrop(this.ctx,s))}),this.drops=r}}function gwt(t,e,r){const i=Object.assign(Object.assign({},t),{anchorX:e,anchorY:r});return delete i.x,delete i.y,delete i.width,delete i.height,ou(i),{x:i.x,y:i.y,width:i.width,height:i.height,anchorX:i.anchorX,anchorY:i.anchorY}}var mwt=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};function uQ(t){if(!t||t.length<2)return"";const[e,r]=t[0];let i=`M ${e} ${r}`;for(let s=1;s<t.length;s++)i+=` L ${t[s][0]} ${t[s][1]}`;return i}Ftt=function(t){return(e,r)=>{let i=e.points;if(!i||i.length<2)return new Qe(0,0,0,0);typeof i=="string"&&(i=nc(i));const s=uQ(i);if(!s)return new Qe(0,0,0,0);try{const a=t({d:s});if(a&&Number.isFinite(a.minX+a.minY+a.maxX+a.maxY))return new Qe(a.minX,a.minY,a.maxX,a.maxY)}catch{}const o=_t.geometryBoundsProvider;_t.geometryBoundsProvider=null;const n=_t.getGeometryBounds(e);return _t.geometryBoundsProvider=o,n}},Ntt=function(t){return(e,r,i)=>{const s=uQ(e.points);if(!s)return new Qe(0,0,0,0);try{const a={d:s};r&&r.width>0&&(a.stroke={width:r.width,linecap:r.linecap,linejoin:r.linejoin,miterLimit:r.miterlimit,alignment:r.alignment,dasharray:r.dasharray?[...r.dasharray]:void 0,dashoffset:r.dashoffset,blur:0}),i&&(a.markerStart=i.start,a.markerEnd=i.end,a.markerFactor=i.factor);const l=t(a);if(l&&Number.isFinite(l.minX+l.minY+l.maxX+l.maxY))return new Qe(l.minX,l.minY,l.maxX,l.maxY)}catch{}const o=_t.renderBoundsProvider;_t.renderBoundsProvider=null;const n=_t.getRenderBounds(e,r,i);return _t.renderBoundsProvider=o,n}},Gtt=function(t){return e=>{const r=uQ(e.points);if(!r)return!1;try{const i={d:r,x:e.x,y:e.y,fill:!1,fillRule:"nonzero"};return e.stroke&&e.stroke.width>0&&(i.stroke={width:e.stroke.width,linecap:e.stroke.linecap,linejoin:e.stroke.linejoin,miterLimit:e.stroke.miterlimit,alignment:e.stroke.alignment,dasharray:e.stroke.dasharray?[...e.stroke.dasharray]:void 0,dashoffset:e.stroke.dashoffset,blur:0}),t(i)}catch{return!1}}},_t=class{static getGeometryBounds(t){if(_t.geometryBoundsProvider)return _t.geometryBoundsProvider(t);let{points:e}=t;if(!e||e.length<2)return new Qe(0,0,0,0);typeof e=="string"&&(e=nc(e));const r=Math.min(...e.map(n=>isNaN(n[0])?1/0:n[0])),i=Math.max(...e.map(n=>isNaN(n[0])?-1/0:n[0])),s=Math.min(...e.map(n=>isNaN(n[1])?1/0:n[1])),o=Math.max(...e.map(n=>isNaN(n[1])?-1/0:n[1]));return new Qe(r,s,i,o)}static getRenderBounds(t,e,r){if(_t.renderBoundsProvider)return _t.renderBoundsProvider(t,e,r);const{width:i=0,linecap:s="butt",linejoin:o="miter",miterlimit:n=4}=e??{};let a=.5;s==="square"&&(a=Math.SQRT1_2);const l=o==="miter"?n*.5:.5,c=Math.max(a,l)*i,{minX:h,minY:u,maxX:d,maxY:f}=_t.getGeometryBounds(t);return new Qe(h-c,u-c,d+c,f+c)}constructor(t){Object.assign(this,t)}},_t.geometryBoundsProvider=null,_t.renderBoundsProvider=null,_t.hitTestProvider=null,mwt([P({type:$.object,default:[[0,0],[0,0]]}
10359)],_t.prototype,"points",void 0),mwt([P({type:$.float32,default:-1})],_t.prototype,"hitStrokeWidth",void 0);function Sne(t,e){return e==null||!Number.isFinite(e)||e<0?t:Math.max(t,e)}function Tne(t){return t.has(Mt)?t.read(Mt).hitStrokeWidth:t.has(_t)?t.read(_t).hitStrokeWidth:t.has(xt)?t.read(xt).hitStrokeWidth:-1}function ywt(t,e){if(!e)return 0;const r=Tne(t),i=r>=0?r:void 0;return Sne(e.width,i)}function PB(t,e){return{width:ywt(t,e),linecap:e.linecap,linejoin:e.linejoin,miterlimit:e.miterlimit,alignment:e.alignment,dasharray:[e.dasharray[0],e.dasharray[1]],dashoffset:e.dashoffset}}function Zz(t){return Number(t.toFixed(2))}function vwt(t,e,r,i=-Math.PI/2){const s=e/2,o=r/2,n=e/2,a=r/2,l=Math.PI*2/t,c=[];for(let h=0;h<t;h++){const u=i+h*l;c.push([Zz(s+Math.cos(u)*n),Zz(o+Math.sin(u)*a)])}return c}function _wt(t){return t.map(([e,r],i)=>`${i===0?"M":"L"} ${e} ${r}`).join(" ").concat(" Z")}function bwt(t,e,r,i=-Math.PI/2){return t<3||e<=0||r<=0?"":_wt(vwt(t,e,r,i))}function Rne(t,e,r,i=-Math.PI/2){if(t<3||e<=0||r<=0)return null;const s=vwt(t,e,r,i);let o=1/0,n=1/0,a=-1/0,l=-1/0;for(const[h,u]of s)o=Math.min(o,h),n=Math.min(n,u),a=Math.max(a,h),l=Math.max(l,u);const c=s.map(([h,u])=>[Zz(h-o),Zz(u-n)]);return{d:_wt(c),offsetX:o,offsetY:n,width:a-o,height:l-n}}function Jz(t){var e;return{filter:t.filter,layersSelected:[...t.layersSelected],variables:structuredClone((e=t.variables)!==null&&e!==void 0?e:{})}}const wwt=(t,e,r=!1)=>{let i=!1;for(const s in e){const o=e[s];if(typeof o<"u"){if(t[s]===o&&(typeof o!="object"||o===null))continue;i=!0}}return!i&&!r?t:Object.assign(Object.assign(Object.assign({},t),e),{updated:wbt(),version:(t.version||0)+1,versionNonce:VK()})};class Qz{constructor(e,r,i={didElementsChange:!1,didAppStateChange:!1,isEmpty:!1}){this.elements=e,this.appState=r,this.meta=i}static empty(){return new Qz(new Map,Jz(yO()),{didElementsChange:!1,didAppStateChange:!1,isEmpty:!0})}isEmpty(){return!!this.meta.isEmpty}maybeClone(e,r){const i=this.maybeCreateElementsSnapshot(e),s=this.maybeCreateAppStateSnapshot(r);let o=!1,n=!1;return this.elements!==i&&(o=!0),this.appState!==s&&(n=!0),!this.isEmpty()&&!o&&!n?this:new Qz(i,s,{didElementsChange:o,didAppStateChange:n})}maybeCreateAppStateSnapshot(e){if(!e)return this.appState;const r=Jz(e);return this.detectChangedAppState(r)?r:this.appState}detectChangedAppState(e){return!_w(this.appState,e)}maybeCreateElementsSnapshot(e){return e?this.detectChangedElements(e)?this.createElementsSnapshot(e):this.elements:this.elements}detectChangedElements(e){if(this.elements===e)return!1;if(this.elements.size!==e.size)return!0;const r=Array.from(e.keys());for(let i=r.length-1;i>=0;i--){const s=this.elements.get(r[i]),o=e.get(r[i]);if(!s||!o||s.id!==o.id||s.versionNonce!==o.versionNonce||!_w(s,o))return!0}return!1}createElementsSnapshot(e){const r=new Map;for(const[i,s]of this.elements.entries())e.get(i)?r.set(i,s):r.set(i,s.isDeleted?s:wwt(s,{isDeleted:!0}));for(const[i,s]of e.entries()){const o=r.get(i);(!o||o&&!_w(o,s))&&r.set(i,structuredClone(s))}return r}}class FB{constructor(e,r){this.delta=e,this.api=r}static empty(){return new FB(lh.create({},{}),void 0)}static calculate(e,r,i){const s=lh.calculate(Jz(e),Jz(r),void 0);return new FB(s,i)}inverse(){const e=lh.create(this.delta.inserted,this.delta.deleted);return new FB(e,this.api)}applyTo(e,r){const i=this.delta.inserted,s=Object.assign(Object.assign({},e),i),o=this.filterInvisibleChanges(e,s,r);if(this.api){this.api.setAppState(s,{recordDesignVariableUndo:!1,replaceVariables:!0});const{layersHighlighted:n,layersSelected:a}=e,{layersHighlighted:l,layersSelected:c}=s,h=new Set(a),u=new Set(c),d=a.filter(b=>!u.has(b)),f=c.filter(b=>!h.has(b));d.length>0&&this.api.deselectNodes(d.map(b=>this.api.getNodeById(b)).filter(b=>b!==void 0)),f.length>0&&this.api.selectNodes(f.map(b=>this.api.getNodeById(b)).filter(b=>b!==void 0),!1,!1);const g=new Set(n),p=new Set(l),m=n.filter(b=>!p.has(b)),v=l.filter(b=>!g.has(b));m.length>0&&this.api.unhighlightNodes(m.map(b=>this.api.getNodeById(b)).filter(b=>b!==void 0)),v.length>0&&this.api.highlightNodes(v.map(b=>this.api.getNodeById(b)).filter(b=>b!==void 0),!1,!1)}return[s,o]}filterInvisibleChanges(e,r,i){return r.layersSelected=r.layersSelected.filter(s=>i.has(s)&&!i.get(s).isDeleted),e.filter!==r.filter||!_w(e.variables,r.variables)||e.layersSelected.length!==r.layersSelected.length||e.layersSelected.some((s,o)=>s!==r.layersSelected[o])}isEmpty(){return lh.isEmpty(this.delta)}}var tV=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Ewt=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");
10359return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},eV,NB;const Awt="storeIncrement",Sy={IMMEDIATELY:"IMMEDIATELY",NEVER:"NEVER",EVENTUALLY:"EVENTUALLY"};class Cne{constructor(e){this.api=e,eV.set(this,Qz.empty()),NB.set(this,new Set),this.onStoreIncrementEmitter=new Uo}get snapshot(){return tV(this,eV,"f")}set snapshot(e){Ewt(this,eV,e,"f")}scheduleAction(e){tV(this,NB,"f").add(e)}shouldCaptureIncrement(){this.scheduleAction(Sy.IMMEDIATELY)}shouldUpdateSnapshot(){this.scheduleAction(Sy.NEVER)}commit(e,r){try{tV(this,NB,"f").has(Sy.IMMEDIATELY)?this.captureIncrement(e,r):tV(this,NB,"f").has(Sy.NEVER)&&this.updateSnapshot(e,r)}finally{Ewt(this,NB,new Set,"f")}}captureIncrement(e,r){const i=this.snapshot,s=this.snapshot.maybeClone(e,r);if(i!==s){const o=s.meta.didElementsChange?ma.calculate(i.elements,s.elements,this.api):ma.empty(),n=s.meta.didAppStateChange?FB.calculate(i.appState,s.appState,this.api):FB.empty();(!o.isEmpty()||!n.isEmpty())&&this.onStoreIncrementEmitter.emit(Awt,{elementsChange:o,appStateChange:n}),this.snapshot=s}}updateSnapshot(e,r){const i=this.snapshot.maybeClone(e,r);this.snapshot!==i&&(this.snapshot=i)}}eV=new WeakMap,NB=new WeakMap;const Ud=t=>({ok:!1,reason:t}),dQ=t=>Object.assign({vertices:t.vertices.map(e=>Object.assign({},e)),segments:t.segments.map(e=>Object.assign(Object.assign(Object.assign({},e),e.tangentStart?{tangentStart:Object.assign({},e.tangentStart)}:{}),e.tangentEnd?{tangentEnd:Object.assign({},e.tangentEnd)}:{}))},t.regions!==void 0?{regions:t.regions.map(e=>Object.assign(Object.assign({},e),{loops:e.loops.map(r=>[...r])}))}:{}),xwt=t=>{var e;return t.vertices.every(r=>Number.isFinite(r.x)&&Number.isFinite(r.y))&&t.segments.every(r=>Number.isInteger(r.start)&&Number.isInteger(r.end)&&!!lm(t.vertices,r))&&((e=t.regions)!==null&&e!==void 0?e:[]).every(r=>r.loops.length&&r.loops.every(i=>!!gy(t.segments,i)))},kB=(t,e)=>Number.isInteger(e)&&!!t.segments[e];HV=function(t,e){var r;return kB(t,e)?((r=t.regions)!==null&&r!==void 0?r:[]).flatMap((i,s)=>i.loops.flatMap((o,n)=>o.flatMap((a,l)=>a===e?[{regionIndex:s,loopIndex:n,offset:l}]:[]))):[]};function Swt(t,e,r){if(!kB(t,e)||!kB(t,r))return null;const i=lm(t.vertices,t.segments[e]),s=lm(t.vertices,t.segments[r]);if(!i||!s)return null;const o=n=>i.every((a,l)=>Math.hypot(a[0]-s[n?3-l:l][0],a[1]-s[n?3-l:l][1])<=1e-6);return o(!1)?"forward":o(!0)?"reverse":null}Htt=function(t,e,r){if(!kB(t,e))return Ud("invalid-edge");if(!xwt(t))return Ud("invalid-network");const i=h=>`${h.regionIndex}/${h.loopIndex}/${h.offset}`,s=HV(t,e),o=new Set(s.map(i)),n=new Set(r.map(i));if(!r.length||r.length>=s.length||n.size!==r.length||[...n].some(h=>!o.has(h)))return Ud("invalid-uses");const a=dQ(t),l=a.segments.length,c=dQ({vertices:[],segments:[t.segments[e]]}).segments[0];return a.segments.push(c),a.regions=a.regions.map((h,u)=>Object.assign(Object.assign({},h),{loops:h.loops.map((d,f)=>d.map((g,p)=>n.has(i({regionIndex:u,loopIndex:f,offset:p}))?l:g))})),{ok:!0,network:a,selectedVertex:c.start,selectedSegment:l,vertexMap:t.vertices.map((h,u)=>[u]),segmentMap:t.segments.map((h,u)=>u===e?[u,l]:[u])}},$tt=function(t,e,r){var i,s,o,n,a,l;if(!kB(t,e)||!kB(t,r))return Ud("invalid-edge");if(e===r)return Ud("same-edge");if(!xwt(t))return Ud("invalid-network");const c=Swt(t,e,r);if(!c)return Ud("different-geometry");const h=t.segments[e],u=t.segments[r];if(h.start===h.end!=(u.start===u.end))return Ud("incompatible-endpoints");if(((i=t.regions)!==null&&i!==void 0?i:[]).some(_=>_.loops.some(w=>w.includes(e)&&w.includes(r))))return Ud("collapsed-region");const d=t.vertices.map((_,w)=>w),f=_=>d[_]===_?_:d[_]=f(d[_]),g=(_,w)=>{d[f(_)]=f(w)};if(g(h.start,c==="forward"?u.start:u.end),g(h.end,c==="forward"?u.end:u.start),u.start!==u.end&&f(u.start)===f(u.end))return Ud("incompatible-endpoints");const p=dQ(t),m=new Map;p.vertices=p.vertices.filter((_,w)=>f(w)!==w?!1:(m.set(w,m.size),!0));const v=t.vertices.map((_,w)=>[m.get(f(w))]),b=r-(e<r?1:0),y=t.segments.map((_,w)=>[w===e?b:w-(w>e?1:0)]);if(p.segments=p.segments.filter((_,w)=>w!==e).map(_=>Object.assign(Object.assign({},_),{start:v[_.start][0],end:v[_.end][0]})),p.regions=(s=p.regions)===null||s===void 0?void 0:s.map(_=>Object.assign(Object.assign({},_),{loops:_.loops.map(w=>w.map(E=>y[E][0]))})),((o=p.regions)!==null&&o!==void 0?o:[]).some(_=>_.loops.some(w=>!gy(p.segments,w))))return Ud("invalid-network");for(let _=0;_<((a=(n=t.regions)===null||n===void 0?void 0:n.length)!==null&&a!==void 0?a:0);
10359_++){const w=t.regions[_];if(w.fillRule?w.fillRule==="evenodd":((l=w.windingRule)===null||l===void 0?void 0:l.toLowerCase())==="evenodd")continue;const E=[];for(let A=0;A<w.loops.length;A++){const x=gy(t.segments,w.loops[A]),S=gy(p.segments,p.regions[_].loops[A]),T=x.map((R,B)=>R.reversed!==(S[B].reversed!==(R.segmentIndex===e&&c==="reverse")));if(T.some(R=>R!==T[0]))return Ud("incompatible-winding");E.push(T[0])}if(E.some(A=>A!==E[0]))return Ud("incompatible-winding")}return{ok:!0,network:p,vertexMap:v,segmentMap:y,selectedSegment:b,selectedVertex:p.segments[b].start}};const fQ=new WeakMap;Jtt=function(t,e,r){var i;Number.isInteger(r)&&!((i=e.segments)===null||i===void 0)&&i[r]&&fQ.set(t,{node:e,index:r})};function Mne(t,e){const r=fQ.get(t);return r?r.node.id!==e||t.getNodeById(e)!==r.node||!r.node.isEditing?(fQ.delete(t),-1):r.index:-1}let Uw,LB,Gw,Twt,Rwt,pQ,xU;Uw=5,LB=20,Gw=5,Twt=22,Rwt=42,pQ=Uw+3,Kh="#e0f2ff",Zs="#147af3",xU="white",aG=class extends We{constructor(){super(),this.commands=new nE(this),this.vectorEditModes=new WeakMap,this.cameras=this.query(t=>t.current.and.added.with(jt)),this.selected=this.query(t=>t.current.and.added.and.removed.with(ks)),this.bounds=this.query(t=>t.changed.with(fe).trackWrites),this.editable=this.query(t=>t.changed.with(Mi).trackWrites),this.editableAdded=this.query(t=>t.added.with(Mi)),this.query(t=>t.using(fe,Pe,jt,Gs,_t,xt,Mt,wo,Mi,je,fh).read.and.using(wt,Ae,Nt,Ii,ks,_e,ze,be,Zi,Ce,Gt,Fs,$t,_t,xt,et,Ls,Xc,Qn,Tn,ba,he,aV,ke,Yt,Mt,Wl,hl,Pn).write)}shouldSuppressTransformer(t){if(!t.has(Nt))return!1;const{selecteds:e}=t.read(Nt);if(e.some(N2))return!0;const{canvas:r}=t.read(jt);return r?R9t(r):!1}hideAllTransformerUi(t,e){e.mask&&(e.mask.write(he).value="hidden"),this.hideLineMaskAndEndpointAnchors(e),e.polylineMask&&(e.polylineMask.write(he).value="hidden")}createOrUpdate(t){if(!nr(t)||!t.has(jt))return;const{canvas:e}=t.read(jt);if(!(e!=null&&e.has(wt)))return;const{api:r}=e.read(wt);nt(t,Nt);const i=r.getAppState().penbarSelected,s=t.write(Nt);if(this.shouldSuppressTransformer(t)){this.hideAllTransformerUi(t,s);return}if(i===vt.VECTOR_NETWORK){s.polylineMask||this.createPolylineMask(t,s),s.mask||this.createRectMask(t,s);const{selecteds:o,mask:n,polylineMask:a}=t.read(Nt);o.length===1&&o[0].has(ke)?(n.write(he).value="hidden",this.hideLineMaskAndEndpointAnchors(s),a.write(he).value="hidden",this.updateVectorNetworkControlPoints(t,o[0],s,r.getAppState().vectorNetworkEditMode,!0)):this.hideVectorNetworkEditAnchors(s);return}else{s.lineMask||this.createLineMask(t,s),s.polylineMask||this.createPolylineMask(t,s),s.mask||this.createRectMask(t,s);const{selecteds:o,mask:n,polylineMask:a}=t.read(Nt);if(o.length===1&&o[0].has(ke)&&TU(i,o[0])||(s.hoveredSegmentIndex!==-1&&(s.hoveredSegmentIndex=-1),s.hoveredControlPointIndex!==-1&&(s.hoveredControlPointIndex=-1),s.selectedControlPointIndex!==-1&&(s.selectedControlPointIndex=-1),this.hideVectorNetworkEditAnchors(s)),o.length===0){n.write(he).value="hidden",this.hideLineMaskAndEndpointAnchors(t.read(Nt)),a.write(he).value="hidden";return}if(i===vt.SELECT&&o.length===1&&o[0].has(ke)&&TU(i,o[0])){n.write(he).value="hidden",this.hideLineMaskAndEndpointAnchors(s),a.write(he).value="hidden",this.updateVectorNetworkControlPoints(t,o[0],s,r.getAppState().vectorNetworkEditMode);return}One(t)?(n.write(he).value="hidden",this.hideLineMaskAndEndpointAnchors(t.read(Nt)),this.updatePolylineMask(t)):Cwt(t)?(n.write(he).value="hidden",a.write(he).value="hidden",this.updateLineMask(t)):(this.hideLineMaskAndEndpointAnchors(t.read(Nt)),a.write(he).value="hidden",this.updateRectMask(t))}}updateVectorNetworkControlPoints(t,e,r,i,s=!1){var o,n,a,l;if(!nr(e)||!e.has(ke)||!s&&i===So.FILL||!s&&(!e.has(Mi)||!e.read(Mi).isEditing)){this.hideVectorNetworkEditAnchors(r);return}if(!e.has(Ae)&&(s&&Sr(e),!e.has(Ae))){this.hideVectorNetworkEditAnchors(r);return}const{vertices:c,segments:h}=e.read(ke);this.syncControlPoints(t,c.length,r),this.syncSegmentMidpoints(t,h.length,r);const u=ie.toGLMat3(e.read(Ae).matrix),d=(o=r.hoveredSegmentIndex)!==null&&o!==void 0?o:-1,f=(n=r.hoveredControlPointIndex)!==null&&n!==void 0?n:-1,g=(a=r.selectedControlPointIndex)!==null&&a!==void 0?a:-1,p=!s&&(i===So.MOVE||i===So.CUT);
10359r.controlPoints.forEach((m,v)=>{const b=c[v];if(!b){m.write(he).value="hidden",Sr(m);return}const y=Qt(it(),[b.x,b.y],u),_=v===g,w=v===f&&!_;Object.assign(m.write(et),{cx:y[0],cy:y[1],r:_?Uw+2:w?Uw+1.5:Uw}),m.write(Ce).layers=[{type:"solid",value:_?Zs:w?Kh:xU}],m.write(he).value="visible",Sr(m)}),(l=r.segmentMidpoints)===null||l===void 0||l.forEach((m,v)=>{const b=h[v],y=b?_G(c,b,.5):null;if(!y||!p){mQ(m,"hidden"),Sr(m);return}const _=Qt(it(),y,u);Object.assign(m.write(et),{cx:_[0],cy:_[1]}),mQ(m,v===d?"visible":"hidden"),Sr(m)}),this.updateVectorNetworkTangentHandles(t,e,r,i,u,c,h)}updateVectorNetworkTangentHandles(t,e,r,i,s,o,n){var a,l,c;const h=()=>{var p,m;(p=r.vnTangentHandles)===null||p===void 0||p.forEach(v=>{v.write(he).value="hidden",Sr(v)}),(m=r.pathHandleLines)===null||m===void 0||m.forEach(v=>{v.write(he).value="hidden",Sr(v)})};if(i!==So.BEND){h();return}const u=(a=r.selectedControlPointIndex)!==null&&a!==void 0?a:-1;if(u<0){h();return}const d=[];n.forEach((p,m)=>{const v=(b,y)=>{var _,w;const E=o[y];if(!E)return;const A=b==="start"?p.end:p.start,x=o[A],S=b==="start"?p.tangentStart:p.tangentEnd;let T=(_=S==null?void 0:S.x)!==null&&_!==void 0?_:0,R=(w=S==null?void 0:S.y)!==null&&w!==void 0?w:0;if(Math.abs(T)<1e-6&&Math.abs(R)<1e-6&&x){const B=x.x-E.x,O=x.y-E.y,C=Math.hypot(B,O)||1,F=Math.min(48,C*.35);T=B/C*F,R=O/C*F}d.push({segmentIndex:m,end:b,local:[E.x+T,E.y+R],vertexLocal:[E.x,E.y]})};p.start===u&&v("start",p.start),p.end===u&&v("end",p.end)}),this.syncVnTangentHandles(t,d.length,r),r.vnTangentMeta=d.map(({segmentIndex:p,end:m})=>({segmentIndex:p,end:m}));const f=(l=r.vnTangentHandles)!==null&&l!==void 0?l:[],g=(c=r.pathHandleLines)!==null&&c!==void 0?c:[];d.forEach((p,m)=>{const v=f[m],b=g[m];if(!(v!=null&&v.has(et)))return;const y=Qt(it(),p.local,s),_=Qt(it(),p.vertexLocal,s);Object.assign(v.write(et),{cx:y[0],cy:y[1],r:Uw-1}),v.write(he).value="visible",Sr(v),b!=null&&b.has(Mt)&&(Object.assign(b.write(Mt),{x1:_[0],y1:_[1],x2:y[0],y2:y[1]}),b.write(he).value="visible",Sr(b))});for(let p=d.length;p<f.length;p++)f[p].write(he).value="hidden",Sr(f[p]),g[p]&&(g[p].write(he).value="hidden",Sr(g[p]))}syncVnTangentHandles(t,e,r){var i,s,o,n;const a=(i=r.vnTangentHandles)!==null&&i!==void 0?i:[],l=(s=r.pathHandleLines)!==null&&s!==void 0?s:[],c=e-a.length;if(c>0){const h=[],u=[];for(let d=0;d<c;d++){const f=this.createAnchor(0,0,gt.TANGENT);this.commands.entity(t).appendChild(this.commands.entity(f)),h.push(f);const g=this.createPathHandleLine();this.commands.entity(t).appendChild(this.commands.entity(g)),u.push(g)}Object.assign(r,{vnTangentHandles:[...a,...h],pathHandleLines:[...l,...u]}),this.commands.execute();return}if(c<0)for(let h=0;h<Math.abs(c);h++){const u=(o=r.vnTangentHandles)===null||o===void 0?void 0:o.pop();u&&u.add(Tn);const d=(n=r.pathHandleLines)===null||n===void 0?void 0:n.pop();d&&d.add(Tn)}}updatePolylineControlPoints(t){var e,r,i,s,o;const n=t.write(Nt),{selecteds:a,polylineMask:l}=t.read(Nt),c=a.length===1?a[0]:void 0;if(!(c!=null&&c.hasSomeOf(_t,xt))){(e=n.controlPoints)===null||e===void 0||e.forEach(p=>{p.write(he).value="hidden"}),(r=n.segmentMidpoints)===null||r===void 0||r.forEach(p=>{p.write(he).value="hidden"}),(i=n.pathHandleLines)===null||i===void 0||i.forEach(p=>{p.write(he).value="hidden"}),this.syncPathHandleLines(l,0,n),n.controlPointMeta=[],n.pathControlCommands=[];return}const h=ie.toGLMat3(c.read(Ae).matrix);if(c.has(_t)){this.syncPathHandleLines(l,0,n);const{points:p}=c.read(_t);this.syncControlPoints(l,p.length,n),this.syncSegmentMidpoints(l,Math.max(p.length-1,0),n),n.controlPointMeta=[],n.pathControlCommands=[],n.controlPoints.forEach((m,v)=>{const b=p[v];if(!b){m.write(he).value="hidden";return}const y=Qt(it(),b,h);Object.assign(m.write(et),{cx:y[0],cy:y[1]}),m.write(he).value="visible",Sr(m)}),(s=n.segmentMidpoints)===null||s===void 0||s.forEach((m,v)=>{const b=p[v],y=p[v+1];if(!b||!y){m.write(he).value="hidden";return}const _=(b[0]+y[0])/2,w=(b[1]+y[1])/2,E=Qt(it(),[_,w],h);Object.assign(m.write(et),{cx:E[0],cy:E[1]}),m.write(he).value="visible",Sr(m)});return}const u=_X(c.read(xt).d),d=mmt(u),f=o7t(u);this.syncPathHandleLines(l,f.length,n),this.syncControlPoints(l,d.length,n),this.syncSegmentMidpoints(l,0,n),n.pathControlCommands=u,n.controlPointMeta=d.map(p=>p.meta);const g=(o=n.pathHandleLines)!==null&&o!==void 0?o:[];f.forEach((p,m)=>{const v=g[m];
10359if(!(v!=null&&v.has(Mt)))return;const b=Qt(it(),[p.x1,p.y1],h),y=Qt(it(),[p.x2,p.y2],h);Object.assign(v.write(Mt),{x1:b[0],y1:b[1],x2:y[0],y2:y[1]}),v.write(he).value="visible",Sr(v)}),n.controlPoints.forEach((p,m)=>{const v=d[m];if(!v){p.write(he).value="hidden";return}const b=Qt(it(),[v.x,v.y],h);Object.assign(p.write(et),{cx:b[0],cy:b[1]}),p.write(he).value="visible",Sr(p)})}syncControlPoints(t,e,r){var i,s,o;const n=e-((s=(i=r.controlPoints)===null||i===void 0?void 0:i.length)!==null&&s!==void 0?s:0);if(n>0){const a=[];for(let l=0;l<n;l++){const c=this.createAnchor(0,0,gt.CONTROL);this.commands.entity(t).appendChild(this.commands.entity(c)),a.push(c)}Object.assign(r,{controlPoints:[...(o=r.controlPoints)!==null&&o!==void 0?o:[],...a]}),this.commands.execute();return}if(n<0)for(let a=0;a<Math.abs(n);a++){const l=r.controlPoints.pop();l&&l.add(Tn)}}createPathHandleLine(){return this.commands.spawn(new Ii(va.TRANSFORMER_MASK),new ba("path-handle-line"),new _e,new Zi,new Mt({x1:0,y1:0,x2:0,y2:0}),new Fs([{type:"solid",value:Zs,opacity:.45}]),new Gt({width:1,dasharray:[6,6]}),new Qn,new Xc,new Ls(nw-2),new he).id().hold()}syncPathHandleLines(t,e,r){var i,s,o,n;const a=e-((s=(i=r.pathHandleLines)===null||i===void 0?void 0:i.length)!==null&&s!==void 0?s:0);if(a>0){const l=[];for(let c=0;c<a;c++){const h=this.createPathHandleLine();this.commands.entity(t).appendChild(this.commands.entity(h)),l.push(h)}Object.assign(r,{pathHandleLines:[...(o=r.pathHandleLines)!==null&&o!==void 0?o:[],...l]}),this.commands.execute();return}if(a<0)for(let l=0;l<Math.abs(a);l++){const c=(n=r.pathHandleLines)===null||n===void 0?void 0:n.pop();c&&c.add(Tn)}}syncSegmentMidpoints(t,e,r){var i,s,o;const n=e-((s=(i=r.segmentMidpoints)===null||i===void 0?void 0:i.length)!==null&&s!==void 0?s:0);if(n>0){const a=[];for(let l=0;l<n;l++){const c=this.createAnchor(0,0,gt.SEGMENT_MIDPOINT);this.commands.entity(t).appendChild(this.commands.entity(c)),a.push(c)}Object.assign(r,{segmentMidpoints:[...(o=r.segmentMidpoints)!==null&&o!==void 0?o:[],...a]}),this.commands.execute()}else if(n<0)for(let a=0;a<Math.abs(n);a++){const l=r.segmentMidpoints.pop();l&&l.add(Tn)}}execute(){const t=new Set;this.cameras.current.forEach(e=>{if(!e.has(jt))return;const{canvas:r}=e.read(jt);if(!r)return;const{api:i}=r.read(wt),s=i.getAppState().penbarSelected,o=i.getAppState().vectorNetworkEditMode;if(this.vectorEditModes.get(i)!==o&&(this.vectorEditModes.set(i,o),t.add(e)),e.has(Nt)){if(s!==vt.SELECT){const{mask:n}=e.read(Nt);n&&(n.write(he).value="hidden");const a=e.read(Nt);this.hideLineMaskAndEndpointAnchors(a),a.polylineMask&&(a.polylineMask.write(he).value="hidden")}s!==vt.VECTOR_NETWORK&&!Bne(e,s)&&this.hideVectorNetworkEditAnchors(e.read(Nt))}}),this.cameras.added.forEach(e=>{t.add(e)}),this.selected.added.forEach(e=>{const r=e.read(ks).camera;nr(r)&&t.add(r)}),this.selected.removed.forEach(e=>{this.accessRecentlyDeletedData();try{const r=e.read(ks).camera;nr(r)&&t.add(r)}catch{}}),this.cameras.current.forEach(e=>{if(!e.has(jt))return;const{canvas:r}=e.read(jt);r&&C9t(r)&&t.add(e)}),this.accessRecentlyDeletedData(!1),this.bounds.changed.forEach(e=>{let r=e;for(;r;){if(r.has(ks)){const i=r.read(ks).camera;nr(i)&&t.add(i);break}if(!r.has(be))break;r=r.read(be).parent}}),this.editable.changed.forEach(e=>{if(!nr(e))return;const r=En(e);nr(r)&&r.has(jt)&&t.add(r)}),this.editableAdded.added.forEach(e=>{if(!nr(e))return;const r=En(e);nr(r)&&r.has(jt)&&t.add(r)}),this.cameras.current.forEach(e=>{if(!e.has(jt))return;const{canvas:r}=e.read(jt);if(!(r!=null&&r.has(wt)))return;const{api:i}=r.read(wt);i.getAppState().penbarSelected===vt.VECTOR_NETWORK&&t.add(e)}),t.forEach(e=>{this.createOrUpdate(e)})}createAnchor(t,e,r){return this.commands.spawn(new Ii(va.TRANSFORMER_ANCHOR),new ba(r),new _e,new Zi,new Ce([{type:"solid",value:xU}]),new Fs([{type:"solid",value:Zs}]),new Gt({width:1}),new et({cx:t,cy:e,r:r===gt.SEGMENT_MIDPOINT||r===gt.CENTER?Uw-1:Uw}),new Qn,new Xc,new he(r===gt.SEGMENT_MIDPOINT||r===gt.TANGENT?"hidden":"inherited"),new Ls(nw)).id().hold()}hideLineMaskAndEndpointAnchors(t){const{lineMask:e,x1y1Anchor:r,x2y2Anchor:i}=t;e&&(e.write(he).value="hidden"),r&&(r.write(he).value="hidden"),i&&(i.write(he).value="hidden")}hideVectorNetworkEditAnchors(t){var e,r,i,s;(e=t.controlPoints)===null||e===void 0||e.forEach(o=>{o.write(he).value="hidden",Sr(o)}),(r=t.segmentMidpoints)===null||r===void 0||r.forEach(o=>{mQ(o,"hidden"),Sr(o)}
10359),(i=t.vnTangentHandles)===null||i===void 0||i.forEach(o=>{o.write(he).value="hidden",Sr(o)}),(s=t.pathHandleLines)===null||s===void 0||s.forEach(o=>{o.write(he).value="hidden",Sr(o)})}createRectMask(t,e){const r=this.commands.spawn(new Ii(va.TRANSFORMER_MASK),new _e,new Zi,new Ce([{type:"solid",value:xU,opacity:0}]),new Fs([{type:"solid",value:Zs}]),new Gt({width:1}),new $t,new Qn,new Ls(nw),new he).id().hold(),i=this.createAnchor(0,0,gt.TOP_LEFT),s=this.createAnchor(0,0,gt.TOP_RIGHT),o=this.createAnchor(0,0,gt.BOTTOM_LEFT),n=this.createAnchor(0,0,gt.BOTTOM_RIGHT),a=this.createAnchor(0,0,gt.CENTER);this.commands.entity(r).appendChild(this.commands.entity(i)).appendChild(this.commands.entity(s)).appendChild(this.commands.entity(o)).appendChild(this.commands.entity(n)).appendChild(this.commands.entity(a)),this.commands.entity(t).appendChild(this.commands.entity(r)),this.commands.execute(),Object.assign(e,{mask:r,tlAnchor:i,trAnchor:s,blAnchor:o,brAnchor:n,centerAnchor:a})}updateRectMask(t){const{x:e,y:r,width:i,height:s,rotation:o,scaleX:n,scaleY:a}=SU(t),{tlAnchor:l,trAnchor:c,blAnchor:h,brAnchor:u,centerAnchor:d,mask:f}=t.read(Nt);f.write(he).value="visible",Object.assign(f.write($t),{x:0,y:0,width:i,height:s}),Object.assign(f.write(_e),{translation:{x:e,y:r},rotation:o,scale:{x:n,y:a}}),Object.assign(l.write(et),{cx:0,cy:0}),Object.assign(c.write(et),{cx:i,cy:0}),Object.assign(h.write(et),{cx:0,cy:s}),Object.assign(u.write(et),{cx:i,cy:s});const g=t.write(Nt);(!g.rotatePivotPinned||Number.isNaN(g.rotatePivotX)||Number.isNaN(g.rotatePivotY))&&(g.rotatePivotX=i/2,g.rotatePivotY=s/2),Object.assign(d.write(et),{cx:g.rotatePivotX,cy:g.rotatePivotY}),Sr(f)}createLineMask(t,e){const r=this.commands.spawn(new Ii(va.TRANSFORMER_MASK),new _e,new Zi,new $t,new Ls(nw),new he).id().hold(),i=this.createAnchor(0,0,gt.X1Y1),s=this.createAnchor(0,0,gt.X2Y2);Object.assign(e,{lineMask:r,x1y1Anchor:i,x2y2Anchor:s}),this.commands.entity(r).appendChild(this.commands.entity(i)).appendChild(this.commands.entity(s)),this.commands.entity(t).appendChild(this.commands.entity(r)),this.commands.execute()}updateLineMask(t){const{lineMask:e,x1y1Anchor:r,x2y2Anchor:i,selecteds:s}=t.read(Nt),{x:o,y:n,width:a,height:l,rotation:c,scaleX:h,scaleY:u}=SU(t),d=s[0];let f,g;if(d.has(_t)){const{points:p}=d.read(_t),m=_t.getGeometryBounds({points:p}),v=m.minX,b=m.minY;f=[p[0][0]-v,p[0][1]-b],g=[p[p.length-1][0]-v,p[p.length-1][1]-b],LS(d)?(r.write(he).value="visible",i.write(he).value="visible"):(r.write(he).value="hidden",i.write(he).value="hidden")}else if(d.has(Mt)){const{x1:p,y1:m,x2:v,y2:b}=d.read(Mt),y=Mt.getGeometryBounds({x1:p,y1:m,x2:v,y2:b}),_=y.minX,w=y.minY;f=[p-_,m-w],g=[v-_,b-w],r.write(he).value="visible",i.write(he).value="visible"}e.write(he).value="visible",Object.assign(e.write($t),{x:0,y:0,width:a,height:l}),Object.assign(e.write(_e),{translation:{x:o,y:n},rotation:c,scale:{x:h,y:u}}),Object.assign(r.write(et),{cx:f[0],cy:f[1]}),Object.assign(i.write(et),{cx:g[0],cy:g[1]}),Sr(e)}createPolylineMask(t,e){const r=this.commands.spawn(new Ii(va.TRANSFORMER_MASK),new _e,new Zi,new Gt({width:LB*2}),new Fs([{type:"solid",value:Zs,opacity:0}]),new _t,new Ls(nw),new he).id().hold();Object.assign(e,{polylineMask:r}),this.commands.entity(t).appendChild(this.commands.entity(r)),this.commands.execute()}updatePolylineMask(t){const{polylineMask:e,selecteds:r}=t.read(Nt),i=r[0];if(!i||!i.hasSomeOf(_t,xt)){e.write(he).value="hidden";return}e.write(he).value="visible",Object.assign(e.write(_e),{translation:{x:0,y:0},rotation:0,scale:{x:1,y:1}}),i.has(_t)?e.write(_t).points=i.read(_t).points:e.write(_t).points=i.read(wo).points.flat().map(s=>[s[0],s[1]]),this.updatePolylineControlPoints(t),Sr(e)}};function gQ(t){const e=t.map(n=>{if(n.has(fe)){const{geometryWorldBounds:a}=n.read(fe);return{minX:a.minX,minY:a.minY,maxX:a.maxX,maxY:a.maxY}}if(n.has(ze)){const{children:a}=n.read(ze),l=gQ(a);return{minX:l.x,minY:l.y,maxX:l.x+l.width,maxY:l.y+l.height}}}).filter(n=>n!==void 0);if(e.length===0)return{x:0,y:0,width:0,height:0,rotation:0,scaleX:1,scaleY:1};const{minX:r,minY:i,maxX:s,maxY:o}=e.reduce((n,a)=>({minX:Math.min(n.minX,a.minX),minY:Math.min(n.minY,a.minY),maxX:Math.max(n.maxX,a.maxX),maxY:Math.max(n.maxY,a.maxY)}),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return{x:r,y:i,width:s-r,height:o-i,rotation:0,scaleX:1,scaleY:1}}function SU(t){var e;const r=t.read(Nt),{selecteds:i,status:s,resizeWidth:o,resizeHeight:n}=r;if(i.length===1){const a=i[0];if(a.has(fe)){const{selectionOBB:l}=a.read(fe);if(s===Nn.RESIZING&&o>=0&&n>=0&&a.has(Yt)){const c=a.read(Yt);
10359if(c.wordWrap&&((e=c.wordWrapWidth)!==null&&e!==void 0?e:0)>0){const h=l;return new Yu({x:h.x,y:h.y,width:o,height:n,rotation:h.rotation,scaleX:h.scaleX,scaleY:h.scaleY})}}}}if(s===Nn.ROTATING&&r.transformerObbFrozenDuringRotate&&i.length>1){const a=r.gestureFrozenSelectionOBB;return new Yu({x:a.x,y:a.y,width:a.width,height:a.height,rotation:a.rotation,scaleX:a.scaleX,scaleY:a.scaleY})}if(i.length===1){const a=i[0];if(a.has(fe))return a.read(fe).selectionOBB}return i.length>1?gQ(i):{x:0,y:0,width:0,height:0,rotation:0,scaleX:1,scaleY:1}}function mQ(t,e){t.write(he).value=e,t.has(Pn)||t.add(Pn);const r=t.write(Pn);if(e==="hidden")r.visible=!1;else if(e==="visible")r.visible=!0;else{const i=t.has(be)&&t.read(be).parent;r.visible=i!=null&&i.has(Pn)?i.read(Pn).visible:!0}}function TU(t,e){return t!==vt.SELECT||!e.has(Mi)||!e.read(Mi).isEditing?!1:!!(e.has(ke)||e.hasSomeOf(_t,xt)&&!(LS(e)&&e.has(_t)))}function Bne(t,e){const{selecteds:r}=t.read(Nt);return r.length===1&&TU(e,r[0])}function Cwt(t){const{selecteds:e}=t.read(Nt);if(e.length!==1)return!1;const r=e[0];return!!(r.has(Mt)||LS(r)&&r.has(_t))}function One(t){const{selecteds:e}=t.read(Nt);return e.length===1&&e[0].hasSomeOf(_t,xt)?LS(e[0])&&e[0].has(_t)?!1:TU(vt.SELECT,e[0]):!1}function Ine(t,e,r,i,s,o){const n=tJ(r,i);if(n.length<4)return 1/0;const a=[];for(let h=0;h<n.length;h+=2){const u=Qt(it(),[n[h],n[h+1]],e),d=t.canvas2Viewport({x:u[0],y:u[1]});a.push([d.x,d.y])}const l=[s,o];let c=1/0;for(let h=0;h<a.length-1;h++)c=Math.min(c,zx(l,a[h],a[h+1]));return c}function Mwt(t,e,r,i,s,o,n=pQ){const a=t.canvas2Viewport({x:s,y:o});let l=-1,c=n;for(let h=0;h<e.length;h++){if(h===i)continue;const u=e[h],d=Qt(it(),[u.x,u.y],r),f=t.canvas2Viewport({x:d[0],y:d[1]}),g=Math.hypot(f.x-a.x,f.y-a.y);g<=c&&(c=g,l=h)}return l}function yQ(t,e,r,i,s=LB){if(!e.has(ke))return-1;const{vertices:o,segments:n}=e.read(ke),a=ie.toGLMat3(e.read(Ae).matrix);let l=-1,c=s;for(let d=0;d<n.length;d++){const f=Ine(t,a,o,n[d],r,i);f<=c&&(c=f,l=d)}const h=t.getNodeByEntity(e),u=h?Mne(t,h.id):-1;return l>=0&&u>=0&&Swt({vertices:o,segments:n},l,u)?u:l}function vQ(t,{x:e,y:r},i="mouse"){const s=i==="touch"?Twt:Gw,o=i==="touch"?Rwt:LB,n=t.getCamera(),{rotateEnabled:a,penbarSelected:l,vectorNetworkEditMode:c}=t.getAppState(),h=[e,r],{selecteds:u}=n.read(Nt),d=u.length===1&&TU(l,u[0]),{tlAnchor:f,trAnchor:g,blAnchor:p,brAnchor:m,controlPoints:v,segmentMidpoints:b,mask:y,lineMask:_,polylineMask:w,x1y1Anchor:E,x2y2Anchor:A,centerAnchor:x,vnTangentHandles:S}=n.read(Nt),T=u[0];if(T!=null&&T.has(ke)&&(l===vt.VECTOR_NETWORK||d)){if(c===So.BEND&&S)for(let U=0;U<S.length;U++){const H=S[U];if(H.read(he).value==="hidden")continue;const{cx:N,cy:G}=H.read(et),{x:Y,y:q}=t.canvas2Viewport({x:N,y:G});if(Sa(e,r,Y,q)<=Gw)return{anchor:gt.TANGENT,cursor:"crosshair",index:U}}const{vertices:R,segments:B}=T.read(ke),O=ie.toGLMat3(T.read(Ae).matrix),C=U=>{const H=Qt(it(),U,O),N=t.canvas2Viewport({x:H[0],y:H[1]});return Sa(e,r,N.x,N.y)<=Gw},F=n.read(Nt).selectedControlPointIndex;for(let U=0;U<R.length;U++)if(C([R[U].x,R[U].y])){const H=R[F],N=H&&Math.hypot(H.x-R[U].x,H.y-R[U].y)<1e-6;return{anchor:gt.CONTROL,cursor:"crosshair",index:N?F:U}}if(c===So.MOVE||c===So.CUT)for(let U=0;U<B.length;U++){const H=_G(R,B[U],.5);if(H&&C(H))return{anchor:gt.SEGMENT_MIDPOINT,cursor:"crosshair",index:U}}if(c===So.MOVE||c===So.BEND){const U=yQ(t,T,e,r);if(U>=0)return{anchor:gt.SEGMENT,cursor:c===So.BEND?"crosshair":"move",index:U}}return{anchor:gt.OUTSIDE,cursor:"default",index:-1}}if((l===vt.VECTOR_NETWORK||d)&&v){for(let O=0;O<v.length;O++){if(v[O].read(he).value==="hidden")continue;const{cx:C,cy:F}=v[O].read(et),{x:U,y:H}=t.canvas2Viewport({x:C,y:F});if(Sa(e,r,U,H)<=Gw)return{anchor:gt.CONTROL,cursor:"crosshair",index:O}}const R=b??[];for(let O=0;O<R.length;O++){if(R[O].read(he).value==="hidden")continue;const{cx:C,cy:F}=R[O].read(et),{x:U,y:H}=t.canvas2Viewport({x:C,y:F});if(Sa(e,r,U,H)<=Gw)return{anchor:gt.SEGMENT_MIDPOINT,cursor:"crosshair",index:O}}let B=1/0;
10359if(T.has(_t)){const O=w.read(_t).points.map(C=>t.canvas2Viewport(t.transformer2Canvas({x:C[0],y:C[1]},w)));for(let C=0;C<O.length-1;C++)B=Math.min(B,zx(h,[O[C].x,O[C].y],[O[C+1].x,O[C+1].y]))}else if(T.has(xt)){const O=ie.toGLMat3(T.read(Ae).matrix);T.read(wo).points.forEach(C=>{if(C.length<2)return;const F=C.map(U=>{const H=Qt(it(),U,O);return t.canvas2Viewport({x:H[0],y:H[1]})});for(let U=0;U<F.length-1;U++)B=Math.min(B,zx(h,[F[U].x,F[U].y],[F[U+1].x,F[U+1].y]))})}return B<=LB?{anchor:gt.INSIDE,cursor:"default"}:{anchor:gt.OUTSIDE,cursor:"default"}}else if(Cwt(n)){const{x:R,y:B}=t.canvas2Viewport(t.transformer2Canvas({x:E.read(et).cx,y:E.read(et).cy},_)),{x:O,y:C}=t.canvas2Viewport(t.transformer2Canvas({x:A.read(et).cx,y:A.read(et).cy},_)),F=Pdt(h,[[R,B],[R,C],[O,B],[O,C]]),U=Sa(e,r,R,B),H=Sa(e,r,O,C),N=Math.min(U,H);if(N<=s){if(N===U)return{anchor:gt.X1Y1,cursor:"crosshair"};if(N===H)return{anchor:gt.X2Y2,cursor:"crosshair"}}return F?{anchor:gt.INSIDE,cursor:"default"}:{anchor:gt.OUTSIDE,cursor:"default"}}else{const{x:R,y:B}=t.canvas2Viewport(t.transformer2Canvas({x:f.read(et).cx,y:f.read(et).cy},y)),{x:O,y:C}=t.canvas2Viewport(t.transformer2Canvas({x:g.read(et).cx,y:g.read(et).cy},y)),{x:F,y:U}=t.canvas2Viewport(t.transformer2Canvas({x:p.read(et).cx,y:p.read(et).cy},y)),{x:H,y:N}=t.canvas2Viewport(t.transformer2Canvas({x:m.read(et).cx,y:m.read(et).cy},y)),{x:G,y:Y}=t.canvas2Viewport(t.transformer2Canvas({x:x.read(et).cx,y:x.read(et).cy},y)),q=Pdt(h,[[R,B],[O,C],[H,N],[F,U]]),L=Sa(e,r,R,B),J=Sa(e,r,O,C),tt=Sa(e,r,F,U),bt=Sa(e,r,H,N);if(Sa(e,r,G,Y)<=Gw+1)return{anchor:gt.CENTER,cursor:"move"};const ct=Math.min(L,J,tt,bt),Xt=zx(h,[R,B],[O,C]),It=zx(h,[F,U],[H,N]),zt=zx(h,[R,B],[F,U]),Ht=zx(h,[O,C],[H,N]),Lt=Math.min(Xt,It,zt,Ht);if(ct<=s){if(ct===L)return{anchor:gt.TOP_LEFT,cursor:"nwse-resize"};if(ct===J)return{anchor:gt.TOP_RIGHT,cursor:"nesw-resize"};if(ct===tt)return{anchor:gt.BOTTOM_LEFT,cursor:"nesw-resize"};if(ct===bt)return{anchor:gt.BOTTOM_RIGHT,cursor:"nwse-resize"}}else if(a&&!q&&ct<=o&&Lt>s){if(ct===L)return{anchor:gt.TOP_LEFT,cursor:"nwse-rotate"};if(ct===J)return{anchor:gt.TOP_RIGHT,cursor:"nesw-rotate"};if(ct===tt)return{anchor:gt.BOTTOM_LEFT,cursor:"swne-rotate"};if(ct===bt)return{anchor:gt.BOTTOM_RIGHT,cursor:"senw-rotate"}}if(Lt<=s){if(Lt===Xt)return{anchor:gt.TOP_CENTER,cursor:"ns-resize"};if(Lt===It)return{anchor:gt.BOTTOM_CENTER,cursor:"ns-resize"};if(Lt===zt)return{anchor:gt.MIDDLE_LEFT,cursor:"ew-resize"};if(Lt===Ht)return{anchor:gt.MIDDLE_RIGHT,cursor:"ew-resize"}}return q?{anchor:gt.INSIDE,cursor:"default"}:{anchor:gt.OUTSIDE,cursor:"default"}}}let _Q;_Q=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},(function(t){t.LIGHT="light",t.DARK="dark"})(Tr||(Tr={})),ZU=function(t){return t==="light"?Tr.LIGHT:t==="dark"?Tr.DARK:typeof globalThis>"u"||typeof globalThis.matchMedia!="function"?Tr.LIGHT:globalThis.matchMedia("(prefers-color-scheme: dark)").matches?Tr.DARK:Tr.LIGHT},Ytt=function(t){return t.themePreference!=null?t.themePreference:t.themeMode===Tr.DARK?"dark":"light"};const Ty={[Tr.LIGHT]:{background:"#fbfbfb",grid:"#dedede",selectionBrushFill:Kh,selectionBrushStroke:Zs,swatches:[]},[Tr.DARK]:{background:"#121212",grid:"#242424",selectionBrushFill:Kh,selectionBrushStroke:Zs,swatches:[]}};function bQ(t,e){var r,i,s,o,n,a,l;return e?{mode:(s=e.mode)!==null&&s!==void 0?s:t.mode,colors:{[Tr.LIGHT]:Object.assign(Object.assign(Object.assign({},Ty[Tr.LIGHT]),(o=t.colors)===null||o===void 0?void 0:o[Tr.LIGHT]),(n=e.colors)===null||n===void 0?void 0:n[Tr.LIGHT]),[Tr.DARK]:Object.assign(Object.assign(Object.assign({},Ty[Tr.DARK]),(a=t.colors)===null||a===void 0?void 0:a[Tr.DARK]),(l=e.colors)===null||l===void 0?void 0:l[Tr.DARK])}}:{mode:t.mode,colors:{[Tr.LIGHT]:Object.assign(Object.assign({},Ty[Tr.LIGHT]),(r=t.colors)===null||r===void 0?void 0:r[Tr.LIGHT]),[Tr.DARK]:Object.assign(Object.assign({},Ty[Tr.DARK]),(i=t.colors)===null||i===void 0?void 0:i[Tr.DARK])}}}ul=class{},_Q([P({type:$.staticString([Tr.LIGHT,Tr.DARK]),default:Tr.LIGHT})],ul.prototype,"mode",void 0),_Q([P({type:$.object,default:{[Tr.LIGHT]:Object.assign({},Ty[Tr.LIGHT]),[Tr.DARK]:Object.assign({},Ty[Tr.DARK])}})],ul.prototype,"colors",void 0);var Dne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
10359a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};let wQ=class{};Dne([P.object],wQ.prototype,"value",void 0);var Bwt=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};_o=class{constructor(t){Object.assign(this,t)}},Bwt([P.ref],_o.prototype,"canvas",void 0),Bwt([P({type:$.object,default:"default"})],_o.prototype,"value",void 0);var qs=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Ca=class{},qs([P({type:$.staticString(["image/png","image/jpeg","image/webp","image/bmp"]),default:"image/png"})],Ca.prototype,"type",void 0),qs([P({type:$.float32,default:.92})],Ca.prototype,"encoderOptions",void 0),qs([P.boolean],Ca.prototype,"grid",void 0),qs([P.ref],Ca.prototype,"canvas",void 0),qs([P.boolean],Ca.prototype,"download",void 0),qs([P.object],Ca.prototype,"nodes",void 0),qs([P({type:$.float32,default:1})],Ca.prototype,"scale",void 0),qs([P({type:$.float32,default:0})],Ca.prototype,"rainWarmupSec",void 0),qs([P({type:$.float32,default:0})],Ca.prototype,"rainCaptureTimeSec",void 0),Ga=class{},qs([P.ref],Ga.prototype,"canvas",void 0),qs([P.boolean],Ga.prototype,"download",void 0),qs([P({type:$.staticString(["webm","gif"]),default:"webm"})],Ga.prototype,"format",void 0),qs([P({type:$.float32,default:3})],Ga.prototype,"durationSec",void 0),qs([P({type:$.float32,default:24})],Ga.prototype,"fps",void 0),qs([P.boolean],Ga.prototype,"grid",void 0),qs([P.object],Ga.prototype,"nodes",void 0),qs([P({type:$.float32,default:1})],Ga.prototype,"scale",void 0),qs([P({type:$.float32,default:0})],Ga.prototype,"timeStart",void 0),qs([P({type:$.staticString(["high","medium","low"]),default:"high"})],Ga.prototype,"gifQuality",void 0),qs([P({type:$.float32,default:0})],Ga.prototype,"rainWarmupSec",void 0),Vy=class{},qs([P.ref],Vy.prototype,"canvas",void 0),qs([P.boolean],Vy.prototype,"download",void 0),qs([P.object],Vy.prototype,"blob",void 0),qs([P.object],Vy.prototype,"fileName",void 0);class Vg{}qs([P.boolean],Vg.prototype,"grid",void 0),qs([P.ref],Vg.prototype,"canvas",void 0),qs([P.boolean],Vg.prototype,"download",void 0),qs([P.object],Vg.prototype,"nodes",void 0),vh=class{},qs([P.object],vh.prototype,"dataURL",void 0),qs([P.object],vh.prototype,"svg",void 0),qs([P.ref],vh.prototype,"canvas",void 0),qs([P.boolean],vh.prototype,"download",void 0);var UB=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};cs=class{constructor(t){Object.assign(this,t)}},UB([P.object],cs.prototype,"device",void 0),UB([P.object],cs.prototype,"swapChain",void 0),UB([P.object],cs.prototype,"renderCache",void 0),UB([P.object],cs.prototype,"renderGraph",void 0),UB([P.object],cs.prototype,"texturePool",void 0),UB([P.object],cs.prototype,"scope",void 0),AV=class{};var Pne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};ba=class{constructor(t){this.value=t||""}},Pne([P.dynamicString(1e3)],ba.prototype,"value",void 0),jc=class{};var EQ=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
10359a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};_e=class{constructor(t){var e,r,i,s,o;this.translation=t!=null&&t.translation?new tl((e=t.translation.x)!==null&&e!==void 0?e:0,(r=t.translation.y)!==null&&r!==void 0?r:0):tl.ZERO,this.scale=t!=null&&t.scale?new tl((i=t.scale.x)!==null&&i!==void 0?i:1,(s=t.scale.y)!==null&&s!==void 0?s:1):tl.ONE,this.rotation=(o=t==null?void 0:t.rotation)!==null&&o!==void 0?o:0}},EQ([P({type:WK,default:tl.ZERO})],_e.prototype,"translation",void 0),EQ([P({type:WK,default:tl.ONE})],_e.prototype,"scale",void 0),EQ([P({type:$.float32,default:0})],_e.prototype,"rotation",void 0);var Fne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Ae=class{constructor(t=ie.IDENTITY){this.matrix=t}},Fne([P(Xx)],Ae.prototype,"matrix",void 0);var Nne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};be=class{},Nne([P.ref],be.prototype,"parent",void 0);var kne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};ze=class{},kne([P.backrefs(be,"parent")],ze.prototype,"children",void 0);var Owt=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Wl=class{constructor(t){Object.assign(this,t)}},Owt([P.ref],Wl.prototype,"from",void 0),Owt([P.ref],Wl.prototype,"to",void 0);var Iwt=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};hl=class{constructor(t){Object.assign(this,t)}},Iwt([P.ref],hl.prototype,"attached",void 0),Iwt([P.int32],hl.prototype,"sourceIsAttached",void 0);function LS(t){return t.has(Wl)||t.has(hl)}var AQ=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};cl=class{},AQ([P.backrefs(Wl,"from")],cl.prototype,"fromBindings",void 0),AQ([P.backrefs(Wl,"to")],cl.prototype,"toBindings",void 0),AQ([P.backrefs(hl,"attached")],cl.prototype,"partialBindings",void 0);var Dwt=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};class Ww{constructor(e){Object.assign(this,e)}}Dwt([P({type:$.float32,default:.5})],Ww.prototype,"labelPosition",void 0),Dwt([P({type:$.float32,default:0})],Ww.prototype,"labelOffset",void 0);var Pwt=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
10359a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Zi=class{constructor(t){var e,r;this.batchable=(e=t==null?void 0:t.batchable)!==null&&e!==void 0?e:!1,this.hitArea=(r=t==null?void 0:t.hitArea)!==null&&r!==void 0?r:null}},Pwt([P({type:$.boolean,default:!1})],Zi.prototype,"batchable",void 0),Pwt([P({type:$.object,default:null})],Zi.prototype,"hitArea",void 0);var Lne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};bo=class{constructor(t){(t==null?void 0:t.opacity)!=null&&(this.opacity=t.opacity)}},Lne([P({type:$.float32,default:1})],bo.prototype,"opacity",void 0);var rV=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};ro=class{constructor(t){Object.assign(this,t)}},rV([P({type:$.dynamicString(20),default:"black"})],ro.prototype,"color",void 0),rV([P({type:$.float32,default:0})],ro.prototype,"offsetX",void 0),rV([P({type:$.float32,default:0})],ro.prototype,"offsetY",void 0),rV([P({type:$.float32,default:0})],ro.prototype,"blurRadius",void 0);var iV=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};ac=class{constructor(t){Object.assign(this,t)}},iV([P.object],ac.prototype,"color",void 0),iV([P({type:$.float32,default:0})],ac.prototype,"offsetX",void 0),iV([P({type:$.float32,default:0})],ac.prototype,"offsetY",void 0),iV([P({type:$.float32,default:0})],ac.prototype,"blurRadius",void 0);var Une=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};jy=class{constructor(t){this.enabled=t??!1}},Une([P({type:$.boolean,default:!1})],jy.prototype,"enabled",void 0);var Gne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Ls=class{constructor(t){this.value=t??void 0}},Gne([P({type:$.float32,default:0})],Ls.prototype,"value",void 0);var Wne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Gs=class{constructor(t){this.value=t??void 0}},Wne([P({type:$.dynamicString(1e3)})],Gs.prototype,"value",void 0);var jne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Ln=class{},jne([P({type:$.float32,default:0})],Ln.prototype,"value",void 0);var ya=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
10359a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};ue=class{constructor(t){Object.assign(this,t)}},ya([P({type:$.float32,default:1})],ue.prototype,"seed",void 0),ya([P({type:$.float32,default:1})],ue.prototype,"roughness",void 0),ya([P({type:$.float32,default:1})],ue.prototype,"bowing",void 0),ya([P({type:$.staticString(["hachure","solid","zigzag","cross-hatch","dots","dashed","zigzag-line","watercolor"]),default:"hachure"})],ue.prototype,"fillStyle",void 0),ya([P({type:$.float32,default:-1})],ue.prototype,"fillWeight",void 0),ya([P({type:$.float32,default:-41})],ue.prototype,"hachureAngle",void 0),ya([P({type:$.float32,default:-1})],ue.prototype,"hachureGap",void 0),ya([P({type:$.float32,default:9})],ue.prototype,"curveStepCount",void 0),ya([P({type:$.float32,default:.95})],ue.prototype,"curveFitting",void 0),ya([P({type:$.float32})],ue.prototype,"fillLineDash",void 0),ya([P({type:$.float32})],ue.prototype,"fillLineDashOffset",void 0),ya([P({type:$.boolean,default:!1})],ue.prototype,"disableMultiStroke",void 0),ya([P({type:$.boolean,default:!1})],ue.prototype,"disableMultiStrokeFill",void 0),ya([P({type:$.float32})],ue.prototype,"simplification",void 0),ya([P({type:$.float32})],ue.prototype,"dashOffset",void 0),ya([P({type:$.float32})],ue.prototype,"dashGap",void 0),ya([P({type:$.float32})],ue.prototype,"zigzagOffset",void 0),ya([P({type:$.boolean,default:!1})],ue.prototype,"preserveVertices",void 0),iu=class{},ya([P({type:$.object,default:[]})],iu.prototype,"strokePoints",void 0),ya([P({type:$.object,default:[]})],iu.prototype,"fillPoints",void 0),ya([P({type:$.object,default:[]})],iu.prototype,"fillPathPoints",void 0),ya([P({type:$.object})],iu.prototype,"drawableSets",void 0),vG=function(t){var e,r,i;const s=t,{stroke:o,strokeWidth:n,strokeDasharray:a,strokeDashoffset:l,roughSeed:c,roughBowing:h,roughRoughness:u,roughFillStyle:d,roughFillWeight:f,roughHachureAngle:g,roughHachureGap:p,roughCurveStepCount:m,roughCurveFitting:v,roughDisableMultiStroke:b,roughDisableMultiStrokeFill:y,roughSimplification:_,roughDashOffset:w,roughDashGap:E,roughZigzagOffset:A,roughPreserveVertices:x,roughFillLineDash:S,roughFillLineDashOffset:T}=s,R=(e=mft(s.fills))!==null&&e!==void 0?e:"none",B=(i=(r=oX(s))!==null&&r!==void 0?r:o)!==null&&i!==void 0?i:"none",O=n!=null?Number(n):1,C=a?nc(a):[0,0],F=d==="watercolor";return RV({fill:F?"":R,stroke:B,strokeWidth:O,seed:c,bowing:h,roughness:u,fillStyle:F?"solid":d,fillWeight:f!==-1?f:O/2,hachureAngle:g,hachureGap:p!==-1?p:O*4,curveStepCount:m,curveFitting:v,disableMultiStroke:b,disableMultiStrokeFill:y,simplification:_,dashOffset:w,dashGap:E,zigzagOffset:A,preserveVertices:x,strokeLineDash:[C[0],C[1]],strokeLineDashOffset:l,fillLineDash:S,fillLineDashOffset:T})};var GB=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};fe=class{},GB([P(g3)],fe.prototype,"renderBounds",void 0),GB([P(g3)],fe.prototype,"geometryBounds",void 0),GB([P(g3)],fe.prototype,"renderWorldBounds",void 0),GB([P(g3)],fe.prototype,"geometryWorldBounds",void 0),GB([P(rX)],fe.prototype,"transformOBB",void 0),GB([P(rX)],fe.prototype,"selectionOBB",void 0);var Xne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};he=class{constructor(t="inherited"){this.value=t}},Xne([P({type:$.staticString(["inherited","hidden","visible"])})],he.prototype,"value",void 0),Tn=class{},Xc=class{},Qn=class{};var zne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
10359a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};class Pn{}zne([P({type:$.boolean,default:!1})],Pn.prototype,"visible",void 0),Sn=class{},yi=class{};var sV=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};wa=class{constructor(t){Object.assign(this,t)}},sV([P({type:$.object,default:"black"})],wa.prototype,"color",void 0),sV([P({type:$.staticString(["underline","overline","line-through","none"]),default:"none"})],wa.prototype,"line",void 0),sV([P({type:$.staticString(["solid","double","dotted","dashed","wavy"]),default:"solid"})],wa.prototype,"style",void 0),sV([P({type:$.float32,default:0})],wa.prototype,"thickness",void 0);var xQ=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};qo=class{constructor(t){Object.assign(this,t)}},xQ([P({type:$.staticString(["none","line","triangle","diamond"]),default:"none"})],qo.prototype,"start",void 0),xQ([P({type:$.staticString(["none","line","triangle","diamond"]),default:"none"})],qo.prototype,"end",void 0),xQ([P({type:$.float32,default:3})],qo.prototype,"factor",void 0);var Vne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Mv=class{constructor(t=!0){this.enabled=t}},Vne([P({type:$.boolean,default:!0})],Mv.prototype,"enabled",void 0);var Yne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Mi=class{constructor(t){Object.assign(this,t)}},Yne([P({type:$.boolean,default:!1})],Mi.prototype,"isEditing",void 0);var $ne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};La=class{constructor(t){Object.assign(this,t)}},$ne([P({type:$.object,default:""})],La.prototype,"value",void 0);var Hne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};zy=class{constructor(t){Object.assign(this,t)}},Hne([P({type:$.object,default:"normal"})],zy.prototype,"mode",void 0),tu=class{};var Fwt=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Gc=class{constructor(t,e){this.value=t??"clip",this.outsideAlpha=e??.5}},Fwt([P({type:$.staticString(["clip","erase","soft"]),default:"clip"})],Gc.prototype,"value",void 0),Fwt([P({type:$.float32,default:.5})],Gc.prototype,"outsideAlpha",void 0),mh=class{},uE=class{};var SQ=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
10359a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};et=class{static getGeometryBounds(t){const{cx:e,cy:r,r:i}=t;return new Qe(e-i,r-i,e+i,r+i)}static getRenderBounds(t,e){const{cx:r,cy:i,r:s}=t,o=o3(e);return new Qe(r-s-o,i-s-o,r+s+o,i+s+o)}constructor(t){this.cx=t==null?void 0:t.cx,this.cy=t==null?void 0:t.cy,this.r=t==null?void 0:t.r}},SQ([P({type:$.float32,default:0})],et.prototype,"cx",void 0),SQ([P({type:$.float32,default:0})],et.prototype,"cy",void 0),SQ([P({type:$.float32,default:0})],et.prototype,"r",void 0);var RU=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};$t=class{static getGeometryBounds(t){const{x:e=0,y:r=0,width:i=0,height:s=0}=t;return new Qe(Math.min(e,e+i),Math.min(r,r+s),Math.max(e,e+i),Math.max(r,r+s))}static getRenderBounds(t,e,r){const{x:i,y:s,width:o,height:n}=t,{offsetX:a=0,offsetY:l=0,blurRadius:c=0}=r??{},h=o3(e),u=new Qe(i-h,s-h,i+o+h,s+n+h);return u.addBounds(new Qe(i+a-c,s+l-c,i+a+o+c,s+l+n+c)),u}constructor(t){this.x=t==null?void 0:t.x,this.y=t==null?void 0:t.y,this.width=t==null?void 0:t.width,this.height=t==null?void 0:t.height,this.cornerRadius=t==null?void 0:t.cornerRadius}},RU([P({type:$.float32,default:0})],$t.prototype,"x",void 0),RU([P({type:$.float32,default:0})],$t.prototype,"y",void 0),RU([P({type:$.float32,default:0})],$t.prototype,"width",void 0),RU([P({type:$.float32,default:0})],$t.prototype,"height",void 0),RU([P({type:$.float32,default:0})],$t.prototype,"cornerRadius",void 0);var Ps=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Yt=class{static getGeometryBounds(t,e){const{anchorX:r=0,anchorY:i=0,textAlign:s="start",textBaseline:o="alphabetic",lineHeight:n,fontSize:a}=t;let{width:l,height:c,fontMetrics:h}=e??{},u=n||a;if(!l||!c||!h){const p=om(t);l=p.width,c=p.height,h=p.fontMetrics}const d=l/2;let f=r;s==="center"?f+=-d:(s==="right"||s==="end")&&(f+=-d*2);let g=i;return g+=u3(o,h),g-=(u-h.fontSize)/2,new Qe(f,g,f+l,g+c)}static getRenderBounds(t,e,r,i){const{offsetX:s=0,offsetY:o=0,blurRadius:n=0}=i??{},a=o3(r),{minX:l,minY:c,maxX:h,maxY:u}=Yt.getGeometryBounds(t,e),d=new Qe(l-a,c-a,h+a,u+a);return d.addBounds(new Qe(l+s-n,c+o-n,h+s+n,u+o+n)),d}constructor(t){Object.assign(this,t)}},Ps([P({type:$.float32,default:0})],Yt.prototype,"anchorX",void 0),Ps([P({type:$.float32,default:0})],Yt.prototype,"anchorY",void 0),Ps([P({type:$.dynamicString(1e3),default:""})],Yt.prototype,"content",void 0),Ps([P({type:$.dynamicString(100),default:"sans-serif"})],Yt.prototype,"fontFamily",void 0),Ps([P({type:$.object,default:12})],Yt.prototype,"fontSize",void 0),Ps([P({type:$.dynamicString(200),default:""})],Yt.prototype,"fontSizeVariableRef",void 0),Ps([P({type:$.object,default:"normal"})],Yt.prototype,"fontWeight",void 0),Ps([P({type:$.dynamicString(100),default:"normal"})],Yt.prototype,"fontStyle",void 0),Ps([P({type:$.dynamicString(100),default:"normal"})],Yt.prototype,"fontVariant",void 0),Ps([P({type:$.boolean,default:!0})],Yt.prototype,"fontKerning",void 0),Ps([P({type:$.float32,default:0})],Yt.prototype,"letterSpacing",void 0),Ps([P({type:$.staticString(["normal","pre","pre-line"]),default:"normal"})],Yt.prototype,"whiteSpace",void 0),Ps([P({type:$.staticString(["start","end","left","right","center"]),default:"start"})],Yt.prototype,"textAlign",void 0),Ps([P({type:$.staticString(["top","hanging","middle","alphabetic","ideographic","bottom"]),default:"alphabetic"})],Yt.prototype,"textBaseline",void 0),Ps([P({type:$.float32,default:0})],Yt.prototype,"lineHeight",void 0),Ps([P({type:$.float32,default:0})],Yt.prototype,"leading",void 0),Ps([P({type:$.object})],Yt.prototype,"bitmapFont",void 0),Ps([P({type:$.boolean,default:!0})],Yt.prototype,"bitmapFontKerning",void 0),Ps([P({type:$.boolean,default:!0})],Yt.prototype,"esdt",void 0),Ps([P({type:$.boolean,default:!1})],Yt.prototype,"physical",void 0),Ps([P({type:$.boolean,default:!1})],Yt.prototype,"wordWrap",void 0),Ps([P({type:$.float32,default:0})],Yt.prototype,"wordWrapWidth",void 0),Ps([P({type:$.staticString(["ellipsis","clip"])})],Yt.prototype,"textOverflow",void 0),Ps([P({type:$.int32,default:1/0})],Yt.prototype,"maxLines",void 0),Ji=class{},Ps([P({type:$.object})],Ji.prototype,"bidiChars",void 0),Ps([P({type:$.dynamicString(100),default:""})],Ji.prototype,"font",void 0),Ps([P({type:$.float32,default:0})],Ji.prototype,"width",void 0),Ps([P({type:$.float32,default:0})],Ji.prototype,"height",void 0),Ps([P({type:$.object})],Ji.prototype,"lines",void 0),Ps([P({type:$.float32,default:[]})],Ji.prototype,"lineWidths",void 0),Ps([P({type:$.float32,default:0})],Ji.prototype,"lineHeight",void 0),Ps([P({type:$.float32,default:0})],Ji.prototype,"maxLineWidth",void 0),Ps([P({type:$.object})],Ji.prototype,"fontMetrics",void 0),Ps([P({type:$.object})],Ji.prototype,"lineMetrics",void 0);let US;US=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
10359a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},(function(t){t.VANILLA="vanilla",t.STAMP="stamp"})(Qw||(Qw={}));var jw;(function(t){t.EQUI_DISTANCE="equi_distance",t.RATIO_DISTANCE="ratio_distance"})(jw||(jw={})),ai=class{static getGeometryBounds(t){let{points:e}=t;if(!e||e.length<2)return new Qe(0,0,0,0);typeof e=="string"&&(e=v3(e));const r=Math.min(...e.map(n=>isNaN(n.x)?1/0:n.x)),i=Math.max(...e.map(n=>isNaN(n.x)?-1/0:n.x)),s=Math.min(...e.map(n=>isNaN(n.y)?1/0:n.y)),o=Math.max(...e.map(n=>isNaN(n.y)?-1/0:n.y));return new Qe(r,s,i,o)}static getRenderBounds(t){const{minX:e,minY:r,maxX:i,maxY:s}=ai.getGeometryBounds(t),o=0;return new Qe(e-o,r-o,i+o,s+o)}constructor(t){Object.assign(this,t)}},US([P({type:$.staticString([Qw.VANILLA,Qw.STAMP]),default:Qw.VANILLA})],ai.prototype,"type",void 0),US([P({type:$.object,default:[]})],ai.prototype,"points",void 0),US([P({type:$.float32,default:20})],ai.prototype,"stampInterval",void 0),US([P({type:$.staticString([jw.EQUI_DISTANCE,jw.RATIO_DISTANCE]),default:jw.RATIO_DISTANCE})],ai.prototype,"stampMode",void 0),US([P({type:$.float32,default:.4})],ai.prototype,"stampNoiseFactor",void 0),US([P({type:$.float32,default:.75})],ai.prototype,"stampRotationFactor",void 0);var TQ=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};ke=class{static getGeometryBounds(t){let{vertices:e}=t;if(!(e!=null&&e.length))return new Qe(0,0,0,0);const r=Math.min(...e.map(({x:a})=>isNaN(a)?1/0:a)),i=Math.max(...e.map(({x:a})=>isNaN(a)?-1/0:a)),s=Math.min(...e.map(({y:a})=>isNaN(a)?1/0:a)),o=Math.max(...e.map(({y:a})=>isNaN(a)?-1/0:a)),{segments:n}=t;if(n!=null&&n.length){const a=J0t(e,n,r,s,i,o);return new Qe(a.minX,a.minY,a.maxX,a.maxY)}return new Qe(r,s,i,o)}static getRenderBounds(t,e){const{width:r,linecap:i}=e??{};let s=.5;i==="square"&&(s=Math.SQRT1_2),s*=r;const{minX:o,minY:n,maxX:a,maxY:l}=ke.getGeometryBounds(t);return new Qe(o-s,n-s,a+s,l+s)}static toSerializedNode(t,e){if(e.type==="polyline"){const{vertices:r}=t,i=r.map(({x:s,y:o})=>[s,o]);e.points=ip(i)}return e}static fromEntity(t){if(t.has(_t)){const{points:e}=t.read(_t),r=e.map(([s,o])=>({x:s,y:o})),i=e.slice(1).map((s,o)=>({start:o,end:o+1}));return{vertices:r,segments:i}}if(t.has(xt)){const{d:e,fillRule:r}=t.read(xt),{vertices:i,segments:s,regions:o}=xse(e,r);return{vertices:i,segments:s,regions:o}}}constructor(t){Object.assign(this,t)}},TQ([P.object],ke.prototype,"vertices",void 0),TQ([P.object],ke.prototype,"segments",void 0),TQ([P.object],ke.prototype,"regions",void 0);var fv=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Js=class{constructor(t){t&&Object.assign(this,t)}},fv([P({type:$.object,default:""})],Js.prototype,"fill",void 0),fv([P({type:$.object,default:""})],Js.prototype,"stroke",void 0),fv([P({type:$.float32,default:-1})],Js.prototype,"strokeWidth",void 0),fv([P({type:$.object,default:""})],Js.prototype,"fillRule",void 0),fv([P({type:$.float32,default:-1})],Js.prototype,"opacity",void 0),fv([P({type:$.float32,default:-1})],Js.prototype,"fillOpacity",void 0),fv([P({type:$.float32,default:-1})],Js.prototype,"strokeOpacity",void 0),fv([P({type:$.object,default:""})],Js.prototype,"strokeLinecap",void 0),fv([P({type:$.object,default:""})],Js.prototype,"strokeLinejoin",void 0);var oV=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Hn=class{constructor(t){Object.assign(this,t)}},oV([P({type:$.dynamicString(128),default:""})],Hn.prototype,"iconFontName",void 0),oV([P({type:$.dynamicString(128),default:""})],Hn.prototype,"iconFontFamily",void 0),oV([P({type:$.float32,default:0})],Hn.prototype,"layoutWidth",void 0),oV([P({type:$.float32,default:0})],Hn.prototype,"layoutHeight",void 0),sm=class{};var Yg=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
10359a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};function RQ(t,e,r=0){return[t,-e,r]}function CU(t,e=0){return new Ai(t.m00,t.m01,t.m02,0,t.m10,t.m11,t.m12,0,0,0,e,0,t.m20,t.m21,0,t.m22)}function Kne(t){return new Ai(t.m00,t.m01,t.m02,0,t.m10,t.m11,t.m12,0,0,0,1,0,0,0,0,1)}function CQ(t){return new Ai(t.m00,t.m01,t.m02,0,t.m10,t.m11,t.m12,0,0,0,1,0,t.m20,t.m21,0,t.m22)}function MQ(t,e,r){const i=t/2/e,s=Math.tan(r/2);return s<=0?i:i/s}Bi=class{constructor(t){var e,r,i,s,o,n,a,l,c,h,u;t&&Object.assign(this,t),(e=this.fovy)!==null&&e!==void 0||(this.fovy=Math.PI/4),(r=this.near)!==null&&r!==void 0||(this.near=.1),(i=this.far)!==null&&i!==void 0||(this.far=1e3),(s=this.eye)!==null&&s!==void 0||(this.eye=[0,0,5]),(o=this.center)!==null&&o!==void 0||(this.center=[0,0,0]),(n=this.up)!==null&&n!==void 0||(this.up=[0,1,0]),(a=this.order)!==null&&a!==void 0||(this.order=-1),(l=this.clearColor)!==null&&l!==void 0||(this.clearColor=!0),(c=this.linked)!==null&&c!==void 0||(this.linked=!1),(h=this.baseDistance)!==null&&h!==void 0||(this.baseDistance=5),(u=this.projection)!==null&&u!==void 0||(this.projection=this.linked?"orthographic":"perspective")}},Yg([P.float32],Bi.prototype,"fovy",void 0),Yg([P.float32],Bi.prototype,"near",void 0),Yg([P.float32],Bi.prototype,"far",void 0),Yg([P.object],Bi.prototype,"eye",void 0),Yg([P.object],Bi.prototype,"center",void 0),Yg([P.object],Bi.prototype,"up",void 0),Yg([P.int32],Bi.prototype,"order",void 0),Yg([P.boolean],Bi.prototype,"clearColor",void 0),Yg([P.object],Bi.prototype,"projection",void 0),Yg([P.boolean],Bi.prototype,"linked",void 0),Yg([P.float32],Bi.prototype,"baseDistance",void 0);var nV=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Ns=class{constructor(t){var e,r,i,s;t&&Object.assign(this,t),(e=this.positions)!==null&&e!==void 0||(this.positions=new Float32Array(0)),(r=this.normals)!==null&&r!==void 0||(this.normals=new Float32Array(0)),(i=this.uvs)!==null&&i!==void 0||(this.uvs=null),(s=this.indices)!==null&&s!==void 0||(this.indices=null)}get vertexCount(){return this.positions.length/3}},nV([P.object],Ns.prototype,"positions",void 0),nV([P.object],Ns.prototype,"normals",void 0),nV([P.object],Ns.prototype,"uvs",void 0),nV([P.object],Ns.prototype,"indices",void 0);var $g=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Ni=class{constructor(t){var e,r,i,s,o,n,a,l,c,h,u;t&&Object.assign(this,t),(e=this.baseColor)!==null&&e!==void 0||(this.baseColor=[1,1,1,1]),(r=this.ambient)!==null&&r!==void 0||(this.ambient=.1),(i=this.diffuse)!==null&&i!==void 0||(this.diffuse=.7),(s=this.specular)!==null&&s!==void 0||(this.specular=.3),(o=this.shininess)!==null&&o!==void 0||(this.shininess=32),(n=this.metallic)!==null&&n!==void 0||(this.metallic=0),(a=this.roughness)!==null&&a!==void 0||(this.roughness=1),(l=this.map)!==null&&l!==void 0||(this.map=null),(c=this.specularMap)!==null&&c!==void 0||(this.specularMap=null),(h=this.bumpMap)!==null&&h!==void 0||(this.bumpMap=null),(u=this.bumpScale)!==null&&u!==void 0||(this.bumpScale=1)}},$g([P.object],Ni.prototype,"baseColor",void 0),$g([P.float32],Ni.prototype,"ambient",void 0),$g([P.float32],Ni.prototype,"diffuse",void 0),$g([P.float32],Ni.prototype,"specular",void 0),$g([P.float32],Ni.prototype,"shininess",void 0),$g([P.float32],Ni.prototype,"metallic",void 0),$g([P.float32],Ni.prototype,"roughness",void 0),$g([P.object],Ni.prototype,"map",void 0),$g([P.object],Ni.prototype,"specularMap",void 0),$g([P.object],Ni.prototype,"bumpMap",void 0),$g([P.float32],Ni.prototype,"bumpScale",void 0);var Xw=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
10359a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};const Nwt={directional:1,point:2,spot:3};Kn=class{constructor(t){var e,r,i,s,o,n,a,l;t&&Object.assign(this,t),(e=this.type)!==null&&e!==void 0||(this.type="directional"),(r=this.color)!==null&&r!==void 0||(this.color=[1,1,1]),(i=this.intensity)!==null&&i!==void 0||(this.intensity=1),(s=this.position)!==null&&s!==void 0||(this.position=[0,0,0]),(o=this.direction)!==null&&o!==void 0||(this.direction=[-.5,-.7,-.5]),(n=this.range)!==null&&n!==void 0||(this.range=0),(a=this.innerConeAngle)!==null&&a!==void 0||(this.innerConeAngle=Math.PI/8),(l=this.outerConeAngle)!==null&&l!==void 0||(this.outerConeAngle=Math.PI/4)}},Xw([P.object],Kn.prototype,"type",void 0),Xw([P.object],Kn.prototype,"color",void 0),Xw([P.float32],Kn.prototype,"intensity",void 0),Xw([P.object],Kn.prototype,"position",void 0),Xw([P.object],Kn.prototype,"direction",void 0),Xw([P.float32],Kn.prototype,"range",void 0),Xw([P.float32],Kn.prototype,"innerConeAngle",void 0),Xw([P.float32],Kn.prototype,"outerConeAngle",void 0);var BQ=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};ki=class{constructor(t){var e,r,i;t&&Object.assign(this,t),(e=this.translation)!==null&&e!==void 0||(this.translation=[0,0,0]),(r=this.rotation)!==null&&r!==void 0||(this.rotation=[0,0,0]),(i=this.scale)!==null&&i!==void 0||(this.scale=[1,1,1])}},BQ([P.object],ki.prototype,"translation",void 0),BQ([P.object],ki.prototype,"rotation",void 0),BQ([P.object],ki.prototype,"scale",void 0);var kwt=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};Lo=class{constructor(t){var e;t&&Object.assign(this,t),(e=this.depth)!==null&&e!==void 0||(this.depth=100)}},kwt([P.float32],Lo.prototype,"depth",void 0),kwt([P.ref],Lo.prototype,"meshEntity",void 0);var Lwt=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};class Gd{constructor(e){var r;e!=null&&e.source&&(this.source=e.source),this.unifiedSpace=(r=e==null?void 0:e.unifiedSpace)!==null&&r!==void 0?r:!0}}Lwt([P.ref],Gd.prototype,"source",void 0),Lwt([P.boolean],Gd.prototype,"unifiedSpace",void 0);var Fc=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};je=class{constructor(t){var e,r,i,s,o,n,a,l,c,h,u,d,f,g,p;t&&Object.assign(this,t),(e=this.geometry)!==null&&e!==void 0||(this.geometry={type:"cube"}),(r=this.z)!==null&&r!==void 0||(this.z=0),(i=this.rotation3d)!==null&&i!==void 0||(this.rotation3d=[0,0,0]),(s=this.scale3d)!==null&&s!==void 0||(this.scale3d=100),(o=this.baseColor)!==null&&o!==void 0||(this.baseColor=[1,1,1,1]),(n=this.ambient)!==null&&n!==void 0||(this.ambient=.25),(a=this.diffuse)!==null&&a!==void 0||(this.diffuse=.75),(l=this.specular)!==null&&l!==void 0||(this.specular=.4),(c=this.shininess)!==null&&c!==void 0||(this.shininess=48),(h=this.metallic)!==null&&h!==void 0||(this.metallic=0),(u=this.roughness)!==null&&u!==void 0||(this.roughness=1),(d=this.map)!==null&&d!==void 0||(this.map=null),(f=this.specularMap)!==null&&f!==void 0||(this.specularMap=null),(g=this.bumpMap)!==null&&g!==void 0||(this.bumpMap=null),(p=this.bumpScale)!==null&&p!==void 0||(this.bumpScale=1)}},Fc([P.object],je.prototype,"geometry",void 0),Fc([P.float32],je.prototype,"z",void 0),Fc([P.object],je.prototype,"rotation3d",void 0),Fc([P.object],je.prototype,"scale3d",void 0),Fc([P.object],je.prototype,"baseColor",void 0),Fc([P.float32],je.prototype,"ambient",void 0),Fc([P.float32],je.prototype,"diffuse",void 0),Fc([P.float32],je.prototype,"specular",void 0),Fc([P.float32],je.prototype,"shininess",void 0),Fc([P.float32],je.prototype,"metallic",void 0),Fc([P.float32],je.prototype,"roughness",void 0),Fc([P.object],je.prototype,"map",void 0),Fc([P.object],je.prototype,"specularMap",void 0),Fc([P.object],je.prototype,"bumpMap",void 0),Fc([P.float32],je.prototype,"bumpScale",void 0),Fc([P.object],je.prototype,"camera3d",void 0),Fc([P.ref],je.prototype,"meshEntity",void 0);var qne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
10359a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};class fh{constructor(e){e!=null&&e.source&&(this.source=e.source)}}qne([P.ref],fh.prototype,"source",void 0);var Zne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};class js{constructor(e){e!=null&&e.canvas&&(this.canvas=e.canvas)}}Zne([P.ref],js.prototype,"canvas",void 0);var Jne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},va;(function(t){t.UNKNOWN="unknown",t.TRANSFORMER_MASK="transformer-mask",t.TRANSFORMER_ANCHOR="transformer-anchor",t.HIGHLIGHTER="highlighter",t.BRUSH="brush",t.LABEL="label",t.SNAP_POINT="snap-point",t.SNAP_LINE="snap-line"})(va||(va={})),Ii=class{constructor(t){this.type=t??va.UNKNOWN}},Jne([P({type:$.staticString([va.UNKNOWN,va.TRANSFORMER_MASK,va.TRANSFORMER_ANCHOR,va.HIGHLIGHTER,va.BRUSH,va.LABEL,va.SNAP_POINT,va.SNAP_LINE]),default:va.UNKNOWN})],Ii.prototype,"type",void 0);var Qne=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};ks=class{},Qne([P.ref],ks.prototype,"camera",void 0),Us=class{};let eo;eo=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},(function(t){t.IDLE="idle",t.MOVING="moving",t.MOVED="moved",t.RESIZING="resizing",t.RESIZED="resized",t.ROTATING="rotating",t.ROTATED="rotated"})(Nn||(Nn={})),Nt=class{constructor(t){Object.assign(this,t)}},eo([P.ref],Nt.prototype,"mask",void 0),eo([P.ref],Nt.prototype,"lineMask",void 0),eo([P.ref],Nt.prototype,"polylineMask",void 0),eo([P.ref],Nt.prototype,"cropMask",void 0),eo([P.ref],Nt.prototype,"tlAnchor",void 0),eo([P.ref],Nt.prototype,"trAnchor",void 0),eo([P.ref],Nt.prototype,"blAnchor",void 0),eo([P.ref],Nt.prototype,"brAnchor",void 0),eo([P.ref],Nt.prototype,"centerAnchor",void 0),eo([P.ref],Nt.prototype,"x1y1Anchor",void 0),eo([P.ref],Nt.prototype,"x2y2Anchor",void 0),eo([P.object],Nt.prototype,"controlPoints",void 0),eo([P.object],Nt.prototype,"segmentMidpoints",void 0),eo([P({type:$.int32,default:-1})],Nt.prototype,"hoveredSegmentIndex",void 0),eo([P({type:$.int32,default:-1})],Nt.prototype,"hoveredControlPointIndex",void 0),eo([P({type:$.int32,default:-1})],Nt.prototype,"selectedControlPointIndex",void 0),eo([P.object],Nt.prototype,"vnTangentHandles",void 0),eo([P.object],Nt.prototype,"vnTangentMeta",void 0),eo([P.object],Nt.prototype,"controlPointMeta",void 0),eo([P.object],Nt.prototype,"pathControlCommands",void 0),eo([P.object],Nt.prototype,"pathHandleLines",void 0),eo([P.backrefs(ks,"camera",!1)],Nt.prototype,"selecteds",void 0),eo([P({type:$.staticString([Nn.IDLE,Nn.MOVING,Nn.MOVED,Nn.RESIZING,Nn.RESIZED,Nn.ROTATING,Nn.ROTATED]),default:Nn.IDLE})],Nt.prototype,"status",void 0),eo([P({type:$.float32,default:-1})],Nt.prototype,"resizeWidth",void 0),eo([P({type:$.float32,default:-1})],Nt.prototype,"resizeHeight",void 0),eo([P({type:$.float32,default:NaN})],Nt.prototype,"rotatePivotX",void 0),eo([P({type:$.float32,default:NaN})],Nt.prototype,"rotatePivotY",void 0),eo([P({type:$.boolean,default:!1})],Nt.prototype,"rotatePivotPinned",void 0),eo([P({type:$.boolean,default:!1})],Nt.prototype,"transformerObbFrozenDuringRotate",void 0),eo([P(rX)],Nt.prototype,"gestureFrozenSelectionOBB",void 0);var tae=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;
10359a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},gt;(function(t){t.TOP_LEFT="top-left",t.TOP_RIGHT="top-right",t.BOTTOM_LEFT="bottom-left",t.BOTTOM_RIGHT="bottom-right",t.TOP_CENTER="top-center",t.MIDDLE_LEFT="middle-left",t.MIDDLE_RIGHT="middle-right",t.BOTTOM_CENTER="bottom-center",t.INSIDE="inside",t.OUTSIDE="outside",t.CONTROL="control",t.SEGMENT="segment",t.SEGMENT_MIDPOINT="segment-midpoint",t.TANGENT="tangent",t.X1Y1="x1y1",t.X2Y2="x2y2",t.CENTER="center"})(gt||(gt={}));class aV{constructor(e){Object.assign(this,e)}}tae([P.ref],aV.prototype,"camera",void 0);var MU=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};ko=class{static getGeometryBounds(t){const{x:e=0,y:r=0,width:i=0,height:s=0}=t;return new Qe(Math.min(e,e+i),Math.min(r,r+s),Math.max(e,e+i),Math.max(r,r+s))}constructor(t){t&&Object.assign(this,t)}},MU([P({type:$.object,default:""})],ko.prototype,"html",void 0),MU([P({type:$.float32,default:0})],ko.prototype,"x",void 0),MU([P({type:$.float32,default:0})],ko.prototype,"y",void 0),MU([P({type:$.float32,default:0})],ko.prototype,"width",void 0),MU([P({type:$.float32,default:0})],ko.prototype,"height",void 0);var eae=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};ka=class{constructor(t){t&&Object.assign(this,t)}},eae([P({type:$.object,default:null})],ka.prototype,"element",void 0);var BU=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};To=class{static getGeometryBounds(t){const{x:e=0,y:r=0,width:i=0,height:s=0}=t;return new Qe(Math.min(e,e+i),Math.min(r,r+s),Math.max(e,e+i),Math.max(r,r+s))}constructor(t){t&&Object.assign(this,t)}},BU([P({type:$.object,default:null})],To.prototype,"url",void 0),BU([P({type:$.float32,default:0})],To.prototype,"x",void 0),BU([P({type:$.float32,default:0})],To.prototype,"y",void 0),BU([P({type:$.float32,default:0})],To.prototype,"width",void 0),BU([P({type:$.float32,default:0})],To.prototype,"height",void 0);var rae=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o};_a=class{constructor(t){if(!t){this.controller=null;return}"controller"in t?this.controller=t.controller:this.controller=new XX(t.keyframes,t.options)}},rae([P({type:$.object,default:null})],_a.prototype,"controller",void 0);const Uwt=()=>{te(wt),te(_o),te(rd),te(ul),Ve(uO)(KZ),Ve(t=>t.inAnyOrderWith(t.allSystems))(KZ)},Gwt=()=>{te(ze),te(be),te(Ls),te(Gs),te(Wl),te(hl),te(cl),te(Ww),Ve(Dg)(ibt)},Wwt=()=>{te(_e),te(Ae),Ve(zf)(tT),Ve(t=>t.after(tT))(eT)};function iae(t={}){return()=>{var e,r;te(cs),te(AV),te(Bi),te(js),te(Lo),te(Gd),te(Ns),te(je),te(fh),te(Ni),te(Kn),te(ki),te(ar),te(Zi),te(ba),te(Mv),te(jy),te(Ln),te(he),te(Pn),te(Tn),te(Xc),te(Qn),te(Sn),te(yi),te(Mi),te(tu),te(mh),te(uE),te(yh),te(JU),te(Ce),te(Fs),te(Gt),te(bo),te(ro),te(ac),te(ue),te(Xy),te(wa),te(qo),te(La),te(zy),te(Gc),te(Hn),te(sm),te(Js),te(et),te(ae),te($t),te(Mt),te(_t),te(xt),te(Yt),te(ai),te(wo),te(iu),te(Ji),te(fe);const i=(e=t.setupDeviceSystemCtor)!==null&&e!==void 0?e:G3;Ve(D3)(i),Ve(o=>o.before(fU))(i),Ve(Dg)(c_t),Ve(Dg)(W0t),Ve(Dg)(_gt),Ve(Dg)(Dz),Ve(zf)(lE),Ve(zf)(mz),Ve(o=>o.after(eT,mz))(lE),Ve(o=>o.after(rp).before(An))(Az),Ve(An)(d_t);const s=(r=t.rendererSystemCtor)!==null&&r!==void 0?r:sG;Ve(An)(s),Ve(o=>o.before(IB,cU))(s),Ve(An)(IB)}}LV={configure(t){return iae(t)}},kV=LV.configure({});function sae(t={}){return()=>{var e;const r=(e=t.rendererSystemCtor)!==null&&e!==void 0?e:Gvt;Ve(Dg)(r),Ve(zf)(xz),Ve(i=>i.after(lE).before(rp))(xz),Ve(zf)(Sz),Ve(i=>i.after(xz).before(rp))(Sz),Ve(zf)(Rz),Ve(i=>i.after(Sz).before(rp))(Rz),Ve(zf)(Tz),Ve(i=>i.after(Rz).before(Cz,dO))(Tz),Ve(zf)(Cz),Ve(i=>i.after(Tz).before(rp))(Cz),Ve(i=>i.after(Az,fU).before(An))(vbt),Ve(Dg)(_bt)}}let OQ,IQ,DQ,PQ,FQ,NQ,kQ,LQ;OQ={configure(t){return sae(t)}}
10359,Mtt=OQ.configure({}),IQ=()=>{te(jt),te(Pe),te(so),te(dl),Ve(t=>t.after(fO,tT,eT,Dz,lE,rp))(dO),Ve(t=>t.afterWritersOf(jt))(rp)},DQ=()=>{te(wQ),te(le),te(xa),Ve(P3)(fO),Ve(An)(RJ),Ve(t=>t.before(IB))(RJ)},PQ=()=>{te(Ca),te(Ga),te(Vy),te(Vg),te(vh),Ve(An)(cU),Ve(t=>t.before(IB))(cU)},FQ=()=>{te(Ii),te(ks),te(Us),te(Nt),te(aV),te(ke),Ve(t=>t.after(lE,tT,eT,mz,rp,Dz,dO,Az).before(An))(fU),Ve(t=>t.after(fU).before(An))(KJ),Ve(t=>t.after(KJ).before(An))(zJ),Ve(t=>t.after(zJ).before(An))(XJ),Ve(t=>t.after(XJ).before(An))(YJ),Ve(t=>t.after(YJ).before(An))($J),Ve(t=>t.after($J).before(An))(oG),Ve(t=>t.after(oG).before(An))(IV),Ve(t=>t.afterWritersOf(ks).before(An))(aG),Ve(t=>t.afterWritersOf(Us).inAnyOrderWith(aG).before(An))(nG),Ve(t=>t.after(nG).before(An))(nbt)},NQ=()=>{te(jc),Ve(t=>t.afterWritersOf(fe).after(rp).before(An))(cG)},kQ=()=>{te(ko),te(To),te(ka),Ve(An)(HJ),Ve(t=>t.before(IB))(HJ)},LQ=()=>{te(_a),Ve(F3)(z0t)};class UQ{constructor(){this.pending=[],this.deferred=[],this.disposed=!1}add(e,r=!1){this.disposed||(r?this.deferred:this.pending).push(e)}flush(){const e=this.pending;this.pending=this.deferred,this.deferred=[];for(let r=0;r<e.length&&!this.disposed;r++)try{e[r]()}catch(i){throw this.disposed||this.pending.unshift(...e.slice(r+1)),i}}dispose(){this.disposed=!0,this.pending=[],this.deferred=[]}}class oae{constructor(e){this.enqueue=e,this.cancellations=new Set,this.disposed=!1}
10359add(e,r,i){return this.disposed||i!=null&&i.aborted?Promise.resolve(!1):new Promise((s,o)=>{let n=!1;const a=c=>{n||(n=!0,this.cancellations.delete(l),i==null||i.removeEventListener("abort",l),c())},l=()=>a(()=>s(!1));this.cancellations.add(l),i==null||i.addEventListener("abort",l,{once:!0});try{this.enqueue(()=>{if(!n)try{const c=e();if(c&&typeof c.then=="function")throw Promise.resolve(c).catch(()=>{}),new TypeError("Canvas edits must be synchronous. Await work before edit().");if(n)return;r(),a(()=>s(!0))}catch(c){a(()=>o(c))}})}catch(c){a(()=>o(c))}})}dispose(){this.disposed||(this.disposed=!0,[...this.cancellations].forEach(e=>e()))}}class jwt{constructor(){this.providers=new Map,this.selected=new Map,this.disposed=!1}register(e,r,i){if(this.disposed)throw new Error("Canvas capabilities have been disposed");let s=this.providers.get(e);if(s||this.providers.set(e,s=new Map),s.has(r))throw new Error(`${e}: provider ${r} is already registered`);return s.set(r,i),()=>{s.get(r)===i&&s.delete(r)}}select(e,r){if(this.disposed)throw new Error("Canvas capabilities have been disposed");this.selected.set(e,r)}list(e){var r,i;return[...(i=(r=this.providers.get(e))===null||r===void 0?void 0:r.keys())!==null&&i!==void 0?i:[]]}get(e){if(this.disposed)throw new Error("Canvas capabilities have been disposed");const r=this.providers.get(e),i=this.selected.get(e);if(i){if(!(r!=null&&r.has(i)))throw new Error(`${e}: provider ${i} is unavailable`);return r.get(i)}if(!(r!=null&&r.size))throw new Error(`${e}: no provider is registered`);if(r.size>1)throw new Error(`${e}: multiple providers (${this.list(e).join(", ")}); select one with api.capabilities.select()`);return r.values().next().value}dispose(){this.disposed=!0,this.providers.clear(),this.selected.clear()}}var nae=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};let OU,IU,Xwt;OU="infinite-canvas",IU=1,iO=".ic",Xwt=new Set(["g","rect","ellipse","line","polyline","path","text","brush","rough-rect","rough-ellipse","rough-line","rough-polyline","rough-path","vector-network","html","embed","iconfont","mesh3d","light3d","ref"]);function DU(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function zwt(t,e,r){const{variables:i,theme:s}=t,o=nae(t,["variables","theme"]);return{type:OU,version:IU,source:r??"https://infinitecanvas.cc",variables:Object.assign({},i),themes:{mode:s.mode,colors:{[Tr.LIGHT]:Object.assign({},s.colors[Tr.LIGHT]),[Tr.DARK]:Object.assign({},s.colors[Tr.DARK])}},elements:e.map(n=>Object.assign({},n)),appState:Object.assign({},o)}}function Vwt(t,e=2){return JSON.stringify(t,null,e)}function Ywt(t){const e=typeof t=="string"?JSON.parse(t):t;if(!DU(e))throw new Error("IC document must be a JSON object");if(e.type!==OU)throw new Error(`Invalid IC document type: expected "${OU}", got ${JSON.stringify(e.type)}`);if(e.version!==IU)throw new Error(`Unsupported IC schema version: ${String(e.version)} (supported: ${IU})`);if(!DU(e.variables))throw new Error('IC document "variables" must be an object');if(!DU(e.themes))throw new Error('IC document "themes" must be an object');if(!Array.isArray(e.elements))throw new Error('IC document "elements" must be an array');if(!DU(e.appState))throw new Error('IC document "appState" must be an object');for(const i of["layersSelected","layersHighlighted","layersExpanded","propertiesOpened","layersCropping","layersLassoing"]){const s=e.appState[i];if(s!==void 0&&(!Array.isArray(s)||s.some(o=>typeof o!="string")))throw new Error(`IC document appState.${i} must be an array of IDs`)}for(const i of["cameraX","cameraY","cameraZoom","cameraRotation"]){const s=e.appState[i];if(s!==void 0&&(typeof s!="number"||!Number.isFinite(s)||i==="cameraZoom"&&s<=0))throw new Error(`Invalid IC document appState.${i}`)}for(const i of[e.themes.mode,e.appState.themeMode])if(i!==void 0&&i!==Tr.LIGHT&&i!==Tr.DARK)throw new Error("IC document theme mode must be light or dark");const r=e.appState.checkboardStyle;if(r!==void 0&&!Object.values(wh).includes(r))throw new Error("Invalid IC document appState.checkboardStyle");for(const i of e.elements){if(!DU(i)||typeof i.id!="string"||!i.id)throw new Error("IC document elements must have non-empty string IDs");if(!Xwt.has(i.type))throw new Error(`Unsupported IC element type: ${String(i.type)}`);
10359if(i.parentId!=null&&typeof i.parentId!="string")throw new Error(`Invalid parent ID for IC element ${i.id}`)}return XZ(e.elements.filter(i=>!i.isDeleted)),e}function aae(t){const e=t.getCamera();if(!e.has(ze))return[];const r=[];for(const i of e.read(ze).children){const s=t.getNodeByEntity(i);s&&r.push(s.id)}return r}function WB(t,e){return(t??[]).filter(r=>e.has(r))}function $wt(t,e,r){var i,s,o;const n=(i=r==null?void 0:r.recordHistory)!==null&&i!==void 0?i:!0,a=yO(),l=Object.assign(Object.assign({},a),e.appState),c=bQ({mode:(s=l.themeMode)!==null&&s!==void 0?s:a.themeMode,colors:{[Tr.LIGHT]:a.theme.colors[Tr.LIGHT],[Tr.DARK]:a.theme.colors[Tr.DARK]}},e.themes),h=new Set(e.elements.filter(f=>!f.isDeleted).map(f=>f.id)),u=WB(l.layersSelected,h),d=Object.assign(Object.assign({},l),{variables:(o=e.variables)!==null&&o!==void 0?o:{},theme:{mode:c.mode,colors:c.colors},themeMode:c.mode,layersSelected:[],layersHighlighted:WB(l.layersHighlighted,h),layersExpanded:WB(l.layersExpanded,h),propertiesOpened:WB(l.propertiesOpened,h),layersCropping:WB(l.layersCropping,h),layersLassoing:WB(l.layersLassoing,h)});t.replaceDocument(e.elements),t.selectNodes([]),t.setAppState(d,{replaceVariables:!0,recordDesignVariableUndo:!1}),t.selectNodes(u.map(f=>t.getNodeById(f))),t.record(n?"IMMEDIATELY":"NEVER")}Vtt=function(t,e=`canvas${iO}`){var r;const i=Vwt(t),s=Pr.get().getWindow(),o=Pr.get().getDocument();if(!(!((r=s==null?void 0:s.URL)===null||r===void 0)&&r.createObjectURL)||!(o!=null&&o.createElement))return;const n=e.endsWith(iO)?e:`${e}${iO}`,a=new Blob([i],{type:"application/json"}),l=s.URL.createObjectURL(a),c=o.createElement("a");c.href=l,c.download=n,c.rel="noopener",o.body.appendChild(c),c.click(),o.body.removeChild(c),s.URL.revokeObjectURL(l)};let Zf,at,ol,Hwt,lV,cV,ec,bs,Fn,jB,$o,GS,WS,Ry,pv,jS,PU,FU,NU,gv,kU,XB,hV,zB,VB,LU,Cy,uV,XS,UU,dV,GQ,WQ,Kwt,qwt,Zwt,Jwt,Qwt,fV;Zf=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},at=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},ol=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},Hwt=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r},(function(t){t.SVG="svg",t.PNG="png",t.JPEG="jpeg",t.WEBM="webm",t.GIF="gif"})(am||(am={})),gtt=class{constructor(){lV.set(this,yO()),cV.set(this,[])}getAppState(){return at(this,lV,"f")}setAppState(t){ol(this,lV,t,"f")}getNodes(){return at(this,cV,"f")}setNodes(t){ol(this,cV,t,"f")}onChange(t){}},lV=new WeakMap,cV=new WeakMap;const lae=t=>Array.from(t.values()),jQ=t=>t instanceof Map?t:t.reduce((e,r)=>(e.set(typeof r=="string"?r:r.id,r),e),new Map);dtt=class{constructor(t,e){ec.add(this),this.stateManagement=t,this.commands=e,bs.set(this,void 0),Fn.set(this,void 0),jB.set(this,void 0),$o.set(this,new Map),GS.set(this,[]),WS.set(this,new Map),Ry.set(this,[]),pv.set(this,new m2(()=>this.notifyHistoryChange())),jS.set(this,{canUndo:!1,canRedo:!1}),PU.set(this,new Set),FU.set(this,new Set),NU.set(this,!1),gv.set(this,new Cne(this)),kU.set(this,new UQ),XB.set(this,new UQ),hV.set(this,new oae(r=>at(this,XB,"f").add(r))),zB.set(this,!1),VB.set(this,!1),LU.set(this,new UQ),Cy.set(this,!1),uV.set(this,new H0t),XS.set(this,0),UU.set(this,new Set),this.capabilities=new jwt,at(this,gv,"f").onStoreIncrementEmitter.on(Awt,r=>
10359{at(this,pv,"f").record(r.elementsChange,r.appStateChange),this.notifyChange(!r.elementsChange.isEmpty(),!r.appStateChange.isEmpty())})}notifyChange(t=!0,e=!0){var r,i,s,o,n;const a={appState:this.getAppState(),nodes:this.getNodes()};(i=(r=this.stateManagement).onChange)===null||i===void 0||i.call(r,a),t&&((s=this.onNodesChange)===null||s===void 0||s.call(this,a.nodes)),e&&((o=this.onAppStateChange)===null||o===void 0||o.call(this,a.appState)),(t||e)&&((n=this.onchange)===null||n===void 0||n.call(this,a)),(t||e)&&this.notifySubscribers(a,{nodesChanged:t,appStateChanged:e})}notifySubscribers(t,e){at(this,UU,"f").forEach(r=>r(t,e))}subscribe(t){if(at(this,Cy,"f"))return()=>{};const e=(r,i)=>t(r,i);return at(this,UU,"f").add(e),this.onDestroy(()=>at(this,UU,"f").delete(e))}getHistoryState(){return at(this,jS,"f")}subscribeHistory(t){if(at(this,Cy,"f"))return()=>{};const e=r=>t(r);return at(this,PU,"f").add(e),this.onDestroy(()=>at(this,PU,"f").delete(e))}notifyHistoryChange(){const t=!at(this,pv,"f").isUndoStackEmpty,e=!at(this,pv,"f").isRedoStackEmpty;t===at(this,jS,"f").canUndo&&e===at(this,jS,"f").canRedo||(ol(this,jS,{canUndo:t,canRedo:e},"f"),at(this,PU,"f").forEach(r=>r(at(this,jS,"f"))))}onDestroy(t){return at(this,uV,"f").add(t)}onBeforeHistoryChange(t){return at(this,FU,"f").add(t),this.onDestroy(()=>at(this,FU,"f").delete(t))}getCommands(){return this.commands}spawn3D(...t){return this.commands.spawn(...t,new js({canvas:at(this,bs,"f")}))}getAppState(){return this.stateManagement.getAppState()}getRegisteredIconifyIconFamilies(){return VV()}setAppState(t,e){var r,i,s,o,n;const a=Object.assign({},t);Object.prototype.hasOwnProperty.call(a,"themePreference")&&a.themePreference!==void 0&&!Object.prototype.hasOwnProperty.call(a,"themeMode")&&(a.themeMode=ZU(a.themePreference));const l=this.getAppState(),{cameraZoom:c,cameraX:h,cameraY:u,cameraRotation:d}=Object.assign(Object.assign({},l),a);Object.prototype.hasOwnProperty.call(a,"checkboardStyle")&&a.checkboardStyle!==l.checkboardStyle&&nt(at(this,bs,"f"),rd,{checkboardStyle:a.checkboardStyle});let f={};if(Object.prototype.hasOwnProperty.call(a,"theme")||Object.prototype.hasOwnProperty.call(a,"themeMode")||Object.prototype.hasOwnProperty.call(a,"themePreference")){const y=a.themeMode!==void 0?a.themeMode:l.themeMode,_=bQ(Object.assign(Object.assign({},l.theme),{mode:l.themeMode}),Object.assign(Object.assign({},(r=a.theme)!==null&&r!==void 0?r:{}),{mode:y}));f={themeMode:y,theme:{mode:_.mode,colors:_.colors}},!((i=at(this,bs,"f"))===null||i===void 0)&&i.has(ul)&&nt(at(this,bs,"f"),ul,{mode:_.mode,colors:_.colors})}let g={};Object.prototype.hasOwnProperty.call(a,"propertiesPanelSectionsOpen")&&(g={propertiesPanelSectionsOpen:Object.assign(Object.assign({},l.propertiesPanelSectionsOpen),a.propertiesPanelSectionsOpen)});let p={};const m=(s=l.variables)!==null&&s!==void 0?s:{};if(Object.prototype.hasOwnProperty.call(a,"variables")&&(p={variables:e!=null&&e.replaceVariables?a.variables:Object.assign(Object.assign({},m),a.variables)}),c!==l.cameraZoom||h!==l.cameraX||u!==l.cameraY||d!==l.cameraRotation)if(!((o=at(this,Fn,"f"))===null||o===void 0)&&o.has(Pe)){const{x:y,y:_,zoom:w,rotation:E}=at(this,Fn,"f").read(Pe);(y!==(h??0)||_!==(u??0)||w!==(c??1)||E!==(d??0))&&this.gotoLandmark({zoom:c??1,x:h??0,y:u??0,rotation:d??0},{duration:0})}else this.runAtNextTick(()=>{this.gotoLandmark({zoom:c??1,x:h??0,y:u??0,rotation:d??0},{duration:0})});const v=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},l),a),f),g),p),b=v.themeMode!==l.themeMode;if(this.stateManagement.setAppState(v),Object.prototype.hasOwnProperty.call(a,"variables")&&JSON.stringify(p.variables)!==JSON.stringify(m)||b&&Object.keys((n=v.variables)!==null&&n!==void 0?n:{}).length>0){const y=()=>{for(const _ of this.getNodes())if(at(this,$o,"f").has(_.id)){const w=Zdt(_);Object.keys(w).length>0&&this.updateNode(_,w,!1)}(e==null?void 0:e.recordDesignVariableUndo)!==!1&&this.record()};at(this,VB,"f")||at(this,zB,"f")?y():this.runAtNextTick(y)}}getNodes(){return this.stateManagement.getNodes()}getMesh3DLayers(){return at(this,GS,"f")}getSelectedMesh3DLayerIds(){return at(this,Ry,"f")}setMesh3DLayers(t){const e=t.map(o=>{var{entity:n}=o,a=Hwt(o,["entity"]);return a}
10359),r=JSON.stringify(e)!==JSON.stringify(at(this,GS,"f"));ol(this,GS,e,"f"),ol(this,WS,new Map(t.map(o=>[o.id,o.entity])),"f");const i=new Set(e.map(o=>o.id)),s=at(this,Ry,"f").filter(o=>i.has(o));return s.length!==at(this,Ry,"f").length&&this.setSelectedMesh3DLayerIds(s),r}setSelectedMesh3DLayerIds(t){const e=t.filter((i,s,o)=>o.indexOf(i)===s),r=e.length!==at(this,Ry,"f").length||e.some((i,s)=>i!==at(this,Ry,"f")[s]);return ol(this,Ry,e,"f"),r}getMesh3DLayerIdByEntity(t){for(const[e,r]of at(this,WS,"f").entries())if(r===t)return e}clear2DSelectionComponents(t=this.getAppState().layersSelected){t.forEach(e=>{var r;const i=(r=at(this,$o,"f").get(e))===null||r===void 0?void 0:r.id();i&&i.has(ks)&&i.remove(ks),i&&Zr(i,Us)})}clearSelectedMesh3DLayers(){return at(this,Ry,"f").forEach(t=>{const e=at(this,WS,"f").get(t);e!=null&&e.has(ar)&&e.remove(ar)}),this.setSelectedMesh3DLayerIds([])}syncMesh3DLayerAppState(t){const e=this.getMesh3DLayerIdByEntity(t),r=at(this,GS,"f").find(s=>s.id===e);if(!e||!r)return!1;this.setSelectedMesh3DLayerIds([e]);const i=this.getAppState();return this.setAppState(Object.assign(Object.assign({},i),{layersSelected:r.sourceNodeId?[r.sourceNodeId]:[],layersHighlighted:[]})),!0}clearMesh3DLayerAppState(){this.setSelectedMesh3DLayerIds([]);const t=this.getAppState();this.setAppState(Object.assign(Object.assign({},t),{layersSelected:t.layersSelected.filter(e=>{const r=this.getNodeById(e);return(r==null?void 0:r.type)!=="mesh3d"}),layersHighlighted:t.layersHighlighted.filter(e=>{const r=this.getNodeById(e);return(r==null?void 0:r.type)!=="mesh3d"})}))}selectMesh3DLayer(t){const e=at(this,WS,"f").get(t),r=at(this,GS,"f").find(o=>o.id===t);if(!e||!r)return!1;const i=this.getAppState();this.clear2DSelectionComponents(i.layersSelected),at(this,Ry,"f").forEach(o=>{const n=at(this,WS,"f").get(o);n&&n!==e&&n.has(ar)&&n.remove(ar)}),e.has(ar)||e.add(ar,{mode:"transform",activeAxis:"none",activePartKind:null,dragging:!1});const s=this.setSelectedMesh3DLayerIds([t]);return this.setAppState(Object.assign(Object.assign({},i),{layersSelected:r.sourceNodeId?[r.sourceNodeId]:[],layersHighlighted:[]})),s}selectMesh3DLayerByEntity(t){const e=this.getMesh3DLayerIdByEntity(t);return e?this.selectMesh3DLayer(e):!1}setNodes(t){this.stateManagement.setNodes(t.slice())}getEntityCommands(){return at(this,$o,"f")}getEntity(t){var e;return(e=at(this,$o,"f").get(t.id))===null||e===void 0?void 0:e.id()}getNodeById(t){return this.getNodes().find(e=>e.id===t)}getNodeByEntity(t){for(const[e,r]of at(this,$o,"f").entries())if(r.id()===t)return this.getNodeById(e)}getParentTransform(t){return t.has(be)&&!t.read(be).parent.has(jt)?ie.toGLMat3(t.read(be).parent.read(Ae).matrix):Bt()}getTransform(t){var e,r;return Bgt(t)?ie.toGLMat3(ie.fromTransform(t.read(_e))):ie.toGLMat3(ie.from_scale_angle_translation({x:t.scaleX,y:t.scaleY},t.rotation,{x:(e=t.x)!==null&&e!==void 0?e:0,y:(r=t.y)!==null&&r!==void 0?r:0}))}getAbsoluteTransformAndSize(t){var e,r,i,s,o,n,a;const l=this.getEntity(t);if(l.has(fe)){const{translation:c,rotation:h,scale:u}=l.read(_e),{width:d,height:f}=l.read(fe).transformOBB;return{id:t.id,x:c.x,y:c.y,width:d,height:f,rotation:h,scaleX:u[0],scaleY:u[1]}}else return{id:t.id,x:(e=t.x)!==null&&e!==void 0?e:0,y:(r=t.y)!==null&&r!==void 0?r:0,width:(i=t.width)!==null&&i!==void 0?i:0,height:(s=t.height)!==null&&s!==void 0?s:0,rotation:(o=t.rotation)!==null&&o!==void 0?o:0,scaleX:(n=t.scaleX)!==null&&n!==void 0?n:1,scaleY:(a=t.scaleY)!==null&&a!==void 0?a:1}}readLayoutFromECS(t){return t.map(e=>{const r=this.getAbsoluteTransformAndSize(e),i=Object.assign(Object.assign({},e),{x:r.x,y:r.y,width:r.width,height:r.height,rotation:r.rotation,scaleX:r.scaleX,scaleY:r.scaleY}),s=this.getEntity(e);return s&&s.has($t)&&(e.type==="rect"||e.type==="rough-rect")&&(i.cornerRadius=s.read($t).cornerRadius),i})}getCanvas(){return at(this,bs,"f")}getCamera(){return at(this,Fn,"f")}getCanvasElement(){return at(this,bs,"f").read(wt).element}getHtmlLayer(){return at(this,bs,"f").read(wt).htmlLayer}getSvgLayer(){return at(this,bs,"f").read(wt).svgLayer}createCanvas(t){return ol(this,bs,this.commands.spawn(new wt(Object.assign(Object.assign({},t),{api:this}))).id().hold(),"f"),this.commands.execute(),at(this,bs,"f")}createCamera(t){const{zoom:e,x:r,y:i}=t;return ol(this,Fn,this.commands.spawn(new jt({canvas:at(this,bs,"f")}),new _e({scale:{x:1/e,y:1/e},translation:{x:r,y:i}})).id().hold(),"f"),this.commands.execute(),at(this,Fn,"f")}client2Viewport({x:t,y:e}){const{scaleX:r,scaleY:i,bbox:s}=Udt(this.getCanvasElement());return{x:(t-((s==null?void 0:s.left)||0))/r,y:(e-((s==null?void 0:s.top)||0))/i}}viewport2Client({x:t,y:e}){const{scaleX:r,scaleY:i,bbox:s}=Udt(this.getCanvasElement());return{x:t*r+((s==null?void 0:s.left)||0),y:e*i+((s==null?void 0:s.top)||0)}}viewport2Canvas({x:t,y:e},r){const i=at(this,Fn,"f"),{width:s,height:o}=i.read(jt).canvas.read(wt);
10359r||(r=ie.toGLMat3(i.read(Pe).viewProjectionMatrixInv));const n=Qt(it(),[t/s*2-1,(1-e/o)*2-1],r);return{x:n[0],y:n[1]}}canvas2Viewport({x:t,y:e},r){const{width:i,height:s}=at(this,Fn,"f").read(jt).canvas.read(wt);r||(r=ie.toGLMat3(at(this,Fn,"f").read(Pe).viewProjectionMatrix));const o=Qt(it(),[t,e],r);return{x:(o[0]+1)/2*i,y:(1-(o[1]+1)/2)*s}}transformer2Canvas(t,e){const r=ie.toGLMat3(e.read(Ae).matrix),[i,s]=Qt(it(),[t.x,t.y],r);return{x:i,y:s}}canvas2Transformer(t,e){const r=ie.toGLMat3(e.read(Ae).matrix),i=_i(Bt(),r),[s,o]=Qt(it(),[t.x,t.y],i);return{x:s,y:o}}elementsFromBBox(t,e,r,i,s=!0){return at(this,Fn,"f").has(dl)?at(this,Fn,"f").read(dl).value.search({minX:t,minY:e,maxX:r,maxY:i}).map(o=>o.entity).filter(o=>o.__valid&&(!s||!o.has(tu))).sort(vO).reverse():[]}elementsFromPoint(t,e=!0){const r=this.elementsFromBBox(t.x,t.y,t.x,t.y,e),i=[];return r.forEach(s=>{var o;if(!s.has(Ae)){console.warn("entity has no GlobalTransform",s.__id);return}const n=ie.toGLMat3(s.read(Ae).matrix),a=_i(Bt(),n),[l,c]=Qt(it(),[t.x,t.y],a);let h=!1;const u=s.has(Ce)&&Nh(s).length>0,d=u?"black":void 0,f=yft(s),g=vft(s),p=f&&g,m=f?s.read(Gt):void 0,v=p?m.width/2:0,b=p?ywt(s,m):0,y=o3(m);if(s.has(et)){const{cx:_,cy:w,r:E}=s.read(et),A=Sa(l,c,_,w);u&&p?h=A<=E+y:u?h=A<=E:p&&(h=A>=E+y-v&&A<=E+y+v)}else if(s.has(ae)){const{cx:_,cy:w,rx:E,ry:A}=s.read(ae);u&&p?h=rj(l,c,_,w,E+y,A+y):u?h=rj(l,c,_,w,E,A):p&&(h=!rj(l,c,_,w,E+y-v*2,A+y-v*2)&&rj(l,c,_,w,E+y,A+y))}else if(s.has(Mt)){if(Mt.hitTestProvider&&p){const{x1:_,y1:w,x2:E,y2:A}=s.read(Mt),x=PB(s,m);h=Mt.hitTestProvider({x1:_,y1:w,x2:E,y2:A,x:l,y:c,stroke:x})}else if(p){const{x1:_,y1:w,x2:E,y2:A}=s.read(Mt);h=Fdt(_,w,E,A,b,l,c)}}else if(s.has(_t)){if(_t.hitTestProvider&&p){const{points:_}=s.read(_t),w=PB(s,m);h=_t.hitTestProvider({points:_,x:l,y:c,stroke:w})}else if(p){const{shiftedPoints:_}=s.read(wo);h=Vjt(_,b,l,c)}}else if(s.has(xt)){const{d:_,fillRule:w}=s.read(xt);if(xt.hitTestProvider){const E=p?PB(s,m):void 0;h=xt.hitTestProvider({d:_,x:l,y:c,fill:u,fillRule:w??"nonzero",stroke:E})}else{const E=Pr.get().createCanvas(100,100).getContext("2d"),A=new Path2D(_);p&&(E.strokeStyle=(o=H0(s))!==null&&o!==void 0?o:"transparent",E.lineWidth=b,E.lineCap=m.linecap,E.lineJoin=m.linejoin,E.miterLimit=m.miterlimit,E.stroke(A)),u&&(E.fillStyle=d,E.fill(A,w)),p&&!u?h=E.isPointInStroke(A,l,c):u&&(h=E.isPointInPath(A,l,c))}}else h=!0;h&&i.push(s)}),i}getViewportBounds(){const{width:t,height:e}=at(this,bs,"f").read(wt),r=this.viewport2Canvas({x:0,y:0}),i=this.viewport2Canvas({x:t,y:0}),s=this.viewport2Canvas({x:t,y:e}),o=this.viewport2Canvas({x:0,y:e});return{minX:Math.min(r.x,i.x,s.x,o.x),minY:Math.min(r.y,i.y,s.y,o.y),maxX:Math.max(r.x,i.x,s.x,o.x),maxY:Math.max(r.y,i.y,s.y,o.y)}}createLandmark(t={}){const{zoom:e,x:r,y:i,rotation:s}=at(this,Fn,"f").read(Pe);return Object.assign({zoom:e,x:r,y:i,rotation:s},t)}gotoLandmark(t,e={}){const{easing:r="linear",duration:i=100,onframe:s=void 0,onfinish:o=void 0}=e,n=at(this,Fn,"f"),{x:a,y:l,zoom:c,rotation:h,viewportX:u=0,viewportY:d=0}=Object.assign(Object.assign({},n.read(Pe)),t),f=u||d,g=()=>{this.applyLandmark({x:a,y:l,zoom:c,rotation:h,viewportX:u,viewportY:d}),o&&o()};if(this.cancelLandmarkAnimation(),i===0){g();return}let p;const m=[a,l],v=[c,h],b=1e-4,y=_=>{if(at(this,Cy,"f"))return;p===void 0&&(p=_);const w=_-p;if(w>i){g();return}const{x:E,y:A,zoom:x,rotation:S}=at(this,Fn,"f").read(Pe),T=LZ[r](w/i),R=it(),B=Be(1,0);if(ta(R,[E,A],m,T),ta(B,[x,S],v,T),this.applyLandmark({x:R[0],y:R[1],zoom:B[0],rotation:B[1],viewportX:u,viewportY:d}),f?za(B,v)<=b:za(R,m)<=b){g();return}w<i&&(s&&s(T),at(this,Cy,"f")||ol(this,jB,Pr.get().requestAnimationFrame(y),"f"))};ol(this,jB,Pr.get().requestAnimationFrame(y),"f")}applyLandmark(t){const e=at(this,Fn,"f").write(_e),{x:r,y:i,zoom:s,rotation:o,viewportX:n,viewportY:a}=t,l=n||a;let c=0,h=0;if(l){const u=this.viewport2Canvas({x:n,y:a});c=u.x,h=u.y}if(Object.assign(e,{translation:{x:r,y:i},rotation:o,scale:{x:1/s,y:1/s}}),l){const{projectionMatrix:u}=at(this,Fn,"f").read(Pe),d=Bt(),f=Bt(),g=Bt(),p=CJ(r,i,o,s);_i(d,p),us(f,ie.toGLMat3(u),d),_i(g,f);const{x:m,y:v}=this.viewport2Canvas({x:n,y:a},g);e.translation.x+=c-m,e.translation.y+=h-v}}cancelLandmarkAnimation(){at(this,jB,"f")!==void 0&&Pr.get().cancelAnimationFrame(at(this,jB,"f"))}animate(t,e,r){let i;if(typeof t=="string"){const o=this.getNodeById(t);i=o?this.getEntity(o):void 0}else Bgt(t)?i=t:i=this.getEntity(t);if(!i)return;const s=new XX(e,r);return i.has(_a)?i.write(_a).controller=s:i.add(_a,new _a({controller:s})),this.commands.execute(),s}getNodeAnimationController(t){var e;const r=this.getNodeById(t);if(!r)return null;const i=this.getEntity(r);return!i||!i.has(_a)?null:(e=i.read(_a).controller)!==null&&e!==void 0?e:null}getNodeAnimation(t){const e=this.getNodeAnimationController(t);if(!e)return null;const{keyframes:r,options:i}=e.serialize();return{keyframes:r,options:i}}setNodeAnimation(t,e){const r=this.getNodeById(t);r&&this.updateNode(r,{animation:e??void 0})}removeNodeAnimation(t){this.setNodeAnimation(t,null)}updateNodeAnimationOptions(t,e){const r=this.getNodeAnimation(t);r&&this.setNodeAnimation(t,{keyframes:r.keyframes,options:Object.assign(Object.assign({},r.options),e)})}setNodeAnimationKeyframes(t,e){const r=this.getNodeAnimation(t);r&&this.setNodeAnimation(t,{keyframes:e,options:r.options})}addNodeAnimationKeyframe(t,e){const r=this.getNodeAnimation(t);r&&this.setNodeAnimationKeyframes(t,[...r.keyframes,Object.assign({},e)])}updateNodeAnimationKeyframe(t,e,r){const i=this.getNodeAnimation(t);
10359if(!i||e<0||e>=i.keyframes.length)return;const s=i.keyframes.map((o,n)=>n===e?Object.assign(Object.assign({},o),r):Object.assign({},o));this.setNodeAnimationKeyframes(t,s)}removeNodeAnimationKeyframe(t,e){const r=this.getNodeAnimation(t);if(!r||r.keyframes.length<=1)return;const i=r.keyframes.filter((s,o)=>o!==e);this.setNodeAnimationKeyframes(t,i)}getAnimatedTracks(){const t=[];for(const e of this.getNodes()){const r=this.getNodeAnimationController(e.id);if(!r)continue;const i=r.getOptions();t.push({id:e.id,name:e.name||e.id,properties:r.getAnimatedProperties(),delay:i.delay,duration:r.getDuration()-i.delay,totalDuration:r.getDuration()})}return t}getSceneAnimationDuration(){let t=0;for(const e of this.getNodes()){const r=this.getNodeAnimationController(e.id);r&&(t=Math.max(t,r.getDuration()))}return t}setAnimationEditing(t){this.setAppState({animationEditing:t})}setAnimationCurrentTime(t){this.setAppState({animationCurrentTime:Math.max(0,t),animationPlaying:!1})}playAnimation(){this.setAppState({animationEditing:!0,animationPlaying:!0})}pauseAnimation(){this.setAppState({animationPlaying:!1})}toggleAnimationPlaying(){this.getAppState().animationPlaying?this.pauseAnimation():this.playAnimation()}setAnimationLoop(t){this.setAppState({animationLoop:t})}getSceneGraphBounds(){const t=at(this,Fn,"f").read(dl).value,e=new Qe;return t.all().forEach(r=>{const{minX:i,minY:s,maxX:o,maxY:n,entity:a}=r;a.has(Ii)||a.has(Tn)||e.addFrame(i,s,o,n)}),e}zoomTo(t,e){const{width:r,height:i}=this.getCanvas().read(wt);this.gotoLandmark(this.createLandmark({viewportX:r/2,viewportY:i/2,zoom:t}),e??{duration:300,easing:"ease"})}zoomToFit(t,e){const{minX:r,minY:i,maxX:s,maxY:o}=this.getSceneGraphBounds();if(r>s||i>o)return;const{width:n,height:a}=at(this,bs,"f").read(wt),{rotation:l}=at(this,Fn,"f").read(Pe),c=Math.cos(l),h=Math.sin(l),u=s-r,d=o-i,f=n/(Math.abs(c)*u+Math.abs(h)*d),g=a/(Math.abs(h)*u+Math.abs(c)*d),p=t(f,g);if(!Number.isFinite(p)||p<=0)return;const m=(r+s)/2,v=(i+o)/2,b=n/2/p,y=a/2/p;this.gotoLandmark(this.createLandmark({x:m-c*b+h*y,y:v-h*b-c*y,zoom:p}),e??{duration:300,easing:"ease"})}fitToScreen(t){this.zoomToFit(Math.min,t)}fillScreen(t){this.zoomToFit(Math.max,t)}resizeCanvas(t,e){Object.assign(at(this,bs,"f").write(wt),{width:t,height:e})}setCursor(t){at(this,bs,"f").has(_o)||at(this,bs,"f").add(_o),Object.assign(at(this,bs,"f").write(_o),{value:t})}selectNodes(t,e=!1,r=!0){const i=this.getAppState(),s=i.layersSelected;
10359e||(this.clearSelectedMesh3DLayers(),s.forEach(n=>{var a;const l=(a=at(this,$o,"f").get(n))===null||a===void 0?void 0:a.id();l&&at(this,ec,"m",WQ).call(this,l)}),this.clear2DSelectionComponents(s));const o=e?[...i.layersSelected,...t.map(n=>n.id)].filter((n,a,l)=>l.indexOf(n)===a):t.map(n=>n.id).filter((n,a,l)=>l.indexOf(n)===a);if(r){const n=e?i.layersHighlighted:i.layersHighlighted.filter(a=>!s.includes(a)||o.includes(a));this.setAppState(Object.assign(Object.assign({},i),{layersSelected:o,layersHighlighted:n}))}o.forEach(n=>{var a;const l=(a=at(this,$o,"f").get(n))===null||a===void 0?void 0:a.id();l&&!l.has(ks)&&l.add(ks,{camera:at(this,Fn,"f")}),l&&at(this,ec,"m",qwt).call(this,l)})}deselectNodes(t){const e=t.map(i=>i.id);t.forEach(i=>{var s;const o=(s=at(this,$o,"f").get(i.id))===null||s===void 0?void 0:s.id();o&&o.has(ks)&&o.remove(ks),o&&(Zr(o,Us),at(this,ec,"m",WQ).call(this,o))});const r=this.getAppState();this.setAppState(Object.assign(Object.assign({},r),{layersSelected:r.layersSelected.filter(i=>!e.includes(i)),layersHighlighted:r.layersHighlighted.filter(i=>!e.includes(i))})),at(this,ec,"m",Jwt).call(this)}highlightNodes(t,e=!1,r=!0){const i=n=>{const a=this.getNodeById(n);return(a==null?void 0:a.type)==="mesh3d"||(a==null?void 0:a.type)==="light3d"};t=t.filter(n=>n.type!=="mesh3d"&&n.type!=="light3d"),e||this.getAppState().layersHighlighted.forEach(n=>{var a;const l=(a=at(this,$o,"f").get(n))===null||a===void 0?void 0:a.id();Zr(l,Us)});const s=this.getAppState(),o=e?[...s.layersHighlighted,...t.map(n=>n.id)].filter((n,a,l)=>l.indexOf(n)===a):t.map(n=>n.id).filter((n,a,l)=>l.indexOf(n)===a);r&&this.setAppState(Object.assign(Object.assign({},s),{layersHighlighted:o})),o.forEach(n=>{var a;const l=(a=at(this,$o,"f").get(n))===null||a===void 0?void 0:a.id();if(!l||i(n)){Zr(l,Us);return}nt(l,Us)})}unhighlightNodes(t){t.forEach(i=>{var s;const o=(s=at(this,$o,"f").get(i.id))===null||s===void 0?void 0:s.id();Zr(o,Us)});const e=new Set(t.map(i=>i.id)),r=this.getAppState();this.setAppState(Object.assign(Object.assign({},r),{layersHighlighted:r.layersHighlighted.filter(i=>!e.has(i))}))}applyCrop(){const[t]=this.getAppState().layersCropping,e=this.getNodeById(t);e&&e.clipMode==="soft"&&this.updateNode(e,{clipMode:"clip",locked:!1}),this.getChildren(e).forEach(r=>{this.updateNode(this.getNodeByEntity(r),{locked:!0})}),this.setAppState({layersCropping:[]}),this.selectNodes([e]),this.record()}cancelCrop(){const[t]=this.getAppState().layersCropping,e=this.getNodeById(t);e&&e.clipMode==="soft"&&this.updateNode(e,{clipMode:"clip",locked:!1}),this.getChildren(e).forEach(r=>{this.updateNode(this.getNodeByEntity(r),{locked:!0})}),this.setAppState({layersCropping:[]}),this.selectNodes([e]),this.record()}cancelLasso(){const[t]=this.getAppState().layersLassoing,e=this.getNodeById(t),r=this.getChildren(e);this.deleteNodesById(r.map(i=>this.getNodeByEntity(i).id)),this.setAppState({layersLassoing:[],penbarLasso:Object.assign(Object.assign({},this.getAppState().penbarLasso),{mode:void 0})}),this.selectNodes([e]),this.record()}updateNode(t,e,r=!0,i=[]){var s;const o=(s=at(this,$o,"f").get(t.id))===null||s===void 0?void 0:s.id(),n=this.getNodes();if(o){const a=Toe(o,t,e??t,i,this);if(this.commands.execute(),r){const l=n.findIndex(c=>c.id===a.id);l!==-1&&(n[l]=a,this.setNodes(n))}}else{const a=this.commands.entity(at(this,Fn,"f")),{entities:l,idEntityMap:c}=iQ([t],at(this,bs,"f").read(wt).fonts,this.commands,at(this,$o,"f"),{lookupNodes:at(this,ec,"m",dV).call(this,[t]),variables:this.getAppState().variables,themeMode:this.getAppState().themeMode,canvas:at(this,bs,"f")});at(this,$o,"f").set(t.id,c.get(t.id)),this.commands.execute(),l.forEach(h=>{h.has(be)||a.appendChild(this.commands.entity(h)),Sr(h)}),this.commands.execute(),r&&this.setNodes([...n,...at(this,ec,"m",GQ).call(this,[t])])}}updateNodes(t,e=!0){if(!t.length)return;const r=e?this.getNodes().slice():[],i=new Map(r.map((n,a)=>[n.id,a])),s=t.filter(n=>at(this,$o,"f").has(n.id)),o=t.filter(n=>!at(this,$o,"f").has(n.id));if(o.length>0){const n=this.commands.entity(at(this,Fn,"f")),{entities:a,idEntityMap:l}=iQ(o,at(this,bs,"f").read(wt).fonts,this.commands,at(this,$o,"f"),{lookupNodes:at(this,ec,"m",dV).call(this,o),variables:this.getAppState().variables,themeMode:this.getAppState().themeMode,canvas:at(this,bs,"f")});o.forEach(c=>{at(this,$o,"f").set(c.id,l.get(c.id))}),this.commands.execute(),a.forEach(c=>{c.has(be)||n.appendChild(this.commands.entity(c)),Sr(c)}),this.commands.execute(),e&&r.push(...at(this,ec,"m",GQ).call(this,o))}s.length>
103590&&s.forEach(n=>{this.updateNode(n,void 0,!1);const a=i.get(n.id);e&&a!==void 0&&(r[a]=Object.assign({},n))}),e&&this.setNodes(r)}replaceDocument(t,e="remote"){const r=structuredClone(t.filter(u=>!u.isDeleted));XZ(r);const i=FL(r,r);XZ(i),i.forEach(u=>{var d,f,g,p,m,v;if(u.type==="mesh3d"){(d=u.x)!==null&&d!==void 0||(u.x=0),(f=u.y)!==null&&f!==void 0||(u.y=0);const b=typeof u.scale3d=="number"?u.scale3d:(p=(g=u.scale3d)===null||g===void 0?void 0:g[0])!==null&&p!==void 0?p:100;(m=u.width)!==null&&m!==void 0||(u.width=b),(v=u.height)!==null&&v!==void 0||(u.height=b)}[u.x,u.y,u.width,u.height].some(me)&&ou(u)});const s=this.getNodes(),o=new Map(s.map(u=>[u.id,u])),n=new Set(i.map(u=>u.id)),a=i.filter(u=>!_w(o.get(u.id),u)),l=a.some(u=>{const d=o.get(u.id);return d&&(d.type!==u.type||d.parentId!==u.parentId||Object.keys(d).some(f=>d[f]!==void 0&&u[f]===void 0))}),c=this.getAppState().layersSelected.filter(u=>n.has(u)),h=s.filter(u=>l||!n.has(u.id));h.length&&this.deleteNodesById(h.map(u=>u.id),!1),this.updateNodes(structuredClone(l?i:a),!1),this.setNodes(i),l&&c.length&&this.selectNodes(c.map(u=>this.getNodeById(u))),this.record(e==="remote"?Sy.NEVER:Sy.IMMEDIATELY)}updateNodeVectorNetwork(t,e){var r,i,s,o,n,a,l;const c=(r=e.vertices)!==null&&r!==void 0?r:[],h=(i=e.segments)!==null&&i!==void 0?i:[],{regions:u}=e,{minX:d,minY:f,maxX:g,maxY:p}=ke.getGeometryBounds({vertices:c,segments:h}),m=c.map(_=>Object.assign(Object.assign({},_),{x:_.x-d,y:_.y-f})),v=(s=t.rotation)!==null&&s!==void 0?s:0,b=d*((o=t.scaleX)!==null&&o!==void 0?o:1),y=f*((n=t.scaleY)!==null&&n!==void 0?n:1);this.updateNode(t,Object.assign({x:((a=t.x)!==null&&a!==void 0?a:0)+Math.cos(v)*b-Math.sin(v)*y,y:((l=t.y)!==null&&l!==void 0?l:0)+Math.sin(v)*b+Math.cos(v)*y,width:g-d,height:p-f,vertices:m,segments:h},u!==void 0?{regions:u}:{}))}updateNodeOBB(t,e,r=!1,i,s){var o,n,a,l,c,h,u,d,f,g,p,m;const{x:v,y:b,width:y,height:_,rotation:w,scaleX:E,scaleY:A}=e,x={};if(me(v)||(x.x=v),me(b)||(x.y=b),me(w)||(x.rotation=w),me(E)||(x.scaleX=E),me(A)||(x.scaleY=A),!me(y)){if(r){const S=((o=t.width)!==null&&o!==void 0?o:0)/((n=t.height)!==null&&n!==void 0?n:1);x.height=y/S}x.width=y}if(!me(_)){if(r){const S=((a=t.width)!==null&&a!==void 0?a:0)/((l=t.height)!==null&&l!==void 0?l:1);x.width=_*S}x.height=_}if(t.display==="flex"&&(me(y)||(x.flexHugWidth=!1),me(_)||(x.flexHugHeight=!1)),i){let S=Yoe(i);const T=(h=(c=s==null?void 0:s.rotation)!==null&&c!==void 0?c:t.rotation)!==null&&h!==void 0?h:0;if(T){const R=TV(Bt(),-T);S=us(Bt(),R,S)}if(t.type==="polyline"||t.type==="rough-polyline"){const{strokeAlignment:R="center",strokeWidth:B=1}=t,O=MJ(nc(s==null?void 0:s.points).map(U=>{const[H,N]=U,[G,Y]=Qt(it(),[H,N],S);return[G,Y]}),R,B),{minX:C,minY:F}=_t.getGeometryBounds({points:O});x.points=ip(O.map(U=>[U[0]-C,U[1]-F]))}else if(t.type==="path"||t.type==="rough-path"){const R=EU(s.d,S),{subPaths:B}=a3(R),O=B.map(U=>U.getPoints().map(H=>[H[0],H[1]])),{minX:C,minY:F}=xt.getGeometryBounds({d:R},{points:O});x.d=xy(R,-C,-F)}else if(t.type==="line"||t.type==="rough-line"){const{x1:R,y1:B,x2:O,y2:C}=s,[F,U]=Qt(it(),[R,B],S),[H,N]=Qt(it(),[O,C],S),{minX:G,minY:Y}=Mt.getGeometryBounds({x1:F,y1:U,x2:H,y2:N});x.x1=F-G,x.y1=U-Y,x.x2=H-G,x.y2=N-Y}else if(t.type==="vector-network"){const R=s,B=Ose({vertices:((u=R.vertices)!==null&&u!==void 0?u:[]).map(O=>Object.assign({},O)),segments:((d=R.segments)!==null&&d!==void 0?d:[]).map(O=>Object.assign(Object.assign({},O),{tangentStart:O.tangentStart?Object.assign({},O.tangentStart):void 0,tangentEnd:O.tangentEnd?Object.assign({},O.tangentEnd):void 0})),regions:(f=R.regions)===null||f===void 0?void 0:f.map(O=>({fillRule:O.fillRule,loops:O.loops.map(C=>[...C])}))},S);x.vertices=B.vertices,x.segments=B.segments,B.regions!==void 0&&(x.regions=B.regions)}else if(t.type==="brush"){const R=v3(s==null?void 0:s.points).map(C=>{const{x:F,y:U,radius:H}=C,[N,G]=Qt(it(),[F,U],i);return{x:N,y:G,radius:H}}),{minX:B,minY:O}=ai.getGeometryBounds({points:R});x.points=oq(R.map(C=>({x:C.x-B,y:C.y-O,radius:C.radius})))}else if(t.type==="text"){const R=s??t,B=om(R),{minX:O,minY:C,maxX:F,maxY:U}=Yt.getGeometryBounds(R,B),H=[[O,C],[F,C],[F,U],[O,U]];let N=1/0,G=1/0;for(const[It,zt]of H){const[Ht,Lt]=Qt(it(),[It,zt],i);N=Math.min(N,Ht),G=Math.min(G,Lt)}const[Y,q]=Qt(it(),[(g=R.anchorX)!==null&&g!==void 0?g:0,(p=R.anchorY)!==null&&p!==void 0?p:0],i);
10359x.anchorX=Y-N,x.anchorY=q-G;const{scale:L}=Q8(i),J=Math.abs(L[0]),tt=Math.abs(L[1]),bt=R.fontSize,ct=typeof bt=="number"?bt:typeof bt=="string"&&parseFloat(bt)||12;x.fontSize=ct*tt;const Xt=(m=R.wordWrapWidth)!==null&&m!==void 0?m:0;Xt>0&&(x.wordWrapWidth=Xt*J)}}this.updateNode(t,x)}getBounds(t){const e=new Qe;return t.forEach(r=>{var i;const s=(i=at(this,$o,"f").get(r.id))===null||i===void 0?void 0:i.id();if(s&&s.has(fe)){const o=this.getParent(r),n=this.getNodeByEntity(o);if(n&&n.clipMode&&n.clipMode==="clip"){const{minX:a,minY:l,maxX:c,maxY:h}=s.read(fe).renderWorldBounds,{minX:u,minY:d,maxX:f,maxY:g}=o.read(fe).renderWorldBounds,p=Math.max(a,u),m=Math.max(l,d),v=Math.min(c,f),b=Math.min(h,g);e.addFrame(p,m,v,b)}else e.addBounds(s.read(fe).renderWorldBounds)}}),e}getGeometryBounds(t){const e=new Qe;return t.forEach(r=>{var i;const s=(i=at(this,$o,"f").get(r.id))===null||i===void 0?void 0:i.id();s&&s.has(fe)&&e.addBounds(s.read(fe).geometryWorldBounds)}),e}alignSelectedNodes(t,e){const r=e??this.getAppState().layersSelected;if(r.length<2)return;const i=r.map(o=>this.getNodeById(o)).filter(o=>!!o&&o.locked!==!0);if(i.length<2)return;const s=this.getGeometryBounds(i);if(!(!Number.isFinite(s.minX)||!Number.isFinite(s.maxX)||!Number.isFinite(s.minY)||!Number.isFinite(s.maxY)||s.minX>s.maxX||s.minY>s.maxY)){for(const o of i){const n=this.getEntity(o);if(!(n!=null&&n.has(fe)))continue;const a=n.read(fe).geometryWorldBounds;if(!Number.isFinite(a.minX)||!Number.isFinite(a.maxX)||!Number.isFinite(a.minY)||!Number.isFinite(a.maxY)||a.minX>a.maxX||a.minY>a.maxY)continue;let l=0,c=0;if(t==="left")l=s.minX-a.minX;else if(t==="right")l=s.maxX-a.maxX;else if(t==="top")c=s.minY-a.minY;else if(t==="bottom")c=s.maxY-a.maxY;else if(t==="centerH"){const h=(a.minX+a.maxX)*.5;l=(s.minX+s.maxX)*.5-h}else{const h=(a.minY+a.maxY)*.5;c=(s.minY+s.maxY)*.5-h}at(this,ec,"m",fV).call(this,o,l,c)}this.record()}}distributeSelectedNodesSpacing(t,e){const r=e??this.getAppState().layersSelected;if(r.length<2)return;const i=r.map(n=>this.getNodeById(n)).filter(n=>!!n&&n.locked!==!0);if(i.length<2)return;const s=[];for(const n of i){const a=this.getEntity(n);if(!(a!=null&&a.has(fe)))continue;const l=a.read(fe).geometryWorldBounds;!Number.isFinite(l.minX)||!Number.isFinite(l.maxX)||!Number.isFinite(l.minY)||!Number.isFinite(l.maxY)||l.minX>l.maxX||l.minY>l.maxY||s.push({node:n,minX:l.minX,maxX:l.maxX,minY:l.minY,maxY:l.maxY,w:l.maxX-l.minX,h:l.maxY-l.minY})}if(s.length<2)return;t==="horizontal"?s.sort((n,a)=>n.minX-a.minX):s.sort((n,a)=>n.minY-a.minY);const o=s.length;if(t==="horizontal"){const n=s.reduce((c,h)=>c+h.w,0),a=(s[o-1].maxX-s[0].minX-n)/(o-1);if(!Number.isFinite(a))return;const l=new Array(o);l[0]=s[0].minX;for(let c=1;c<o;c++)l[c]=l[c-1]+s[c-1].w+a;for(let c=0;c<o;c++)at(this,ec,"m",fV).call(this,s[c].node,l[c]-s[c].minX,0)}else{const n=s.reduce((c,h)=>c+h.h,0),a=(s[o-1].maxY-s[0].minY-n)/(o-1);if(!Number.isFinite(a))return;const l=new Array(o);l[0]=s[0].minY;for(let c=1;c<o;c++)l[c]=l[c-1]+s[c-1].h+a;for(let c=0;c<o;c++)at(this,ec,"m",fV).call(this,s[c].node,0,l[c]-s[c].minY)}this.record()}deleteNodesById(t,e=!0){var r;const i=this.getNodes(),s=new Map;i.forEach(c=>{var h;if(c.parentId!=null){const u=(h=s.get(c.parentId))!==null&&h!==void 0?h:[];u.push(c.id),s.set(c.parentId,u)}});const o=new Set,n=[...t];for(;n.length;){const c=n.pop();o.has(c)||(o.add(c),n.push(...(r=s.get(c))!==null&&r!==void 0?r:[]))}const a=i.filter(c=>!o.has(c.id)),l=i.filter(c=>o.has(c.id));return this.deselectNodes(l),this.unhighlightNodes(l),l.forEach(c=>{const h=at(this,$o,"f").get(c.id);h&&h.id().add(Tn),at(this,$o,"f").delete(c.id)}),e&&this.setNodes(a),l}getSiblings(t){const e=this.getEntity(t);return e.has(be)?e.read(be).parent.read(ze).children.filter(r=>!!this.getNodeByEntity(r)):[]}getParent(t){const e=this.getEntity(t);if(e.has(be))return e.read(be).parent}getChildren(t){const e=this.getEntity(t);return e.has(ze)?e.read(ze).children:[]}getChildrenRecursively(t){return this.getChildren(t).flatMap(e=>{const r=this.getNodeByEntity(e);return r?[r,...this.getChildrenRecursively(r)]:[]})}reparentNode(t,e){var r,i,s,o;this.updateNode(t,{parentId:e.id,x:((r=t.x)!==null&&r!==void 0?r:0)-((i=e.x)!==null&&i!==void 0?i:0),y:((s=t.y)!==null&&s!==void 0?s:0)-((o=e.y)!==null&&o!==void 0?o:0)})}bringToFront(t){const e=this.getSiblings(t).filter(i=>!i.has(Ii)),r=Math.max(...e.map(i=>i.read(Ls).value));t.zIndex!==r&&this.updateNode(t,{zIndex:r+1})}bringForward(t){var e,r;const i=this.getSiblings(t).filter(a=>!a.has(Ii)).map(a=>a.read(Ls).value).sort((a,l)=>a-l),s=i.indexOf(t.zIndex);if(s===i.length-1)return;const o=(e=i[s+1])!==null&&e!==void 0?e:_O,n=(r=i[s+2])!==null&&r!==void 0?r:_O;this.updateNode(t,{zIndex:(o+n)/2})}sendBackward(t){var e,r;const i=this.getSiblings(t).filter(a=>!a.has(Ii)).map(a=>a.read(Ls).value).sort((a,l)=>a-l),s=i.indexOf(t.zIndex);if(s===0)return;const o=(e=i[s-1])!==null&&e!==void 0?e:mG,n=(r=i[s-2])!==null&&r!==void 0?r:mG;this.updateNode(t,{zIndex:(o+n)/2})}sendToBack(t){const e=this.getSiblings(t).filter(i=>!i.has(Ii)),r=Math.min(...e.map(i=>i.read(Ls).value));t.zIndex!==r&&this.updateNode(t,{zIndex:r-1})}group(t){var e;const r=[...new Map(t.map(a=>
10359[a.id,a])).values()].filter(Boolean);if(r.length===0)return;const i=this.getGeometryBounds(r);if(!Number.isFinite(i.minX)||!Number.isFinite(i.minY)||!Number.isFinite(i.maxX)||!Number.isFinite(i.maxY))return;const s=new Set(r.map(a=>{var l;return(l=a.parentId)!==null&&l!==void 0?l:"__ROOT__"})).size===1&&(e=r[0].parentId)!==null&&e!==void 0?e:void 0,o=Math.max(...r.map(a=>{var l;return(l=a.zIndex)!==null&&l!==void 0?l:0}),0),n={id:oc(),type:"g",parentId:s,zIndex:o};this.updateNode(n),r.forEach(a=>{a.id!==n.id&&this.reparentNode(a,n)}),this.selectNodes([n])}ungroup(t){var e,r,i;if(t.type!=="g")return;const s=t.parentId,o=(e=t.x)!==null&&e!==void 0?e:0,n=(r=t.y)!==null&&r!==void 0?r:0,a=(i=t.zIndex)!==null&&i!==void 0?i:0,l=this.getChildren(t).map(c=>this.getNodeByEntity(c)).filter(Boolean);if(l.length===0){this.deleteNodesById([t.id]);return}l.forEach((c,h)=>{var u,d;this.updateNode(c,{parentId:s,x:((u=c.x)!==null&&u!==void 0?u:0)+o,y:((d=c.y)!==null&&d!==void 0?d:0)+n,zIndex:a+h*.001})}),this.deleteNodesById([t.id]),this.selectNodes(l)}record(t=Sy.IMMEDIATELY){if(at(this,zB,"f"))return;const e=at(this,gv,"f").snapshot,r=t===Sy.NEVER||e.isEmpty();r?at(this,gv,"f").shouldUpdateSnapshot():at(this,gv,"f").shouldCaptureIncrement(),at(this,gv,"f").commit(jQ(this.getNodes()),this.getAppState());const i=at(this,gv,"f").snapshot;r&&!at(this,NU,"f")&&i!==e&&(i.meta.didElementsChange||i.meta.didAppStateChange)&&this.notifySubscribers({appState:this.getAppState(),nodes:this.getNodes()},{nodesChanged:i.meta.didElementsChange,appStateChanged:i.meta.didAppStateChange})}undo(){this.restoreHistory("undo")}redo(){this.restoreHistory("redo")}restoreHistory(t){at(this,XB,"f").add(()=>{at(this,FU,"f").forEach(r=>r());let e=!1;ol(this,NU,!0,"f");try{e=!!at(this,pv,"f")[t](jQ(this.getNodes()),this.getAppState(),at(this,gv,"f").snapshot),e&&this.record(Sy.NEVER)}finally{ol(this,NU,!1,"f")}e&&this.notifyChange()})}isUndoStackEmpty(){return at(this,pv,"f").isUndoStackEmpty}isRedoStackEmpty(){return at(this,pv,"f").isRedoStackEmpty}clearHistory(){at(this,pv,"f").clear()}export(t){const{format:e,download:r=!0,nodes:i=[]}=t;if(e===am.SVG)nt(at(this,bs,"f"),Vg,{canvas:at(this,bs,"f"),download:r,nodes:i});else if(e===am.PNG||e===am.JPEG){const s=t.scale!=null&&Number.isFinite(t.scale)?Math.max(.25,Math.min(8,t.scale)):1,o=t.rainWarmupSec,n=Math.max(0,Math.min(30,o!=null&&Number.isFinite(o)?o:0)),a=t.rainCaptureTimeSec,l=a!=null&&Number.isFinite(a)?Math.max(0,Math.min(120,a)):0;nt(at(this,bs,"f"),Ca,{canvas:at(this,bs,"f"),type:`image/${e}`,download:r,nodes:i,scale:s,rainWarmupSec:n,rainCaptureTimeSec:l})}else if(e===am.WEBM||e===am.GIF){const s=t.scale!=null&&Number.isFinite(t.scale)?Math.max(.25,Math.min(8,t.scale)):1,o=t.durationSec,n=Math.max(.2,Math.min(15,o!=null&&Number.isFinite(o)?o:3)),a=t.fps,l=Math.max(1,Math.min(30,a!=null&&Number.isFinite(a)?a:24)),c=t.timeStart,h=c!=null&&Number.isFinite(c)?c:0,u=t.gifQuality,d=u==="medium"||u==="low"||u==="high"?u:"high",f=t.rainWarmupSec,g=Math.max(0,Math.min(30,f!=null&&Number.isFinite(f)?f:0));nt(at(this,bs,"f"),Ga,{canvas:at(this,bs,"f"),download:r,format:e===am.WEBM?"webm":"gif",durationSec:n,fps:l,grid:!1,nodes:i,scale:s,timeStart:h,rainWarmupSec:g,gifQuality:e===am.GIF?d:"high"})}this.commands.execute()}renderToSVG(t){return Zf(this,arguments,void 0,function*(e,r={}){const i=at(this,bs,"f"),{grid:s,padding:o=0,designVariablesExport:n="resolved"}=r,{cameras:a,api:l}=i.read(wt),{width:c,height:h}=i.read(wt),{mode:u,colors:d}=i.read(ul),{checkboardStyle:f}=i.read(rd),{grid:g,background:p}=d[u];if(e&&e.length)return p_t(l,e,o,{designVariablesExport:n});const m=we("svg");m.setAttribute("width",`${c}`),m.setAttribute("height",`${h}`),f!==wh.NONE&&m.setAttribute("style",`background-color: ${p}`);{const{x:y,y:_,zoom:w}=a[0].read(Pe);m.setAttribute("viewBox",`${y} ${_} ${c/w} ${h/w}`)}s&&(f===wh.GRID?g_t(m,g):f===wh.DOTS&&m_t(m,g));const v=tq(l.readLayoutFromECS(l.getNodes()),l.getAppState().variables,n,l.getAppState().themeMode),b=rft(v.nodes,l.getNodes());if(v.cssRootStyle){const y=we("defs"),_=Pr.get().getDocument().createElementNS("http://www.w3.org/2000/svg","style");_.textContent=v.cssRootStyle,y.appendChild(_),m.insertBefore(y,m.firstChild)}
10359return(yield Vz(b)).forEach(y=>{m.appendChild(y)}),m})}exportCode(t,e={}){const r=at(this,bs,"f").read(wt).api,i=t&&t.length?t:r.getNodes();return pft(i,Object.assign({variables:r.getAppState().variables,themeMode:r.getAppState().themeMode},e))}renderToCanvas(t){return Zf(this,arguments,void 0,function*(e,r={}){var i,s,o,n,a;let{canvas:l,width:c=(i=e.width)!==null&&i!==void 0?i:0,height:h=(s=e.height)!==null&&s!==void 0?s:0}=r;l||(l=Pr.get().createCanvas(c,h));const u=l.getContext("2d");su(e),zc(e);const d=Ky(e.fills),f=(o=d==null?void 0:d.fill)!==null&&o!==void 0?o:"",g=(()=>{var y;const _=(y=d==null?void 0:d.fillOpacity)!==null&&y!==void 0?y:1;if(typeof _=="number"&&Number.isFinite(_))return Math.max(0,Math.min(1,_));const w=parseFloat(String(_));return Number.isFinite(w)?Math.max(0,Math.min(1,w)):1})(),p=rv(e.strokes),m=(n=p==null?void 0:p.stroke)!==null&&n!==void 0?n:"",v=(()=>{var y;const _=(y=p==null?void 0:p.strokeOpacity)!==null&&y!==void 0?y:1;if(typeof _=="number"&&Number.isFinite(_))return Math.max(0,Math.min(1,_));const w=parseFloat(String(_));return Number.isFinite(w)?Math.max(0,Math.min(1,w)):1})(),b=(a=e.opacity)!==null&&a!==void 0?a:1;if(e.type==="rect"||e.type==="rough-rect"){const{x:y,y:_,width:w,height:E,strokeWidth:A,strokeLinecap:x,strokeLinejoin:S}=e,T=f;if(u.save(),EO(T)||iT(T)){u.globalAlpha=b*g;const R=yield Pr.get().createImage(T);u.drawImage(R,y??0,_??0,w??0,E??0)}else u.globalAlpha=b*g,u.fillStyle=T,u.fillRect(y??0,_??0,w??0,E??0);u.globalAlpha=b*v,u.strokeStyle=m,u.lineWidth=A,u.lineCap=x,u.lineJoin=S,u.stroke(),u.restore()}else if(e.type==="ellipse"||e.type==="rough-ellipse"){const{x:y,y:_,width:w,height:E,strokeWidth:A,strokeLinecap:x,strokeLinejoin:S}=e,T=f;u.save(),u.globalAlpha=b*g,u.fillStyle=T,u.ellipse((y??0)+(w??0)/2,(_??0)+(E??0)/2,(w??0)/2,(E??0)/2,0,0,2*Math.PI),u.fill(),u.globalAlpha=b*v,u.strokeStyle=m,u.lineWidth=A,u.lineCap=x,u.lineJoin=S,u.stroke(),u.restore()}else if(e.type==="path"||e.type==="rough-path"){const{d:y,strokeWidth:_}=e,w=f;u.save(),u.globalAlpha=b*g,u.fillStyle=w,u.beginPath(),ep(y).forEach(([E,...A])=>{E==="M"?u.moveTo(A[0],A[1]):E==="L"?u.lineTo(A[0],A[1]):E==="C"&&u.bezierCurveTo(A[0],A[1],A[2],A[3],A[4],A[5])}),u.closePath(),u.fill(),u.globalAlpha=b*v,u.strokeStyle=m,u.lineWidth=_,u.stroke(),u.restore()}else if(e.type==="polyline"||e.type==="rough-polyline"){const{points:y,strokeWidth:_,strokeLinecap:w,strokeLinejoin:E,x:A,y:x}=e;u.save(),u.globalAlpha=b*v,u.strokeStyle=m,nc(y).forEach((S,T)=>{T===0?u.moveTo(S[0]+(A??0),S[1]+(x??0)):u.lineTo(S[0]+(A??0),S[1]+(x??0))}),u.lineWidth=_,u.lineCap=w,u.lineJoin=E,u.stroke(),u.restore()}else if(e.type==="line"||e.type==="rough-line"){const{x1:y,y1:_,x2:w,y2:E,strokeWidth:A,strokeLinecap:x,strokeLinejoin:S}=e;u.save(),u.globalAlpha=b*v,u.strokeStyle=m,u.moveTo(y??0,_??0),u.lineTo(w??0,E??0),u.lineWidth=A,u.lineCap=x,u.lineJoin=S,u.stroke(),u.restore()}return yield Promise.all(this.getChildren(e).map(y=>this.renderToCanvas(this.getNodeByEntity(y),{canvas:l})).filter(Boolean)),l})}destroy(){if(!at(this,Cy,"f")){ol(this,Cy,!0,"f"),at(this,hV,"f").dispose(),at(this,XB,"f").dispose(),at(this,kU,"f").dispose(),at(this,LU,"f").dispose(),this.cancelLandmarkAnimation(),this.capabilities.dispose();try{at(this,uV,"f").dispose()}finally{const t=this.getAppState();this.setAppState(Object.assign(Object.assign({},t),{layersSelected:[],layersHighlighted:[],layersCropping:[]}));for(const e of[...this.getNodes()]){const r=this.getEntity(e);if(r){try{r.has(ks)&&r.remove(ks),Zr(r,Us)}catch{}try{r.delete()}catch{}}at(this,$o,"f").delete(e.id)}if(this.setNodes([]),at(this,Fn,"f"))try{at(this,Fn,"f").delete()}catch{}if(at(this,bs,"f"))try{at(this,bs,"f").delete()}catch{}}}}loadBitmapFont(t){this.commands.spawn(new Xy({canvas:at(this,bs,"f"),type:"bitmap",bitmapFont:t})),this.commands.execute()}cloneNodes(t){return ewt(t)}copyToClipboard(t,e){return Zf(this,void 0,void 0,function*(){const r=JSON.stringify(t);yield one(r,e)})}edit(t,e={}){var r;const i=(r=e.capture)!==null&&r!==void 0?r:Sy.IMMEDIATELY;return at(this,hV,"f").add(()=>{if(Object.prototype.toString.call(t)==="[object AsyncFunction]")throw new TypeError("Canvas edits must be synchronous. Await work before edit().");ol(this,zB,!0,"f");try{return t(this)}finally{ol(this,zB,!1,"f")}},()=>this.record(i),e.signal)}runAtNextTick(t){at(this,kU,"f").add(t,at(this,VB,"f"))}flushPendingEdits(){ol(this,VB,!0,"f");try{at(this,XB,"f").flush()}finally{ol(this,VB,!1,"f")}}flushPendingTasks(){at(this,kU,"f").flush()}flushAfterDeleteTasks(){at(this,LU,"f").flush()}runImageTask(t,e){return Zf(this,void 0,void 0,function*(){var r,i;if(at(this,Cy,"f"))throw new Error("Canvas has been destroyed");ol(this,XS,(r=at(this,XS,"f"),r++,r),"f"),this.setAppState({loading:!0,loadingMessage:t});try{return yield e()}finally{ol(this,XS,(i=at(this,XS,"f"),i--,i),"f"),!at(this,Cy,"f")&&!at(this,XS,"f")&&this.setAppState({loading:!1,loadingMessage:""})}})}runAfterDeletedEntities(t){at(this,LU,"f").add(t)}exportIcDocument(t){return zwt(this.getAppState(),this.getNodes(),t)}importIcDocument(t,e){const r=structuredClone(Ywt(t));return this.edit(i=>$wt(i,r,e),{capture:(e==null?void 0:e.recordHistory)===!1?"NEVER":"IMMEDIATELY",signal:e==null?void 0:e.signal})}createOrEditImage(t,e,r){return Zf(this,void 0,void 0,function*(){return this.runImageTask("Generating image...",()=>this.capabilities.get("createOrEditImage")(t,e,r))})}upload(t){return Zf(this,void 0,void 0,function*(){return this.runImageTask("Uploading image...",()=>this.capabilities.get("upload")(t))})}encodeImage(t){return Zf(this,void 0,void 0,function*(){return this.runImageTask("Encoding image...",()=>this.capabilities.get("encodeImage")(t))})}segmentImage(t){return Zf(this,void 0,void 0,function*(){return this.runImageTask("Segmenting image...",()=>this.capabilities.get("segmentImage")(t))})}decomposeImage(t){return Zf(this,void 0,void 0,function*(){return this.runImageTask("Decomposing image...",()=>this.capabilities.get("decomposeImage")(t))})}upscaleImage(t){return Zf(this,void 0,void 0,function*(){return this.runImageTask("Upscaling image...",()=>this.capabilities.get("upscaleImage")(t))})}removeByMask(t){return Zf(this,void 0,void 0,function*(){return this.runImageTask("Removing by mask...",()=>this.capabilities.get("removeByMask")(t))})}},bs=new WeakMap,Fn=new WeakMap,jB=new WeakMap,$o=new WeakMap,GS=new WeakMap,W
10359S=new WeakMap,Ry=new WeakMap,pv=new WeakMap,jS=new WeakMap,PU=new WeakMap,FU=new WeakMap,NU=new WeakMap,gv=new WeakMap,kU=new WeakMap,XB=new WeakMap,hV=new WeakMap,zB=new WeakMap,VB=new WeakMap,LU=new WeakMap,Cy=new WeakMap,uV=new WeakMap,XS=new WeakMap,UU=new WeakMap,ec=new WeakSet,dV=function(t){const e=new Map;for(const r of this.getNodes())e.set(r.id,r);for(const r of t)e.set(r.id,r);return[...e.values()]},GQ=function(t){return FL(t,lj(t,at(this,ec,"m",dV).call(this,t)))},WQ=function(t){this.runAtNextTick(()=>at(this,ec,"m",Kwt).call(this,t))},Kwt=function(t){if(!t.has(je))return;const e=t.read(je).meshEntity;if(!(!e||!nr(e)||!e.has(ar)))try{e.remove(ar)}catch{}},qwt=function(t){this.runAtNextTick(()=>at(this,ec,"m",Zwt).call(this,t,0))},Zwt=function t(e,r=0){if(!e.has(je)||!e.has(ks))return;const i=e.read(je).meshEntity;if(!i||!nr(i)){r<120&&this.runAtNextTick(()=>at(this,ec,"m",t).call(this,e,r+1));return}i.has(ar)||i.add(ar,{mode:"transform",activeAxis:"none",activePartKind:null,dragging:!1}),tX(at(this,bs,"f"),!0)},Jwt=function(){this.runAtNextTick(()=>at(this,ec,"m",Qwt).call(this))},Qwt=function(){const t=this.getAppState().layersSelected.some(e=>{var r;const i=(r=at(this,$o,"f").get(e))===null||r===void 0?void 0:r.id();if(!(i!=null&&i.has(je)))return!1;const s=i.read(je).meshEntity;return!!(s&&nr(s)&&s.has(ar))});tX(at(this,bs,"f"),t)},fV=function(t,e,r){var i,s,o,n,a,l,c,h,u;if(Math.abs(e)<1e-9&&Math.abs(r)<1e-9)return;const d=this.getEntity(t);if(!d)return;const f=.01,g=Object.assign(Object.assign({},t),this.getAbsoluteTransformAndSize(t)),p={x:(i=g.x)!==null&&i!==void 0?i:0,y:(s=g.y)!==null&&s!==void 0?s:0,width:(o=g.width)!==null&&o!==void 0?o:0,height:(n=g.height)!==null&&n!==void 0?n:0,rotation:(a=g.rotation)!==null&&a!==void 0?a:0,scaleX:(l=g.scaleX)!==null&&l!==void 0?l:1,scaleY:(c=g.scaleY)!==null&&c!==void 0?c:1},m=p.width,v=p.height,b=Bt();eG(b,[e,r]);const y=this.getParentTransform(d),_=this.getTransform(g),w=Bt();us(w,y,_),us(w,b,w),us(w,_i(Bt(),y),w);const{rotation:E,translation:A,scale:x}=Q8(w),S={x:A[0],y:A[1],width:Math.max(Math.abs(((h=g.width)!==null&&h!==void 0?h:0)*x[0]),f),height:Math.max(Math.abs(((u=g.height)!==null&&u!==void 0?u:0)*x[1]),f),rotation:E,scaleX:p.scaleX*(Math.sign(m)||1),scaleY:p.scaleY*(Math.sign(v)||1)};if(d.hasSomeOf(_t,xt,Mt)){const T=Math.sign(m)||1,R=Math.sign(v)||1;S.scaleX=Math.sign(p.scaleX||1)*T,S.scaleY=Math.sign(p.scaleY||1)*R}this.updateNodeOBB(t,S,t.lockAspectRatio,void 0,g),Sr(d),_h(d)};var mv=function(t,e,r,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o},XQ=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})},Nl=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},yv=function(t,e,r,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r},pV,zw,YB,$B,GU,zS,HB;let tEt=class extends We{};tEt=mv([Ve(rG)],tEt);let eEt=class extends We{};eEt=mv([Ve(D3)],eEt);let rEt=class extends We{};rEt=mv([Ve(iG)],rEt);let iEt=class extends We{};iEt=mv([Ve(Dg)],iEt);let sEt=class extends We{};sEt=mv([Ve(F3)],sEt);let oEt=class extends We{};oEt=mv([Ve(zf)],oEt);let nEt=class extends We{};nEt=mv([Ve(P3)],nEt);let aEt=class extends We{};aEt=mv([Ve(uO)],aEt);let lEt=class extends We{};lEt=mv([Ve(An)],lEt),Rtt=class{constructor(){pV.set(this,[]),zw.set(this,void 0),YB.set(this,void 0),$B.set(this,void 0),GU.set(this,void 0),zS.set(this,!1),HB.set(this,void 0)}addPlugin(t){return Nl(this,pV,"f").push(t),this}
10359addPlugins(...t){return t.forEach(e=>{this.addPlugin(e)}),this}run(){var t;return Nl(this,zS,"f")?Promise.reject(new Error("App has exited")):yv(this,YB,(t=Nl(this,YB,"f"))!==null&&t!==void 0?t:this.start(),"f")}start(){return XQ(this,void 0,void 0,function*(){yv(this,HB,Pr.get(),"f");for(const e of Nl(this,pV,"f"))if(Array.isArray(e))yield e[0](e[1]);else{if(typeof e=="object"&&e!==null&&"configure"in e)throw new Error("Plugin with configuration must be called with .configure(options) before adding to app");yield e()}HZ(),this.world=yield Z8.create({threads:1,maxEntities:4194304,maxLimboComponents:4194304});const t=()=>XQ(this,void 0,void 0,function*(){yv(this,zw,void 0,"f"),!Nl(this,zS,"f")&&(yv(this,GU,this.world.execute(),"f"),yield Nl(this,GU,"f"),Nl(this,zS,"f")||yv(this,zw,Nl(this,HB,"f").requestAnimationFrame(t),"f"))});return Nl(this,zS,"f")||yv(this,zw,Nl(this,HB,"f").requestAnimationFrame(t),"f"),this})}exit(){return Nl(this,YB,"f")?Nl(this,$B,"f")?Nl(this,$B,"f"):(yv(this,zS,!0,"f"),Nl(this,zw,"f")!==void 0&&(Nl(this,HB,"f").cancelAnimationFrame(Nl(this,zw,"f")),yv(this,zw,void 0,"f")),yv(this,$B,XQ(this,void 0,void 0,function*(){yield Nl(this,YB,"f");try{yield Nl(this,GU,"f")}finally{yield this.world.terminate()}}),"f"),Nl(this,$B,"f")):Promise.resolve()}},pV=new WeakMap,zw=new WeakMap,YB=new WeakMap,$B=new WeakMap,GU=new WeakMap,zS=new WeakMap,HB=new WeakMap;var cae=function(t,e,r,i){function s(o){return o instanceof r?o:new r(function(n){n(o)})}return new(r||(r=Promise))(function(o,n){function a(h){try{c(i.next(h))}catch(u){n(u)}}function l(h){try{c(i.throw(h))}catch(u){n(u)}}function c(h){h.done?o(h.value):s(h.value).then(a,l)}c((i=i.apply(t,e||[])).next())})};class hae{constructor(e){this.createWorker=e,this.nextId=0,this.pending=new Map,this.tail=Promise.resolve(),this.disposed=!1,this.runs=new Set,this.onMessage=r=>{const{requestId:i,type:s,data:o,error:n,done:a}=r.data;if(!a)return;const l=this.pending.get(i);l&&(this.pending.delete(i),s==="error"?l.reject(new Error(n||"Worker request failed")):l.resolve(o))},this.onError=r=>{this.dispose(new Error("message"in r?r.message:"Worker message could not be decoded"))}}run(e){const r=this.tail.then(()=>cae(this,void 0,void 0,function*(){return this.assertActive(),this.ready||(this.worker=this.createWorker(),this.worker.addEventListener("message",this.onMessage),this.worker.addEventListener("error",this.onError),this.worker.addEventListener("messageerror",this.onError),this.ready=this.request("ping").then(i=>{if((i==null?void 0:i.success)===!1)throw new Error("Worker model initialization failed")})),yield this.ready,this.assertActive(),e()}));return this.tail=r.catch(()=>{}),new Promise((i,s)=>{this.runs.add(s),r.then(o=>{this.runs.delete(s),i(o)},o=>{this.runs.delete(s),s(o)})})}request(e,r){this.assertActive();const i=++this.nextId;return new Promise((s,o)=>{this.pending.set(i,{resolve:s,reject:o});try{this.worker.postMessage({requestId:i,type:e,data:r})}catch(n){this.pending.delete(i),o(n)}})}assertActive(){if(this.disposed)throw new Error("Worker client disposed")}dispose(e=new Error("Worker client disposed")){var r,i,s,o;this.disposed||(this.disposed=!0,this.runs.forEach(n=>n(e)),this.runs.clear(),this.pending.forEach(({reject:n})=>n(e)),this.pending.clear(),(r=this.worker)===null||r===void 0||r.removeEventListener("message",this.onMessage),(i=this.worker)===null||i===void 0||i.removeEventListener("error",this.onError),(s=this.worker)===null||s===void 0||s.removeEventListener("messageerror",this.onError),(o=this.worker)===null||o===void 0||o.terminate())}}const Hg=1e-7,Nc=t=>({ok:!1,reason:t}),cEt=t=>{var e;return{vertices:t.vertices.map(r=>Object.assign({},r)),segments:t.segments.map(r=>Object.assign(Object.assign(Object.assign({},r),r.tangentStart?{tangentStart:Object.assign({},r.tangentStart)}:{}),r.tangentEnd?{tangentEnd:Object.assign({},r.tangentEnd)}:{})),regions:((e=t.regions)!==null&&e!==void 0?e:[]).map(r=>Object.assign(Object.assign({},r),{loops:r.loops.map(i=>[...i])}))}},hEt=t=>{var e;return t.vertices.every(r=>Number.isFinite(r.x)&&Number.isFinite(r.y))&&t.segments.every(r=>Number.isInteger(r.start)&&Number.isInteger(r.end)&&!!lm(t.vertices,r))&&((e=t.regions)!==null&&e!==void 0?e:[]).every(r=>r.loops.length&&r.loops.every(i=>!!gy(t.segments,i)))},uEt=t=>[t[0],3*(t[1]-t[0]),3*(t[2]-2*t[1]+t[0]),t[3]-3*t[2]+3*t[1]-t[0]],WU=(t,e)=>t[0]+e*(t[1]+e*(t[2]+e*t[3]));function dEt(t){const e=3*t[3],r=2*t[2],i=t[1],s=Math.max(1,Math.abs(e),Math.abs(r),Math.abs(i));if(Math.abs(e)<1e-14*s)return Math.abs(r)<1e-14*s?[]:[-i/r];const o=r*r-4*e*i;if(o<0)return[];const n=-.5*(r+(r>=0?1:-1)*Math.sqrt(o));return n===0?[-r/(2*e)]:[n/e,i/n]}function uae(t){const e=[0,...dEt(t).filter(i=>i>0&&i<1),1].sort((i,s)=>i-s),r=e.filter(i=>Math.abs(WU(t,i))<=Hg);for(let i=1;i<e.length;i++){let s=e[i-1],o=e[i],n=WU(t,s);if(!(n*WU(t,o)>=0)){for(let a=0;a<48;a++){const l=(s+o)/2,c=WU(t,l);c>0==n>0?(s=l,n=c):o=l}r.push((s+o)/2)}
10359}return r}function dae(t,e,r){const i=t.vertices[e],s=t.vertices[r],o=s.x-i.x,n=s.y-i.y,a=Math.hypot(o,n),l=o/a,c=n/a;return a<=Hg?!1:t.segments.every(h=>{const u=lm(t.vertices,h),d=uEt(u.map(g=>l*(g[1]-i.y)-c*(g[0]-i.x))),f=uEt(u.map(g=>l*(g[0]-i.x)+c*(g[1]-i.y)));if(d.every(g=>Math.abs(g)<=Hg)){const g=[0,1,...dEt(f).filter(v=>v>0&&v<1)].map(v=>WU(f,v)),p=Math.max(0,Math.min(...g)),m=Math.min(a,Math.max(...g));return m<p-Hg?!0:m-p>Hg?!1:m<=Hg&&(h.start===e||h.end===e)||p>=a-Hg&&(h.start===r||h.end===r)}return uae(d).every(g=>{const p=FS(u,g),m=l*(p[0]-i.x)+c*(p[1]-i.y);if(m<-Hg||m>a+Hg)return!0;const v=g<=1e-9?h.start:g>=1-1e-9?h.end:-1;return v===e&&Math.abs(m)<=Hg||v===r&&Math.abs(m-a)<=Hg})})}Ktt=function(t,e,r){if(![e,r].every(p=>Number.isInteger(p)&&!!t.vertices[p]))return Nc("invalid-vertex");if(e===r)return Nc("same-vertex");if(!hEt(t))return Nc("invalid-network");const i=MB(t.vertices,t.segments),s=t.vertices[e],o=t.vertices[r],n=V_t(i,[(s.x+o.x)/2,(s.y+o.y)/2]);if(!n)return Nc("no-shared-face");const a=n.region.loops.map(p=>gy(t.segments,p));if(a.some(p=>!p))return Nc("unsupported-topology");const l=a.map(p=>p.map(m=>m.from)),c=l.findIndex(p=>p.includes(e)),h=l.findIndex(p=>p.includes(r));if(c===-1||h===-1)return Nc("no-shared-face");if(!dae(t,e,r))return Nc("crossing-cut");const u=c!==h,d=cEt(t);d.segments.push({start:e,end:r});const f=MB(d.vertices,d.segments);if(f.length!==i.length+(u?0:1))return Nc("unsupported-topology");const g=Gz(t.vertices,t.segments,t.regions,f);return g.some(p=>p===null)?Nc("unsupported-topology"):(d.regions=f.filter((p,m)=>g[m]).map(p=>p.region),{ok:!0,network:d,selectedVertex:e,vertexMap:t.vertices.map((p,m)=>[m]),segmentMap:t.segments.map((p,m)=>[m])})},qtt=function(t,e){if(!Number.isInteger(e)||!t.segments[e])return Nc("not-interior-edge");if(!hEt(t))return Nc("invalid-network");const r=MB(t.vertices,t.segments),i=r.filter(h=>h.region.loops.some(u=>u.includes(e))),s=i.map(h=>h.region.loops.flat().filter(u=>u===e).length),o=i.length===1&&s[0]===2;if(!o&&(i.length!==2||s.some(h=>h!==1)))return Nc("not-interior-edge");const n=Gz(t.vertices,t.segments,t.regions,i);if(n.some(h=>h===null))return Nc("unsupported-topology");if(!o&&n[0]!==n[1])return Nc("different-fills");const a=cEt(t);a.segments.splice(e,1);const l=MB(a.vertices,a.segments);if(l.length!==r.length-(o?0:1))return Nc("unsupported-topology");if(o){const h=u=>u.reduce((d,f)=>d+f.region.loops.length,0);if(h(l)!==h(r)+1)return Nc("not-interior-edge")}const c=Gz(t.vertices,t.segments,t.regions,l);return c.some(h=>h===null)?Nc("unsupported-topology"):(a.regions=l.filter((h,u)=>c[u]).map(h=>h.region),{ok:!0,network:a,selectedVertex:t.segments[e].start,vertexMap:t.vertices.map((h,u)=>[u]),segmentMap:t.segments.map((h,u)=>u===e?[]:[u>e?u-1:u])})};let fEt,pEt,gEt;Ctt=[Gwt,Wwt,Uwt,IQ,DQ,NQ,kV,PQ,FQ,kQ,LQ],tet=Object.freeze(Object.defineProperty({__proto__:null,AABB:Qe,ADJUSTMENT_DEFAULTS:m7t,API:dtt,ASCII_DEFAULTS:x7t,Anchor:aV,get AnchorName(){return gt},AnimationController:XX,AnimationExportOutput:Vy,AnimationPlayer:_a,AnimationPlugin:LQ,AnimationSystem:z0t,App:Rtt,ApplyEdits:KZ,BLUR_DEFAULTS:_7t,BURN_DEFAULTS:F7t,BatchManager:Tvt,Binded:cl,Binding:Wl,BrowserAdapter:kdt,Brush:ai,get BrushType(){return Qw},Bundle:OL,CRT_DEFAULTS:E7t,Camera:jt,Camera3D:Bi,CameraControl:dO,CameraPlugin:IQ,CameraSync:Az,Canvas:wt,Canvas3DScope:js,CanvasPlugin:Uwt,CapabilityRegistry:jwt,get CheckboardStyle(){return wh},Children:be,Circle:et,ClipMode:Gc,Commands:nE,ComputeBounds:lE,ComputeCamera:rp,ComputePoints:c_t,ComputeRough:W0t,ComputeTextMetrics:_gt,ComputeVisibility:Dz,ComputeZIndex:ibt,ComputedBounds:fe,ComputedCamera:Pe,ComputedCameraControl:so,ComputedPoints:wo,ComputedRough:iu,ComputedTextMetrics:Ji,ComputedVisibility:Pn,Culled:jc,CullingPlugin:NQ,Cursor:_o,DEFAULT_MESH_GRADIENT_CORNER_POSITIONS:wG,DEFAULT_THEME_COLORS:Ty,DIRECTION_EAST:gG,DIRECTION_NORTH:gO,DIRECTION_SOUTH:mO,DIRECTION_WEST:pG,DOMAdapter:Pr,DRAW_RECT_Z_INDEX:g2,DefaultPlugins:Ctt,DefaultRenderer3DPlugin:Mtt,DefaultRendererPlugin:kV,DefaultStateManagement:gtt,Deleter:IB,DrawArrowConnect:zJ,DrawBrush:YJ,DrawPencil:oG,DrawPoint:$J,DrawRect:XJ,DrawVectorNetwork:IV,DropShadow:ro,EdgeLabel:Ww,get EdgeStyle(){return qh},Edit:uO,Editable:Mi,Ellipse:ae,Embed:To,EnsureExtrudeMeshes:xz,EnsureMesh3DNodes:Sz,EntityCommands:J8,Event:wQ,EventDisposer:RJ,EventPlugin:DQ,EventWriter:fO,get ExportFormat(){return am},ExportSVG:cU,Extrude3D:Lo,Extrude3DTarget:Gd,FLUTED_GLASS_DEFAULTS:w7t,FillLayers:Ce,FillTexture:yh,FillTextureLive:JU,Filter:La,First:P3,Flex:mh,FlexLayoutDirty:uE,Font:Xy,FractionalIndex:Gs,GEM_SMOKE_DEFAULTS:M7t,GLITCH_DEFAULTS:S7t,GPUResource:cs,GeometryDirty:Sn,GlobalRenderOrder:Ln,GlobalTransform:Ae,Grid:rd,Group:Js,HALFTONE_DOTS_DEFAULTS:v7t,HEATMAP_DEFAULTS:C7t,HIGHLIGHTER_Z_INDEX:ij,HTML:ko,HTMLContainer:ka,HTMLPlugin:kQ,HierarchyPlugin:Gwt,Highlighted:Us,IC_DOCUMENT_TYPE:OU,IC_FILE_SUFFIX:iO,IC_SCHEMA_VERSION:IU,IMAGE_MIME_TYPES:rO,IconFont:Hn,IconFontEllipseStrokeRasterPlaceholder:sm,InnerShadow:ac,Input:le,InputPoint:xa,LIGHT_3D_TYPE:Nwt,LIQUID_GLASS_DEFAULTS:T7t,LIQUID_METAL_DEFAULTS:R7t,LIQUID_METAL_POISSON_DEFAULTS:dwt,LUT_EFFECT_DEFAULTS:b7t,Last:An,Light3D:Kn,Line:Mt,LoadMesh3DGeometry:Tz,LockAspectRatio:Mv,Locked:tu,MIME_TYPES:Kd,Marker:qo,Mat3:ie,Mat4:Ai,Material3D:Ni,MaterialDirty:yi,Mesh3D:Ns,Mesh3DNode:je,Mesh3DNodeTarget:fh,MeshPipeline:sG,MeshPipeline3D:Gvt,Name:ba,NodeLayerBlendM
10359ode:zy,OBB:Yu,Opacity:bo,Parent:ze,PartialBinding:hl,Path:xt,get Pen(){return vt},PenPlugin:FQ,Pick3D:vbt,Polyline:_t,PostEffectTime:Ire,PostStartUp:iG,PostUpdate:zf,PreStartUp:rG,PreUpdate:Dg,PropagateTransforms:eT,RAINDROPS_SIM_DEFAULTS:P7t,RAINDROPS_WATER_DEFAULTS:D7t,RAINDROP_FX_COMPOSE_DECAY_DEFAULT:eKt,RAINDROP_FX_COMPOSE_DEFAULTS:J7t,RAINDROP_FX_RENDER_DEFAULTS:Z7t,RAINDROP_FX_SIM_DEFAULTS:q7t,RAINDROP_FX_SIM_DT:tKt,RAIN_DEFAULTS:O7t,RAIN_DROPDROP_TEXTURE_DEFAULT:Q7t,RAIN_DROP_TEXTURE_DEFAULTS:I7t,RBush:dl,RaindropSimulator:H7t,RaindropsCodropsSimulator:xne,RasterAnimationExportRequest:Ga,RasterScreenshotRequest:Ca,Rect:$t,RenderBindings:KJ,RenderGizmo3D:_bt,RenderHTML:HJ,RenderHighlighter:nG,RenderNameLabel:nbt,RenderTransformer:aG,Renderable:Zi,Renderer3DPlugin:OQ,RendererPlugin:LV,Rough:ue,SATURATE_ADJUSTMENT_SATURATION:y7t,SERIALIZED_NODE_VARIABLE_KEYS:aj,SIBLINGS_MAX_Z_INDEX:_O,SIBLINGS_MIN_Z_INDEX:mG,Screenshot:vh,ScreenshotPlugin:PQ,Select:fU,Selected:ks,Selected3D:ar,get SelectionMode(){return qt},SetCursor:d_t,SetupDevice:G3,SizeAttenuation:Xc,Sort:mz,get StampMode(){return jw},StartUp:D3,Stroke:Gt,StrokeAttenuation:Qn,StrokeLayers:Fs,SyncExtrude3D:Rz,SyncMesh3DNodes:Cz,SyncSimpleTransforms:tT,System:We,TRANSFORMER_ANCHOR_FILL_COLOR:xU,TRANSFORMER_ANCHOR_RESIZE_RADIUS:Gw,TRANSFORMER_ANCHOR_ROTATE_RADIUS:LB,TRANSFORMER_ANCHOR_STROKE_COLOR:Zs,TRANSFORMER_MASK_FILL_COLOR:Kh,TRANSFORMER_Z_INDEX:nw,TSUNAMI_DEFAULTS:B7t,get Task(){return fE},get TesselationMethod(){return im},Text:Yt,TextDecoration:wa,TexturePool:V0t,Theme:ul,get ThemeMode(){return Tr},ToBeDeleted:Tn,Transform:_e,Transform3D:ki,TransformPlugin:Wwt,Transformable:Nt,get TransformableStatus(){return Nn},Type:$,UI:Ii,get UIType(){return va},Update:F3,VECTOR_NETWORK_VERTEX_SNAP_RADIUS:pQ,VIGNETTE_DEFAULTS:A7t,Vec2:tl,Vec3:Ri,VectorNetwork:ke,get VectorNetworkEditMode(){return So},VectorScreenshotRequest:Vg,VelloCanvasSurface:AV,ViewportCulling:cG,Visibility:he,WebWorkerAdapter:o$t,Wireframe:jy,WorkerClient:hae,World:Z8,ZIndex:Ls,aabbType:g3,applyIcDocumentToApi:$wt,applyPathPreserveLayoutFromSnapshot:eQ,applySvgDataAttributesToElement:Fbt,arrayToMap:jQ,asciiUniformValues:Wmt,buildCodeIR:nft,buildDesignVariableRefreshPatch:Zdt,buildDesignVariableThemeContext:ZK,buildDesignVariablesCssRootBlock:QK,buildGroupWirePresentation:k2,buildIcDocumentFromState:zwt,buildIconFontScalablePrimitives:dX,buildVectorNetworkFillMesh:KV,burnUniformValues:Lmt,calculateOBBRecursive:gQ,canvasWorldToWorld3D:RQ,clearRainFxExportContext:rz,cloneSerializedNodes:ewt,co:bO,coerceDesignVariableType:hXt,collectRainDropTextureUrlsFromFilterValue:vZ,collectSceneRootNodeIds:aae,component:te,computeConicGradient:dG,computeDrawableSets:j0t,computeLinearGradient:dE,computeObjectFitDrawRect:NV,computeRadialGradient:pO,computeTranslationWithTransformOrigin:X0t,createDefaultEffect:Amt,createDefaultRainEffect:Mmt,createDrawcallPostChain:Qmt,createGeometryBoundsProviderFromComputePathBounds:Dtt,createGeometryBoundsProviderFromComputePathBoundsForLine:ktt,createGeometryBoundsProviderFromComputePathBoundsForPolyline:Ftt,createHitTestProviderFromHitTestPath:Utt,createHitTestProviderFromHitTestPathForLine:Wtt,createHitTestProviderFromHitTestPathForPolyline:Gtt,createPasteEvent:Xtt,createPostProcessingRenderer:Jmt,createRenderBoundsProviderFromComputePathBounds:Ptt,createRenderBoundsProviderFromComputePathBoundsForLine:Ltt,createRenderBoundsProviderFromComputePathBoundsForPolyline:Ntt,createSVGElement:we,crtUniformValues:Umt,cssColorToHex:ret,cutVectorNetworkFace:Ktt,deserializePoints:nc,designTokenKeyToCssCustomProperty:y2,designVariableRefKeyFromWire:qy,designVariableThemeMatches:JK,distanceBetweenPoints:Sa,documentValueEqual:_w,downloadIcDocument:Vtt,drawCanvasImageWithObjectFit:lz,drawDotsGrid:m_t,drawLinesGrid:g_t,edgeEndsResolvable:Xz,effectiveMeshGradientPointsNum:Ydt,effectiveThemePreference:Ytt,emitHtmlCss:fft,emitReactTailwind:uft,exportFillGradientOrPattern:jV,exportFillImage:XV,exportMarker:zV,exportStrokeGradientOrPattern:Ubt,field:P,fillLayerImageRasterOptions:nJ,filterRasterPostEffects:G2,filterStringUsesEngineTimeCrt:Smt,filterStringUsesEngineTimeGlitch:Tmt,f
10359ilterStringUsesEngineTimePost:U2,filterUndefined:RV,findHoveredVectorNetworkSegmentIndex:yQ,findSnapTargetVertexIndex:Mwt,findThemedValueEntryIndexForMode:Kdt,firstEnabledFillPresentation:Ky,firstEnabledStrokePresentation:rv,flutedGlassUniformValues:Pmt,fontStringFromTextStyle:D2,fontWeightMap:UV,formatFilter:Emt,formatLutFilterSegment:xmt,formatMeshGradientStringSuffix:oet,formatNumber:Zt,gemSmokeUniformValues:Ymt,getCubeLutGpu:btt,getDefaultAppState:yO,getDescendants:Ov,getDesignVariableLightDarkValues:$V,getFillLayerDecodedBitmap:wO,getFilterBackend:mZ,getMeshPipeline3D:bJ,getOBB:SU,getPostEffectEngineTimeSeconds:Kmt,getPrimaryFillValue:oT,getPrimaryStrokeValue:oX,getRainDropTextureBitmapIfReady:wtt,getRainFxAnimationExportContext:BV,getRainFxPngExportContext:Ett,getRaindropSpriteBitmapIfReady:qmt,getRegisteredIconifyIconFamilies:VV,getRegisteredIconifyIconNames:eet,getRoughOptions:vG,getSceneRoot:En,getSvgPathFromStroke:EV,getVectorSegmentPointAt:_G,glitchUniformValues:jmt,glueVectorNetworkEdges:$tt,glueVertices:WV,halftoneDotsUniformValues:Dmt,hasFullOrPartialEdgeBinding:LS,hasRasterPostEffects:iv,hasTerminalPoint:kS,heatmapUniformValues:Vmt,hideLabel:NS,hitTest:vQ,iconFontSvgFillIsNoneOrTransparent:Jgt,imageDataToHeatmapProcessed:_tt,imageDataToLiquidMetalPoissonMap:vtt,imageToCanvas:SV,inferEdgePoints:_U,inferPointsWithFromIdAndToId:Mbt,inferXYWidthHeight:ou,initLabel:Wz,isBrowser:Zo,isDataUrl:EO,isDesignVariableReference:Pv,isEntityAlive:nr,isGradient:sT,isLiquidMetalReadbackSyncSupported:Ene,isMeshGradientGradient:Zy,isPattern:Dv,isRainCodropsRainEffect:Rmt,isRainFxEffect:YV,isSaturateOnlyAdjustment:Cmt,isSupportedImageFileType:GV,isUrl:iT,kawaseBlurUniformValues:Hmt,kawaseKernelsForBlurEffect:$mt,layoutTextAnchoredInParent:gwt,linkedPerspectiveEyeDistance:MQ,liquidGlassUniformValues:Xmt,liquidMetalUniformValues:zmt,listRegisteredCubeLutKeys:set,loadBitmapFont:l$t,loadRainDropTextureCached:OV,loadRaindropSpriteCached:Zmt,m3Type:Xx,m4Type:I9t,mapSvgLineCap:mX,mapSvgLineJoin:yX,mapToArray:lae,mat3ProjectionToMat4:Kne,mat3ViewProjectionToMat4:CU,mat3ViewToMat4:CQ,maybeShiftPoints:MJ,get measureFontFn(){return Jq},measureText:om,mergeThemeState:bQ,migrateLegacyFillWireInPlace:su,migrateLegacyStrokeWireInPlace:zc,moveVectorHandle:GJ,normalizeAnimationOptions:GZ,normalizeKeyframes:WX,normalizeStrokeDashCap:sX,obbType:rX,parseAdobeCube:hwt,parseClipboard:ztt,parseColor:Wo,parseEffect:Iv,parseGradient:nm,parseIcDocumentJson:Ywt,parseObjectPosition:gvt,pathFillRuleFromIconStyle:cX,pickChildFill:gX,pickStrokeColorForChild:pX,pickThemedValueFromVariableEntries:Hdt,pointAlongPolylineByT:a7t,preferVectorNetworkEdge:Jtt,preloadRaindropSprites:_Z,prepareSerializedNodesForSvgExport:tq,prepareStages:HZ,rainCodropsWaterUniformValues:kmt,rainFxRenderOptionsFromEffect:Bmt,rainUniformValues:Nmt,raindropSimulatorOptionsForEffect:Omt,raindropsSimulatorOptionsForEffect:Imt,randomInteger:VK,rasterizeFillLayerImageUrlForTexture:uG,readFillWireFromEntity:YXt,readFontSizeWireFromEntity:KXt,readStrokeColorWireFromEntity:$Xt,readStrokeWidthWireFromEntity:HXt,readSystemClipboard:Ttt,refreshComputedRoughForEntity:I3,registerCubeLutFromText:_ne,registerFilterBackend:xtt,registerIconifyIconSet:ttt,requestTransformerRefreshForCanvas:bh,requireFilterBackend:d7t,resolveDesignVariableDefinitionScalar:DL,resolveDesignVariableValue:ds,resolveFillLayerImageRasterPixelSize:uJ,resolveFillLayerItemsForEcs:PL,resolveFillLayerOpacityFromWire:jtt,resolveIconFontTargetDimensions:Zgt,resolveIconFontWireStyle:nX,resolveIconifyBodyToScalablePrimitives:uZ,resolveImageFillRasterOptions:hG,resolveSerializedNodesDesignVariables:eq,resolveThemeModeFromPreference:ZU,safeAddComponent:nt,safeRemoveComponent:Zr,serializeNodesToSVGElements:Vz,serializePoints:ip,serializedNodesToCode:pft,serializedNodesToEntities:iQ,setDesignVariableLightDarkColumn:iet,setFillLayerDecodedBitmapForUrl:cJ,setMeasureFontFn:Itt,setMeasureLineFn:Ott,setPostEffectEngineTimeSeconds:wX,setRainFxExportContext:ZZ,setVectorVertexMirroring:Qtt,shiftPoints:BJ,shouldUseIconFontEllipseStrokeRasterPlaceholder:dZ,showLabel:jz,showNameLabel:obt,sortByFractionalIndex:vO,sortByZIndex:rbt,splitVectorNetworkIntersections:Uz,stringifyIcDocument:Vwt,strokeWidthFromIconStyle:fX,svgElementsToSerializedNodes:EG,svgSvgElementToComputedCamera:Woe,system:Ve,toDomPrecision:Hd,toSVG:Xbt,toSVGDataURL:zbt,toSVGElement:p_t,tsunamiUniformValues:Fmt,uncutVectorNetworkEdge:qtt,unglueVectorNetworkEdge:Htt,unglueVertex:Ztt,unregisterIconifyIconSet:F9t,updateBounds:Iw,updateComputedPoints:_h,updateDesignVariableValueForMode:cXt,updateGlobalTransform:Sr,updateMatrix:CJ,upload2DRasterCanvasToTexture:hE,v2Type:WK,v3Type:Djt,vectorEdgeUses:HV,vectorHandlesAtVertex:bG,vectorSegmentCubic:lm,vectorVertexEndpoints:qV,vignetteUniformValues:Gmt,warnMissingCubeLutOnce:Att,yOffsetFromTextBaseline:u3},Symbol.toStringTag,{value:"Module"})),fEt={createCanvas:async(t,e,r,i="webgl")=>{const s=document.createElement("canvas");return s.style.outline="none",s.style.padding="0px",s.style.margin="0px",s.style.border="1px solid black",s.width=e*window.devicePixelRatio,s.height=r*window.devicePixelRatio,s.style.width=`${e}px`,s.style.height=`${r}px`,s.style.touchAction="none",await new t({canvas:s,renderer:i,shaderCompilerPath:"https://unpkg.com/@antv/[email protected]/dist/pkg/glsl_wgsl_compiler_bg.w
10359asm"}).initialized},resizeCanvas:(t,e,r)=>{const i=t.getDOM();i.width=e*window.devicePixelRatio,i.height=r*window.devicePixelRatio,i.style.width=`${e}px`,i.style.height=`${r}px`,i.style.touchAction="none",t.resize(e,r)},loadImage:async t=>nu(t,Hh)},pEt={Theme:wet,library:{Lesson1:uLt,Lesson2:wLt,Lesson3:ILt,Lesson4:HLt,Lesson5:g3t,Lesson6:Y3t,Lesson7:jUt,Lesson8:TGt,Lesson9:g4t,Lesson10:C5t,Lesson12:qWt,Lesson13:G8t,Utils:fEt,Stats:mY,Core:sLt,GUI:ZV,ECS:tet}},gEt=ir({name:"SiteLayout",setup(){return Py(()=>{const t="ca-pub-7249050617996057";if(document.querySelector('script[src^="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"]'))return;const e=document.createElement("script");e.async=!0,e.crossOrigin="anonymous",e.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${encodeURIComponent(t)}`,document.head.append(e)}),()=>Bae(nRt,pEt)}}),DEt={extends:wet,Layout:gEt,async enhanceApp(){{const{setBasePath:t}=await JB(async()=>{const{setBasePath:e}=await import("./base-path.r-Ppr3Mh.js");return{setBasePath:e}},[]);t("https://cdn.jsdelivr.net/npm/@shoelace-style/[email protected]/cdn"),await JB(()=>import("./shoelace.Ls2kLUQv.js"),__vite__mapDeps([2,3,4])),await JB(()=>import("./index.BIwviW0q.js"),__vite__mapDeps([5,4,3,6,1]))}}}})();export{QQ as $,ttt as A,Qw as B,Gl as C,Sv as D,$h as E,I as F,Tv as G,Ci as H,Hh as I,sr as J,Kh as K,tE as L,qh as M,Zs as N,Lc as O,vt as P,Pa as Q,DEt as R,al as S,Ny as T,PEt as U,So as V,em as W,FEt as X,Fa as Y,eE as Z,rE as _,Oae as __tla,ed as a,oc as a$,iE as a0,ett as a1,Zh as a2,ky as a3,tp as a4,QB as a5,rtt as a6,Rv as a7,qU as a8,Uc as a9,itt as aA,Cv as aB,ll as aC,stt as aD,ott as aE,ntt as aF,att as aG,ltt as aH,QS as aI,ctt as aJ,htt as aK,gh as aL,tO as aM,eO as aN,Ly as aO,utt as aP,Uy as aQ,Yd as aR,me as aS,rO as aT,iO as aU,we as aV,EV as aW,Pr as aX,ZU as aY,dtt as aZ,Na as a_,sO as aa,oO as ab,nO as ac,NEt as ad,kEt as ae,sE as af,$d as ag,LEt as ah,UEt as ai,GEt as aj,WEt as ak,Gy as al,or as am,jEt as an,XEt as ao,zEt as ap,VEt as aq,Wy as ar,YEt as as,$Et as at,oE as au,Jh as av,aO as aw,lO as ax,ftt as ay,ptt as az,Qh as b,Ni as b$,ep as b0,nc as b1,gtt as b2,We as b3,nE as b4,Pe as b5,fe as b6,wt as b7,jt as b8,rd as b9,jy as bA,qo as bB,ac as bC,Mv as bD,ko as bE,ka as bF,To as bG,Mi as bH,La as bI,Wl as bJ,cl as bK,hl as bL,tu as bM,Gc as bN,mh as bO,ul as bP,_a as bQ,yi as bR,Hn as bS,cs as bT,AV as bU,Nt as bV,yh as bW,JU as bX,Fs as bY,Bi as bZ,Ns as b_,ba,_o as bb,_e as bc,ze as bd,be,Zi as bf,he as bg,Ce as bh,Gt as bi,et as bj,ae as bk,$t as bl,_t as bm,Mt as bn,xt as bo,Yt as bp,ue as bq,ai as br,ke as bs,Js as bt,ks as bu,bo as bv,ro as bw,Ls as bx,Xy as by,wa as bz,Wc as c,id as c$,ki as c0,Lo as c1,Kn as c2,je as c3,zy as c4,vh as c5,Vy as c6,Zr as c7,Hd as c8,Nn as c9,QU as cA,HEt as cB,mtt as cC,cO as cD,xV as cE,tG as cF,Ro as cG,hs as cH,ho as cI,KEt as cJ,SV as cK,eG as cL,Bt as cM,TV as cN,us as cO,Qt as cP,Ea as cQ,Aa as cR,it as cS,Yy as cT,hO as cU,aE as cV,cr as cW,uo as cX,ye as cY,Uo as cZ,wn as c_,En as ca,le as cb,Ve as cc,rG as cd,iG as ce,uO as cf,tT as cg,eT as ch,lE as ci,dO as cj,rp as ck,An as cl,fO as cm,qEt as cn,Bv as co,RV as cp,lc as cq,qn as cr,Zt as cs,xn as ct,io as cu,Zn as cv,vi as cw,Xr as cx,X as cy,Ee as cz,cE as d,Zo as d$,eu as d0,ytt as d1,Be as d2,ru as d3,rm as d4,$y as d5,CV as d6,MV as d7,Ua as d8,ce as d9,hE as dA,vtt as dB,_tt as dC,BV as dD,btt as dE,wtt as dF,OV as dG,Ett as dH,Att as dI,xtt as dJ,sG as dK,so as dL,Ae as dM,xa as dN,Ii as dO,Us as dP,Sa as dQ,Ov as dR,IV as dS,oG as dT,nG as dU,aG as dV,ZEt as dW,DV as dX,wo as dY,dl as dZ,Gs as d_,qe as da,kn as db,kt as dc,hr as dd,Di as de,rT as df,Go as dg,Hy as dh,di,lG as dj,Jn as dk,sd as dl,Ta as dm,Eo as dn,Stt as dp,PV as dq,Oi as dr,li as ds,jl as dt,Re as du,Li as dv,oo as dw,rr as dx,Ra as dy,Pi as dz,FV as e,Ttt as e$,im as e0,Sr as e1,_h as e2,cG as e3,uE as e4,Sn as e5,sm as e6,om as e7,te as e8,Wo as e9,hG as eA,uG as eB,nm as eC,NV as eD,dE as eE,pO as eF,dG as eG,Rtt as eH,Ctt as eI,kV as eJ,Mtt as eK,LV as eL,JEt as eM,fG as eN,pG as eO,gG as eP,gO as eQ,mO as eR,ip as eS,QEt as eT,t1t as eU,e1t as eV,yO as eW,Btt as eX,vO as eY,mG as eZ,_O as e_,Ott as ea,Itt as eb,Dtt as ec,Ptt as ed,Ftt as ee,Ntt as ef,ktt as eg,Ltt as eh,Utt as ei,Gtt as ej,Wtt as ek,UV as el,bO as em,Tn as en,jc as eo,Ca as ep,Ga as eq,Xc as er,Qn as es,Ln as et,iu as eu,Ji as ev,nt as ew,Iv as ex,wO as ey,jtt as ez,yG as f,GV as f0,Kd as f1,Xtt as f2,ztt as f3,iT as f4,am as f5,Vtt as f6,Ytt as f7,vG as f8,su as f9,lm as fA,_G as fB,$tt as fC,Htt as fD,Ktt as fE,qtt as fF,WV as fG,Ztt as fH,Jtt as fI,bh as fJ,r1t as fK,Qtt as fL,bG as fM,tet as fN,Ky as fa,sT as fb,Dv as fc,EO as fd,jV as fe,XV as ff,zV as fg,VV as fh,eet as fi,oT as fj,ret as fk,YV as fl,Pv as fm,ds as fn,zc as fo,qy as fp,ou as fq,iet as fr,$V as fs,set as ft,Zy as fu,wG as fv,oet as fw,HV as fx,KV as fy,qV as fz,nu as g,au as h,ZV as i,sp as j,xr as k,net as l,fE as m,EG as n,cm as o,AG as p,dt as q,Wa as r,i1t as s,Vc as t,Et as u,ne as v,op as w,Ao as x,Tr as y,wh as z};
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.